1 | <?php |
||
2 | /** |
||
3 | * Smarty Internal Plugin Compile Registered Block |
||
4 | * Compiles code for the execution of a registered block function |
||
5 | * |
||
6 | * @package Smarty |
||
7 | * @subpackage Compiler |
||
8 | * @author Uwe Tews |
||
9 | */ |
||
10 | |||
11 | /** |
||
12 | * Smarty Internal Plugin Compile Registered Block Class |
||
13 | * |
||
14 | * @package Smarty |
||
15 | * @subpackage Compiler |
||
16 | */ |
||
17 | class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_Compile_Private_Block_Plugin |
||
18 | { |
||
19 | /** |
||
20 | * Setup callback, parameter array and nocache mode |
||
21 | * |
||
22 | * @param \Smarty_Internal_TemplateCompilerBase $compiler |
||
23 | * @param array $_attr attributes |
||
24 | * @param string $tag |
||
25 | * @param null $function |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
26 | * |
||
27 | * @return array |
||
28 | */ |
||
29 | public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function) |
||
30 | { |
||
31 | if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ])) { |
||
32 | $tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; |
||
33 | $callback = $tag_info[ 0 ]; |
||
34 | if (is_array($callback)) { |
||
35 | if (is_object($callback[ 0 ])) { |
||
36 | $callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')"; |
||
37 | $callback = |
||
38 | array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "->{$callback[1]}"); |
||
39 | } else { |
||
40 | $callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')"; |
||
41 | $callback = |
||
42 | array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "::{$callback[1]}"); |
||
43 | } |
||
44 | } else { |
||
45 | $callable = "\$_block_plugin{$this->nesting}"; |
||
46 | $callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0]", ''); |
||
47 | } |
||
48 | } else { |
||
49 | $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; |
||
50 | $callback = $tag_info[ 0 ]; |
||
51 | if (is_array($callback)) { |
||
52 | $callable = "array('{$callback[0]}', '{$callback[1]}')"; |
||
53 | $callback = "{$callback[1]}::{$callback[1]}"; |
||
54 | } else { |
||
55 | $callable = null; |
||
56 | } |
||
57 | } |
||
58 | $compiler->tag_nocache = !$tag_info[ 1 ] | $compiler->tag_nocache; |
||
0 ignored issues
–
show
The property
$tag_nocache was declared of type boolean , but ! $tag_info[1] | $compiler->tag_nocache is of type integer . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
Loading history...
|
|||
59 | $_paramsArray = array(); |
||
60 | foreach ($_attr as $_key => $_value) { |
||
61 | if (is_int($_key)) { |
||
62 | $_paramsArray[] = "$_key=>$_value"; |
||
63 | } elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) { |
||
64 | $_value = str_replace('\'', "^#^", $_value); |
||
65 | $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^"; |
||
66 | } else { |
||
67 | $_paramsArray[] = "'$_key'=>$_value"; |
||
68 | } |
||
69 | } |
||
70 | return array($callback, $_paramsArray, $callable); |
||
71 | } |
||
72 | } |
||
73 |