Skip to content

Conversation

rajyan
Copy link
Contributor

@rajyan rajyan commented Oct 31, 2022

fixes phpstan/phpstan#8034

blocking
phpstan/phpstan#8191

regression from
#1938

Steps to fix

@rajyan rajyan changed the title add failing test from bug8034 handle ClassConstFetch in scope Oct 31, 2022
@rajyan
Copy link
Contributor Author

rajyan commented Oct 31, 2022

@rajyan rajyan marked this pull request as ready for review October 31, 2022 23:42
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

Comment on lines +7 to +51
class HelloWorld
{
public static function doFoo()
{
if (defined('Foo::TEST')) {
Foo::TEST;
\Foo::TEST;
\ClassConstFetchDefined\Foo::TEST;
} else {
Foo::TEST;
\Foo::TEST;
\ClassConstFetchDefined\Foo::TEST;
}

if (defined('\Foo::TEST')) {
Foo::TEST;
\Foo::TEST;
\ClassConstFetchDefined\Foo::TEST;
} else {
Foo::TEST;
\Foo::TEST;
\ClassConstFetchDefined\Foo::TEST;
}

if (defined('ClassConstFetchDefined\Foo::TEST')) {
Foo::TEST;
\Foo::TEST;
\ClassConstFetchDefined\Foo::TEST;
} else {
Foo::TEST;
\Foo::TEST;
\ClassConstFetchDefined\Foo::TEST;
}

if (defined('\ClassConstFetchDefined\Foo::TEST')) {
Foo::TEST;
\Foo::TEST;
\ClassConstFetchDefined\Foo::TEST;
} else {
Foo::TEST;
\Foo::TEST;
\ClassConstFetchDefined\Foo::TEST;
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified the behavior by https://3v4l.org/ueJTH

&& !$context->null();
&& $context->truthy();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exist !== NeverType so I think this makes things better.

@ondrejmirtes ondrejmirtes merged commit 1536997 into phpstan:1.9.x Nov 1, 2022
@ondrejmirtes
Copy link
Member

Perfect, thank you!

@rajyan rajyan deleted the fix-bug-8034 branch November 1, 2022 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Access to undefined constant static(HelloWorld)::FIELDS
3 participants