mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Fix XML unserializer
This commit is contained in:
parent
94eca2ce44
commit
d9bd550414
@ -49,9 +49,8 @@ class XML implements Unserializer
|
||||
}
|
||||
}
|
||||
|
||||
protected function readNode()
|
||||
{
|
||||
$className = 'PHPParser_Node_' . $this->reader->localName;
|
||||
protected function readNode() {
|
||||
$className = $this->getClassNameFromType($this->reader->localName);
|
||||
|
||||
// create the node without calling it's constructor
|
||||
$node = unserialize(
|
||||
@ -136,4 +135,12 @@ class XML implements Unserializer
|
||||
$this->reader->getAttribute('line')
|
||||
);
|
||||
}
|
||||
|
||||
protected function getClassNameFromType($type) {
|
||||
$className = 'PhpParser\\Node\\' . strtr($type, '_', '\\');
|
||||
if (!class_exists($className)) {
|
||||
$className .= '_';
|
||||
}
|
||||
return $className;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ XML;
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AST xmlns:node="http://nikic.github.com/PHPParser/XML/node">
|
||||
<node:Scalar_ClassConst />
|
||||
<node:Scalar_MagicConst_Class />
|
||||
</AST>
|
||||
XML;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user