diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index 349a8b81b8..7473221277 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -159,14 +159,20 @@ EOF throw new \UnexpectedValueException('Unsupported callback type'); } - // filter out context/environment args - $args = array_filter($refl->getParameters(), function ($param) use ($entity) { - if ($entity->needsContext() && $param->getName() === 'context') { - return false; - } + $args = $refl->getParameters(); - return !$param->getClass() || $param->getClass()->getName() !== 'Twig_Environment'; - }); + // filter out context/environment args + if ($entity->needsEnvironment()) { + array_shift($args); + } + if ($entity->needsContext()) { + array_shift($args); + } + + if ($type === 'filters') { + // remove the value the filter is applied on + array_shift($args); + } // format args $args = array_map(function ($param) { @@ -177,11 +183,6 @@ EOF return $param->getName(); }, $args); - if ($type === 'filters') { - // remove the value the filter is applied on - array_shift($args); - } - return $args; } }