Skip to content

handle ClassConstFetch in scope #1944

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

Merged
merged 11 commits into from
Nov 1, 2022
Merged

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

Sorry, something went wrong.

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

Verified

This commit was signed with the committer’s verified signature. The key has expired.
ondrejmirtes Ondřej Mirtes

Verified

This commit was signed with the committer’s verified signature. The key has expired.
ondrejmirtes Ondřej Mirtes

Verified

This commit was signed with the committer’s verified signature. The key has expired.
ondrejmirtes Ondřej Mirtes

Verified

This commit was signed with the committer’s verified signature. The key has expired.
ondrejmirtes Ondřej Mirtes

Verified

This commit was signed with the committer’s verified signature. The key has expired.
ondrejmirtes Ondřej Mirtes

Verified

This commit was signed with the committer’s verified signature. The key has expired.
ondrejmirtes Ondřej Mirtes
@rajyan
Copy link
Contributor Author

rajyan commented Oct 31, 2022

Verified

This commit was signed with the committer’s verified signature. The key has expired.
ondrejmirtes Ondřej Mirtes
@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