Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Nyholm commentedFeb 16, 2021
I've updated the code to use |
e94abb1 tocc00e0eComparenicolas-grekas commentedFeb 16, 2021
Thank you@Nyholm. |
Nyholm commentedFeb 16, 2021
Thank you for merging. |
weirdan commentedMar 6, 2021
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')) { |
Nyholm commentedMar 6, 2021
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? |
weirdan commentedMar 6, 2021
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. |
If you installed a command line tool like
psalmwith 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.