mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-30 04:19:30 +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()
|
protected function readNode() {
|
||||||
{
|
$className = $this->getClassNameFromType($this->reader->localName);
|
||||||
$className = 'PHPParser_Node_' . $this->reader->localName;
|
|
||||||
|
|
||||||
// create the node without calling it's constructor
|
// create the node without calling it's constructor
|
||||||
$node = unserialize(
|
$node = unserialize(
|
||||||
@ -136,4 +135,12 @@ class XML implements Unserializer
|
|||||||
$this->reader->getAttribute('line')
|
$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 = <<<XML
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<AST xmlns:node="http://nikic.github.com/PHPParser/XML/node">
|
<AST xmlns:node="http://nikic.github.com/PHPParser/XML/node">
|
||||||
<node:Scalar_ClassConst />
|
<node:Scalar_MagicConst_Class />
|
||||||
</AST>
|
</AST>
|
||||||
XML;
|
XML;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user