Skip to content

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

Open
jpastoor wants to merge 3 commits into
console-helpers:masterfrom
jpastoor:improvement/73-InconsistencyApiCallsReturnType
Open

Api methods now consistently return as associative arrays instead of Result (BC warning)#137
jpastoor wants to merge 3 commits into
console-helpers:masterfrom
jpastoor:improvement/73-InconsistencyApiCallsReturnType

Conversation

@jpastoor

Copy link
Copy Markdown
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

aik099 commented Aug 18, 2016

Copy link
Copy Markdown
Member

Please rebase due merge conflicts.

Comment thread CHANGELOG.md Outdated
- 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
Copy Markdown
Member

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
Comment thread src/Jira/Api.php Outdated
* Get fields definitions.
*
* @return array
* @return array|false

@aik099 aik099 Aug 18, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
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 :)

@jpastoor jpastoor Aug 18, 2016

Copy link
Copy Markdown
Collaborator Author

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.

@aik099 aik099 Aug 18, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We'll do this in #241 or #228.

@jpastoor jpastoor mentioned this pull request Aug 18, 2016
Comment thread CHANGELOG.md Outdated
- 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
Copy Markdown
Member

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
Copy Markdown
Collaborator Author

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

@jpastoor

Copy link
Copy Markdown
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 :))

Comment thread src/Jira/Api.php Outdated
'maxResults' => $max_results,
'fields' => $fields,
)
), false

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Done.

@aik099

aik099 commented Aug 25, 2016

Copy link
Copy Markdown
Member

Today’s review completed.

@aik099

aik099 commented Sep 14, 2016

Copy link
Copy Markdown
Member

@jpastoor , any updates?

@jpastoor

Copy link
Copy Markdown
Collaborator Author

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

@aik099

aik099 commented Sep 17, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
Collaborator Author

Sweet, done

@aik099

aik099 commented Jan 25, 2025

Copy link
Copy Markdown
Member

All tests from this PR were added as part of #244.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistency in return type of API calls

2 participants