-
Notifications
You must be signed in to change notification settings - Fork 21
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
Increase phpstan level to 9 #113
Conversation
// errored. Therefore, we need to throw an exception. | ||
if ($this->value instanceof \Throwable) { | ||
throw $this->value; | ||
} | ||
// The state should have been REJECTED, with "value" a Throwable | ||
// But "value" was not a Throwable. So throw a more general exception. | ||
throw new \LogicException('The Promise was not fulfilled but no exception was specified'); |
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 is confident that "value" will be a Throwable at this point. So I added an extra check, and throw a LogicException if value was not a Throwable. LogicException is already used elsewhere in this code, so I chose to throw that.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #113 +/- ##
============================================
- Coverage 99.73% 99.21% -0.53%
- Complexity 109 111 +2
============================================
Files 7 7
Lines 376 380 +4
============================================
+ Hits 375 377 +2
- Misses 1 3 +2 ☔ View full report in Codecov by Sentry. |
if ($this->value instanceof \Throwable) { | ||
$subPromise->reject($this->value); | ||
} else { | ||
throw new \LogicException('The subPromise was not fulfilled but no exception was specified'); | ||
} |
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 is confident that "value" will be a Throwable at this point. So I added an extra check, and throw a LogicException if value was not a Throwable. LogicException is already used elsewhere in this code, so I chose to throw that.
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.
lgtm
@@ -302,7 +302,7 @@ protected function runStreams(?float $timeout): void | |||
/** | |||
* A list of timers, added by setTimeout. | |||
* | |||
* @var array<int, mixed> | |||
* @var array<int, array{0:float, 1:callable}> |
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 might even define the callable signatures which can help to identify issues at the caller side (can be a separate PR)
mostly be better at declaring the various arrays of Promises, associated callables, exceptions etc.