Skip to content

Commit a45c187

Browse files
committed
bug #12187 [CssSelector] don't raise warnings when exception is thrown (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [CssSelector] don't raise warnings when exception is thrown | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11947 | License | MIT | Doc PR | `array_map()` raises a warning when an exception is thrown inside the callback (see https://bugs.php.net/bug.php?id=55416). To avoid these warnings, `selectorToXPath()` is applied inside the loop. Commits ------- 38e9623 don't raise warnings when exception is thrown
2 parents 6df49bb + 38e9623 commit a45c187

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Symfony/Component/CssSelector/XPath/Translator.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,15 @@ public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::')
123123
$selectors = $this->parseSelectors($cssExpr);
124124

125125
/** @var SelectorNode $selector */
126-
foreach ($selectors as $selector) {
126+
foreach ($selectors as $index => $selector) {
127127
if (null !== $selector->getPseudoElement()) {
128128
throw new ExpressionErrorException('Pseudo-elements are not supported.');
129129
}
130-
}
131130

132-
$translator = $this;
131+
$selectors[$index] = $this->selectorToXPath($selector, $prefix);
132+
}
133133

134-
return implode(' | ', array_map(function (SelectorNode $selector) use ($translator, $prefix) {
135-
return $translator->selectorToXPath($selector, $prefix);
136-
}, $selectors));
134+
return implode(' | ', $selectors);
137135
}
138136

139137
/**

0 commit comments

Comments
 (0)