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
$_SERVER['APP_DEBUG'] is considered as a string instead of a bool. #8556
Comments
Hey @VincentLanglet, can you reproduce the issue on https://psalm.dev ? |
Seems different than the float one if PHP itself outputs a boolean @kkmuffme this seems legit, don't you think? Now the question is if that can be string or if it's always bool |
This is expected, as I couldn't plan for all possible cases, I just added was is declared in the specification and commonly found in nginx/apache/cloudflare.
Technically parsing XML into $_SERVER isn't what is intended to be done in PHP though, as $_SERVER should only be populated by the actual webserver. I will provide the PR for it today for APP_ENV non-empty-string and APP_DEBUG bool if that's fine. |
I dunno how For instance, there is
in the Symfony code. And I found https://blog.digital-craftsman.de/beware-of-app-debug-false/ So I wonder if it's not phpunit which is casting the APP_DEBUG=false value automatically from the config. I just found out the "issue" is related to phpunit which is doing
on every I'm not sure what is the best strategy between
|
Yes, phpunit does it and populates the $_SERVER config, which it shouldn't. But alas, since phpunit is common, I will add it for now as bool |
if you use It can prevent some error from people writing
in the .env file. And it force to cast for people writing
That's why if we add APP_DEBUG, it should be string|bool and not just bool. I personally will add |
I think it's fine to enforce bool here, when we make it explicit now anyway, might as well force people to use true/false in the config file, if that's what is expected here. |
It's expected when you're setting them with phpunit, but not if you set them with a |
Ok changed it in the PR to bool|string |
@orklah @kkmuffme Now I get the following errors
This is kinda annoying since the APP_ENV and APP_DEBUG values will always be defined for most of phpunit/symfony users. Is there something we can do about it ? |
Do you use the "ensureArrayStringOffsetsExist" config? |
No. |
This is correct and not a bug. While it might exist for you, it might not exist generally in all environments. |
Hi @orklah @kkmuffme , I have a similar issue
After the merge and the release of #8473, I now have with the code
the error
I have
in my phpunit.xml.dist config, and when I dump
this is correctly the bool
false
and not a string.There might be some discussion about
Request_time_float
(cf #8552) but, here, in APP_DEBUG, I don't feel like I put a wrong value.The text was updated successfully, but these errors were encountered: