From e2c810f8b672d7b4bd35c8eb33c579bb26e43462 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 10 Dec 2018 13:16:16 +0100 Subject: [PATCH] Add "platform" to composer.json This is required to pull in PHP 7.0 compatible libraries. --- .../files/lib/system/api/composer.json | 6 +- .../files/lib/system/api/composer.lock | 22 +++--- .../lib/system/api/composer/installed.json | 16 ++--- .../css-selector/CssSelectorConverter.php | 2 +- .../Exception/ExceptionInterface.php | 2 +- .../css-selector/Node/AbstractNode.php | 2 +- .../css-selector/Node/AttributeNode.php | 38 +++++++--- .../symfony/css-selector/Node/ClassNode.php | 20 ++++-- .../Node/CombinedSelectorNode.php | 26 +++++-- .../symfony/css-selector/Node/ElementNode.php | 6 +- .../css-selector/Node/FunctionNode.php | 16 +++-- .../symfony/css-selector/Node/HashNode.php | 20 ++++-- .../css-selector/Node/NegationNode.php | 4 +- .../css-selector/Node/NodeInterface.php | 21 +++++- .../symfony/css-selector/Node/PseudoNode.php | 20 ++++-- .../css-selector/Node/SelectorNode.php | 20 ++++-- .../symfony/css-selector/Node/Specificity.php | 19 ++++- .../Parser/Handler/CommentHandler.php | 2 +- .../Parser/Handler/HandlerInterface.php | 2 +- .../Parser/Handler/HashHandler.php | 2 +- .../Parser/Handler/IdentifierHandler.php | 2 +- .../Parser/Handler/NumberHandler.php | 2 +- .../Parser/Handler/StringHandler.php | 2 +- .../Parser/Handler/WhitespaceHandler.php | 2 +- .../symfony/css-selector/Parser/Parser.php | 45 ++++++++++-- .../css-selector/Parser/ParserInterface.php | 4 +- .../symfony/css-selector/Parser/Reader.php | 44 +++++++++--- .../Parser/Shortcut/ClassParser.php | 2 +- .../Parser/Shortcut/ElementParser.php | 2 +- .../Parser/Shortcut/EmptyStringParser.php | 2 +- .../Parser/Shortcut/HashParser.php | 2 +- .../api/symfony/css-selector/Parser/Token.php | 62 ++++++++++++---- .../Parser/Tokenizer/TokenizerEscaping.php | 21 +++++- .../Parser/Tokenizer/TokenizerPatterns.php | 37 ++++++++-- .../Extension/AttributeMatchingExtension.php | 72 ++++++++++++++++--- .../XPath/Extension/CombinationExtension.php | 4 +- .../XPath/Extension/FunctionExtension.php | 31 ++++++-- .../XPath/Extension/NodeExtension.php | 71 ++++++++++++++---- .../symfony/css-selector/XPath/Translator.php | 67 +++++++++++++---- .../XPath/TranslatorInterface.php | 14 +++- .../symfony/css-selector/XPath/XPathExpr.php | 43 ++++++++--- .../api/symfony/css-selector/composer.json | 4 +- 42 files changed, 628 insertions(+), 173 deletions(-) diff --git a/wcfsetup/install/files/lib/system/api/composer.json b/wcfsetup/install/files/lib/system/api/composer.json index 65ecab83ea..d5a70ef3d8 100644 --- a/wcfsetup/install/files/lib/system/api/composer.json +++ b/wcfsetup/install/files/lib/system/api/composer.json @@ -1,7 +1,11 @@ { "config": { "vendor-dir": "./", - "prepend-autoloader": false + "prepend-autoloader": false, + "platform": { + "php": "7.0.22", + "ext-gd": "0" + } }, "require": { "ezyang/htmlpurifier": "4.10.*", diff --git a/wcfsetup/install/files/lib/system/api/composer.lock b/wcfsetup/install/files/lib/system/api/composer.lock index 89eaf185da..1c2dc3cb9e 100644 --- a/wcfsetup/install/files/lib/system/api/composer.lock +++ b/wcfsetup/install/files/lib/system/api/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": "c2cc66e87530c77c42e08cef2e6af144", + "content-hash": "b95904d82ddc37f1e3ada56aa0d9637f", "packages": [ { "name": "chrisjean/php-ico", @@ -373,25 +373,25 @@ }, { "name": "symfony/css-selector", - "version": "v4.2.1", + "version": "v3.4.20", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "aa9fa526ba1b2ec087ffdfb32753803d999fcfcd" + "reference": "345b9a48595d1ab9630db791dbc3e721bf0233e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/aa9fa526ba1b2ec087ffdfb32753803d999fcfcd", - "reference": "aa9fa526ba1b2ec087ffdfb32753803d999fcfcd", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/345b9a48595d1ab9630db791dbc3e721bf0233e8", + "reference": "345b9a48595d1ab9630db791dbc3e721bf0233e8", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^5.5.9|>=7.0.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -422,7 +422,7 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2018-11-11T19:52:12+00:00" + "time": "2018-11-11T19:48:54+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -537,5 +537,9 @@ "prefer-stable": false, "prefer-lowest": false, "platform": [], - "platform-dev": [] + "platform-dev": [], + "platform-overrides": { + "php": "7.0.22", + "ext-gd": "0" + } } diff --git a/wcfsetup/install/files/lib/system/api/composer/installed.json b/wcfsetup/install/files/lib/system/api/composer/installed.json index f36b09bd4c..bbe6939c4a 100644 --- a/wcfsetup/install/files/lib/system/api/composer/installed.json +++ b/wcfsetup/install/files/lib/system/api/composer/installed.json @@ -380,27 +380,27 @@ }, { "name": "symfony/css-selector", - "version": "v4.2.1", - "version_normalized": "4.2.1.0", + "version": "v3.4.20", + "version_normalized": "3.4.20.0", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "aa9fa526ba1b2ec087ffdfb32753803d999fcfcd" + "reference": "345b9a48595d1ab9630db791dbc3e721bf0233e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/aa9fa526ba1b2ec087ffdfb32753803d999fcfcd", - "reference": "aa9fa526ba1b2ec087ffdfb32753803d999fcfcd", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/345b9a48595d1ab9630db791dbc3e721bf0233e8", + "reference": "345b9a48595d1ab9630db791dbc3e721bf0233e8", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^5.5.9|>=7.0.8" }, - "time": "2018-11-11T19:52:12+00:00", + "time": "2018-11-11T19:48:54+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "installation-source": "dist", diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/CssSelectorConverter.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/CssSelectorConverter.php index d1aeb7eb17..8d66dbd0e1 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/CssSelectorConverter.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/CssSelectorConverter.php @@ -31,7 +31,7 @@ class CssSelectorConverter /** * @param bool $html Whether HTML support should be enabled. Disable it for XML documents */ - public function __construct(bool $html = true) + public function __construct($html = true) { $this->translator = new Translator(); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Exception/ExceptionInterface.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Exception/ExceptionInterface.php index 9e259006b0..e4c5ae1b6b 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Exception/ExceptionInterface.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Exception/ExceptionInterface.php @@ -19,6 +19,6 @@ namespace Symfony\Component\CssSelector\Exception; * * @author Jean-François Simon */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface { } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/AbstractNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/AbstractNode.php index aac3f0a555..1d5d8ff7ba 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/AbstractNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/AbstractNode.php @@ -31,7 +31,7 @@ abstract class AbstractNode implements NodeInterface /** * @return string */ - public function getNodeName(): string + public function getNodeName() { if (null === $this->nodeName) { $this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', \get_called_class()); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/AttributeNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/AttributeNode.php index bf702d9ce4..1caccb6bfe 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/AttributeNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/AttributeNode.php @@ -29,7 +29,14 @@ class AttributeNode extends AbstractNode private $operator; private $value; - public function __construct(NodeInterface $selector, ?string $namespace, string $attribute, string $operator, ?string $value) + /** + * @param NodeInterface $selector + * @param string $namespace + * @param string $attribute + * @param string $operator + * @param string $value + */ + public function __construct(NodeInterface $selector, $namespace, $attribute, $operator, $value) { $this->selector = $selector; $this->namespace = $namespace; @@ -38,27 +45,42 @@ class AttributeNode extends AbstractNode $this->value = $value; } - public function getSelector(): NodeInterface + /** + * @return NodeInterface + */ + public function getSelector() { return $this->selector; } - public function getNamespace(): ?string + /** + * @return string + */ + public function getNamespace() { return $this->namespace; } - public function getAttribute(): string + /** + * @return string + */ + public function getAttribute() { return $this->attribute; } - public function getOperator(): string + /** + * @return string + */ + public function getOperator() { return $this->operator; } - public function getValue(): ?string + /** + * @return string + */ + public function getValue() { return $this->value; } @@ -66,7 +88,7 @@ class AttributeNode extends AbstractNode /** * {@inheritdoc} */ - public function getSpecificity(): Specificity + public function getSpecificity() { return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } @@ -74,7 +96,7 @@ class AttributeNode extends AbstractNode /** * {@inheritdoc} */ - public function __toString(): string + public function __toString() { $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute; diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/ClassNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/ClassNode.php index 1998b4bd5b..69462e8e71 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/ClassNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/ClassNode.php @@ -26,18 +26,28 @@ class ClassNode extends AbstractNode private $selector; private $name; - public function __construct(NodeInterface $selector, string $name) + /** + * @param NodeInterface $selector + * @param string $name + */ + public function __construct(NodeInterface $selector, $name) { $this->selector = $selector; $this->name = $name; } - public function getSelector(): NodeInterface + /** + * @return NodeInterface + */ + public function getSelector() { return $this->selector; } - public function getName(): string + /** + * @return string + */ + public function getName() { return $this->name; } @@ -45,7 +55,7 @@ class ClassNode extends AbstractNode /** * {@inheritdoc} */ - public function getSpecificity(): Specificity + public function getSpecificity() { return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } @@ -53,7 +63,7 @@ class ClassNode extends AbstractNode /** * {@inheritdoc} */ - public function __toString(): string + public function __toString() { return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/CombinedSelectorNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/CombinedSelectorNode.php index f97fd21aeb..2aa583aaf6 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/CombinedSelectorNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/CombinedSelectorNode.php @@ -27,24 +27,38 @@ class CombinedSelectorNode extends AbstractNode private $combinator; private $subSelector; - public function __construct(NodeInterface $selector, string $combinator, NodeInterface $subSelector) + /** + * @param NodeInterface $selector + * @param string $combinator + * @param NodeInterface $subSelector + */ + public function __construct(NodeInterface $selector, $combinator, NodeInterface $subSelector) { $this->selector = $selector; $this->combinator = $combinator; $this->subSelector = $subSelector; } - public function getSelector(): NodeInterface + /** + * @return NodeInterface + */ + public function getSelector() { return $this->selector; } - public function getCombinator(): string + /** + * @return string + */ + public function getCombinator() { return $this->combinator; } - public function getSubSelector(): NodeInterface + /** + * @return NodeInterface + */ + public function getSubSelector() { return $this->subSelector; } @@ -52,7 +66,7 @@ class CombinedSelectorNode extends AbstractNode /** * {@inheritdoc} */ - public function getSpecificity(): Specificity + public function getSpecificity() { return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); } @@ -60,7 +74,7 @@ class CombinedSelectorNode extends AbstractNode /** * {@inheritdoc} */ - public function __toString(): string + public function __toString() { $combinator = ' ' === $this->combinator ? '' : $this->combinator; diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/ElementNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/ElementNode.php index 8fc0be89f0..54869af6cd 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/ElementNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/ElementNode.php @@ -30,7 +30,7 @@ class ElementNode extends AbstractNode * @param string|null $namespace * @param string|null $element */ - public function __construct(string $namespace = null, string $element = null) + public function __construct($namespace = null, $element = null) { $this->namespace = $namespace; $this->element = $element; @@ -55,7 +55,7 @@ class ElementNode extends AbstractNode /** * {@inheritdoc} */ - public function getSpecificity(): Specificity + public function getSpecificity() { return new Specificity(0, 0, $this->element ? 1 : 0); } @@ -63,7 +63,7 @@ class ElementNode extends AbstractNode /** * {@inheritdoc} */ - public function __toString(): string + public function __toString() { $element = $this->element ?: '*'; diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/FunctionNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/FunctionNode.php index 89b6437801..50268255ce 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/FunctionNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/FunctionNode.php @@ -34,19 +34,25 @@ class FunctionNode extends AbstractNode * @param string $name * @param Token[] $arguments */ - public function __construct(NodeInterface $selector, string $name, array $arguments = array()) + public function __construct(NodeInterface $selector, $name, array $arguments = array()) { $this->selector = $selector; $this->name = strtolower($name); $this->arguments = $arguments; } - public function getSelector(): NodeInterface + /** + * @return NodeInterface + */ + public function getSelector() { return $this->selector; } - public function getName(): string + /** + * @return string + */ + public function getName() { return $this->name; } @@ -62,7 +68,7 @@ class FunctionNode extends AbstractNode /** * {@inheritdoc} */ - public function getSpecificity(): Specificity + public function getSpecificity() { return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } @@ -70,7 +76,7 @@ class FunctionNode extends AbstractNode /** * {@inheritdoc} */ - public function __toString(): string + public function __toString() { $arguments = implode(', ', array_map(function (Token $token) { return "'".$token->getValue()."'"; diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/HashNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/HashNode.php index f73fa2e740..ebf9a9872a 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/HashNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/HashNode.php @@ -26,18 +26,28 @@ class HashNode extends AbstractNode private $selector; private $id; - public function __construct(NodeInterface $selector, string $id) + /** + * @param NodeInterface $selector + * @param string $id + */ + public function __construct(NodeInterface $selector, $id) { $this->selector = $selector; $this->id = $id; } - public function getSelector(): NodeInterface + /** + * @return NodeInterface + */ + public function getSelector() { return $this->selector; } - public function getId(): string + /** + * @return string + */ + public function getId() { return $this->id; } @@ -45,7 +55,7 @@ class HashNode extends AbstractNode /** * {@inheritdoc} */ - public function getSpecificity(): Specificity + public function getSpecificity() { return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0)); } @@ -53,7 +63,7 @@ class HashNode extends AbstractNode /** * {@inheritdoc} */ - public function __toString(): string + public function __toString() { return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/NegationNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/NegationNode.php index 9d3e9bc7a6..bf97caeb58 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/NegationNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/NegationNode.php @@ -51,7 +51,7 @@ class NegationNode extends AbstractNode /** * {@inheritdoc} */ - public function getSpecificity(): Specificity + public function getSpecificity() { return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); } @@ -59,7 +59,7 @@ class NegationNode extends AbstractNode /** * {@inheritdoc} */ - public function __toString(): string + public function __toString() { return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/NodeInterface.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/NodeInterface.php index b078d26d4d..d919e20c71 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/NodeInterface.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/NodeInterface.php @@ -23,9 +23,24 @@ namespace Symfony\Component\CssSelector\Node; */ interface NodeInterface { - public function getNodeName(): string; + /** + * Returns node's name. + * + * @return string + */ + public function getNodeName(); - public function getSpecificity(): Specificity; + /** + * Returns node's specificity. + * + * @return Specificity + */ + public function getSpecificity(); - public function __toString(): string; + /** + * Returns node's string representation. + * + * @return string + */ + public function __toString(); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/PseudoNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/PseudoNode.php index 7d4a011e1f..3842c695e8 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/PseudoNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/PseudoNode.php @@ -26,18 +26,28 @@ class PseudoNode extends AbstractNode private $selector; private $identifier; - public function __construct(NodeInterface $selector, string $identifier) + /** + * @param NodeInterface $selector + * @param string $identifier + */ + public function __construct(NodeInterface $selector, $identifier) { $this->selector = $selector; $this->identifier = strtolower($identifier); } - public function getSelector(): NodeInterface + /** + * @return NodeInterface + */ + public function getSelector() { return $this->selector; } - public function getIdentifier(): string + /** + * @return string + */ + public function getIdentifier() { return $this->identifier; } @@ -45,7 +55,7 @@ class PseudoNode extends AbstractNode /** * {@inheritdoc} */ - public function getSpecificity(): Specificity + public function getSpecificity() { return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } @@ -53,7 +63,7 @@ class PseudoNode extends AbstractNode /** * {@inheritdoc} */ - public function __toString(): string + public function __toString() { return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/SelectorNode.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/SelectorNode.php index a76aa5bb5f..057107f6f5 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/SelectorNode.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/SelectorNode.php @@ -26,18 +26,28 @@ class SelectorNode extends AbstractNode private $tree; private $pseudoElement; - public function __construct(NodeInterface $tree, string $pseudoElement = null) + /** + * @param NodeInterface $tree + * @param string|null $pseudoElement + */ + public function __construct(NodeInterface $tree, $pseudoElement = null) { $this->tree = $tree; $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null; } - public function getTree(): NodeInterface + /** + * @return NodeInterface + */ + public function getTree() { return $this->tree; } - public function getPseudoElement(): ?string + /** + * @return string|null + */ + public function getPseudoElement() { return $this->pseudoElement; } @@ -45,7 +55,7 @@ class SelectorNode extends AbstractNode /** * {@inheritdoc} */ - public function getSpecificity(): Specificity + public function getSpecificity() { return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); } @@ -53,7 +63,7 @@ class SelectorNode extends AbstractNode /** * {@inheritdoc} */ - public function __toString(): string + public function __toString() { return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : ''); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/Specificity.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/Specificity.php index 9b35cb4116..a11b7f73d8 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/Specificity.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Node/Specificity.php @@ -33,19 +33,32 @@ class Specificity private $b; private $c; - public function __construct(int $a, int $b, int $c) + /** + * @param int $a + * @param int $b + * @param int $c + */ + public function __construct($a, $b, $c) { $this->a = $a; $this->b = $b; $this->c = $c; } - public function plus(self $specificity): self + /** + * @return self + */ + public function plus(self $specificity) { return new self($this->a + $specificity->a, $this->b + $specificity->b, $this->c + $specificity->c); } - public function getValue(): int + /** + * Returns global specificity value. + * + * @return int + */ + public function getValue() { return $this->a * self::A_FACTOR + $this->b * self::B_FACTOR + $this->c * self::C_FACTOR; } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/CommentHandler.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/CommentHandler.php index 93f318844a..a29775cab3 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/CommentHandler.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/CommentHandler.php @@ -29,7 +29,7 @@ class CommentHandler implements HandlerInterface /** * {@inheritdoc} */ - public function handle(Reader $reader, TokenStream $stream): bool + public function handle(Reader $reader, TokenStream $stream) { if ('/*' !== $reader->getSubstring(2)) { return false; diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/HandlerInterface.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/HandlerInterface.php index d7ac4d332b..de931f6797 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/HandlerInterface.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/HandlerInterface.php @@ -29,5 +29,5 @@ interface HandlerInterface /** * @return bool */ - public function handle(Reader $reader, TokenStream $stream): bool; + public function handle(Reader $reader, TokenStream $stream); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/HashHandler.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/HashHandler.php index 7ae9b438ca..e451328f17 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/HashHandler.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/HashHandler.php @@ -41,7 +41,7 @@ class HashHandler implements HandlerInterface /** * {@inheritdoc} */ - public function handle(Reader $reader, TokenStream $stream): bool + public function handle(Reader $reader, TokenStream $stream) { $match = $reader->findPattern($this->patterns->getHashPattern()); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/IdentifierHandler.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/IdentifierHandler.php index 7b2a14e2c3..1591fcb54b 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/IdentifierHandler.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/IdentifierHandler.php @@ -41,7 +41,7 @@ class IdentifierHandler implements HandlerInterface /** * {@inheritdoc} */ - public function handle(Reader $reader, TokenStream $stream): bool + public function handle(Reader $reader, TokenStream $stream) { $match = $reader->findPattern($this->patterns->getIdentifierPattern()); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/NumberHandler.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/NumberHandler.php index 8291a68d13..5955903cd4 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/NumberHandler.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/NumberHandler.php @@ -38,7 +38,7 @@ class NumberHandler implements HandlerInterface /** * {@inheritdoc} */ - public function handle(Reader $reader, TokenStream $stream): bool + public function handle(Reader $reader, TokenStream $stream) { $match = $reader->findPattern($this->patterns->getNumberPattern()); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/StringHandler.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/StringHandler.php index eea1aa9b0c..00155b0465 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/StringHandler.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/StringHandler.php @@ -43,7 +43,7 @@ class StringHandler implements HandlerInterface /** * {@inheritdoc} */ - public function handle(Reader $reader, TokenStream $stream): bool + public function handle(Reader $reader, TokenStream $stream) { $quote = $reader->getSubstring(1); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/WhitespaceHandler.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/WhitespaceHandler.php index 21345e32c7..396467af0f 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/WhitespaceHandler.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Handler/WhitespaceHandler.php @@ -30,7 +30,7 @@ class WhitespaceHandler implements HandlerInterface /** * {@inheritdoc} */ - public function handle(Reader $reader, TokenStream $stream): bool + public function handle(Reader $reader, TokenStream $stream) { $match = $reader->findPattern('~^[ \t\r\n\f]+~'); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Parser.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Parser.php index d42bdca604..87c05a74b5 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Parser.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Parser.php @@ -37,7 +37,7 @@ class Parser implements ParserInterface /** * {@inheritdoc} */ - public function parse(string $source): array + public function parse($source) { $reader = new Reader($source); $stream = $this->tokenizer->tokenize($reader); @@ -50,9 +50,11 @@ class Parser implements ParserInterface * * @param Token[] $tokens * + * @return array + * * @throws SyntaxErrorException */ - public static function parseSeries(array $tokens): array + public static function parseSeries(array $tokens) { foreach ($tokens as $token) { if ($token->isString()) { @@ -92,7 +94,12 @@ class Parser implements ParserInterface ); } - private function parseSelectorList(TokenStream $stream): array + /** + * Parses selector nodes. + * + * @return array + */ + private function parseSelectorList(TokenStream $stream) { $stream->skipWhitespace(); $selectors = array(); @@ -111,7 +118,14 @@ class Parser implements ParserInterface return $selectors; } - private function parserSelectorNode(TokenStream $stream): Node\SelectorNode + /** + * Parses next selector or combined node. + * + * @return Node\SelectorNode + * + * @throws SyntaxErrorException + */ + private function parserSelectorNode(TokenStream $stream) { list($result, $pseudoElement) = $this->parseSimpleSelector($stream); @@ -144,9 +158,14 @@ class Parser implements ParserInterface /** * Parses next simple node (hash, class, pseudo, negation). * + * @param TokenStream $stream + * @param bool $insideNegation + * + * @return array + * * @throws SyntaxErrorException */ - private function parseSimpleSelector(TokenStream $stream, bool $insideNegation = false): array + private function parseSimpleSelector(TokenStream $stream, $insideNegation = false) { $stream->skipWhitespace(); @@ -260,7 +279,12 @@ class Parser implements ParserInterface return array($result, $pseudoElement); } - private function parseElementNode(TokenStream $stream): Node\ElementNode + /** + * Parses next element node. + * + * @return Node\ElementNode + */ + private function parseElementNode(TokenStream $stream) { $peek = $stream->getPeek(); @@ -286,7 +310,14 @@ class Parser implements ParserInterface return new Node\ElementNode($namespace, $element); } - private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $stream): Node\AttributeNode + /** + * Parses next attribute node. + * + * @return Node\AttributeNode + * + * @throws SyntaxErrorException + */ + private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $stream) { $stream->skipWhitespace(); $attribute = $stream->getNextIdentifierOrStar(); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/ParserInterface.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/ParserInterface.php index 51c3d93506..c5af20367d 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/ParserInterface.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/ParserInterface.php @@ -28,7 +28,9 @@ interface ParserInterface /** * Parses given selector source into an array of tokens. * + * @param string $source + * * @return SelectorNode[] */ - public function parse(string $source): array; + public function parse($source); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Reader.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Reader.php index 4b43effed3..076cb711c0 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Reader.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Reader.php @@ -27,33 +27,56 @@ class Reader private $length; private $position = 0; - public function __construct(string $source) + /** + * @param string $source + */ + public function __construct($source) { $this->source = $source; $this->length = \strlen($source); } - public function isEOF(): bool + /** + * @return bool + */ + public function isEOF() { return $this->position >= $this->length; } - public function getPosition(): int + /** + * @return int + */ + public function getPosition() { return $this->position; } - public function getRemainingLength(): int + /** + * @return int + */ + public function getRemainingLength() { return $this->length - $this->position; } - public function getSubstring(int $length, int $offset = 0): string + /** + * @param int $length + * @param int $offset + * + * @return string + */ + public function getSubstring($length, $offset = 0) { return substr($this->source, $this->position + $offset, $length); } - public function getOffset(string $string) + /** + * @param string $string + * + * @return int + */ + public function getOffset($string) { $position = strpos($this->source, $string, $this->position); @@ -61,9 +84,11 @@ class Reader } /** + * @param string $pattern + * * @return array|false */ - public function findPattern(string $pattern) + public function findPattern($pattern) { $source = substr($this->source, $this->position); @@ -74,7 +99,10 @@ class Reader return false; } - public function moveForward(int $length) + /** + * @param int $length + */ + public function moveForward($length) { $this->position += $length; } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/ClassParser.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/ClassParser.php index ce7b20ef2e..c513de5ff1 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/ClassParser.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/ClassParser.php @@ -31,7 +31,7 @@ class ClassParser implements ParserInterface /** * {@inheritdoc} */ - public function parse(string $source): array + public function parse($source) { // Matches an optional namespace, optional element, and required class // $source = 'test|input.ab6bd_field'; diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/ElementParser.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/ElementParser.php index 3b93f0068f..c29f5e442e 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/ElementParser.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/ElementParser.php @@ -30,7 +30,7 @@ class ElementParser implements ParserInterface /** * {@inheritdoc} */ - public function parse(string $source): array + public function parse($source) { // Matches an optional namespace, required element or `*` // $source = 'testns|testel'; diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/EmptyStringParser.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/EmptyStringParser.php index e8a89cc4db..16d374af30 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/EmptyStringParser.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/EmptyStringParser.php @@ -34,7 +34,7 @@ class EmptyStringParser implements ParserInterface /** * {@inheritdoc} */ - public function parse(string $source): array + public function parse($source) { // Matches an empty string if ('' == $source) { diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/HashParser.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/HashParser.php index e94ce0a46a..3f3883bb8d 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/HashParser.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Shortcut/HashParser.php @@ -31,7 +31,7 @@ class HashParser implements ParserInterface /** * {@inheritdoc} */ - public function parse(string $source): array + public function parse($source) { // Matches an optional namespace, optional element, and required id // $source = 'test|input#ab6bd_field'; diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Token.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Token.php index 91a98f7154..72baae776d 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Token.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Token.php @@ -35,34 +35,54 @@ class Token private $value; private $position; - public function __construct(?string $type, ?string $value, ?int $position) + /** + * @param int $type + * @param string $value + * @param int $position + */ + public function __construct($type, $value, $position) { $this->type = $type; $this->value = $value; $this->position = $position; } - public function getType(): ?int + /** + * @return int + */ + public function getType() { return $this->type; } - public function getValue(): ?string + /** + * @return string + */ + public function getValue() { return $this->value; } - public function getPosition(): ?int + /** + * @return int + */ + public function getPosition() { return $this->position; } - public function isFileEnd(): bool + /** + * @return bool + */ + public function isFileEnd() { return self::TYPE_FILE_END === $this->type; } - public function isDelimiter(array $values = array()): bool + /** + * @return bool + */ + public function isDelimiter(array $values = array()) { if (self::TYPE_DELIMITER !== $this->type) { return false; @@ -75,32 +95,50 @@ class Token return \in_array($this->value, $values); } - public function isWhitespace(): bool + /** + * @return bool + */ + public function isWhitespace() { return self::TYPE_WHITESPACE === $this->type; } - public function isIdentifier(): bool + /** + * @return bool + */ + public function isIdentifier() { return self::TYPE_IDENTIFIER === $this->type; } - public function isHash(): bool + /** + * @return bool + */ + public function isHash() { return self::TYPE_HASH === $this->type; } - public function isNumber(): bool + /** + * @return bool + */ + public function isNumber() { return self::TYPE_NUMBER === $this->type; } - public function isString(): bool + /** + * @return bool + */ + public function isString() { return self::TYPE_STRING === $this->type; } - public function __toString(): string + /** + * @return string + */ + public function __toString() { if ($this->value) { return sprintf('<%s "%s" at %s>', $this->type, $this->value, $this->position); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php index 200272f23d..55ea421493 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php @@ -30,21 +30,36 @@ class TokenizerEscaping $this->patterns = $patterns; } - public function escapeUnicode(string $value): string + /** + * @param string $value + * + * @return string + */ + public function escapeUnicode($value) { $value = $this->replaceUnicodeSequences($value); return preg_replace($this->patterns->getSimpleEscapePattern(), '$1', $value); } - public function escapeUnicodeAndNewLine(string $value): string + /** + * @param string $value + * + * @return string + */ + public function escapeUnicodeAndNewLine($value) { $value = preg_replace($this->patterns->getNewLineEscapePattern(), '', $value); return $this->escapeUnicode($value); } - private function replaceUnicodeSequences(string $value): string + /** + * @param string $value + * + * @return string + */ + private function replaceUnicodeSequences($value) { return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function ($match) { $c = hexdec($match[1]); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Tokenizer/TokenizerPatterns.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Tokenizer/TokenizerPatterns.php index 5f16ac48f8..bc6130d7d3 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Tokenizer/TokenizerPatterns.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/Parser/Tokenizer/TokenizerPatterns.php @@ -52,37 +52,60 @@ class TokenizerPatterns $this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*'; } - public function getNewLineEscapePattern(): string + /** + * @return string + */ + public function getNewLineEscapePattern() { return '~^'.$this->newLineEscapePattern.'~'; } - public function getSimpleEscapePattern(): string + /** + * @return string + */ + public function getSimpleEscapePattern() { return '~^'.$this->simpleEscapePattern.'~'; } - public function getUnicodeEscapePattern(): string + /** + * @return string + */ + public function getUnicodeEscapePattern() { return '~^'.$this->unicodeEscapePattern.'~i'; } - public function getIdentifierPattern(): string + /** + * @return string + */ + public function getIdentifierPattern() { return '~^'.$this->identifierPattern.'~i'; } - public function getHashPattern(): string + /** + * @return string + */ + public function getHashPattern() { return '~^'.$this->hashPattern.'~i'; } - public function getNumberPattern(): string + /** + * @return string + */ + public function getNumberPattern() { return '~^'.$this->numberPattern.'~'; } - public function getQuotedStringPattern(string $quote): string + /** + * @param string $quote + * + * @return string + */ + public function getQuotedStringPattern($quote) { return '~^'.sprintf($this->quotedStringPattern, $quote).'~i'; } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php index 8a4d884212..2078dca61d 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php @@ -43,17 +43,38 @@ class AttributeMatchingExtension extends AbstractExtension ); } - public function translateExists(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateExists(XPathExpr $xpath, $attribute, $value) { return $xpath->addCondition($attribute); } - public function translateEquals(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateEquals(XPathExpr $xpath, $attribute, $value) { return $xpath->addCondition(sprintf('%s = %s', $attribute, Translator::getXpathLiteral($value))); } - public function translateIncludes(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateIncludes(XPathExpr $xpath, $attribute, $value) { return $xpath->addCondition($value ? sprintf( '%1$s and contains(concat(\' \', normalize-space(%1$s), \' \'), %2$s)', @@ -62,7 +83,14 @@ class AttributeMatchingExtension extends AbstractExtension ) : '0'); } - public function translateDashMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateDashMatch(XPathExpr $xpath, $attribute, $value) { return $xpath->addCondition(sprintf( '%1$s and (%1$s = %2$s or starts-with(%1$s, %3$s))', @@ -72,7 +100,14 @@ class AttributeMatchingExtension extends AbstractExtension )); } - public function translatePrefixMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translatePrefixMatch(XPathExpr $xpath, $attribute, $value) { return $xpath->addCondition($value ? sprintf( '%1$s and starts-with(%1$s, %2$s)', @@ -81,7 +116,14 @@ class AttributeMatchingExtension extends AbstractExtension ) : '0'); } - public function translateSuffixMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateSuffixMatch(XPathExpr $xpath, $attribute, $value) { return $xpath->addCondition($value ? sprintf( '%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s', @@ -91,7 +133,14 @@ class AttributeMatchingExtension extends AbstractExtension ) : '0'); } - public function translateSubstringMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateSubstringMatch(XPathExpr $xpath, $attribute, $value) { return $xpath->addCondition($value ? sprintf( '%1$s and contains(%1$s, %2$s)', @@ -100,7 +149,14 @@ class AttributeMatchingExtension extends AbstractExtension ) : '0'); } - public function translateDifferent(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateDifferent(XPathExpr $xpath, $attribute, $value) { return $xpath->addCondition(sprintf( $value ? 'not(%1$s) or %1$s != %2$s' : '%s != %s', diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/CombinationExtension.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/CombinationExtension.php index 85181fd93e..0c9cc0320c 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/CombinationExtension.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/CombinationExtension.php @@ -28,7 +28,7 @@ class CombinationExtension extends AbstractExtension /** * {@inheritdoc} */ - public function getCombinationTranslators(): array + public function getCombinationTranslators() { return array( ' ' => array($this, 'translateDescendant'), @@ -41,7 +41,7 @@ class CombinationExtension extends AbstractExtension /** * @return XPathExpr */ - public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath): XPathExpr + public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath) { return $xpath->join('/descendant-or-self::*/', $combinedXpath); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/FunctionExtension.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/FunctionExtension.php index ebe508fefd..4d34d0ef24 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/FunctionExtension.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/FunctionExtension.php @@ -46,9 +46,16 @@ class FunctionExtension extends AbstractExtension } /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * @param bool $last + * @param bool $addNameTest + * + * @return XPathExpr + * * @throws ExpressionErrorException */ - public function translateNthChild(XPathExpr $xpath, FunctionNode $function, bool $last = false, bool $addNameTest = true): XPathExpr + public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $last = false, $addNameTest = true) { try { list($a, $b) = Parser::parseSeries($function->getArguments()); @@ -103,20 +110,28 @@ class FunctionExtension extends AbstractExtension // -1n+6 means elements 6 and previous } - public function translateNthLastChild(XPathExpr $xpath, FunctionNode $function): XPathExpr + /** + * @return XPathExpr + */ + public function translateNthLastChild(XPathExpr $xpath, FunctionNode $function) { return $this->translateNthChild($xpath, $function, true); } - public function translateNthOfType(XPathExpr $xpath, FunctionNode $function): XPathExpr + /** + * @return XPathExpr + */ + public function translateNthOfType(XPathExpr $xpath, FunctionNode $function) { return $this->translateNthChild($xpath, $function, false, false); } /** + * @return XPathExpr + * * @throws ExpressionErrorException */ - public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function): XPathExpr + public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function) { if ('*' === $xpath->getElement()) { throw new ExpressionErrorException('"*:nth-of-type()" is not implemented.'); @@ -126,9 +141,11 @@ class FunctionExtension extends AbstractExtension } /** + * @return XPathExpr + * * @throws ExpressionErrorException */ - public function translateContains(XPathExpr $xpath, FunctionNode $function): XPathExpr + public function translateContains(XPathExpr $xpath, FunctionNode $function) { $arguments = $function->getArguments(); foreach ($arguments as $token) { @@ -144,9 +161,11 @@ class FunctionExtension extends AbstractExtension } /** + * @return XPathExpr + * * @throws ExpressionErrorException */ - public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathExpr + public function translateLang(XPathExpr $xpath, FunctionNode $function) { $arguments = $function->getArguments(); foreach ($arguments as $token) { diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/NodeExtension.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/NodeExtension.php index 61442b6f7a..715d9611a8 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/NodeExtension.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Extension/NodeExtension.php @@ -33,15 +33,21 @@ class NodeExtension extends AbstractExtension private $flags; - public function __construct(int $flags = 0) + /** + * @param int $flags + */ + public function __construct($flags = 0) { $this->flags = $flags; } /** + * @param int $flag + * @param bool $on + * * @return $this */ - public function setFlag(int $flag, bool $on) + public function setFlag($flag, $on) { if ($on && !$this->hasFlag($flag)) { $this->flags += $flag; @@ -54,7 +60,12 @@ class NodeExtension extends AbstractExtension return $this; } - public function hasFlag(int $flag): bool + /** + * @param int $flag + * + * @return bool + */ + public function hasFlag($flag) { return (bool) ($this->flags & $flag); } @@ -77,17 +88,26 @@ class NodeExtension extends AbstractExtension ); } - public function translateSelector(Node\SelectorNode $node, Translator $translator): XPathExpr + /** + * @return XPathExpr + */ + public function translateSelector(Node\SelectorNode $node, Translator $translator) { return $translator->nodeToXPath($node->getTree()); } - public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator): XPathExpr + /** + * @return XPathExpr + */ + public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator) { return $translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector()); } - public function translateNegation(Node\NegationNode $node, Translator $translator): XPathExpr + /** + * @return XPathExpr + */ + public function translateNegation(Node\NegationNode $node, Translator $translator) { $xpath = $translator->nodeToXPath($node->getSelector()); $subXpath = $translator->nodeToXPath($node->getSubSelector()); @@ -100,21 +120,30 @@ class NodeExtension extends AbstractExtension return $xpath->addCondition('0'); } - public function translateFunction(Node\FunctionNode $node, Translator $translator): XPathExpr + /** + * @return XPathExpr + */ + public function translateFunction(Node\FunctionNode $node, Translator $translator) { $xpath = $translator->nodeToXPath($node->getSelector()); return $translator->addFunction($xpath, $node); } - public function translatePseudo(Node\PseudoNode $node, Translator $translator): XPathExpr + /** + * @return XPathExpr + */ + public function translatePseudo(Node\PseudoNode $node, Translator $translator) { $xpath = $translator->nodeToXPath($node->getSelector()); return $translator->addPseudoClass($xpath, $node->getIdentifier()); } - public function translateAttribute(Node\AttributeNode $node, Translator $translator): XPathExpr + /** + * @return XPathExpr + */ + public function translateAttribute(Node\AttributeNode $node, Translator $translator) { $name = $node->getAttribute(); $safe = $this->isSafeName($name); @@ -139,21 +168,30 @@ class NodeExtension extends AbstractExtension return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value); } - public function translateClass(Node\ClassNode $node, Translator $translator): XPathExpr + /** + * @return XPathExpr + */ + public function translateClass(Node\ClassNode $node, Translator $translator) { $xpath = $translator->nodeToXPath($node->getSelector()); return $translator->addAttributeMatching($xpath, '~=', '@class', $node->getName()); } - public function translateHash(Node\HashNode $node, Translator $translator): XPathExpr + /** + * @return XPathExpr + */ + public function translateHash(Node\HashNode $node, Translator $translator) { $xpath = $translator->nodeToXPath($node->getSelector()); return $translator->addAttributeMatching($xpath, '=', '@id', $node->getId()); } - public function translateElement(Node\ElementNode $node): XPathExpr + /** + * @return XPathExpr + */ + public function translateElement(Node\ElementNode $node) { $element = $node->getElement(); @@ -190,7 +228,14 @@ class NodeExtension extends AbstractExtension return 'node'; } - private function isSafeName(string $name): bool + /** + * Tests if given name is safe. + * + * @param string $name + * + * @return bool + */ + private function isSafeName($name) { return 0 < preg_match('~^[a-zA-Z_][a-zA-Z0-9_.-]*$~', $name); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Translator.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Translator.php index 97e4dfba18..f8585a057d 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Translator.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/Translator.php @@ -61,7 +61,12 @@ class Translator implements TranslatorInterface ; } - public static function getXpathLiteral(string $element): string + /** + * @param string $element + * + * @return string + */ + public static function getXpathLiteral($element) { if (false === strpos($element, "'")) { return "'".$element."'"; @@ -90,7 +95,7 @@ class Translator implements TranslatorInterface /** * {@inheritdoc} */ - public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string + public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::') { $selectors = $this->parseSelectors($cssExpr); @@ -109,12 +114,17 @@ class Translator implements TranslatorInterface /** * {@inheritdoc} */ - public function selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::'): string + public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::') { return ($prefix ?: '').$this->nodeToXPath($selector); } - public function registerExtension(Extension\ExtensionInterface $extension): self + /** + * Registers an extension. + * + * @return $this + */ + public function registerExtension(Extension\ExtensionInterface $extension) { $this->extensions[$extension->getName()] = $extension; @@ -128,9 +138,13 @@ class Translator implements TranslatorInterface } /** + * @param string $name + * + * @return Extension\ExtensionInterface + * * @throws ExpressionErrorException */ - public function getExtension(string $name): Extension\ExtensionInterface + public function getExtension($name) { if (!isset($this->extensions[$name])) { throw new ExpressionErrorException(sprintf('Extension "%s" not registered.', $name)); @@ -139,7 +153,12 @@ class Translator implements TranslatorInterface return $this->extensions[$name]; } - public function registerParserShortcut(ParserInterface $shortcut): self + /** + * Registers a shortcut parser. + * + * @return $this + */ + public function registerParserShortcut(ParserInterface $shortcut) { $this->shortcutParsers[] = $shortcut; @@ -147,9 +166,11 @@ class Translator implements TranslatorInterface } /** + * @return XPathExpr + * * @throws ExpressionErrorException */ - public function nodeToXPath(NodeInterface $node): XPathExpr + public function nodeToXPath(NodeInterface $node) { if (!isset($this->nodeTranslators[$node->getNodeName()])) { throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName())); @@ -159,9 +180,15 @@ class Translator implements TranslatorInterface } /** + * @param string $combiner + * @param NodeInterface $xpath + * @param NodeInterface $combinedXpath + * + * @return XPathExpr + * * @throws ExpressionErrorException */ - public function addCombination(string $combiner, NodeInterface $xpath, NodeInterface $combinedXpath): XPathExpr + public function addCombination($combiner, NodeInterface $xpath, NodeInterface $combinedXpath) { if (!isset($this->combinationTranslators[$combiner])) { throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner)); @@ -171,9 +198,11 @@ class Translator implements TranslatorInterface } /** + * @return XPathExpr + * * @throws ExpressionErrorException */ - public function addFunction(XPathExpr $xpath, FunctionNode $function): XPathExpr + public function addFunction(XPathExpr $xpath, FunctionNode $function) { if (!isset($this->functionTranslators[$function->getName()])) { throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName())); @@ -183,9 +212,14 @@ class Translator implements TranslatorInterface } /** + * @param XPathExpr $xpath + * @param string $pseudoClass + * + * @return XPathExpr + * * @throws ExpressionErrorException */ - public function addPseudoClass(XPathExpr $xpath, string $pseudoClass): XPathExpr + public function addPseudoClass(XPathExpr $xpath, $pseudoClass) { if (!isset($this->pseudoClassTranslators[$pseudoClass])) { throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass)); @@ -195,9 +229,16 @@ class Translator implements TranslatorInterface } /** + * @param XPathExpr $xpath + * @param string $operator + * @param string $attribute + * @param string $value + * + * @return XPathExpr + * * @throws ExpressionErrorException */ - public function addAttributeMatching(XPathExpr $xpath, string $operator, string $attribute, $value): XPathExpr + public function addAttributeMatching(XPathExpr $xpath, $operator, $attribute, $value) { if (!isset($this->attributeMatchingTranslators[$operator])) { throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator)); @@ -207,9 +248,11 @@ class Translator implements TranslatorInterface } /** + * @param string $css + * * @return SelectorNode[] */ - private function parseSelectors(string $css) + private function parseSelectors($css) { foreach ($this->shortcutParsers as $shortcut) { $tokens = $shortcut->parse($css); diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/TranslatorInterface.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/TranslatorInterface.php index c19eefb9c9..0b5de83d57 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/TranslatorInterface.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/TranslatorInterface.php @@ -27,11 +27,21 @@ interface TranslatorInterface { /** * Translates a CSS selector to an XPath expression. + * + * @param string $cssExpr + * @param string $prefix + * + * @return string */ - public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string; + public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::'); /** * Translates a parsed selector node to an XPath expression. + * + * @param SelectorNode $selector + * @param string $prefix + * + * @return string */ - public function selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::'): string; + public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::'); } diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/XPathExpr.php b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/XPathExpr.php index 638cbd0fe0..a1e244c9e4 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/XPathExpr.php +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/XPath/XPathExpr.php @@ -27,7 +27,13 @@ class XPathExpr private $element; private $condition; - public function __construct(string $path = '', string $element = '*', string $condition = '', bool $starPrefix = false) + /** + * @param string $path + * @param string $element + * @param string $condition + * @param bool $starPrefix + */ + public function __construct($path = '', $element = '*', $condition = '', $starPrefix = false) { $this->path = $path; $this->element = $element; @@ -38,24 +44,36 @@ class XPathExpr } } - public function getElement(): string + /** + * @return string + */ + public function getElement() { return $this->element; } - public function addCondition(string $condition): self + /** + * @return $this + */ + public function addCondition($condition) { $this->condition = $this->condition ? sprintf('(%s) and (%s)', $this->condition, $condition) : $condition; return $this; } - public function getCondition(): string + /** + * @return string + */ + public function getCondition() { return $this->condition; } - public function addNameTest(): self + /** + * @return $this + */ + public function addNameTest() { if ('*' !== $this->element) { $this->addCondition('name() = '.Translator::getXpathLiteral($this->element)); @@ -65,7 +83,10 @@ class XPathExpr return $this; } - public function addStarPrefix(): self + /** + * @return $this + */ + public function addStarPrefix() { $this->path .= '*/'; @@ -75,9 +96,12 @@ class XPathExpr /** * Joins another XPathExpr with a combiner. * + * @param string $combiner + * @param XPathExpr $expr + * * @return $this */ - public function join(string $combiner, self $expr): self + public function join($combiner, self $expr) { $path = $this->__toString().$combiner; @@ -92,7 +116,10 @@ class XPathExpr return $this; } - public function __toString(): string + /** + * @return string + */ + public function __toString() { $path = $this->path.$this->element; $condition = null === $this->condition || '' === $this->condition ? '' : '['.$this->condition.']'; diff --git a/wcfsetup/install/files/lib/system/api/symfony/css-selector/composer.json b/wcfsetup/install/files/lib/system/api/symfony/css-selector/composer.json index ebe7d0d5c1..56ab35b814 100644 --- a/wcfsetup/install/files/lib/system/api/symfony/css-selector/composer.json +++ b/wcfsetup/install/files/lib/system/api/symfony/css-selector/composer.json @@ -20,7 +20,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^5.5.9|>=7.0.8" }, "autoload": { "psr-4": { "Symfony\\Component\\CssSelector\\": "" }, @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } } } -- 2.20.1