Narrow DOMDocument::createElement() return type and throw type for valid constant names#5192
Narrow DOMDocument::createElement() return type and throw type for valid constant names#5192janedbal wants to merge 3 commits intophpstan:2.1.xfrom
Conversation
|
You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x. |
|
|
||
| public function isMethodSupported(MethodReflection $methodReflection): bool | ||
| { | ||
| return extension_loaded('dom') && $methodReflection->getName() === 'createElement'; |
There was a problem hiding this comment.
I am not sure whether this kind of optional runtime dependency is a good thing to have.
would it make sense to hard-code a list of valid elements instead?
There was a problem hiding this comment.
This logic was basically copied from SimpleXMLElementXpathMethodReturnTypeExtension, so I just followed that one.
|
This pull request has been marked as ready for review. |
Removes the implicit DOMException throw point when all constant string arguments are valid XML element names.
| 122, | ||
| ]; | ||
| } | ||
| $errors[] = [ |
There was a problem hiding this comment.
I think it's better to have a dedicated test
testBug13792
method rather modifying the existing one
Especially because there is already some
if (PHP_VERSION_ID >=
condition which complexify it.
Fixes phpstan/phpstan#13792