-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[VarDumper] Fix error with uninitialized XMLReader #43413
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
Conversation
Hey! I think @fancyweb has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
Hi @fabpot, |
'VALIDATE' => @$reader->getParserProperty(\XMLReader::VALIDATE), | ||
'SUBST_ENTITIES' => @$reader->getParserProperty(\XMLReader::SUBST_ENTITIES), | ||
]; | ||
} catch (Error $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} catch (Error $e) { | |
} catch (\ValueError $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used Error
instead of ValueError
on purpose because of this fix in PHP: php/php-src@53f8921
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes total sense. I can confirm that an Error
is triggered on the latest PHP snapshot.
That makes me wonder: Is there a better way to detect an uninitialized XMLReader
than to catch a generic Error
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've double-checked the XMLReader documentation and source code, and I couldn't find another way to check if an instance is not yet initialized :(
Thank you for your PR, @villfa. The open source tool that fabbot relies on is PHP CS Fixer. Since the failure is a false positive as you already discovered, you can simply ignore it. 🙂 |
Thank you @villfa. |
When XMLReader is not initialized, getParserProperty() throws an error (or emits a warning, depending on the PHP version).
Now the error is caught and the properties are set to false.