-
Notifications
You must be signed in to change notification settings - Fork 86
phpstan fixes #157
base: develop
Are you sure you want to change the base?
phpstan fixes #157
Conversation
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.
There's a lot of great changes here, but also a ton that look like potential backwards compatibility breaks and/or unrelated changes. Please review and address all comments from myself and @Ocramius, and we can then do a final review.
Thanks, @thomasvargiu !
/** @var Client\Adapter\AdapterInterface $adapter */ | ||
$adapter = $this->adapter; | ||
|
||
return $adapter; |
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 disagree with this change. If $this->adapter
was not previously set, we call setAdapter()
which will either raise an exception, or set the adapter to an appropriate value.
I think the solution to the phpstan errors in this case would be to say that $adapter
can only be an AdapterInterface
instance, and not allow null
. There are no paths through the client that will allow it to remain null when it needs to be used.
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 think we can't say that $adapter
can only be an AdapterInterface
because is not set in constructor. $adapter
will be null
until some method will call getAdapter()
, then a developer should know that $this->adapter
can be null
.
Maybe, can we initialize it in constructor?
|
||
if (null === $nextHost) { | ||
throw new InvalidArgumentException('Invalid URI provided. No host found'); | ||
} |
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 new behavior, and does not have a corresponding test. Please revert, or add a test.
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.
Tests added
*/ | ||
public function isHttponly() | ||
public function isHttpOnly() |
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 comment here as for setHttponly()
; revert, or introduce the new method as a proxy to the original.
@@ -89,6 +90,10 @@ public static function fromString($string) | |||
|
|||
if (preg_match("/^[ \t][^\r\n]*$/", $line, $matches)) { | |||
// continuation: append to current line | |||
if (! isset($current['line'])) { | |||
$current['line'] = ''; | |||
} |
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 likely needs a unit test.
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.
Fixed and tested
src/PhpEnvironment/Request.php
Outdated
@@ -93,6 +96,9 @@ public function getContent() | |||
{ | |||
if (empty($this->content)) { | |||
$requestBody = file_get_contents('php://input'); | |||
if (false === $requestBody) { | |||
throw new RuntimeException('Unable to get contents from php://input'); | |||
} |
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 new behavior and requires a corresponding test.
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.
Fixed and replaced with simpler condition
@@ -198,6 +202,9 @@ public static function fromString($string) | |||
if ($response->statusCode === static::STATUS_CODE_100) { | |||
$next = array_shift($lines); // take next line | |||
$next = empty($next) ? array_shift($lines) : $next; // take next or skip if empty | |||
if (null === $next) { | |||
throw new RuntimeException('Invalid response content'); | |||
} |
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 new behavior and requires a corresponding test.
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.
Tests added
if (false === $uncompressed) { | ||
throw new Exception\RuntimeException( | ||
'An error occurred during inflation' | ||
); |
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 new behavior and requires a corresponding test.
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.
Tests added
Removing the milestone; I suspect this patch will take a bit of back and forth before it's ready, and we're otherwise ready for the 2.9.0 release. We can target 2.10.0 for this. |
@thomasvargiu You will need to rebase against current develop before you start applying changes. |
@weierophinney should I target develop branch for merge? |
Yes, please.
…On Sun, Jan 13, 2019, 6:04 AM Thomas Mauro Vargiu ***@***.*** wrote:
@thomasvargiu <https://github.com/thomasvargiu> You will need to rebase
against current develop before you start applying changes.
@weierophinney <https://github.com/weierophinney> should I target develop
branch for merge?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#157 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABlVw0jtiMLKWbVU8T8dhB4rMJ0eWwAks5vCyDAgaJpZM4Xd9qx>
.
|
478fc5c
to
0921eb1
Compare
.travis.yml
Outdated
@@ -9,6 +9,7 @@ env: | |||
- COMPOSER_ARGS="--no-interaction" | |||
- COVERAGE_DEPS="php-coveralls/php-coveralls" | |||
- TESTS_ZEND_HTTP_CLIENT_ONLINE=true | |||
- PHPSTAN_DEPS="phpstan/phpstan:^0.10.3" |
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.
In other repositories we are adding it to composer dev requirements. Maybe we should do the same here?
Then it will be much easier to run it locally. See: https://github.com/zendframework/zend-expressive/blob/master/composer.json#L40
We can also update to version 0.11 :)
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.
Someone else told me to remove it and to add it in CI.
8d17521
to
6caf9ef
Compare
phpstan fixes phpstan fixes Removed deprecations Fixed wrong condition Better phpdoc types Better tests with relative datetimes Some fixes and removed false return types Replaced return values $this with self Replaced usage of stdClass with object in param doc Removed useless check and getter of adapter Fixed typo Reverted rename of method setHttponly, fixed usage with incorrect case PHPStan fixes Fix variable overwrite Reverted composer changes Fix and test header factory Added test for invalid 100 response Test gzinflate error Added test for default query argument separator Fixed missing char in phpdoc Added test to handle tmpname failure Added test for dispatch() method Fixed cookies usage
23d2b27
to
ccbbb5f
Compare
This repository has been closed and moved to laminas/laminas-http; a new issue has been opened at laminas/laminas-http#4. |
This repository has been moved to laminas/laminas-http. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
Changed
Zend\Http\Client
.Anyway, usage of relative URIs has no sense and no adapter can handle it.
Fixed
Zend\Http\Cookies::getAllCookies(Zend\Http\Cookies::COOKIE_STRING_ARRAY)
.Zend\Http\Cookies::getAllCookies(Zend\Http\Cookies::COOKIE_STRING_CONCAT)
.