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

class-string should not be settable using string literal #223

Open
mvorisek opened this issue Jul 29, 2023 · 2 comments
Open

class-string should not be settable using string literal #223

mvorisek opened this issue Jul 29, 2023 · 2 comments

Comments

@mvorisek
Copy link

repro: https://phpstan.org/r/1b7e94a5-9263-4f0c-83f8-a2964c1b5d5c

This is a feature request to emit a phpstan error /w strict rules to enforce the user to set the string using Xxx::class syntax.

Xxx::class is guaranteed to be always checked by static analysis, is more readable and always in canonical form - no leading backslash.

@kamil-zacek
Copy link
Contributor

In my opinion - rule should be little bit different. It should check whether string literal is assigned to the class-string this should check whether string contains existing class name. To avoid unnecessary autoload for files with classes only for get class name.

@mvorisek
Copy link
Author

mvorisek commented Apr 8, 2024

👍, like any other class (name) is checked.

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

No branches or pull requests

2 participants