Correction to SimpleXmlElement stub?

I have a file that uses SimpleXML heavily and it's overflowing with notices because the SimpleXMLElement stub is not ideal.

I think the stub for SimpleXMLElement::__get() should be:

/**
* Provides access to element's children
* @param string $name child name
* @return SimpleXMLIterator
*/


The difference is that it returns SimpleXMLIterator instead of SimpleXMLElement[].  It also sets the $name to type `string`, since at the moment PHPStorm thinks it's of type `child` and hilights it as a problem.

Also, PHPStorm only seems to half get how the magic method __get() works on SimpleXMLElement.  In some contexts it is ok with $xml->element, but in others it
reports "Field accessed via magic method".

Fore example:

$elem = $xml->element; // PHPStorm says: "Field accessed via magic method" testParamType($xml->element); // PHPStorm says: "Expected SimpleXMLElement, got SimpleXMLElement[]" function testParamType(SimpleXMLElement $se) {     // ... }


It seems like the same exclusion for accessing properties on `stdClass` should be made for `SimpleXMLElement` as well.

Am I wrong?  Nobody seems to be saying anything about this.

0
2 comments
Avatar
Liubov Melnikova

Seems like this issue on tracker is related: http://youtrack.jetbrains.com/issue/WI-15760

0

Thank you, that is the same issue.

I've added a suggestion to the ticket.  My original suggestion above is not correct.

0

Please sign in to leave a comment.