-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix return types & end host on slash #93
Comments
Thanks for opening this issue! A maintainer will review this in the next few days and explicitly select labels so you know what's going on. If no reviewer appears after a week, a reminder will be sent out. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been closed. If you wish to re-open it please provide additional information. |
Code
This is a sample
all()
method, e.g. for blocks. The PHP return type is only array--
src/API/Blocks.php
However, it's using the
get()
method fromAbstractAPI
, which doesn't have a return type. The PHPDoc suggestsarray
orstring
.--
src/API/AbstractAPI.php
However,
json_decode
can never return a string, onlybool
,array
andnull
(and technicallyint
, when first argument istrue
).Expected Behavior
I would expect that I either received an empty array or
null
. I would prefernull
as this symbolizes the API response was empty, vs. an empty array could just be the actual response with valid JSON ({}
/[]
).Current Behavior
Screenshot
We can't get around this e.g. with try/catch as it's return types are a PHP language feature.
Possible Solution
Simplest solution imho: Add
?
to return type so it can acceptnull
coming fromjson_decode
.--
src/API/Blocks.php
Steps to Reproduce (for bugs)
Use a
host
URL not ending on a slash (/
). If you're add a slash at the end the connection works.Your Environment
PHP: 7.4.10
php-client: 0.1.3
Laravel: 8.3
MacOS 10.14.6
The text was updated successfully, but these errors were encountered: