1010class Tintin
1111{
1212 /**
13- * The tintin parse instance
13+ * The compiler instance
1414 *
1515 * @var Compiler
1616 */
@@ -31,7 +31,7 @@ class Tintin
3131 private StackManager $ stackManager ;
3232
3333 /**
34- * The stack manager instance
34+ * The macro manager instance
3535 *
3636 * @var MacroManager
3737 */
@@ -42,7 +42,7 @@ class Tintin
4242 *
4343 * @var array
4444 */
45- private array $ __data = [];
45+ private array $ sharedData = [];
4646
4747 /**
4848 * Tintin constructor.
@@ -91,13 +91,14 @@ public function getLoader(): ?LoaderInterface
9191 * Push shared data
9292 *
9393 * @param array $data
94+ * @return void
9495 */
95- public function pushSharedData (array $ data )
96+ public function pushSharedData (array $ data ): void
9697 {
9798 // The arrangement of values is very important
9899 // To refresh the old variables which are
99100 // a name with the new comer
100- $ this ->__data = array_merge ($ this ->__data , $ data );
101+ $ this ->sharedData = array_merge ($ this ->sharedData , $ data );
101102 }
102103
103104 /**
@@ -107,7 +108,7 @@ public function pushSharedData(array $data)
107108 */
108109 public function getSharedData (): array
109110 {
110- return $ this ->__data ;
111+ return $ this ->sharedData ;
111112 }
112113
113114 /**
@@ -122,6 +123,8 @@ public function render($template, array $data = []): string
122123 {
123124 $ __template = $ template ;
124125
126+ $ this ->stackManager ->setContext ($ data );
127+
125128 if (is_null ($ this ->loader )) {
126129 // Try to compile the plain string
127130 return $ this ->renderString ($ __template , $ data );
@@ -144,7 +147,7 @@ public function render($template, array $data = []): string
144147 // If cache is not still alive we load template
145148 // and create the new cache for
146149 if (! $ this ->loader ->isExpired ($ __template )) {
147- $ this ->obFlushAndStar ();
150+ $ this ->obFlushAndStart ();
148151
149152 require $ this ->loader ->getCacheFileResolvedPath ($ __template );
150153
@@ -159,7 +162,7 @@ public function render($template, array $data = []): string
159162 $ this ->compiler ->compile ($ content )
160163 );
161164
162- $ this ->obFlushAndStar ();
165+ $ this ->obFlushAndStart ();
163166
164167 require $ this ->loader ->getCacheFileResolvedPath ($ __template );
165168
@@ -175,9 +178,8 @@ public function render($template, array $data = []): string
175178 */
176179 public function renderString (string $ template , array $ data = []): string
177180 {
178- $ __template = $ template ;
179181 return $ this ->executePlainRendering (
180- trim ($ this ->compiler ->compile ($ __template )),
182+ trim ($ this ->compiler ->compile ($ template )),
181183 array_merge ($ data , ['__tintin ' => $ this ])
182184 );
183185 }
@@ -191,7 +193,7 @@ public function renderString(string $template, array $data = []): string
191193 */
192194 private function executePlainRendering (string $ content , array $ data ): string
193195 {
194- $ this ->obFlushAndStar ();
196+ $ this ->obFlushAndStart ();
195197
196198 extract ($ data );
197199
@@ -222,7 +224,7 @@ private function obGetContent(): string
222224 *
223225 * @return void
224226 */
225- private function obFlushAndStar ()
227+ private function obFlushAndStart (): void
226228 {
227229 ob_start ();
228230 }
@@ -238,7 +240,7 @@ private function createTmpFile(string $content): string
238240 $ tmp_dir = sys_get_temp_dir () . '/__tintin ' ;
239241
240242 if (!is_dir ($ tmp_dir )) {
241- mkdir ($ tmp_dir , 0777 );
243+ @ mkdir ($ tmp_dir , 0755 , true );
242244 }
243245
244246 $ file = $ tmp_dir . '/ ' . md5 (microtime (true )) . '.php ' ;
0 commit comments