File tree Expand file tree Collapse file tree 1 file changed +13
-15
lines changed
Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Original file line number Diff line number Diff line change 1616use Twig \Error \SyntaxError ;
1717use Twig \Extension \DebugExtension ;
1818use Twig \Loader \FilesystemLoader ;
19+ use Twig \TwigFilter ;
1920use Twig \TwigFunction ;
2021
2122class Twig
@@ -43,7 +44,7 @@ class Twig
4344 /**
4445 * @var array Filters to add to Twig
4546 */
46- private $ filters = [];
47+ private array $ filters = [];
4748
4849 /**
4950 * @var array Functions with `is_safe` option
@@ -93,10 +94,9 @@ public function __construct($params = [])
9394 }
9495
9596 if (isset ($ params ['filters ' ])) {
96- $ this ->filters =
97- array_unique (
98- array_merge ($ this ->filters , $ params ['filters ' ])
99- );
97+ $ this ->filters = array_unique (
98+ array_merge ($ this ->filters , $ params ['filters ' ])
99+ );
100100 unset($ params ['filters ' ]);
101101 }
102102
@@ -201,16 +201,14 @@ public function render($view, $params = []): string
201201
202202 protected function addFilters ()
203203 {
204- if ( !empty ($ this ->filters ) ){
205- foreach ($ this ->filters as $ filter ) {
206- if (function_exists ($ filter )) {
207- $ this ->twig ->addFilter (
208- new \Twig \TwigFilter (
209- $ filter ,
210- $ filter
211- )
212- );
213- }
204+ foreach ($ this ->filters as $ filter ) {
205+ if (function_exists ($ filter )) {
206+ $ this ->twig ->addFilter (
207+ new TwigFilter (
208+ $ filter ,
209+ $ filter
210+ )
211+ );
214212 }
215213 }
216214 }
You can’t perform that action at this time.
0 commit comments