-
Notifications
You must be signed in to change notification settings - Fork 123
Removed incorrect typehint of $data in Api::api() which caused setWatchers to throw a warning #100
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
Conversation
setWatchers Method use String as Data PHP Catchable fatal error: Argument 3 passed to chobie\Jira\Api::api() must be an array, string given
|
Interesting. More issues related to this, that I've found:
|
|
https://docs.atlassian.com/jira/REST/latest/#api/2/issue-addWatcher |
|
The change (when typehint was added) was a result of wrong DocBlock comment on the
|
|
Agree with aik099 points and would very much like to see that in this PR. Some additional wishes (but if you aint sure how to do it I'll add it soon in a separate PR) |
throw InvalidArgumentException
src/Jira/Api.php
Outdated
| * @param string $method Request method. | ||
| * @param string $url URL. | ||
| * @param array $data Data. | ||
| * @param array|string $data Data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reformat DocBlock to alight parameter names and their descriptions.
| $url .= '?' . http_build_query($data); | ||
|
|
||
| if ( !is_array($data) ) { | ||
| throw new \InvalidArgumentException('Data must be an array.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention in DocBlock via @throws tag, that this exception is being thrown.
|
Also |
|
Ok thank you for the quick responses. |
Not used to writing unit tests? |
|
Merged, thanks |
| if ( $method == 'GET' ) { | ||
| $url .= '?' . http_build_query($data); | ||
|
|
||
| if ( !is_array($data) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be moved up. Otherwise you already get notice about wrong parameter usage in http_build_query call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And same part in PHPClient is still missing.
|
@jpastoor , this PR is incomplete. It not only misses tests, but also misses points we've mentioned as needed. Therefore until you check that all requested items were done don't merge it. |
setWatchers Method pass a String as Data for the api call and not an array. This produces an warning that crash some applications.
PHP Error:
PHP Catchable fatal error: Argument 3 passed to chobie\Jira\Api::api() must be an array, string given