Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api methods now consistently return as associative arrays instead of Result (BC warning) #137

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jpastoor
Copy link
Collaborator

As discussed in #73 we feel that the Result class does not add anything useful for Api calls that are not lists of issues on which you can paginate/walk.

This PR proposes a change to more consistently return the data as associative array structures instead of Results. This is a BC break for many users, although we expect it to reduce the boilerplate in the client code. (One less unwrapping to do)

Fixes #73

@aik099
Copy link
Collaborator

aik099 commented Aug 18, 2016

Please rebase due merge conflicts.

…eturn as associative arrays instead of Result
@@ -21,7 +21,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Minimal supported PHP version changed from 5.2 to 5.3 by [@chobie].
- The `Api::getPriorties` renamed into `Api::getPriorities` by [@josevh].
- Remove trailing slash from endpoint url by [@Procta].
- Added local cache to getResolutions [@jpastoor].
- Added local cache to getResolutions by [@jpastoor].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some rebase issue, because this line was part of another PR.

@jpastoor jpastoor force-pushed the improvement/73-InconsistencyApiCallsReturnType branch from a199525 to a33afca Compare August 18, 2016 14:24
@@ -173,14 +173,14 @@ protected function clearLocalCaches()
/**
* Get fields definitions.
*
* @return array
* @return array|false
Copy link
Collaborator

@aik099 aik099 Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Is there a test case to confirm, that false is returned at some point?
  2. Maybe we should throw exception in ClientInterface on broken/error responses from JIRA instead?

This applies to other similar places where you've added |false to DocBlock.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid points, lets investigate that as part of #135.

Here I just made consistent for what we already have, and was not meant to complete unit test coverage for the methods involved, guess that is work for another time :)

Copy link
Collaborator Author

@jpastoor jpastoor Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought its a bit dodgy to make a BC change without adding tests as well. I might add some tomorrow that validate against JIRA responses just like I did with getStatuses etc.

Copy link
Collaborator

@aik099 aik099 Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Luckily changed methods aren't 100% of public class interface. Please create some basic tests for them (at least confirm, that they return non-empty array all the time).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to wait some time and merge PR with a tests, then merge PR quickly, but without any tests.

@jpastoor jpastoor mentioned this pull request Aug 18, 2016
- Added local cache to `Api::getResolutions` by [@jpastoor].
- Renamed `Api::api` parameter $return_as_json to $return_as_array by [@jpastoor].
- Changed default `Api::api` parameter $return_as_array to TRUE by [@jpastoor].
- Api methods (except those that return issue lists) now consistently return as associative arrays instead of Result by [@jpastoor].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace instead of Result with instead of Result class instance.

@jpastoor
Copy link
Collaborator Author

Still WIP, a few more tests are in the pipeline.

@jpastoor
Copy link
Collaborator Author

Thats it for me for now, rest of the tests can be done in a later PR, maybe even by someone else.
(Improved Api class line coverage from 38% to 45%, slowly getting there :))

@@ -564,7 +559,7 @@ public function search($jql, $start_at = 0, $max_results = 20, $fields = '*navig
'startAt' => $start_at,
'maxResults' => $max_results,
'fields' => $fields,
)
), false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS


each multi-line function call must be on separate line

@aik099
Copy link
Collaborator

aik099 commented Aug 25, 2016

Today’s review completed.

@aik099
Copy link
Collaborator

aik099 commented Sep 14, 2016

@jpastoor , any updates?

@jpastoor
Copy link
Collaborator Author

Hard for me to spent time on atm, will have more time in october to finish this and some other stuff :)

@aik099
Copy link
Collaborator

aik099 commented Sep 17, 2016

I recently saw, that repo collaborators (e.g. me) can add new commits to PR branch (e.g. branch in your repo fork) if PR author allows that, see:

2016-09-17_2133

Since I'm the one, who requested changes I already know what needs to be done and you only need to grant me the permission to do it.

@jpastoor
Copy link
Collaborator Author

Sweet, done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants