8000 don't raise warnings when exception is thrown · symfony/symfony@38e9623 · GitHub
[go: up one dir, main page]

Skip to content

Commit 38e9623

Browse files
committed
don't raise warnings when exception is thrown
`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.
1 parent 6df49bb commit 38e9623

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
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)
0