-
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
Explicit never early terminates #366
Explicit never early terminates #366
Conversation
6f9fd27
to
c22522d
Compare
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 almost perfect PR :) Please test it in a more modern way - see NodeScopeResolverTest::testFileAsserts
- add a new dataProvider in it. You can use assertVariableCertainty
function inside the test file. Thanks.
c22522d
to
fd6f35c
Compare
@ondrejmirtes I updated the test |
fd6f35c
to
f0df73c
Compare
@@ -10259,6 +10259,12 @@ public function dataBug4016(): array | |||
return $this->gatherAssertTypes(__DIR__ . '/data/bug-4016.php'); | |||
} | |||
|
|||
/** @return array<string, mixed[]> */ | |||
public function phpDocNeverEarlyTerminates(): array |
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.
Needs to start with data
as any other data provider here.
$pre = 1; | ||
Foo::doBarPhpDoc(); | ||
$a = 1; | ||
assertVariableCertainty(TrinaryLogic::createYes(), $pre); |
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'm not even sure if these are executed. They might not be. Have you seen them fail?
The typical test here should be this instead:
if (rand(0, 1)) {
$a = 1;
} else {
Foo::doBarPhpDoc();
}
assertVariableCertainty(TrinaryLogic::createYes(), $a);
Yeah, I just verified that the asserts are not verified because they're "dead code". I'll bring it over the finish line myselfů |
f0df73c
to
410c3ef
Compare
Thank you. There needs to be a second part - verifying that a function with |
Closes phpstan/phpstan#2638