-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add phpstan phpunit strict-rules #203
Conversation
Codecov Report
@@ Coverage Diff @@
## master #203 +/- ##
============================================
- Coverage 94.40% 94.21% -0.19%
- Complexity 258 260 +2
============================================
Files 15 15
Lines 875 881 +6
============================================
+ Hits 826 830 +4
- Misses 49 51 +2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Note: the new phpstan-strict-rules enforce that I have ignored the "will always evaluate to true" message. The check is a bit superfluous, but it does not hurt to keep it. |
@@ -239,7 +239,7 @@ public function poll(): bool | |||
|
|||
$curlResult['request'] = $request; | |||
|
|||
if ($errorCallback) { | |||
if (is_callable($errorCallback)) { |
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.
Could we instead declar wthe type of the propery?
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.
phpstan-strict-rules
wants all if
checks to be real booleans.
We can only call $errorCallback
if it is a callback anyway.
sendAsyncInternal
already has this passed in as a callback
.
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.
Declaring the type as callable
will not stop the strict rule complaining that the if
condition is not a real boolean.
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 added details of the "array shape" of curlMultiMap
(see below in the diffs).
9442408
to
42b7961
Compare
42b7961
to
58f0184
Compare
58f0184
to
e271735
Compare
@@ -353,7 +354,7 @@ protected function doRequest(RequestInterface $request): ResponseInterface | |||
* Has a list of curl handles, as well as their associated success and | |||
* error callbacks. | |||
* | |||
* @var array<int, mixed> | |||
* @var array<int, array{0: RequestInterface, 1: callable, 2: callable, 3: int}> |
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 at least helps to document what this array-of-arrays should look like.
But I locally tried specifying wrong things here, and I couldn't get phpstan
to give any errors - I was expecting that lines of code that set and/or use entries in this array would cause phpstan
to complain.
looks good, thanks. |
No description provided.