Browse Source

Minor fixes

wrapper-classes
Dustin Wilson 3 years ago
parent
commit
c22a1b54d8
  1. 114
      composer.lock
  2. 13
      lib/Element.php
  3. 3
      lib/InnerNode/Reflection.php
  4. 23
      lib/Node.php
  5. 12
      vendor-bin/phpunit/composer.lock
  6. 14
      vendor-bin/robo/composer.lock

114
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e1ae676c649645ea27cced9dd2587393",
"content-hash": "6ed06e9556bdcc4bbbb5f3f23958e33d",
"packages": [
{
"name": "mensbeam/framework",
@ -238,62 +238,6 @@
},
"time": "2021-03-07T03:58:00+00:00"
},
{
"name": "nikic/php-parser",
"version": "v4.13.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "50953a2691a922aa1769461637869a0a2faa3f53"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/50953a2691a922aa1769461637869a0a2faa3f53",
"reference": "50953a2691a922aa1769461637869a0a2faa3f53",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=7.0"
},
"require-dev": {
"ircmaxell/php-yacc": "^0.0.7",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
},
"bin": [
"bin/php-parse"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.9-dev"
}
},
"autoload": {
"psr-4": {
"PhpParser\\": "lib/PhpParser"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Nikita Popov"
}
],
"description": "A PHP parser written in PHP",
"keywords": [
"parser",
"php"
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.13.0"
},
"time": "2021-09-20T12:20:58+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",
@ -1161,6 +1105,62 @@
},
"time": "2021-09-25T08:05:01+00:00"
},
{
"name": "nikic/php-parser",
"version": "v4.13.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "50953a2691a922aa1769461637869a0a2faa3f53"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/50953a2691a922aa1769461637869a0a2faa3f53",
"reference": "50953a2691a922aa1769461637869a0a2faa3f53",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=7.0"
},
"require-dev": {
"ircmaxell/php-yacc": "^0.0.7",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
},
"bin": [
"bin/php-parse"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.9-dev"
}
},
"autoload": {
"psr-4": {
"PhpParser\\": "lib/PhpParser"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Nikita Popov"
}
],
"description": "A PHP parser written in PHP",
"keywords": [
"parser",
"php"
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.13.0"
},
"time": "2021-09-20T12:20:58+00:00"
},
{
"name": "psr/container",
"version": "1.1.1",

13
lib/Element.php

@ -46,17 +46,16 @@ class Element extends Node {
// but print out the HTML namespace instead.
$namespace = $this->innerNode->namespaceURI;
$doc = $this->ownerDocument;
return (($doc instanceof Document && !$doc instanceof XMLDocument) && $namespace === null) ? Parser::HTML_NAMESPACE : $namespace;
return (!$doc instanceof XMLDocument && $namespace === null) ? Parser::HTML_NAMESPACE : $namespace;
}
protected function __get_prefix(): ?string {
// PHP's DOM does this correctly already.
return $this->innerNode->prefix;
$prefix = $this->innerNode->prefix;
return ($prefix !== '') ? $prefix : null;
}
protected function __get_tagName(): string {
// PHP's DOM does this correctly already.
return $this->innerNode->tagName;
return ($this->prefix === null) ? $this->localName : "{$this->prefix}:{$this->localName}";
}
@ -79,6 +78,10 @@ class Element extends Node {
return $list;
}
public function getAttributeNS(string $namespace, string $localName): ?string {
return $this->innerNode->getAttributeNS($namespace, $localName);
}
public function getAttributeNode(string $qualifiedName): ?Attr {
# The getAttributeNode(qualifiedName) method steps are to return the result of
# getting an attribute given qualifiedName and this.

3
lib/InnerNode/Reflection.php

@ -27,15 +27,12 @@ class Reflection {
}
public static function getProtectedProperty(mixed $instance, string $propertyName): mixed {
$reflector = new \ReflectionClass($instance::class);
$property = new \ReflectionProperty($instance, $propertyName);
$property->setAccessible(true);
return $property->getValue($instance);
}
public static function setProtectedProperties(mixed $instance, array $properties): void {
$reflector = new \ReflectionClass($instance::class);
foreach ($properties as $propertyName => $value) {
$property = new \ReflectionProperty($instance, $propertyName);
$property->setAccessible(true);

23
lib/Node.php

@ -126,18 +126,18 @@ abstract class Node {
protected function __get_nodeName(): string {
# The nodeName getter steps are to return the first matching statement,
# switching on the interface this implements:
$nodeName = $this->innerNode->nodeName;
#
# ↪ Element
# Its HTML-uppercased qualified name.
if ($this instanceof Element) {
$tagName = $this->tagName;
// Uncoerce names if necessary
return strtoupper(!str_contains(needle: 'U', haystack: $nodeName) ? $nodeName : $this->uncoerceName($nodeName));
return strtoupper(!str_contains(needle: 'U', haystack: $tagName) ? $tagName : $this->uncoerceName($tagName));
}
// Attribute nodes and processing instructions need the node name uncoerced if
// necessary
elseif ($this instanceof Attr || $this instanceof ProcessingInstruction) {
return (!str_contains(needle: 'U', haystack: $nodeName)) ? $nodeName : $this->uncoerceName($nodeName);
return (!str_contains(needle: 'U', haystack: $nodeName)) ? $nodeName : $this->uncoerceName($this->innerNode->nodeName);
}
// While the DOM itself cannot create a doctype with an empty string as the
// name, the HTML parser can. PHP's DOM cannot handle an empty string as the
@ -148,7 +148,7 @@ abstract class Node {
}
// PHP's DOM handles everything correctly on everything else.
return $nodeName;
return $this->innerNode->nodeName;
}
protected function __get_nodeType(): int {
@ -292,9 +292,9 @@ abstract class Node {
public function appendChild(Node $node): Node {
// Aside from pre-insertion validity PHP's DOM does this correctly already.
$this->preInsertionValidity($node);
$this->innerNode->appendChild($this->getInnerNode($node));
$innerNode = $this->getInnerNode($node);
$this->innerNode->appendChild($innerNode);
return $node;
}
@ -450,9 +450,9 @@ abstract class Node {
public function insertBefore(Node $node, ?Node $child = null): Node {
# The insertBefore(node, child) method steps are to return the result of
# pre-inserting node into this before child.
// Aside from pre-insertion validity PHP's DOM does this correctly already.
$this->preInsertionValidity($node, $child);
$this->innerNode->insertBefore($this->getInnerNode($node), $this->getInnerNode($child));
$innerNode = $this->getInnerNode($node);
$this->innerNode->insertBefore($innerNode, $this->getInnerNode($child));
return $node;
}
@ -932,6 +932,11 @@ abstract class Node {
}
}
if ($copy instanceof \DOMElement) {
$xpath = new \DOMXPath($innerDocument);
$xpath->query('.//')
}
# 7. Return copy.
return $copyWrapper;
}

12
vendor-bin/phpunit/composer.lock

@ -135,16 +135,16 @@
},
{
"name": "nikic/php-parser",
"version": "v4.13.0",
"version": "v4.13.1",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "50953a2691a922aa1769461637869a0a2faa3f53"
"reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/50953a2691a922aa1769461637869a0a2faa3f53",
"reference": "50953a2691a922aa1769461637869a0a2faa3f53",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/63a79e8daa781cac14e5195e63ed8ae231dd10fd",
"reference": "63a79e8daa781cac14e5195e63ed8ae231dd10fd",
"shasum": ""
},
"require": {
@ -185,9 +185,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.13.0"
"source": "https://github.com/nikic/PHP-Parser/tree/v4.13.1"
},
"time": "2021-09-20T12:20:58+00:00"
"time": "2021-11-03T20:52:16+00:00"
},
{
"name": "phar-io/manifest",

14
vendor-bin/robo/composer.lock

@ -616,20 +616,20 @@
},
{
"name": "psr/container",
"version": "1.1.1",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
"reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
"url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
"reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
"shasum": ""
},
"require": {
"php": ">=7.2.0"
"php": ">=7.4.0"
},
"type": "library",
"autoload": {
@ -658,9 +658,9 @@
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/1.1.1"
"source": "https://github.com/php-fig/container/tree/1.1.2"
},
"time": "2021-03-05T17:36:06+00:00"
"time": "2021-11-05T16:50:12+00:00"
},
{
"name": "psr/event-dispatcher",

Loading…
Cancel
Save