From 38e9623ca4bf1a60009141f1a0f895be621da8ec Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 9 Oct 2014 14:30:02 +0200 Subject: [PATCH] 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. --- src/Symfony/Component/CssSelector/XPath/Translator.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/CssSelector/XPath/Translator.php b/src/Symfony/Component/CssSelector/XPath/Translator.php index 4676677ea4..5675aa6106 100644 --- a/src/Symfony/Component/CssSelector/XPath/Translator.php +++ b/src/Symfony/Component/CssSelector/XPath/Translator.php @@ -123,17 +123,15 @@ class Translator implements TranslatorInterface $selectors = $this->parseSelectors($cssExpr); /** @var SelectorNode $selector */ - foreach ($selectors as $selector) { + foreach ($selectors as $index => $selector) { if (null !== $selector->getPseudoElement()) { throw new ExpressionErrorException('Pseudo-elements are not supported.'); } + + $selectors[$index] = $this->selectorToXPath($selector, $prefix); } - $translator = $this; - - return implode(' | ', array_map(function (SelectorNode $selector) use ($translator, $prefix) { - return $translator->selectorToXPath($selector, $prefix); - }, $selectors)); + return implode(' | ', $selectors); } /**