1
0
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:
nikic 2014-09-12 00:37:04 +02:00
parent 94eca2ce44
commit d9bd550414
2 changed files with 11 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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;