Complex classes like Smarty_Internal_TemplateCompilerBase often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Smarty_Internal_TemplateCompilerBase, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
22 | abstract class Smarty_Internal_TemplateCompilerBase |
||
23 | { |
||
24 | /** |
||
25 | * compile tag objects cache |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | public static $_tag_objects = array(); |
||
30 | |||
31 | /** |
||
32 | * counter for prefix variable number |
||
33 | * |
||
34 | * @var int |
||
35 | */ |
||
36 | public static $prefixVariableNumber = 0; |
||
37 | |||
38 | /** |
||
39 | * Smarty object |
||
40 | * |
||
41 | * @var Smarty |
||
42 | */ |
||
43 | public $smarty = null; |
||
44 | |||
45 | /** |
||
46 | * Parser object |
||
47 | * |
||
48 | * @var Smarty_Internal_Templateparser |
||
49 | */ |
||
50 | public $parser = null; |
||
51 | |||
52 | /** |
||
53 | * hash for nocache sections |
||
54 | * |
||
55 | * @var mixed |
||
56 | */ |
||
57 | public $nocache_hash = null; |
||
58 | |||
59 | /** |
||
60 | * suppress generation of nocache code |
||
61 | * |
||
62 | * @var bool |
||
63 | */ |
||
64 | public $suppressNocacheProcessing = false; |
||
65 | |||
66 | /** |
||
67 | * caching enabled (copied from template object) |
||
68 | * |
||
69 | * @var int |
||
70 | */ |
||
71 | public $caching = 0; |
||
72 | |||
73 | /** |
||
74 | * tag stack |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | public $_tag_stack = array(); |
||
79 | |||
80 | /** |
||
81 | * tag stack count |
||
82 | * |
||
83 | * @var array |
||
84 | */ |
||
85 | public $_tag_stack_count = array(); |
||
86 | |||
87 | /** |
||
88 | * Plugins used by template |
||
89 | * |
||
90 | * @var array |
||
91 | */ |
||
92 | public $required_plugins = array('compiled' => array(), 'nocache' => array()); |
||
93 | |||
94 | /** |
||
95 | * Required plugins stack |
||
96 | * |
||
97 | * @var array |
||
98 | */ |
||
99 | public $required_plugins_stack = array(); |
||
100 | |||
101 | /** |
||
102 | * current template |
||
103 | * |
||
104 | * @var Smarty_Internal_Template |
||
105 | */ |
||
106 | public $template = null; |
||
107 | |||
108 | /** |
||
109 | * merged included sub template data |
||
110 | * |
||
111 | * @var array |
||
112 | */ |
||
113 | public $mergedSubTemplatesData = array(); |
||
114 | |||
115 | /** |
||
116 | * merged sub template code |
||
117 | * |
||
118 | * @var array |
||
119 | */ |
||
120 | public $mergedSubTemplatesCode = array(); |
||
121 | |||
122 | /** |
||
123 | * collected template properties during compilation |
||
124 | * |
||
125 | * @var array |
||
126 | */ |
||
127 | public $templateProperties = array(); |
||
128 | |||
129 | /** |
||
130 | * source line offset for error messages |
||
131 | * |
||
132 | * @var int |
||
133 | */ |
||
134 | public $trace_line_offset = 0; |
||
135 | |||
136 | /** |
||
137 | * trace uid |
||
138 | * |
||
139 | * @var string |
||
140 | */ |
||
141 | public $trace_uid = ''; |
||
142 | |||
143 | /** |
||
144 | * trace file path |
||
145 | * |
||
146 | * @var string |
||
147 | */ |
||
148 | public $trace_filepath = ''; |
||
149 | |||
150 | /** |
||
151 | * stack for tracing file and line of nested {block} tags |
||
152 | * |
||
153 | * @var array |
||
154 | */ |
||
155 | public $trace_stack = array(); |
||
156 | |||
157 | /** |
||
158 | * plugins loaded by default plugin handler |
||
159 | * |
||
160 | * @var array |
||
161 | */ |
||
162 | public $default_handler_plugins = array(); |
||
163 | |||
164 | /** |
||
165 | * saved preprocessed modifier list |
||
166 | * |
||
167 | * @var mixed |
||
168 | */ |
||
169 | public $default_modifier_list = null; |
||
170 | |||
171 | /** |
||
172 | * force compilation of complete template as nocache |
||
173 | * |
||
174 | * @var boolean |
||
175 | */ |
||
176 | public $forceNocache = false; |
||
177 | |||
178 | /** |
||
179 | * flag if compiled template file shall we written |
||
180 | * |
||
181 | * @var bool |
||
182 | */ |
||
183 | public $write_compiled_code = true; |
||
184 | |||
185 | /** |
||
186 | * Template functions |
||
187 | * |
||
188 | * @var array |
||
189 | */ |
||
190 | public $tpl_function = array(); |
||
191 | |||
192 | /** |
||
193 | * called sub functions from template function |
||
194 | * |
||
195 | * @var array |
||
196 | */ |
||
197 | public $called_functions = array(); |
||
198 | |||
199 | /** |
||
200 | * compiled template or block function code |
||
201 | * |
||
202 | * @var string |
||
203 | */ |
||
204 | public $blockOrFunctionCode = ''; |
||
205 | |||
206 | /** |
||
207 | * php_handling setting either from Smarty or security |
||
208 | * |
||
209 | * @var int |
||
210 | */ |
||
211 | public $php_handling = 0; |
||
212 | |||
213 | /** |
||
214 | * flags for used modifier plugins |
||
215 | * |
||
216 | * @var array |
||
217 | */ |
||
218 | public $modifier_plugins = array(); |
||
219 | |||
220 | /** |
||
221 | * type of already compiled modifier |
||
222 | * |
||
223 | * @var array |
||
224 | */ |
||
225 | public $known_modifier_type = array(); |
||
226 | |||
227 | /** |
||
228 | * parent compiler object for merged subtemplates and template functions |
||
229 | * |
||
230 | * @var Smarty_Internal_TemplateCompilerBase |
||
231 | */ |
||
232 | public $parent_compiler = null; |
||
233 | |||
234 | /** |
||
235 | * Flag true when compiling nocache section |
||
236 | * |
||
237 | * @var bool |
||
238 | */ |
||
239 | public $nocache = false; |
||
240 | |||
241 | /** |
||
242 | * Flag true when tag is compiled as nocache |
||
243 | * |
||
244 | * @var bool |
||
245 | */ |
||
246 | public $tag_nocache = false; |
||
247 | |||
248 | /** |
||
249 | * Compiled tag prefix code |
||
250 | * |
||
251 | * @var array |
||
252 | */ |
||
253 | public $prefix_code = array(); |
||
254 | |||
255 | /** |
||
256 | * used prefix variables by current compiled tag |
||
257 | * |
||
258 | * @var array |
||
259 | */ |
||
260 | public $usedPrefixVariables = array(); |
||
261 | |||
262 | /** |
||
263 | * Prefix code stack |
||
264 | * |
||
265 | * @var array |
||
266 | */ |
||
267 | public $prefixCodeStack = array(); |
||
268 | |||
269 | /** |
||
270 | * Tag has compiled code |
||
271 | * |
||
272 | * @var bool |
||
273 | */ |
||
274 | public $has_code = false; |
||
275 | |||
276 | /** |
||
277 | * A variable string was compiled |
||
278 | * |
||
279 | * @var bool |
||
280 | */ |
||
281 | public $has_variable_string = false; |
||
282 | |||
283 | /** |
||
284 | * Stack for {setfilter} {/setfilter} |
||
285 | * |
||
286 | * @var array |
||
287 | */ |
||
288 | public $variable_filter_stack = array(); |
||
289 | |||
290 | /** |
||
291 | * variable filters for {setfilter} {/setfilter} |
||
292 | * |
||
293 | * @var array |
||
294 | */ |
||
295 | public $variable_filters = array(); |
||
296 | |||
297 | /** |
||
298 | * Nesting count of looping tags like {foreach}, {for}, {section}, {while} |
||
299 | * |
||
300 | * @var int |
||
301 | */ |
||
302 | public $loopNesting = 0; |
||
303 | |||
304 | /** |
||
305 | * Strip preg pattern |
||
306 | * |
||
307 | * @var string |
||
308 | */ |
||
309 | public $stripRegEx = '![\t ]*[\r\n]+[\t ]*!'; |
||
310 | |||
311 | /** |
||
312 | * plugin search order |
||
313 | * |
||
314 | * @var array |
||
315 | */ |
||
316 | public $plugin_search_order = array( |
||
317 | 'function', |
||
318 | 'block', |
||
319 | 'compiler', |
||
320 | 'class' |
||
321 | ); |
||
322 | |||
323 | /** |
||
324 | * General storage area for tag compiler plugins |
||
325 | * |
||
326 | * @var array |
||
327 | */ |
||
328 | public $_cache = array(); |
||
329 | |||
330 | /** |
||
331 | * Lexer preg pattern for left delimiter |
||
332 | * |
||
333 | * @var string |
||
334 | */ |
||
335 | private $ldelPreg = '[{]'; |
||
336 | |||
337 | /** |
||
338 | * Lexer preg pattern for right delimiter |
||
339 | * |
||
340 | * @var string |
||
341 | */ |
||
342 | private $rdelPreg = '[}]'; |
||
343 | |||
344 | /** |
||
345 | * Length of right delimiter |
||
346 | * |
||
347 | * @var int |
||
348 | */ |
||
349 | private $rdelLength = 0; |
||
350 | |||
351 | /** |
||
352 | * Length of left delimiter |
||
353 | * |
||
354 | * @var int |
||
355 | */ |
||
356 | private $ldelLength = 0; |
||
357 | |||
358 | /** |
||
359 | * Lexer preg pattern for user literals |
||
360 | * |
||
361 | * @var string |
||
362 | */ |
||
363 | private $literalPreg = ''; |
||
364 | |||
365 | /** |
||
366 | * Initialize compiler |
||
367 | * |
||
368 | * @param Smarty $smarty global instance |
||
369 | */ |
||
370 | public function __construct(Smarty $smarty) |
||
382 | |||
383 | /** |
||
384 | * Method to compile a Smarty template |
||
385 | * |
||
386 | * @param Smarty_Internal_Template $template template object to compile |
||
387 | * @param bool $nocache true is shall be compiled in nocache mode |
||
388 | * @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler |
||
389 | * |
||
390 | * @return bool true if compiling succeeded, false if it failed |
||
391 | * @throws \Exception |
||
392 | */ |
||
393 | public function compileTemplate( |
||
413 | |||
414 | /** |
||
415 | * Compile template source and run optional post filter |
||
416 | * |
||
417 | * @param \Smarty_Internal_Template $template |
||
418 | * @param null|bool $nocache flag if template must be compiled in nocache mode |
||
419 | * @param \Smarty_Internal_TemplateCompilerBase $parent_compiler |
||
420 | * |
||
421 | * @return string |
||
422 | * @throws \Exception |
||
423 | */ |
||
424 | public function compileTemplateSource( |
||
503 | |||
504 | /** |
||
505 | * Optionally process compiled code by post filter |
||
506 | * |
||
507 | * @param string $code compiled code |
||
508 | * |
||
509 | * @return string |
||
510 | * @throws \SmartyException |
||
511 | */ |
||
512 | public function postFilter($code) |
||
523 | |||
524 | /** |
||
525 | * Run optional prefilter |
||
526 | * |
||
527 | * @param string $_content template source |
||
528 | * |
||
529 | * @return string |
||
530 | * @throws \SmartyException |
||
531 | */ |
||
532 | public function preFilter($_content) |
||
543 | |||
544 | /** |
||
545 | * Compile Tag |
||
546 | * This is a call back from the lexer/parser |
||
547 | * |
||
548 | * Save current prefix code |
||
549 | * Compile tag |
||
550 | * Merge tag prefix code with saved one |
||
551 | * (required nested tags in attributes) |
||
552 | * |
||
553 | * @param string $tag tag name |
||
554 | * @param array $args array with tag attributes |
||
555 | * @param array $parameter array with compilation parameter |
||
556 | * |
||
557 | * @throws SmartyCompilerException |
||
558 | * @throws SmartyException |
||
559 | * @return string compiled code |
||
560 | */ |
||
561 | public function compileTag($tag, $args, $parameter = array()) |
||
569 | |||
570 | /** |
||
571 | * compile variable |
||
572 | * |
||
573 | * @param string $variable |
||
574 | * |
||
575 | * @return string |
||
576 | */ |
||
577 | public function compileVariable($variable) |
||
594 | |||
595 | /** |
||
596 | * compile config variable |
||
597 | * |
||
598 | * @param string $variable |
||
599 | * |
||
600 | * @return string |
||
601 | */ |
||
602 | public function compileConfigVariable($variable) |
||
607 | |||
608 | /** |
||
609 | * compile PHP function call |
||
610 | * |
||
611 | * @param string $name |
||
612 | * @param array $parameter |
||
613 | * |
||
614 | * @return string |
||
615 | * @throws \SmartyCompilerException |
||
616 | */ |
||
617 | public function compilePHPFunctionCall($name, $parameter) |
||
673 | |||
674 | /** |
||
675 | * This method is called from parser to process a text content section |
||
676 | * - remove text from inheritance child templates as they may generate output |
||
677 | * - strip text if strip is enabled |
||
678 | * |
||
679 | * @param string $text |
||
680 | * |
||
681 | * @return null|\Smarty_Internal_ParseTree_Text |
||
682 | */ |
||
683 | public function processText($text) |
||
743 | |||
744 | /** |
||
745 | * lazy loads internal compile plugin for tag and calls the compile method |
||
746 | * compile objects cached for reuse. |
||
747 | * class name format: Smarty_Internal_Compile_TagName |
||
748 | * plugin filename format: Smarty_Internal_TagName.php |
||
749 | * |
||
750 | * @param string $tag tag name |
||
751 | * @param array $args list of tag attributes |
||
752 | * @param mixed $param1 optional parameter |
||
753 | * @param mixed $param2 optional parameter |
||
754 | * @param mixed $param3 optional parameter |
||
755 | * |
||
756 | * @return bool|string compiled code or false |
||
757 | * @throws \SmartyCompilerException |
||
758 | */ |
||
759 | public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null) |
||
766 | |||
767 | /** |
||
768 | * lazy loads internal compile plugin for tag compile objects cached for reuse. |
||
769 | * |
||
770 | * class name format: Smarty_Internal_Compile_TagName |
||
771 | * plugin filename format: Smarty_Internal_TagName.php |
||
772 | * |
||
773 | * @param string $tag tag name |
||
774 | * |
||
775 | * @return bool|\Smarty_Internal_CompileBase tag compiler object or false if not found |
||
776 | */ |
||
777 | public function getTagCompiler($tag) |
||
795 | |||
796 | /** |
||
797 | * Check for plugins and return function name |
||
798 | * |
||
799 | * @param $plugin_name |
||
800 | * @param string $plugin_type type of plugin |
||
801 | * |
||
802 | * @return string call name of function |
||
803 | * @throws \SmartyException |
||
804 | */ |
||
805 | public function getPlugin($plugin_name, $plugin_type) |
||
861 | |||
862 | /** |
||
863 | * Check for plugins by default plugin handler |
||
864 | * |
||
865 | * @param string $tag name of tag |
||
866 | * @param string $plugin_type type of plugin |
||
867 | * |
||
868 | * @return bool true if found |
||
869 | * @throws \SmartyCompilerException |
||
870 | */ |
||
871 | public function getPluginFromDefaultHandler($tag, $plugin_type) |
||
920 | |||
921 | /** |
||
922 | * Append code segments and remove unneeded ?> <?php transitions |
||
923 | * |
||
924 | * @param string $left |
||
925 | * @param string $right |
||
926 | * |
||
927 | * @return string |
||
928 | */ |
||
929 | public function appendCode($left, $right) |
||
939 | |||
940 | /** |
||
941 | * Inject inline code for nocache template sections |
||
942 | * This method gets the content of each template element from the parser. |
||
943 | * If the content is compiled code and it should be not cached the code is injected |
||
944 | * into the rendered output. |
||
945 | * |
||
946 | * @param string $content content of template element |
||
947 | * @param boolean $is_code true if content is compiled code |
||
948 | * |
||
949 | * @return string content |
||
950 | */ |
||
951 | public function processNocacheCode($content, $is_code) |
||
982 | |||
983 | /** |
||
984 | * Get Id |
||
985 | * |
||
986 | * @param string $input |
||
987 | * |
||
988 | * @return bool|string |
||
989 | */ |
||
990 | public function getId($input) |
||
997 | |||
998 | /** |
||
999 | * Get variable name from string |
||
1000 | * |
||
1001 | * @param string $input |
||
1002 | * |
||
1003 | * @return bool|string |
||
1004 | */ |
||
1005 | public function getVariableName($input) |
||
1012 | |||
1013 | /** |
||
1014 | * Set nocache flag in variable or create new variable |
||
1015 | * |
||
1016 | * @param string $varName |
||
1017 | */ |
||
1018 | public function setNocacheInVariable($varName) |
||
1019 | { |
||
1020 | // create nocache var to make it know for further compiling |
||
1021 | if ($_var = $this->getId($varName)) { |
||
1022 | if (isset($this->template->tpl_vars[ $_var ])) { |
||
1023 | $this->template->tpl_vars[ $_var ] = clone $this->template->tpl_vars[ $_var ]; |
||
1024 | $this->template->tpl_vars[ $_var ]->nocache = true; |
||
1025 | } else { |
||
1026 | $this->template->tpl_vars[ $_var ] = new Smarty_Variable(null, true); |
||
1027 | } |
||
1028 | } |
||
1029 | } |
||
1030 | |||
1031 | /** |
||
1032 | * @param array $_attr tag attributes |
||
1033 | * @param array $validScopes |
||
1034 | * |
||
1035 | * @return int|string |
||
1036 | * @throws \SmartyCompilerException |
||
1037 | */ |
||
1038 | public function convertScope($_attr, $validScopes) |
||
1039 | { |
||
1040 | $_scope = 0; |
||
1041 | if (isset($_attr[ 'scope' ])) { |
||
1042 | $_scopeName = trim($_attr[ 'scope' ], '\'"'); |
||
1043 | if (is_numeric($_scopeName) && in_array($_scopeName, $validScopes)) { |
||
1044 | $_scope = $_scopeName; |
||
1045 | } elseif (is_string($_scopeName)) { |
||
1046 | $_scopeName = trim($_scopeName, '\'"'); |
||
1047 | $_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false; |
||
1048 | } else { |
||
1049 | $_scope = false; |
||
1050 | } |
||
1051 | if ($_scope === false) { |
||
1052 | $err = var_export($_scopeName, true); |
||
1053 | $this->trigger_template_error("illegal value '{$err}' for \"scope\" attribute", null, true); |
||
1054 | } |
||
1055 | } |
||
1056 | return $_scope; |
||
1057 | } |
||
1058 | |||
1059 | /** |
||
1060 | * Generate nocache code string |
||
1061 | * |
||
1062 | * @param string $code PHP code |
||
1063 | * |
||
1064 | * @return string |
||
1065 | */ |
||
1066 | public function makeNocacheCode($code) |
||
1072 | |||
1073 | /** |
||
1074 | * display compiler error messages without dying |
||
1075 | * If parameter $args is empty it is a parser detected syntax error. |
||
1076 | * In this case the parser is called to obtain information about expected tokens. |
||
1077 | * If parameter $args contains a string this is used as error message |
||
1078 | * |
||
1079 | * @param string $args individual error message or null |
||
1080 | * @param string $line line-number |
||
1081 | * @param null|bool $tagline if true the line number of last tag |
||
1082 | * |
||
1083 | * @throws \SmartyCompilerException when an unexpected token is found |
||
1084 | */ |
||
1085 | public function trigger_template_error($args = null, $line = null, $tagline = null) |
||
1156 | |||
1157 | /** |
||
1158 | * Return var_export() value with all white spaces removed |
||
1159 | * |
||
1160 | * @param mixed $value |
||
1161 | * |
||
1162 | * @return string |
||
1163 | */ |
||
1164 | public function getVarExport($value) |
||
1165 | { |
||
1166 | return preg_replace('/\s/', '', var_export($value, true)); |
||
1167 | } |
||
1168 | |||
1169 | /** |
||
1170 | * enter double quoted string |
||
1171 | * - save tag stack count |
||
1172 | */ |
||
1173 | public function enterDoubleQuote() |
||
1177 | |||
1178 | /** |
||
1179 | * Return tag stack count |
||
1180 | * |
||
1181 | * @return int |
||
1182 | */ |
||
1183 | public function getTagStackCount() |
||
1187 | |||
1188 | /** |
||
1189 | * @param $lexerPreg |
||
1190 | * |
||
1191 | * @return mixed |
||
1192 | */ |
||
1193 | public function replaceDelimiter($lexerPreg) |
||
1205 | |||
1206 | /** |
||
1207 | * Build lexer regular expressions for left and right delimiter and user defined literals |
||
1208 | */ |
||
1209 | public function initDelimiterPreg() |
||
1237 | |||
1238 | /** |
||
1239 | * leave double quoted string |
||
1240 | * - throw exception if block in string was not closed |
||
1241 | * |
||
1242 | * @throws \SmartyCompilerException |
||
1243 | */ |
||
1244 | public function leaveDoubleQuote() |
||
1255 | |||
1256 | /** |
||
1257 | * Get left delimiter preg |
||
1258 | * |
||
1259 | * @return string |
||
1260 | */ |
||
1261 | public function getLdelPreg() |
||
1265 | |||
1266 | /** |
||
1267 | * Get right delimiter preg |
||
1268 | * |
||
1269 | * @return string |
||
1270 | */ |
||
1271 | public function getRdelPreg() |
||
1275 | |||
1276 | /** |
||
1277 | * Get length of left delimiter |
||
1278 | * |
||
1279 | * @return int |
||
1280 | */ |
||
1281 | public function getLdelLength() |
||
1285 | |||
1286 | /** |
||
1287 | * Get length of right delimiter |
||
1288 | * |
||
1289 | * @return int |
||
1290 | */ |
||
1291 | public function getRdelLength() |
||
1295 | |||
1296 | /** |
||
1297 | * Get name of current open block tag |
||
1298 | * |
||
1299 | * @return string|boolean |
||
1300 | */ |
||
1301 | public function getOpenBlockTag() |
||
1310 | |||
1311 | /** |
||
1312 | * Check if $value contains variable elements |
||
1313 | * |
||
1314 | * @param mixed $value |
||
1315 | * |
||
1316 | * @return bool|int |
||
1317 | */ |
||
1318 | public function isVariable($value) |
||
1319 | { |
||
1320 | if (is_string($value)) { |
||
1321 | return preg_match('/[$(]/', $value); |
||
1322 | } |
||
1323 | if (is_bool($value) || is_numeric($value)) { |
||
1324 | return false; |
||
1325 | } |
||
1326 | if (is_array($value)) { |
||
1327 | foreach ($value as $k => $v) { |
||
1328 | if ($this->isVariable($k) || $this->isVariable($v)) { |
||
1329 | return true; |
||
1330 | } |
||
1331 | } |
||
1332 | return false; |
||
1333 | } |
||
1334 | return false; |
||
1335 | } |
||
1336 | |||
1337 | /** |
||
1338 | * Get new prefix variable name |
||
1339 | * |
||
1340 | * @return string |
||
1341 | */ |
||
1342 | public function getNewPrefixVariable() |
||
1343 | { |
||
1344 | ++self::$prefixVariableNumber; |
||
1345 | return $this->getPrefixVariable(); |
||
1346 | } |
||
1347 | |||
1348 | /** |
||
1349 | * Get current prefix variable name |
||
1350 | * |
||
1351 | * @return string |
||
1352 | */ |
||
1353 | public function getPrefixVariable() |
||
1354 | { |
||
1355 | return '$_prefixVariable' . self::$prefixVariableNumber; |
||
1356 | } |
||
1357 | |||
1358 | /** |
||
1359 | * append code to prefix buffer |
||
1360 | * |
||
1361 | * @param string $code |
||
1362 | */ |
||
1363 | public function appendPrefixCode($code) |
||
1364 | { |
||
1365 | $this->prefix_code[] = $code; |
||
1366 | } |
||
1367 | |||
1368 | /** |
||
1369 | * get prefix code string |
||
1370 | * |
||
1371 | * @return string |
||
1372 | */ |
||
1373 | public function getPrefixCode() |
||
1374 | { |
||
1375 | $code = ''; |
||
1376 | $prefixArray = array_merge($this->prefix_code, array_pop($this->prefixCodeStack)); |
||
1377 | $this->prefixCodeStack[] = array(); |
||
1378 | foreach ($prefixArray as $c) { |
||
1379 | $code = $this->appendCode($code, $c); |
||
1380 | } |
||
1381 | $this->prefix_code = array(); |
||
1382 | return $code; |
||
1383 | } |
||
1384 | |||
1385 | /** |
||
1386 | * Save current required plugins |
||
1387 | * |
||
1388 | * @param bool $init if true init required plugins |
||
1389 | */ |
||
1390 | public function saveRequiredPlugins($init = false) |
||
1397 | |||
1398 | /** |
||
1399 | * Restore required plugins |
||
1400 | */ |
||
1401 | public function restoreRequiredPlugins() |
||
1405 | |||
1406 | /** |
||
1407 | * Compile code to call Smarty_Internal_Template::_checkPlugins() |
||
1408 | * for required plugins |
||
1409 | * |
||
1410 | * @return string |
||
1411 | */ |
||
1412 | public function compileRequiredPlugins() |
||
1420 | |||
1421 | /** |
||
1422 | * Compile code to call Smarty_Internal_Template::_checkPlugins |
||
1423 | * - checks if plugin is callable require otherwise |
||
1424 | * |
||
1425 | * @param $requiredPlugins |
||
1426 | * |
||
1427 | * @return string |
||
1428 | */ |
||
1429 | public function compileCheckPlugins($requiredPlugins) |
||
1443 | |||
1444 | /** |
||
1445 | * method to compile a Smarty template |
||
1446 | * |
||
1447 | * @param mixed $_content template source |
||
1448 | * @param bool $isTemplateSource |
||
1449 | * |
||
1450 | * @return bool true if compiling succeeded, false if it failed |
||
1451 | */ |
||
1452 | abstract protected function doCompile($_content, $isTemplateSource = false); |
||
1453 | |||
1454 | /** |
||
1455 | * Compile Tag |
||
1456 | * |
||
1457 | * @param string $tag tag name |
||
1458 | * @param array $args array with tag attributes |
||
1459 | * @param array $parameter array with compilation parameter |
||
1460 | * |
||
1461 | * @throws SmartyCompilerException |
||
1462 | * @throws SmartyException |
||
1463 | * @return string compiled code |
||
1464 | */ |
||
1465 | private function compileTag2($tag, $args, $parameter) |
||
1756 | } |
||
1757 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.