updated dependencies + working api connection

This commit is contained in:
Chris
2018-02-08 14:21:29 +00:00
parent dfc3c2194c
commit 30aea8e361
216 changed files with 21763 additions and 915 deletions

View File

@@ -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());

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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 ? '<followed>' : $this->combinator;

View File

@@ -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 ?: '*';

View File

@@ -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()."'";

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -26,18 +26,28 @@ class SelectorNode extends AbstractNode
private $tree;
private $pseudoElement;
public function __construct(NodeInterface $tree, string $pseudoElement = null)
/**
* @param NodeInterface $tree
* @param null|string $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 null|string
*/
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 : '');
}

View File

@@ -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(Specificity $specificity): Specificity
/**
* @return self
*/
public function plus(Specificity $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;
}