File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
src/TwigComponent/src/Twig Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \UX \TwigComponent \BlockStack ;
15
15
use Twig \Compiler ;
16
+ use Twig \Extension \CoreExtension ;
16
17
use Twig \Node \Expression \AbstractExpression ;
17
18
use Twig \Node \Node ;
18
19
@@ -46,13 +47,14 @@ public function compile(Compiler $compiler): void
46
47
// since twig/twig 3.9.0: Using the internal "twig_to_array" function is deprecated.
47
48
$ compiler
48
49
->write ('$toArray = function ($data) { ' )
49
- ->write ('if (method_exists(Twig\Extension\CoreExtension::class, \'toArray \')) { ' )
50
- ->write ('return Twig\Extension\CoreExtension::toArray($data); ' )
51
- ->write ('} ' )
52
- ->write ('return twig_to_array($data); ' )
53
- ->write ('}; ' )
54
50
;
55
51
52
+ if (method_exists (CoreExtension::class, 'toArray ' )) {
53
+ $ compiler ->write ('return Twig\Extension\CoreExtension::toArray($data);}; ' );
54
+ } else {
55
+ $ compiler ->write ('return twig_to_array($data);}; ' );
56
+ }
57
+
56
58
/*
57
59
* Block 1) PreCreateForRender handling
58
60
*
You can’t perform that action at this time.
0 commit comments