-
-
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 assumes DOMDocument::load() returns mixed #10057
Comments
Please send a PR that updates resources/functionMap.php in phpstan-src. |
@tschoonen After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-5: Only booleans are allowed in a negated boolean, mixed given.
+5: Only booleans are allowed in a negated boolean, bool|DOMDocument given. Full report
|
I've open phpstan/phpstan-src#2975 But seems like for PHP 8, it's now inferred from the I dunno if this issue need to stay open or move to Same issue for loadHTML, loadHTMLFile or loadXML. |
If If that's wrong then you should open a bug report in php-src. |
What I don't understand is the fact that phpstan/php-8-stubs say but php-src say So I thought the bug was in php-8-stubs. |
Interesting, you can try to debug the stubs extractor and see why it happens. There's a potential for a lot of bugs being fixed. |
I find out the issue, it's not really an extractor bug. PHPDoc was wrong on PHP-8.0, PHP-8.1 and PHP-8.2 but is correct in PHP-8.3 branch. I've opened php/php-src#13762 but I dunno if it will be accepted or if we'll require a fix on the extractor side. |
As expected @ondrejmirtes a fix on PHP-8.0 and PHP-8.1 won't be accepted Is it possible to ignore |
Fixed by phpstan/phpstan-src#2975 |
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
PHPStan seems to assume that
DOMDocument::load()
returnsmixed
and notbool
as stated in the documentation.https://www.php.net/manual/en/domdocument.load.php
The documentation does however mention from version 8.3 onwards it will return a "tentative bool" whatever that may mean (quantum bits?). But I get the error even though I have explicitly specified the PHP version as 8.1.
Code snippet that reproduces the problem
https://phpstan.org/r/00db931e-075f-4f74-8f2f-58df9e3003db
Expected output
No errors.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan helps me everyday by saving me from my own errors.
The text was updated successfully, but these errors were encountered: