-
Notifications
You must be signed in to change notification settings - Fork 62
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
Set min PHP to 7.4 #192
Set min PHP to 7.4 #192
Conversation
*/ | ||
public function getHttpStatus(); | ||
public function getHttpStatus(): ?string; |
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.
The PHP doc had string|null
as the return type. I preserved that in the explicit declaration of return type ?string
That has flow-on effects - this is saying that the integer 200
is not acceptable to return, it must return the string "200".
Implementations of this, like in ClientHttpException
above, already had the return value declared as int
What to do? What is the "requirement"? Do we refactor to make all this allow both string|int
to be passed around, or require string
or require int
?
*/ | ||
protected $status; | ||
protected int $status; |
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 this one says that the HTTP status code is an int
public function getHttpStatus(): int | ||
public function getHttpStatus(): string | ||
{ | ||
return $this->response->getStatus(); | ||
return (string) $this->response->getStatus(); | ||
} |
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.
See comment below - various things were "mixed" - do we consistently pass HTTP status as string
or int
?
Codecov Report
@@ Coverage Diff @@
## master #192 +/- ##
============================================
+ Coverage 94.11% 94.78% +0.67%
+ Complexity 260 256 -4
============================================
Files 15 15
Lines 884 806 -78
============================================
- Hits 832 764 -68
+ Misses 52 42 -10
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There are a lot of things reported when I raise phpstan to level 6 - currently working through it, Down to 87 "errors" remaining! |
With phpstan level 6, after adding all the phpdoc array types, we are left with:
They are all related to variables that have address references ( There were a couple of similar things in the test code - I tagged those with |
* @var resource|null | ||
*/ | ||
private $curlHandle; | ||
private $curlHandle = 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 helps phpstan to process potential access to $curlHandle before it is written (checks for === null
are seen as valid)
* @var resource|null | ||
*/ | ||
private $curlMultiHandle; | ||
private $curlMultiHandle = 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 helps phpstan to process potential access to $curlMultiHandle before it is written (checks for === null
are seen as valid)
* | ||
* @var MessageInterface | ||
*/ | ||
protected $inner; |
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 took this out, and added it to the Request and Response decorators. In those places, I can declare it is RequestInterface
and/or ResponseInterface
and then phpstan can work out what is going on and be made happy.
/** | ||
* Returns the HTTP version. | ||
*/ | ||
public function __toString(): string; |
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 needed to do this because otherwise PHPstan complains:
------ ------------------------------------------------------------------------
Line lib/RequestDecorator.php
------ ------------------------------------------------------------------------
189 Call to an undefined method Sabre\HTTP\RequestInterface::__toString().
------ ------------------------------------------------------------------------
------ -------------------------------------------------------------------------
Line lib/ResponseDecorator.php
------ -------------------------------------------------------------------------
76 Call to an undefined method Sabre\HTTP\ResponseInterface::__toString().
------ -------------------------------------------------------------------------
The Decorator classes have __toString
that expects __toStringto exist in a
RequestInterfaceand
ResponseInterface. And they both extend
MessageInterface`
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.
looks great. please merge and do a separate PR in case you plan todo another level up
public function __toString(): string | ||
{ | ||
return 'mock text'; | ||
} |
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 __toString
because Message implements MessageInterface and MessageInterface now has __toString
(and don't squash while merging.. these independent commits are useful) |
WIP
ToDo:
sabre/event
and then use that incomposer.json