-
Notifications
You must be signed in to change notification settings - Fork 426
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
Added DynamicReturnTypeExtension for trigger_error
#766
Conversation
Build errors are unrelated |
rebased against master. all green now. |
$errorType = $scope->getType($functionCall->getArgs()[1]->value); | ||
if ($errorType instanceof ConstantScalarType) { | ||
if ($errorType->getValue() === E_USER_ERROR) { | ||
return new NeverType(); |
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 also test that this behaves as an actual terminating call. Try this:
function foo(?string $s): void
{
if ($s === null) {
trigger_error('foo', E_USER_ERROR);
}
assertType('string', $s);
}
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.
hmm interessting.. you are right, this case is failling atm.
I had the impression that phpstan would handle a NeverType
returned from a DynamicFunctionReturnTypeExtension
automatically as a terminating call. wouldn't that make sense, instead of adding such logic case by case?
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.
You need return new NeverType(true);
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.
already fixed :-). thx.
Thank you! |
closes phpstan/phpstan#5992