This is required to pull in PHP 7.0 compatible libraries.
{
"config": {
"vendor-dir": "./",
- "prepend-autoloader": false
+ "prepend-autoloader": false,
+ "platform": {
+ "php": "7.0.22",
+ "ext-gd": "0"
+ }
},
"require": {
"ezyang/htmlpurifier": "4.10.*",
"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",
},
{
"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": {
],
"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",
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
- "platform-dev": []
+ "platform-dev": [],
+ "platform-overrides": {
+ "php": "7.0.22",
+ "ext-gd": "0"
+ }
}
},
{
"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",
/**
* @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();
*
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
*/
-interface ExceptionInterface extends \Throwable
+interface ExceptionInterface
{
}
/**
* @return string
*/
- public function getNodeName(): string
+ public function getNodeName()
{
if (null === $this->nodeName) {
$this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', \get_called_class());
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;
$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;
}
/**
* {@inheritdoc}
*/
- public function getSpecificity(): Specificity
+ public function getSpecificity()
{
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
}
/**
* {@inheritdoc}
*/
- public function __toString(): string
+ public function __toString()
{
$attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute;
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;
}
/**
* {@inheritdoc}
*/
- public function getSpecificity(): Specificity
+ public function getSpecificity()
{
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
}
/**
* {@inheritdoc}
*/
- public function __toString(): string
+ public function __toString()
{
return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name);
}
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;
}
/**
* {@inheritdoc}
*/
- public function getSpecificity(): Specificity
+ public function getSpecificity()
{
return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity());
}
/**
* {@inheritdoc}
*/
- public function __toString(): string
+ public function __toString()
{
$combinator = ' ' === $this->combinator ? '<followed>' : $this->combinator;
* @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;
/**
* {@inheritdoc}
*/
- public function getSpecificity(): Specificity
+ public function getSpecificity()
{
return new Specificity(0, 0, $this->element ? 1 : 0);
}
/**
* {@inheritdoc}
*/
- public function __toString(): string
+ public function __toString()
{
$element = $this->element ?: '*';
* @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;
}
/**
* {@inheritdoc}
*/
- public function getSpecificity(): Specificity
+ public function getSpecificity()
{
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
}
/**
* {@inheritdoc}
*/
- public function __toString(): string
+ public function __toString()
{
$arguments = implode(', ', array_map(function (Token $token) {
return "'".$token->getValue()."'";
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;
}
/**
* {@inheritdoc}
*/
- public function getSpecificity(): Specificity
+ public function getSpecificity()
{
return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0));
}
/**
* {@inheritdoc}
*/
- public function __toString(): string
+ public function __toString()
{
return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id);
}
/**
* {@inheritdoc}
*/
- public function getSpecificity(): Specificity
+ public function getSpecificity()
{
return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity());
}
/**
* {@inheritdoc}
*/
- public function __toString(): string
+ public function __toString()
{
return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector);
}
*/
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();
}
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;
}
/**
* {@inheritdoc}
*/
- public function getSpecificity(): Specificity
+ public function getSpecificity()
{
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
}
/**
* {@inheritdoc}
*/
- public function __toString(): string
+ public function __toString()
{
return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier);
}
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;
}
/**
* {@inheritdoc}
*/
- public function getSpecificity(): Specificity
+ public function getSpecificity()
{
return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0));
}
/**
* {@inheritdoc}
*/
- public function __toString(): string
+ public function __toString()
{
return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : '');
}
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;
}
/**
* {@inheritdoc}
*/
- public function handle(Reader $reader, TokenStream $stream): bool
+ public function handle(Reader $reader, TokenStream $stream)
{
if ('/*' !== $reader->getSubstring(2)) {
return false;
/**
* @return bool
*/
- public function handle(Reader $reader, TokenStream $stream): bool;
+ public function handle(Reader $reader, TokenStream $stream);
}
/**
* {@inheritdoc}
*/
- public function handle(Reader $reader, TokenStream $stream): bool
+ public function handle(Reader $reader, TokenStream $stream)
{
$match = $reader->findPattern($this->patterns->getHashPattern());
/**
* {@inheritdoc}
*/
- public function handle(Reader $reader, TokenStream $stream): bool
+ public function handle(Reader $reader, TokenStream $stream)
{
$match = $reader->findPattern($this->patterns->getIdentifierPattern());
/**
* {@inheritdoc}
*/
- public function handle(Reader $reader, TokenStream $stream): bool
+ public function handle(Reader $reader, TokenStream $stream)
{
$match = $reader->findPattern($this->patterns->getNumberPattern());
/**
* {@inheritdoc}
*/
- public function handle(Reader $reader, TokenStream $stream): bool
+ public function handle(Reader $reader, TokenStream $stream)
{
$quote = $reader->getSubstring(1);
/**
* {@inheritdoc}
*/
- public function handle(Reader $reader, TokenStream $stream): bool
+ public function handle(Reader $reader, TokenStream $stream)
{
$match = $reader->findPattern('~^[ \t\r\n\f]+~');
/**
* {@inheritdoc}
*/
- public function parse(string $source): array
+ public function parse($source)
{
$reader = new Reader($source);
$stream = $this->tokenizer->tokenize($reader);
*
* @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()) {
);
}
- private function parseSelectorList(TokenStream $stream): array
+ /**
+ * Parses selector nodes.
+ *
+ * @return array
+ */
+ private function parseSelectorList(TokenStream $stream)
{
$stream->skipWhitespace();
$selectors = array();
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);
/**
* 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();
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();
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();
/**
* Parses given selector source into an array of tokens.
*
+ * @param string $source
+ *
* @return SelectorNode[]
*/
- public function parse(string $source): array;
+ public function parse($source);
}
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);
}
/**
+ * @param string $pattern
+ *
* @return array|false
*/
- public function findPattern(string $pattern)
+ public function findPattern($pattern)
{
$source = substr($this->source, $this->position);
return false;
}
- public function moveForward(int $length)
+ /**
+ * @param int $length
+ */
+ public function moveForward($length)
{
$this->position += $length;
}
/**
* {@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';
/**
* {@inheritdoc}
*/
- public function parse(string $source): array
+ public function parse($source)
{
// Matches an optional namespace, required element or `*`
// $source = 'testns|testel';
/**
* {@inheritdoc}
*/
- public function parse(string $source): array
+ public function parse($source)
{
// Matches an empty string
if ('' == $source) {
/**
* {@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';
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;
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);
$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]);
$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';
}
);
}
- 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)',
) : '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))',
));
}
- 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)',
) : '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',
) : '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)',
) : '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',
/**
* {@inheritdoc}
*/
- public function getCombinationTranslators(): array
+ public function getCombinationTranslators()
{
return array(
' ' => array($this, 'translateDescendant'),
/**
* @return XPathExpr
*/
- public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath): XPathExpr
+ public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath)
{
return $xpath->join('/descendant-or-self::*/', $combinedXpath);
}
}
/**
+ * @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());
// -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.');
}
/**
+ * @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) {
}
/**
+ * @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) {
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;
return $this;
}
- public function hasFlag(int $flag): bool
+ /**
+ * @param int $flag
+ *
+ * @return bool
+ */
+ public function hasFlag($flag)
{
return (bool) ($this->flags & $flag);
}
);
}
- 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());
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);
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();
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);
}
;
}
- public static function getXpathLiteral(string $element): string
+ /**
+ * @param string $element
+ *
+ * @return string
+ */
+ public static function getXpathLiteral($element)
{
if (false === strpos($element, "'")) {
return "'".$element."'";
/**
* {@inheritdoc}
*/
- public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
+ public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::')
{
$selectors = $this->parseSelectors($cssExpr);
/**
* {@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;
}
/**
+ * @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));
return $this->extensions[$name];
}
- public function registerParserShortcut(ParserInterface $shortcut): self
+ /**
+ * Registers a shortcut parser.
+ *
+ * @return $this
+ */
+ public function registerParserShortcut(ParserInterface $shortcut)
{
$this->shortcutParsers[] = $shortcut;
}
/**
+ * @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()));
}
/**
+ * @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));
}
/**
+ * @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()));
}
/**
+ * @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));
}
/**
+ * @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));
}
/**
+ * @param string $css
+ *
* @return SelectorNode[]
*/
- private function parseSelectors(string $css)
+ private function parseSelectors($css)
{
foreach ($this->shortcutParsers as $shortcut) {
$tokens = $shortcut->parse($css);
{
/**
* 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::');
}
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;
}
}
- 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));
return $this;
}
- public function addStarPrefix(): self
+ /**
+ * @return $this
+ */
+ public function addStarPrefix()
{
$this->path .= '*/';
/**
* 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;
return $this;
}
- public function __toString(): string
+ /**
+ * @return string
+ */
+ public function __toString()
{
$path = $this->path.$this->element;
$condition = null === $this->condition || '' === $this->condition ? '' : '['.$this->condition.']';
}
],
"require": {
- "php": "^7.1.3"
+ "php": "^5.5.9|>=7.0.8"
},
"autoload": {
"psr-4": { "Symfony\\Component\\CssSelector\\": "" },
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-master": "4.2-dev"
+ "dev-master": "3.4-dev"
}
}
}