upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 deletions

View File

@@ -27,6 +27,10 @@ use Symfony\Component\CssSelector\XPath\Translator;
class CssSelectorConverter
{
private $translator;
private $cache;
private static $xmlCache = [];
private static $htmlCache = [];
/**
* @param bool $html Whether HTML support should be enabled. Disable it for XML documents
@@ -37,6 +41,9 @@ class CssSelectorConverter
if ($html) {
$this->translator->registerExtension(new HtmlExtension($this->translator));
$this->cache = &self::$htmlCache;
} else {
$this->cache = &self::$xmlCache;
}
$this->translator
@@ -53,13 +60,10 @@ class CssSelectorConverter
* Optionally, a prefix can be added to the resulting XPath
* expression with the $prefix parameter.
*
* @param string $cssExpr The CSS expression
* @param string $prefix An optional prefix for the XPath expression
*
* @return string
*/
public function toXPath($cssExpr, $prefix = 'descendant-or-self::')
public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::')
{
return $this->translator->cssToXPath($cssExpr, $prefix);
return $this->cache[$prefix][$cssExpr] ?? $this->cache[$prefix][$cssExpr] = $this->translator->cssToXPath($cssExpr, $prefix);
}
}

View File

@@ -24,32 +24,25 @@ use Symfony\Component\CssSelector\Parser\Token;
class SyntaxErrorException extends ParseException
{
/**
* @param string $expectedValue
*
* @return self
*/
public static function unexpectedToken($expectedValue, Token $foundToken)
public static function unexpectedToken(string $expectedValue, Token $foundToken)
{
return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken));
}
/**
* @param string $pseudoElement
* @param string $unexpectedLocation
*
* @return self
*/
public static function pseudoElementFound($pseudoElement, $unexpectedLocation)
public static function pseudoElementFound(string $pseudoElement, string $unexpectedLocation)
{
return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation));
}
/**
* @param int $position
*
* @return self
*/
public static function unclosedString($position)
public static function unclosedString(int $position)
{
return new self(sprintf('Unclosed/invalid string at %s.', $position));
}

View File

@@ -118,9 +118,7 @@ class TokenStream
}
/**
* Returns nex identifier token.
*
* @return string The identifier token value
* Returns next identifier token.
*
* @throws SyntaxErrorException If next token is not an identifier
*/
@@ -136,9 +134,7 @@ class TokenStream
}
/**
* Returns nex identifier or star delimiter token.
*
* @return string|null The identifier token value or null if star found
* Returns next identifier or null if star delimiter token is found.
*
* @throws SyntaxErrorException If next token is not an identifier or a star delimiter
*/

View File

@@ -49,22 +49,22 @@ class TokenizerPatterns
$this->identifierPattern = '-?(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*';
$this->hashPattern = '#((?:'.$this->nmCharPattern.')+)';
$this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)';
$this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*';
$this->quotedStringPattern = '([^\n\r\f\\\\%s]|'.$this->stringEscapePattern.')*';
}
public function getNewLineEscapePattern(): string
{
return '~^'.$this->newLineEscapePattern.'~';
return '~'.$this->newLineEscapePattern.'~';
}
public function getSimpleEscapePattern(): string
{
return '~^'.$this->simpleEscapePattern.'~';
return '~'.$this->simpleEscapePattern.'~';
}
public function getUnicodeEscapePattern(): string
{
return '~^'.$this->unicodeEscapePattern.'~i';
return '~'.$this->unicodeEscapePattern.'~i';
}
public function getIdentifierPattern(): string

View File

@@ -203,7 +203,7 @@ class Translator implements TranslatorInterface
/**
* @throws ExpressionErrorException
*/
public function addAttributeMatching(XPathExpr $xpath, string $operator, string $attribute, $value): XPathExpr
public function addAttributeMatching(XPathExpr $xpath, string $operator, string $attribute, ?string $value): XPathExpr
{
if (!isset($this->attributeMatchingTranslators[$operator])) {
throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));

View File

@@ -43,6 +43,9 @@ class XPathExpr
return $this->element;
}
/**
* @return $this
*/
public function addCondition(string $condition): self
{
$this->condition = $this->condition ? sprintf('(%s) and (%s)', $this->condition, $condition) : $condition;
@@ -55,6 +58,9 @@ class XPathExpr
return $this->condition;
}
/**
* @return $this
*/
public function addNameTest(): self
{
if ('*' !== $this->element) {
@@ -65,6 +71,9 @@ class XPathExpr
return $this;
}
/**
* @return $this
*/
public function addStarPrefix(): self
{
$this->path .= '*/';

View File

@@ -20,7 +20,7 @@
}
],
"require": {
"php": ">=7.1.3",
"php": ">=7.2.5",
"symfony/polyfill-php80": "^1.16"
},
"autoload": {