laravel-6 support
This commit is contained in:
58
vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
58
vendor/symfony/css-selector/XPath/XPathExpr.php
vendored
@@ -23,28 +23,11 @@ namespace Symfony\Component\CssSelector\XPath;
|
||||
*/
|
||||
class XPathExpr
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $element;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $condition;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $element
|
||||
* @param string $condition
|
||||
* @param bool $starPrefix
|
||||
*/
|
||||
public function __construct($path = '', $element = '*', $condition = '', $starPrefix = false)
|
||||
public function __construct(string $path = '', string $element = '*', string $condition = '', bool $starPrefix = false)
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->element = $element;
|
||||
@@ -55,38 +38,24 @@ class XPathExpr
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getElement()
|
||||
public function getElement(): string
|
||||
{
|
||||
return $this->element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $condition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addCondition($condition)
|
||||
public function addCondition(string $condition): self
|
||||
{
|
||||
$this->condition = $this->condition ? sprintf('%s and (%s)', $this->condition, $condition) : $condition;
|
||||
$this->condition = $this->condition ? sprintf('(%s) and (%s)', $this->condition, $condition) : $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCondition()
|
||||
public function getCondition(): string
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addNameTest()
|
||||
public function addNameTest(): self
|
||||
{
|
||||
if ('*' !== $this->element) {
|
||||
$this->addCondition('name() = '.Translator::getXpathLiteral($this->element));
|
||||
@@ -96,10 +65,7 @@ class XPathExpr
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addStarPrefix()
|
||||
public function addStarPrefix(): self
|
||||
{
|
||||
$this->path .= '*/';
|
||||
|
||||
@@ -109,12 +75,9 @@ class XPathExpr
|
||||
/**
|
||||
* Joins another XPathExpr with a combiner.
|
||||
*
|
||||
* @param string $combiner
|
||||
* @param XPathExpr $expr
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function join($combiner, XPathExpr $expr)
|
||||
public function join(string $combiner, self $expr): self
|
||||
{
|
||||
$path = $this->__toString().$combiner;
|
||||
|
||||
@@ -129,10 +92,7 @@ class XPathExpr
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
$path = $this->path.$this->element;
|
||||
$condition = null === $this->condition || '' === $this->condition ? '' : '['.$this->condition.']';
|
||||
|
Reference in New Issue
Block a user