mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-17 14:28:53 +02:00
N°8834 - Add compatibility with PHP 8.4 (#819)
* N°8834 - Add compatibility with PHP 8.4 * Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
@@ -47,12 +47,12 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
|
||||
public function translateEquals(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition(sprintf('%s = %s', $attribute, Translator::getXpathLiteral($value)));
|
||||
return $xpath->addCondition(\sprintf('%s = %s', $attribute, Translator::getXpathLiteral($value)));
|
||||
}
|
||||
|
||||
public function translateIncludes(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
return $xpath->addCondition($value ? \sprintf(
|
||||
'%1$s and contains(concat(\' \', normalize-space(%1$s), \' \'), %2$s)',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral(' '.$value.' ')
|
||||
@@ -61,7 +61,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
|
||||
public function translateDashMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition(sprintf(
|
||||
return $xpath->addCondition(\sprintf(
|
||||
'%1$s and (%1$s = %2$s or starts-with(%1$s, %3$s))',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral($value),
|
||||
@@ -71,7 +71,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
|
||||
public function translatePrefixMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
return $xpath->addCondition($value ? \sprintf(
|
||||
'%1$s and starts-with(%1$s, %2$s)',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral($value)
|
||||
@@ -80,7 +80,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
|
||||
public function translateSuffixMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
return $xpath->addCondition($value ? \sprintf(
|
||||
'%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s',
|
||||
$attribute,
|
||||
\strlen($value) - 1,
|
||||
@@ -90,7 +90,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
|
||||
public function translateSubstringMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition($value ? sprintf(
|
||||
return $xpath->addCondition($value ? \sprintf(
|
||||
'%1$s and contains(%1$s, %2$s)',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral($value)
|
||||
@@ -99,7 +99,7 @@ class AttributeMatchingExtension extends AbstractExtension
|
||||
|
||||
public function translateDifferent(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition(sprintf(
|
||||
return $xpath->addCondition(\sprintf(
|
||||
$value ? 'not(%1$s) or %1$s != %2$s' : '%s != %s',
|
||||
$attribute,
|
||||
Translator::getXpathLiteral($value)
|
||||
|
||||
@@ -50,7 +50,7 @@ class FunctionExtension extends AbstractExtension
|
||||
try {
|
||||
[$a, $b] = Parser::parseSeries($function->getArguments());
|
||||
} catch (SyntaxErrorException $e) {
|
||||
throw new ExpressionErrorException(sprintf('Invalid series: "%s".', implode('", "', $function->getArguments())), 0, $e);
|
||||
throw new ExpressionErrorException(\sprintf('Invalid series: "%s".', implode('", "', $function->getArguments())), 0, $e);
|
||||
}
|
||||
|
||||
$xpath->addStarPrefix();
|
||||
@@ -83,10 +83,10 @@ class FunctionExtension extends AbstractExtension
|
||||
$expr .= ' - '.$b;
|
||||
}
|
||||
|
||||
$conditions = [sprintf('%s %s 0', $expr, $sign)];
|
||||
$conditions = [\sprintf('%s %s 0', $expr, $sign)];
|
||||
|
||||
if (1 !== $a && -1 !== $a) {
|
||||
$conditions[] = sprintf('(%s) mod %d = 0', $expr, $a);
|
||||
$conditions[] = \sprintf('(%s) mod %d = 0', $expr, $a);
|
||||
}
|
||||
|
||||
return $xpath->addCondition(implode(' and ', $conditions));
|
||||
@@ -134,7 +134,7 @@ class FunctionExtension extends AbstractExtension
|
||||
}
|
||||
}
|
||||
|
||||
return $xpath->addCondition(sprintf(
|
||||
return $xpath->addCondition(\sprintf(
|
||||
'contains(string(.), %s)',
|
||||
Translator::getXpathLiteral($arguments[0]->getValue())
|
||||
));
|
||||
@@ -152,7 +152,7 @@ class FunctionExtension extends AbstractExtension
|
||||
}
|
||||
}
|
||||
|
||||
return $xpath->addCondition(sprintf(
|
||||
return $xpath->addCondition(\sprintf(
|
||||
'lang(%s)',
|
||||
Translator::getXpathLiteral($arguments[0]->getValue())
|
||||
));
|
||||
|
||||
@@ -142,7 +142,7 @@ class HtmlExtension extends AbstractExtension
|
||||
}
|
||||
}
|
||||
|
||||
return $xpath->addCondition(sprintf(
|
||||
return $xpath->addCondition(\sprintf(
|
||||
'ancestor-or-self::*[@lang][1][starts-with(concat('
|
||||
."translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '-')"
|
||||
.', %s)]',
|
||||
|
||||
@@ -91,7 +91,7 @@ class NodeExtension extends AbstractExtension
|
||||
$subXpath->addNameTest();
|
||||
|
||||
if ($subXpath->getCondition()) {
|
||||
return $xpath->addCondition(sprintf('not(%s)', $subXpath->getCondition()));
|
||||
return $xpath->addCondition(\sprintf('not(%s)', $subXpath->getCondition()));
|
||||
}
|
||||
|
||||
return $xpath->addCondition('0');
|
||||
@@ -121,11 +121,11 @@ class NodeExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
if ($node->getNamespace()) {
|
||||
$name = sprintf('%s:%s', $node->getNamespace(), $name);
|
||||
$name = \sprintf('%s:%s', $node->getNamespace(), $name);
|
||||
$safe = $safe && $this->isSafeName($node->getNamespace());
|
||||
}
|
||||
|
||||
$attribute = $safe ? '@'.$name : sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name));
|
||||
$attribute = $safe ? '@'.$name : \sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name));
|
||||
$value = $node->getValue();
|
||||
$xpath = $translator->nodeToXPath($node->getSelector());
|
||||
|
||||
@@ -166,7 +166,7 @@ class NodeExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
if ($node->getNamespace()) {
|
||||
$element = sprintf('%s:%s', $node->getNamespace(), $element);
|
||||
$element = \sprintf('%s:%s', $node->getNamespace(), $element);
|
||||
$safe = $safe && $this->isSafeName($node->getNamespace());
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class PseudoClassExtension extends AbstractExtension
|
||||
{
|
||||
$element = $xpath->getElement();
|
||||
|
||||
return $xpath->addCondition(sprintf('count(preceding-sibling::%s)=0 and count(following-sibling::%s)=0', $element, $element));
|
||||
return $xpath->addCondition(\sprintf('count(preceding-sibling::%s)=0 and count(following-sibling::%s)=0', $element, $element));
|
||||
}
|
||||
|
||||
public function translateEmpty(XPathExpr $xpath): XPathExpr
|
||||
|
||||
@@ -48,7 +48,7 @@ class Translator implements TranslatorInterface
|
||||
private array $pseudoClassTranslators = [];
|
||||
private array $attributeMatchingTranslators = [];
|
||||
|
||||
public function __construct(ParserInterface $parser = null)
|
||||
public function __construct(?ParserInterface $parser = null)
|
||||
{
|
||||
$this->mainParser = $parser ?? new Parser();
|
||||
|
||||
@@ -75,7 +75,7 @@ class Translator implements TranslatorInterface
|
||||
$parts = [];
|
||||
while (true) {
|
||||
if (false !== $pos = strpos($string, "'")) {
|
||||
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
|
||||
$parts[] = \sprintf("'%s'", substr($string, 0, $pos));
|
||||
$parts[] = "\"'\"";
|
||||
$string = substr($string, $pos + 1);
|
||||
} else {
|
||||
@@ -84,7 +84,7 @@ class Translator implements TranslatorInterface
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf('concat(%s)', implode(', ', $parts));
|
||||
return \sprintf('concat(%s)', implode(', ', $parts));
|
||||
}
|
||||
|
||||
public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
|
||||
@@ -130,7 +130,7 @@ class Translator implements TranslatorInterface
|
||||
public function getExtension(string $name): Extension\ExtensionInterface
|
||||
{
|
||||
if (!isset($this->extensions[$name])) {
|
||||
throw new ExpressionErrorException(sprintf('Extension "%s" not registered.', $name));
|
||||
throw new ExpressionErrorException(\sprintf('Extension "%s" not registered.', $name));
|
||||
}
|
||||
|
||||
return $this->extensions[$name];
|
||||
@@ -152,7 +152,7 @@ class Translator implements TranslatorInterface
|
||||
public function nodeToXPath(NodeInterface $node): XPathExpr
|
||||
{
|
||||
if (!isset($this->nodeTranslators[$node->getNodeName()])) {
|
||||
throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
|
||||
throw new ExpressionErrorException(\sprintf('Node "%s" not supported.', $node->getNodeName()));
|
||||
}
|
||||
|
||||
return $this->nodeTranslators[$node->getNodeName()]($node, $this);
|
||||
@@ -164,7 +164,7 @@ class Translator implements TranslatorInterface
|
||||
public function addCombination(string $combiner, NodeInterface $xpath, NodeInterface $combinedXpath): XPathExpr
|
||||
{
|
||||
if (!isset($this->combinationTranslators[$combiner])) {
|
||||
throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
|
||||
throw new ExpressionErrorException(\sprintf('Combiner "%s" not supported.', $combiner));
|
||||
}
|
||||
|
||||
return $this->combinationTranslators[$combiner]($this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
|
||||
@@ -176,7 +176,7 @@ class Translator implements TranslatorInterface
|
||||
public function addFunction(XPathExpr $xpath, FunctionNode $function): XPathExpr
|
||||
{
|
||||
if (!isset($this->functionTranslators[$function->getName()])) {
|
||||
throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
|
||||
throw new ExpressionErrorException(\sprintf('Function "%s" not supported.', $function->getName()));
|
||||
}
|
||||
|
||||
return $this->functionTranslators[$function->getName()]($xpath, $function);
|
||||
@@ -188,7 +188,7 @@ class Translator implements TranslatorInterface
|
||||
public function addPseudoClass(XPathExpr $xpath, string $pseudoClass): XPathExpr
|
||||
{
|
||||
if (!isset($this->pseudoClassTranslators[$pseudoClass])) {
|
||||
throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
|
||||
throw new ExpressionErrorException(\sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
|
||||
}
|
||||
|
||||
return $this->pseudoClassTranslators[$pseudoClass]($xpath);
|
||||
@@ -200,7 +200,7 @@ class Translator implements TranslatorInterface
|
||||
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));
|
||||
throw new ExpressionErrorException(\sprintf('Attribute matcher operator "%s" not supported.', $operator));
|
||||
}
|
||||
|
||||
return $this->attributeMatchingTranslators[$operator]($xpath, $attribute, $value);
|
||||
|
||||
@@ -48,7 +48,7 @@ class XPathExpr
|
||||
*/
|
||||
public function addCondition(string $condition): static
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user