Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Narrow DOMDocument::createElement() return type and throw type for valid constant names#5192

Open
janedbal wants to merge 3 commits intophpstan:2.1.xfrom
janedbal:dom-document-create-element-return-type
Open

Narrow DOMDocument::createElement() return type and throw type for valid constant names#5192
janedbal wants to merge 3 commits intophpstan:2.1.xfrom
janedbal:dom-document-create-element-return-type

Conversation

@janedbal
Copy link
Contributor

@phpstan-bot
Copy link
Collaborator

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.

@janedbal janedbal changed the base branch from 2.2.x to 2.1.x March 10, 2026 15:52

public function isMethodSupported(MethodReflection $methodReflection): bool
{
return extension_loaded('dom') && $methodReflection->getName() === 'createElement';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic was basically copied from SimpleXMLElementXpathMethodReturnTypeExtension, so I just followed that one.

@janedbal janedbal marked this pull request as ready for review March 10, 2026 16:24
@phpstan-bot
Copy link
Collaborator

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.
@janedbal janedbal changed the title Narrow DOMDocument::createElement() return type for valid constant names Narrow DOMDocument::createElement() return type and throw type for valid constant names Mar 10, 2026
@janedbal janedbal requested a review from staabm March 10, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support proper return value of DOMDocument::createElement, false almost never happens

3 participants