-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
phpstan requires ext-simplexml to be installed #9714
Comments
PHP has this extension enabled by default: https://www.php.net/manual/en/simplexml.installation.php Yeah, it should not crash, but your environment is pretty atypical 😊 If PHPStan is not able to detect an error and you can't reproduce it on the playground, please create a small reproducing repository that shows the problem. You can also involve Docker if you want. |
Hi @ondrejmirtes ! What a quick reply! :) Please find a sample repo here: |
There's no difference between the result in your Docker image and in the playground: https://phpstan.org/r/3b235cce-1d56-49e2-94e3-ea2173fd1ecf The difference is between |
You are right. As far as I can see the class is named Here is the Playground example with a capital The git repository already has a capital XML.
Or am I somehow missing the correct spelling of |
My guess is that with |
Oh, I did not realize there is a dynamic return type. Nice 😄. In that case phpstan's behavior with The error without |
There are two bugs:
|
related with #9553 - xpath should be parsed, not tried to be evaluated, as parsing is required to understand if the xpath returns |
@SomeBdyElse After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-11: Argument of an invalid type array<SimpleXMLElement>|false|null supplied for foreach, only iterables are supported.
+No errors |
@ondrejmirtes After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-9: Argument of an invalid type array<SimpleXMLElement>|false|null supplied for foreach, only iterables are supported.
+No errors |
Fixed by phpstan/phpstan-src#2561 and phpstan/phpstan-src#2562 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
In our local dev environment, phpstan requires ext-simplexml to be installed to analyze code with the SimpleXMLElement constructor. The on-line PHPStan playground does it correctly. Locally, we get the following stack trace:
Once we install
php81-simplexml
, phpstan misses the obvious type error shown in the playground example and passes the file without complaint. This seems incorrect, as the example contains a type error.Code snippet that reproduces the problem
https://phpstan.org/r/a523934f-ea45-45f1-98fb-5691c4afb358
Expected output
phpstan should complain about the error, as it does in the playground.
Did PHPStan help you today? Did it make you happy in any way?
It makes our code better :)
The text was updated successfully, but these errors were encountered: