From 804095a879d9f9efb1f3f15396599f1efb278f03 Mon Sep 17 00:00:00 2001 From: Jonathan Vollebregt Date: Mon, 26 Aug 2024 20:23:20 +0200 Subject: [PATCH] DomPlugin/DOMDocumentPlugin: Use array access for lists NodeList and NamedNodeMap have undocumented array access without implemeting ArrayAccess since 5.6.3 - let's use it. --- build/kint.phar | Bin 487491 -> 487451 bytes src/Parser/DOMDocumentPlugin.php | 4 +- src/Parser/DomPlugin.php | 4 +- tests/Parser/DOMDocumentPluginTest.php | 50 ++++++++++----------- tests/Parser/DomPluginTest.php | 60 ++++++++++++------------- tests/Parser/HtmlPluginTest.php | 4 +- 6 files changed, 61 insertions(+), 61 deletions(-) diff --git a/build/kint.phar b/build/kint.phar index 096dfb44b0d2fe03629cb6ca44e722835263205a..b3a34449a72fd175286c941bf9ac2eaaecdc689c 100644 GIT binary patch delta 245 zcmX^7Kz8;6*$qP60>%am3=R8qWI(jY{0MR4FJNSs($O=?V!&+OQ+ zUDLnR35U(B@$uEsUM;)f-|6rPpM!MS?ar`okF@{(bi?KJ1;0ZcWItkIU|?`}@^u0L Djn!XN delta 317 zcmbRJK=$wh*$qP60`3M33=R8qWI%MczT)D^20Y@EExFwU_{<>^AbRDY*fq`l-0l6` zjNALUnS4U{b?wqqOZ*aZQ&T)kQgbz?--%~ZW7M4faSpTa^bf9#9Mk0znEcsw?J~i# zc?nF?Fxd^k%(ByKUNiA*-#?G3hH?6NS7y%X7ydG`Z4XRhYPP0^$?ZUsftVSHS%8=o zXcL>rMUR8r{JVcSTb!@CzQZv==i>#}yxwP~$zuI>JH iTioVI!$;+0*`jyTy>`r8f1q4rwKfX_1B1JhuM+@oDtANx diff --git a/src/Parser/DOMDocumentPlugin.php b/src/Parser/DOMDocumentPlugin.php index 20a833902..f59689e21 100644 --- a/src/Parser/DOMDocumentPlugin.php +++ b/src/Parser/DOMDocumentPlugin.php @@ -244,9 +244,9 @@ private function parseList($var, InstanceValue &$o, int $trigger): void // // Contrary to the PHP docs, getNamedItemNS takes null // as a namespace argument for an unnamespaced item. - $base_obj->access_path = $o->access_path.'->getNamedItem('.\var_export($item->nodeName, true).')'; + $base_obj->access_path = $o->access_path.'['.\var_export($item->nodeName, true).']'; } else { // Dom\NodeList - $base_obj->access_path = $o->access_path.'->item('.\var_export($key, true).')'; + $base_obj->access_path = $o->access_path.'['.\var_export($key, true).']'; } } diff --git a/src/Parser/DomPlugin.php b/src/Parser/DomPlugin.php index edc16fcb9..f6913f9a7 100644 --- a/src/Parser/DomPlugin.php +++ b/src/Parser/DomPlugin.php @@ -289,9 +289,9 @@ private function parseList($var, InstanceValue &$o, int $trigger): void // // Contrary to the PHP docs, getNamedItemNS takes null // as a namespace argument for an unnamespaced item. - $base_obj->access_path = $o->access_path.'->getNamedItem('.\var_export($item->nodeName, true).')'; + $base_obj->access_path = $o->access_path.'['.\var_export($item->nodeName, true).']'; } else { // Dom\NodeList - $base_obj->access_path = $o->access_path.'->item('.\var_export($key, true).')'; + $base_obj->access_path = $o->access_path.'['.\var_export($key, true).']'; } } diff --git a/tests/Parser/DOMDocumentPluginTest.php b/tests/Parser/DOMDocumentPluginTest.php index 035859f74..35b5e9fbd 100644 --- a/tests/Parser/DOMDocumentPluginTest.php +++ b/tests/Parser/DOMDocumentPluginTest.php @@ -228,7 +228,7 @@ public function testNamespaces() $o = $p->parse($v, clone $b); $root = $o->getRepresentation('children')->contents[0]; - $this->assertSame('$v->childNodes->item(0)', $root->access_path); + $this->assertSame('$v->childNodes[0]', $root->access_path); $root_props = []; foreach ($root->value->contents as $val) { @@ -238,8 +238,8 @@ public function testNamespaces() $this->assertSame('x', $root_props['tagName']->value->contents); $this->assertSame('x', $root_props['localName']->value->contents); $this->assertSame('http://localhost/', $root_props['namespaceURI']->value->contents); - $this->assertSame('$v->childNodes->item(0)->namespaceURI', $root_props['namespaceURI']->access_path); - $this->assertSame('$v->childNodes->item(0)->attributes', $root_props['attributes']->access_path); + $this->assertSame('$v->childNodes[0]->namespaceURI', $root_props['namespaceURI']->access_path); + $this->assertSame('$v->childNodes[0]->attributes', $root_props['attributes']->access_path); $this->assertSame(1, $root_props['attributes']->size); $this->assertEquals( @@ -255,11 +255,11 @@ public function testNamespaces() $this->assertCount(1, $attribs); $this->assertSame('0 0 30 150', $attribs['viewBox']->value->contents); - $this->assertSame('$v->childNodes->item(0)->attributes->getNamedItem(\'viewBox\')->nodeValue', $attribs['viewBox']->access_path); + $this->assertSame('$v->childNodes[0]->attributes[\'viewBox\']->nodeValue', $attribs['viewBox']->access_path); $g = $root->getRepresentation('children')->contents[0]; $this->assertSame('test:g', $g->name); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(1)', $g->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[1]', $g->access_path); $gprops = []; foreach ($g->value->contents as $val) { @@ -269,13 +269,13 @@ public function testNamespaces() $this->assertSame('test:g', $gprops['tagName']->value->contents); $this->assertSame('g', $gprops['localName']->value->contents); $this->assertSame('http://localhost/test', $gprops['namespaceURI']->value->contents); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(1)->namespaceURI', $gprops['namespaceURI']->access_path); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(1)->attributes', $gprops['attributes']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[1]->namespaceURI', $gprops['namespaceURI']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[1]->attributes', $gprops['attributes']->access_path); $this->assertSame(2, $gprops['attributes']->size); $g = $root->getRepresentation('children')->contents[1]; $this->assertSame('g', $g->name); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(3)', $g->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[3]', $g->access_path); $gprops = []; foreach ($g->value->contents as $val) { @@ -285,13 +285,13 @@ public function testNamespaces() $this->assertSame('g', $gprops['tagName']->value->contents); $this->assertSame('g', $gprops['localName']->value->contents); $this->assertSame('http://localhost/test', $gprops['namespaceURI']->value->contents); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(3)->namespaceURI', $gprops['namespaceURI']->access_path); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(3)->attributes', $gprops['attributes']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[3]->namespaceURI', $gprops['namespaceURI']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[3]->attributes', $gprops['attributes']->access_path); $this->assertNull($gprops['attributes']->size); $both = $root->getRepresentation('children')->contents[3]; $this->assertSame('both', $both->name); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(5)', $both->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[5]', $both->access_path); $attribs = []; foreach ($both->getRepresentation('attributes')->contents as $val) { @@ -301,10 +301,10 @@ public function testNamespaces() $this->assertCount(2, $attribs); $this->assertSame('base', $attribs['attribs']->value->contents); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(5)->attributes->getNamedItem(\'attribs\')->nodeValue', $attribs['attribs']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[5]->attributes[\'attribs\']->nodeValue', $attribs['attribs']->access_path); $this->assertSame('exists', $attribs['test:attribs']->value->contents); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(5)->attributes->getNamedItem(\'test:attribs\')->nodeValue', $attribs['test:attribs']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[5]->attributes[\'test:attribs\']->nodeValue', $attribs['test:attribs']->access_path); } /** @@ -456,7 +456,7 @@ public function testHTML() $body = $found_props['childNodes']->getRepresentation('iterator')->contents[1] ?? null; $this->assertNotNull($body); $this->assertSame('body', $body->name); - $this->assertSame('$v->childNodes->item(1)', $body->access_path); + $this->assertSame('$v->childNodes[1]', $body->access_path); $found_props = []; foreach ($body->value->contents as $val) { @@ -474,7 +474,7 @@ public function testHTML() // strong $strong = $body->getRepresentation('children')->contents[0]; $this->assertNotNull($strong); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(1)', $strong->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[1]', $strong->access_path); $found_props = []; foreach ($strong->value->contents as $val) { @@ -495,7 +495,7 @@ public function testHTML() $attrib = $attributes->contents[0]; $this->assertInstanceOf(BlobValue::class, $attrib); $this->assertSame('class', $attrib->name); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(1)->attributes->getNamedItem(\'class\')->nodeValue', $attrib->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[1]->attributes[\'class\']->nodeValue', $attrib->access_path); $this->assertSame('text', $attrib->value->contents); if (KINT_PHP83) { @@ -508,7 +508,7 @@ public function testHTML() // div $div = $body->getRepresentation('children')->contents[1]; $this->assertNotNull($div); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(3)', $div->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[3]', $div->access_path); $found_props = []; foreach ($div->value->contents as $val) { @@ -529,7 +529,7 @@ public function testHTML() $attrib = $attributes->contents[0]; $this->assertInstanceOf(BlobValue::class, $attrib); $this->assertSame('namespaces', $attrib->name); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(3)->attributes->getNamedItem(\'namespaces\')->nodeValue', $attrib->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[3]->attributes[\'namespaces\']->nodeValue', $attrib->access_path); $this->assertSame('allowed', $attrib->value->contents); } @@ -597,8 +597,8 @@ protected function basicAssertionsXml(Value $o, bool $verbose) $x = $found_props['childNodes']->getRepresentation('iterator')->contents[0] ?? null; $this->assertNotNull($x); - $this->assertSame('$v->childNodes->item(0)', $x->access_path); - $this->assertSame('$v->childNodes->item(0)', $o->getRepresentation('children')->contents[0]->access_path); + $this->assertSame('$v->childNodes[0]', $x->access_path); + $this->assertSame('$v->childNodes[0]', $o->getRepresentation('children')->contents[0]->access_path); $found_props = []; foreach ($x->value->contents as $val) { @@ -640,13 +640,13 @@ protected function basicAssertionsXml(Value $o, bool $verbose) $attrib = $attributes->contents[0]; $this->assertInstanceOf(BlobValue::class, $attrib); $this->assertSame('viewBox', $attrib->name); - $this->assertSame('$v->childNodes->item(0)->attributes->getNamedItem(\'viewBox\')->nodeValue', $attrib->access_path); + $this->assertSame('$v->childNodes[0]->attributes[\'viewBox\']->nodeValue', $attrib->access_path); $this->assertSame('0 0 30 150', $attrib->value->contents); // g1 $g1 = $x->getRepresentation('children')->contents[0]; $this->assertNotNull($g1); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(1)', $g1->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[1]', $g1->access_path); $found_props = []; foreach ($g1->value->contents as $val) { @@ -684,7 +684,7 @@ protected function basicAssertionsXml(Value $o, bool $verbose) // g2 $g2 = $x->getRepresentation('children')->contents[1]; $this->assertNotNull($g2); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(3)', $g2->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[3]', $g2->access_path); $found_props = []; foreach ($g2->value->contents as $val) { @@ -722,9 +722,9 @@ protected function basicAssertionsXml(Value $o, bool $verbose) // not-php-compatible $incomp = $x->getRepresentation('children')->contents[3]->getRepresentation('children')->contents[1]; - $this->assertSame('$v->childNodes->item(0)->childNodes->item(5)->childNodes->item(3)', $incomp->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[5]->childNodes[3]', $incomp->access_path); $this->assertSame( - '$v->childNodes->item(0)->childNodes->item(5)->childNodes->item(3)->attributes->getNamedItem(\'also-not\')->nodeValue', + '$v->childNodes[0]->childNodes[5]->childNodes[3]->attributes[\'also-not\']->nodeValue', $incomp->getRepresentation('attributes')->contents[0]->access_path ); $this->assertSame('php-compatible', $incomp->getRepresentation('attributes')->contents[0]->value->contents); diff --git a/tests/Parser/DomPluginTest.php b/tests/Parser/DomPluginTest.php index 7933872eb..2ba1d7db2 100644 --- a/tests/Parser/DomPluginTest.php +++ b/tests/Parser/DomPluginTest.php @@ -242,7 +242,7 @@ public function testNamespaces() $o = $p->parse($v, clone $b); $root = $o->getRepresentation('children')->contents[0]; - $this->assertSame('$v->childNodes->item(0)', $root->access_path); + $this->assertSame('$v->childNodes[0]', $root->access_path); $root_props = []; foreach ($root->value->contents as $val) { @@ -252,8 +252,8 @@ public function testNamespaces() $this->assertSame('x', $root_props['tagName']->value->contents); $this->assertSame('x', $root_props['localName']->value->contents); $this->assertSame('http://localhost/', $root_props['namespaceURI']->value->contents); - $this->assertSame('$v->childNodes->item(0)->namespaceURI', $root_props['namespaceURI']->access_path); - $this->assertSame('$v->childNodes->item(0)->attributes', $root_props['attributes']->access_path); + $this->assertSame('$v->childNodes[0]->namespaceURI', $root_props['namespaceURI']->access_path); + $this->assertSame('$v->childNodes[0]->attributes', $root_props['attributes']->access_path); $this->assertSame(3, $root_props['attributes']->size); $this->assertEquals( @@ -269,17 +269,17 @@ public function testNamespaces() $this->assertCount(3, $attribs); $this->assertSame('http://localhost/', $attribs['xmlns']->value->contents); - $this->assertSame('$v->childNodes->item(0)->attributes->getNamedItem(\'xmlns\')->nodeValue', $attribs['xmlns']->access_path); + $this->assertSame('$v->childNodes[0]->attributes[\'xmlns\']->nodeValue', $attribs['xmlns']->access_path); $this->assertSame('http://localhost/test', $attribs['xmlns:test']->value->contents); - $this->assertSame('$v->childNodes->item(0)->attributes->getNamedItem(\'xmlns:test\')->nodeValue', $attribs['xmlns:test']->access_path); + $this->assertSame('$v->childNodes[0]->attributes[\'xmlns:test\']->nodeValue', $attribs['xmlns:test']->access_path); $this->assertSame('0 0 30 150', $attribs['viewBox']->value->contents); - $this->assertSame('$v->childNodes->item(0)->attributes->getNamedItem(\'viewBox\')->nodeValue', $attribs['viewBox']->access_path); + $this->assertSame('$v->childNodes[0]->attributes[\'viewBox\']->nodeValue', $attribs['viewBox']->access_path); $g = $root->getRepresentation('children')->contents[0]; $this->assertSame('test:g', $g->name); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(1)', $g->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[1]', $g->access_path); $gprops = []; foreach ($g->value->contents as $val) { @@ -289,13 +289,13 @@ public function testNamespaces() $this->assertSame('test:g', $gprops['tagName']->value->contents); $this->assertSame('g', $gprops['localName']->value->contents); $this->assertSame('http://localhost/test', $gprops['namespaceURI']->value->contents); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(1)->namespaceURI', $gprops['namespaceURI']->access_path); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(1)->attributes', $gprops['attributes']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[1]->namespaceURI', $gprops['namespaceURI']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[1]->attributes', $gprops['attributes']->access_path); $this->assertSame(2, $gprops['attributes']->size); $g = $root->getRepresentation('children')->contents[1]; $this->assertSame('g', $g->name); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(3)', $g->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[3]', $g->access_path); $gprops = []; foreach ($g->value->contents as $val) { @@ -305,13 +305,13 @@ public function testNamespaces() $this->assertSame('g', $gprops['tagName']->value->contents); $this->assertSame('g', $gprops['localName']->value->contents); $this->assertSame('http://localhost/test', $gprops['namespaceURI']->value->contents); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(3)->namespaceURI', $gprops['namespaceURI']->access_path); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(3)->attributes', $gprops['attributes']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[3]->namespaceURI', $gprops['namespaceURI']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[3]->attributes', $gprops['attributes']->access_path); $this->assertSame(1, $gprops['attributes']->size); $both = $root->getRepresentation('children')->contents[3]; $this->assertSame('both', $both->name); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(5)', $both->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[5]', $both->access_path); $attribs = []; foreach ($both->getRepresentation('attributes')->contents as $val) { @@ -321,10 +321,10 @@ public function testNamespaces() $this->assertCount(2, $attribs); $this->assertSame('base', $attribs['attribs']->value->contents); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(5)->attributes->getNamedItem(\'attribs\')->nodeValue', $attribs['attribs']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[5]->attributes[\'attribs\']->nodeValue', $attribs['attribs']->access_path); $this->assertSame('exists', $attribs['test:attribs']->value->contents); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(5)->attributes->getNamedItem(\'test:attribs\')->nodeValue', $attribs['test:attribs']->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[5]->attributes[\'test:attribs\']->nodeValue', $attribs['test:attribs']->access_path); } /** @@ -481,8 +481,8 @@ public function testHTML() $html = $found_props['childNodes']->getRepresentation('iterator')->contents[1] ?? null; $this->assertNotNull($html); - $this->assertSame('$v->childNodes->item(1)', $html->access_path); - $this->assertSame('$v->childNodes->item(1)', $o->getRepresentation('children')->contents[1]->access_path); + $this->assertSame('$v->childNodes[1]', $html->access_path); + $this->assertSame('$v->childNodes[1]', $o->getRepresentation('children')->contents[1]->access_path); $found_props = []; foreach ($html->value->contents as $val) { @@ -511,12 +511,12 @@ public function testHTML() // head $head = $html->getRepresentation('children')->contents[0]; $this->assertSame('head', $head->name); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(0)', $head->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[0]', $head->access_path); // body $body = $html->getRepresentation('children')->contents[1]; $this->assertNotNull($body); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(1)', $body->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[1]', $body->access_path); $found_props = []; foreach ($body->value->contents as $val) { @@ -534,7 +534,7 @@ public function testHTML() // strong $strong = $body->getRepresentation('children')->contents[0]; $this->assertNotNull($strong); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(1)->childNodes->item(1)', $strong->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[1]->childNodes[1]', $strong->access_path); $found_props = []; foreach ($strong->value->contents as $val) { @@ -555,7 +555,7 @@ public function testHTML() $attrib = $attributes->contents[0]; $this->assertInstanceOf(BlobValue::class, $attrib); $this->assertSame('class', $attrib->name); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(1)->childNodes->item(1)->attributes->getNamedItem(\'class\')->nodeValue', $attrib->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[1]->childNodes[1]->attributes[\'class\']->nodeValue', $attrib->access_path); $this->assertSame('text', $attrib->value->contents); $this->assertSame('text', $found_props['className']->value->contents); @@ -564,7 +564,7 @@ public function testHTML() // div $div = $body->getRepresentation('children')->contents[1]; $this->assertNotNull($div); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(1)->childNodes->item(3)', $div->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[1]->childNodes[3]', $div->access_path); $found_props = []; foreach ($div->value->contents as $val) { @@ -585,7 +585,7 @@ public function testHTML() $attrib = $attributes->contents[0]; $this->assertInstanceOf(BlobValue::class, $attrib); $this->assertSame('no:namespaces', $attrib->name); - $this->assertSame('$v->childNodes->item(1)->childNodes->item(1)->childNodes->item(3)->attributes->getNamedItem(\'no:namespaces\')->nodeValue', $attrib->access_path); + $this->assertSame('$v->childNodes[1]->childNodes[1]->childNodes[3]->attributes[\'no:namespaces\']->nodeValue', $attrib->access_path); $this->assertSame('allowed', $attrib->value->contents); } @@ -647,8 +647,8 @@ protected function basicAssertionsXml(Value $o, bool $verbose) $x = $found_props['childNodes']->getRepresentation('iterator')->contents[0] ?? null; $this->assertNotNull($x); - $this->assertSame('$v->childNodes->item(0)', $x->access_path); - $this->assertSame('$v->childNodes->item(0)', $o->getRepresentation('children')->contents[0]->access_path); + $this->assertSame('$v->childNodes[0]', $x->access_path); + $this->assertSame('$v->childNodes[0]', $o->getRepresentation('children')->contents[0]->access_path); $found_props = []; foreach ($x->value->contents as $val) { @@ -691,13 +691,13 @@ protected function basicAssertionsXml(Value $o, bool $verbose) $attrib = $attributes->contents[0]; $this->assertInstanceOf(BlobValue::class, $attrib); $this->assertSame('viewBox', $attrib->name); - $this->assertSame('$v->childNodes->item(0)->attributes->getNamedItem(\'viewBox\')->nodeValue', $attrib->access_path); + $this->assertSame('$v->childNodes[0]->attributes[\'viewBox\']->nodeValue', $attrib->access_path); $this->assertSame('0 0 30 150', $attrib->value->contents); // g1 $g1 = $x->getRepresentation('children')->contents[0]; $this->assertNotNull($g1); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(1)', $g1->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[1]', $g1->access_path); $found_props = []; foreach ($g1->value->contents as $val) { @@ -736,7 +736,7 @@ protected function basicAssertionsXml(Value $o, bool $verbose) // g2 $g2 = $x->getRepresentation('children')->contents[1]; $this->assertNotNull($g2); - $this->assertSame('$v->childNodes->item(0)->childNodes->item(3)', $g2->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[3]', $g2->access_path); $found_props = []; foreach ($g2->value->contents as $val) { @@ -775,9 +775,9 @@ protected function basicAssertionsXml(Value $o, bool $verbose) // not-php-compatible $incomp = $x->getRepresentation('children')->contents[3]->getRepresentation('children')->contents[1]; - $this->assertSame('$v->childNodes->item(0)->childNodes->item(5)->childNodes->item(3)', $incomp->access_path); + $this->assertSame('$v->childNodes[0]->childNodes[5]->childNodes[3]', $incomp->access_path); $this->assertSame( - '$v->childNodes->item(0)->childNodes->item(5)->childNodes->item(3)->attributes->getNamedItem(\'also-not\')->nodeValue', + '$v->childNodes[0]->childNodes[5]->childNodes[3]->attributes[\'also-not\']->nodeValue', $incomp->getRepresentation('attributes')->contents[0]->access_path ); $this->assertSame('php-compatible', $incomp->getRepresentation('attributes')->contents[0]->value->contents); diff --git a/tests/Parser/HtmlPluginTest.php b/tests/Parser/HtmlPluginTest.php index 39c0156b4..4eb417998 100644 --- a/tests/Parser/HtmlPluginTest.php +++ b/tests/Parser/HtmlPluginTest.php @@ -78,14 +78,14 @@ public function testParse() $this->assertSame(DocumentType::class, $r->contents[0]->classname); $this->assertSame('html', $r->contents[0]->name); $this->assertSame(0, $r->contents[0]->size); - $this->assertSame('\\Dom\\HTMLDocument::createFromString($v)->childNodes->item(0)', $r->contents[0]->access_path); + $this->assertSame('\\Dom\\HTMLDocument::createFromString($v)->childNodes[0]', $r->contents[0]->access_path); $this->assertInstanceOf(InstanceValue::class, $r->contents[1]); $this->assertContains('omit_spl_id', $r->contents[1]->hints); $this->assertSame(HTMLElement::class, $r->contents[1]->classname); $this->assertSame('html', $r->contents[1]->name); $this->assertSame(0, $r->contents[1]->size); - $this->assertSame('\\Dom\\HTMLDocument::createFromString($v)->childNodes->item(1)', $r->contents[1]->access_path); + $this->assertSame('\\Dom\\HTMLDocument::createFromString($v)->childNodes[1]', $r->contents[1]->access_path); $b->access_path = null; $o = $p->parse($v, clone $b);