1111
1212namespace App \Twig ;
1313
14+ use Twig \Environment ;
15+ use Twig \Extension \AbstractExtension ;
16+ use Twig \Template ;
17+ use Twig \TwigFunction ;
18+
1419/**
1520 * CAUTION: this is an extremely advanced Twig extension. It's used to get the
1621 * source code of the controller and the template used to render the current
2025 * @author Ryan Weaver <[email protected] > 2126 * @author Javier Eguiluz <[email protected] > 2227 */
23- class SourceCodeExtension extends \Twig_Extension
28+ class SourceCodeExtension extends AbstractExtension
2429{
2530 private $ controller ;
2631
@@ -35,11 +40,11 @@ public function setController($controller)
3540 public function getFunctions ()
3641 {
3742 return [
38- new \ Twig_SimpleFunction ('show_source_code ' , [$ this , 'showSourceCode ' ], ['is_safe ' => ['html ' ], 'needs_environment ' => true ]),
43+ new TwigFunction ('show_source_code ' , [$ this , 'showSourceCode ' ], ['is_safe ' => ['html ' ], 'needs_environment ' => true ]),
3944 ];
4045 }
4146
42- public function showSourceCode (\ Twig_Environment $ twig , $ template )
47+ public function showSourceCode (Environment $ twig , $ template )
4348 {
4449 return $ twig ->render ('debug/source_code.html.twig ' , [
4550 'controller ' => $ this ->getController (),
@@ -91,7 +96,7 @@ private function getCallableReflector($callable)
9196 return new \ReflectionFunction ($ callable );
9297 }
9398
94- private function getTemplateSource (\ Twig_Template $ template )
99+ private function getTemplateSource (Template $ template )
95100 {
96101 $ templateSource = $ template ->getSourceContext ();
97102
0 commit comments