Skip to content
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

Add stub for \DOMNode::hasAttributes #3800

Open
wants to merge 1 commit into
base: 2.1.x
Choose a base branch
from

Conversation

Niklan
Copy link

@Niklan Niklan commented Jan 29, 2025

I'm not sure if the property should be explicitely declared. It works fine without it. Most likely, it comes from PHPStorm's stubs. Also, I'm not sure if it should be:

@phpstan-assert-if-true DOMNamedNodeMap $this->attributes

to be more specific, or is it fine with !null?

This PR fixes an issue where PHPStan does not understand chained calls, as discussed here: phpstan/phpstan#12495 (comment)

    if ($node->hasAttributes()) {
      foreach ($node->attributes->getIterator() as $attribute) {
  22     Cannot call method getIterator() on DOMNamedNodeMap|null.  
         🪪  method.nonObject   

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.

1 participant