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