Skip to content
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

Fix ::class on string expression #1425

Merged
merged 1 commit into from Sep 2, 2022

Conversation

rvanvelzen
Copy link
Contributor

@rvanvelzen rvanvelzen commented Jun 15, 2022

No description provided.

@ondrejmirtes
Copy link
Member

I think this code pattern isn't supported: https://3v4l.org/MM1pJ

@rvanvelzen
Copy link
Contributor Author

Absolutely right, but strangely enough this is: https://3v4l.org/Rb3oU

@ondrejmirtes
Copy link
Member

Whaat!? :) Sounds like an inconsistency that should be reported in https://github.com/php/php-src/issues :)

I just did: php/doc-en#1646

@rvanvelzen rvanvelzen marked this pull request as draft June 16, 2022 13:33
@rvanvelzen
Copy link
Contributor Author

I'll let this sit here until php/doc-en#1646 is resolved :)

@ondrejmirtes
Copy link
Member

So the conclusion in php/doc-en#1646 is unequivocal :) Can you please add a test that 'Foo'::class is not reported by ClassConstantRule and this example is reported?

$foo = 'Foo';
var_dump($foo::class);

And maybe also assertType() for this example too to make sure we have an ErrorType there.

Thanks :)

@rvanvelzen rvanvelzen changed the base branch from 1.7.x to 1.8.x September 2, 2022 06:48
@rvanvelzen
Copy link
Contributor Author

The error cases are already covered by tests, so this should be ready to go :)

@rvanvelzen rvanvelzen marked this pull request as ready for review September 2, 2022 06:49
@staabm
Copy link
Contributor

staabm commented Sep 2, 2022

Absolutely right, but strangely enough this is: 3v4l.org/Rb3oU

may I ask how you realized this is a thing? did you see such code somewhere?

@rvanvelzen
Copy link
Contributor Author

I stumbled upon it while fumbling around with phpstan/phpstan#7391 😅

@ondrejmirtes ondrejmirtes merged commit 42a9252 into phpstan:1.8.x Sep 2, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@rvanvelzen rvanvelzen deleted the constant-string-class branch September 6, 2022 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants