| Server IP : 54.233.248.239 / Your IP : 172.28.20.13 Web Server : Apache System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/vinumday2_0/vendor/nikic/php-parser/lib/PhpParser/Serializer/ |
Upload File : |
<?php
namespace PhpParser\Serializer;
use PhpParser\Comment;
use PhpParser\Node;
use PhpParser\Serializer;
use XMLWriter;
/**
* @deprecated
*/
class XML implements Serializer
{
protected $writer;
/**
* Constructs a XML serializer.
*/
public function __construct() {
$this->writer = new XMLWriter;
$this->writer->openMemory();
$this->writer->setIndent(true);
}
public function serialize(array $nodes) {
$this->writer->flush();
$this->writer->startDocument('1.0', 'UTF-8');
$this->writer->startElement('AST');
$this->writer->writeAttribute('xmlns:node', 'http://nikic.github.com/PHPParser/XML/node');
$this->writer->writeAttribute('xmlns:subNode', 'http://nikic.github.com/PHPParser/XML/subNode');
$this->writer->writeAttribute('xmlns:attribute', 'http://nikic.github.com/PHPParser/XML/attribute');
$this->writer->writeAttribute('xmlns:scalar', 'http://nikic.github.com/PHPParser/XML/scalar');
$this->_serialize($nodes);
$this->writer->endElement();
return $this->writer->outputMemory();
}
protected function _serialize($node) {
if ($node instanceof Node) {
$this->writer->startElement('node:' . $node->getType());
foreach ($node->getAttributes() as $name => $value) {
$this->writer->startElement('attribute:' . $name);
$this->_serialize($value);
$this->writer->endElement();
}
foreach ($node as $name => $subNode) {
$this->writer->startElement('subNode:' . $name);
$this->_serialize($subNode);
$this->writer->endElement();
}
$this->writer->endElement();
} elseif ($node instanceof Comment) {
$this->writer->startElement('comment');
$this->writer->writeAttribute('isDocComment', $node instanceof Comment\Doc ? 'true' : 'false');
$this->writer->writeAttribute('line', (string) $node->getLine());
$this->writer->text($node->getText());
$this->writer->endElement();
} elseif (is_array($node)) {
$this->writer->startElement('scalar:array');
foreach ($node as $subNode) {
$this->_serialize($subNode);
}
$this->writer->endElement();
} elseif (is_string($node)) {
$this->writer->writeElement('scalar:string', $node);
} elseif (is_int($node)) {
$this->writer->writeElement('scalar:int', (string) $node);
} elseif (is_float($node)) {
// TODO Higher precision conversion?
$this->writer->writeElement('scalar:float', (string) $node);
} elseif (true === $node) {
$this->writer->writeElement('scalar:true');
} elseif (false === $node) {
$this->writer->writeElement('scalar:false');
} elseif (null === $node) {
$this->writer->writeElement('scalar:null');
} else {
throw new \InvalidArgumentException('Unexpected node type');
}
}
}