-
-
Notifications
You must be signed in to change notification settings - Fork 598
Upgrade to PHP 7 #651
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
Upgrade to PHP 7 #651
Conversation
@TomasVotruba I'm not really sure, but I think in PHP7 you can use |
@m1guelpf Sure. We should move to PHP 7.1 in standalone PR, one step at a time. This is rather architecture question, whether all these methods should return array/null |
I think that's probably a bit fast. |
@GrahamCampbell My point was not in this PR. It should be PHP 7.0 only |
Sure. I was just making the point that I'd 👎 anything beyond this PR unless there were some really good reasons. |
What about strict types declaration in every file? |
@cursedcoder Sure, we can require that in coding standard, as I did in php-ml. But again, I'd do that in separate PR, after this one gets resolved to prevent redundant conflicts. |
I will tag 2.7 within a few minutes. |
Hey, I'm glad you got to this. Sure, let me know after 2.7 is tagged |
It's tagged now =) |
Rebase done 👍 |
Btw, what about bumping to PHP 7.1 in next PR? Even PHPUnit is now on board |
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.
Thank you. I've started to review this. I found a few issues that occur repeatedly in this PR. Could you address all of them?
public function getPerPage(); | ||
|
||
public function setPerPage($perPage); | ||
public function setPerPage(int $perPage = null); |
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.
Is this correct? Why do we allow null?
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 is not something new. You can specify no pagination and let github decide AFAIK. It's written as comment on some inheritance of this interface.
* @return array | ||
*/ | ||
public function show($clientId) | ||
public function show($clientId): 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.
should be a string here, right?
public function show($clientId): array | ||
{ | ||
return $this->get('/authorizations/'.rawurlencode($clientId)); | ||
return $this->get('/authorizations/'.rawurlencode((string) $clientId)); |
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.
Type casting here could be removed.
* @return array | ||
* @return array|null | ||
*/ | ||
public function create(array $params, $OTPCode = null) |
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.
$OPTCode is string, right?
public function update($clientId, array $params) | ||
{ | ||
return $this->patch('/authorizations/'.rawurlencode($clientId), $params); | ||
return $this->patch('/authorizations/'.rawurlencode((string) $clientId), $params); |
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.
Same here, shouldnt client ID be a string? Can you verify?
* Reset an authorization. | ||
* | ||
* @param $clientId | ||
* @param $token |
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.
We should not remove these with adding type annotations.
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.
What is the type here?
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.
I’m not sure without reading the code and docs.
Every added type was to fix tests, that failed due to strict types. |
* @author Joseph Bielawski <stloyd@gmail.com> | ||
*/ | ||
class ErrorException extends \ErrorException implements ExceptionInterface | ||
class ErrorException extends \Exception implements ExceptionInterface |
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.
Why is this change needed?
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.
It's quite a long time since PR so I'm not sure.
I think it was related to mocks in some way. Try running test with/without it please to confirm.
Imho this PR does a bit to much. Bumping php, adding typehints, cs fixes, etc. This makes it a bit hard for me to review the PR. Maybe we should split this up a bit. Leave the style changes out for example as this can be done in a separate pr (I've started one with new styleci fixers, but maybe more is needed). Bump the php version, adapt travis to it and make sure the tests still pass. After that we can start converting typehints. This way we have multiple "small" pr's which makes easy reviews and quick merges :) This is just my opinion of course, don't know what you guys think of this. Btw I'm definitely in favor of bumping php and thanks already for the work @TomasVotruba! |
I agree with acrobat. Tomas, what is the status here? |
What is the decision here? |
I think we should split the pr. Leave this one for now and open a new PR where you bump the php version, adapt the travis build matrix and make sure tests still pass. From there on we can make the next steps (like adding typehints etc) in separate pr's. |
@@ -1,4 +1,4 @@ | |||
<?php | |||
<?php declare(strict_types=1); |
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.
I don't think this is in the way of think of the project. Keeping the PHP way looks like a better alternative. Also, the indentation is wrong (it should definitely be on a new line)
About the first point ( |
Not relevant anymore. I'm closing to clean my opened PRs. Feel free to cherry pick anything you need. |
Replaces #647 with passing tests and CS
Why?
This package would be still available for PHP 5.6-.
Questions
1. How to approach
string
/int
issue in parameters?Often there was random typehint and for
string
andint
there was autore-type to stringrawurlencode
method.Should be allow both
string
andint
and manuallrawurlencode((string) $id)
or be strict in parameters?2. How to approach
null
/array
return values?At least accroding to tests, some api calls return null on fail or empty results. Array was expected in typehtings.
At the moment they return
array|null
. Is that ok?