c2ec1c97c9
A poor man's formatter since I didn't like any of the other ones I found. The original C++ source sometimes put newlines and sometimes not.
Codemods:
codemod '([;{}])([^\n])' '\1\n\2'
codemod -m '\s*<\?php\s+' '<?php\n\n'
codemod '\t' ' '
I hand-fixed all the failing tests
26 linhas
755 B
PHP
26 linhas
755 B
PHP
<?php
|
|
|
|
function addChildNode(SimpleXMLElement $parent, SimpleXMLElement $node) {
|
|
$newchild = $parent->addChild($node->getName(), (string)$node);
|
|
foreach ($node->attributes() as $name => $value) {
|
|
$newchild->addAttribute($name, $value);
|
|
}
|
|
foreach ($node->children() as $child) {
|
|
addChildNode($newchild, $child);
|
|
}
|
|
}
|
|
|
|
$xmlreq = '<a><item><node><sub>1st</sub><sub>2nd</sub></node></item></a>';
|
|
$quote = simplexml_load_string($xmlreq);
|
|
$req = new SimpleXMLElement('<node/>');
|
|
foreach ($quote->attributes() as $name => $value) {
|
|
$req->addAttribute($name, $value);
|
|
}
|
|
foreach ($quote->children() as $child) {
|
|
addChildNode($req, $child);
|
|
}
|
|
|
|
$vertex = new SimpleXMLElement('<root/>');
|
|
addChildNode($vertex, $req);
|
|
var_dump($vertex->asXML());
|