22
33namespace TwigCS \Environment ;
44
5- use \Closure ;
65use Symfony \Bridge \Twig \TokenParser \DumpTokenParser ;
76use Symfony \Bridge \Twig \TokenParser \FormThemeTokenParser ;
87use Symfony \Bridge \Twig \TokenParser \StopwatchTokenParser ;
@@ -35,11 +34,6 @@ class StubbedEnvironment extends Environment
3534 */
3635 private $ stubTests ;
3736
38- /**
39- * @var Closure
40- */
41- private $ stubCallable ;
42-
4337 /**
4438 * @param LoaderInterface|null $loader
4539 * @param array $options
@@ -54,6 +48,10 @@ public function __construct(LoaderInterface $loader = null, $options = [])
5448 $ this ->addTokenParser (new TransChoiceTokenParser ());
5549 $ this ->addTokenParser (new TransDefaultDomainTokenParser ());
5650 $ this ->addTokenParser (new TransTokenParser ());
51+
52+ $ this ->stubFilters = [];
53+ $ this ->stubFunctions = [];
54+ $ this ->stubTests = [];
5755 }
5856
5957 /**
@@ -64,7 +62,7 @@ public function __construct(LoaderInterface $loader = null, $options = [])
6462 public function getFilter ($ name )
6563 {
6664 if (!isset ($ this ->stubFilters [$ name ])) {
67- $ this ->stubFilters [$ name ] = new TwigFilter ('stub ' , $ this -> stubCallable );
65+ $ this ->stubFilters [$ name ] = new TwigFilter ('stub ' );
6866 }
6967
7068 return $ this ->stubFilters [$ name ];
@@ -78,7 +76,7 @@ public function getFilter($name)
7876 public function getFunction ($ name )
7977 {
8078 if (!isset ($ this ->stubFunctions [$ name ])) {
81- $ this ->stubFunctions [$ name ] = new TwigFunction ('stub ' , $ this -> stubCallable );
79+ $ this ->stubFunctions [$ name ] = new TwigFunction ('stub ' );
8280 }
8381
8482 return $ this ->stubFunctions [$ name ];
@@ -92,7 +90,7 @@ public function getFunction($name)
9290 public function getTest ($ name )
9391 {
9492 if (!isset ($ this ->stubTests [$ name ])) {
95- $ this ->stubTests [$ name ] = new TwigTest ('stub ' , $ this -> stubCallable );
93+ $ this ->stubTests [$ name ] = new TwigTest ('stub ' );
9694 }
9795
9896 return $ this ->stubTests [$ name ];
0 commit comments