-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[String] Check if function exists before declaring it #40203
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
Conversation
I've updated the code to use |
e94abb1
to
cc00e0e
Compare
Thank you @Nyholm. |
Thank you for merging. |
Ironically, this broke Psalm tests: https://github.com/vimeo/psalm/runs/2037304361#step:7:42 I would suggest to replace if (!\function_exists(u::class)) { with if (!\function_exists(__NAMESPACE__ . '\\u')) { |
The current implementation is valid PHP code. I’m not sure what the benefits are to implement to your suggestion. I don’t want to be disrespectful, but this is a problem psalm should fix, isn’t it? |
Clearer code, mostly. I had this little 'huh?' moment looking at it, thinking 'What are those weirdly named classes? And why are they used in
Perhaps. Hardly a high-priority issue though, as in practice it will only happen when people run Psalm with badly written custom autoloader. |
…nt (#5335) These appeared in symfony/symfony#40203
If you installed a command line tool like
psalm
with composer and then try to run it on a project that included the String component you will get an error like:That is because we are loading two installations of the string component.