Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 63a8aff

Browse filesBrowse files
committed
Harden the debugging of Twig filters and functions
Removing the environment and context arguments is now based on Twig metadata rather than on some wild guessing which might go wrong.
1 parent aa04f35 commit 63a8aff
Copy full SHA for 63a8aff

File tree

1 file changed

+12
-11
lines changed
Filter options

1 file changed

+12
-11
lines changed

‎src/Symfony/Bridge/Twig/Command/DebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Command/DebugCommand.php
+12-11Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,20 @@ private function getMetadata($type, $entity)
159159
throw new \UnexpectedValueException('Unsupported callback type');
160160
}
161161

162+
$args = $refl->getParameters();
163+
162164
// filter out context/environment args
163-
$args = array_filter($refl->getParameters(), function ($param) use ($entity) {
164-
if ($entity->needsContext() && $param->getName() === 'context') {
165-
return false;
166-
}
165+
if ($entity->needsEnvironment()) {
166+
array_shift($args);
167+
}
168+
if ($entity->needsContext()) {
169+
array_shift($args);
170+
}
167171

168-
return !$param->getClass() || $param->getClass()->getName() !== 'Twig_Environment';
169-
});
172+
if ($type === 'filters') {
173+
// remove the value the filter is applied on
174+
array_shift($args);
175+
}
170176

171177
// format args
172178
$args = array_map(function ($param) {
@@ -177,11 +183,6 @@ private function getMetadata($type, $entity)
177183
return $param->getName();
178184
}, $args);
179185

180-
if ($type === 'filters') {
181-
// remove the value the filter is applied on
182-
array_shift($args);
183-
}
184-
185186
return $args;
186187
}
187188
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.