Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
35 | class SmartyRenderer extends Renderer implements ReusableRendererInterface |
||
36 | { |
||
37 | /** |
||
38 | * @constant string The directory inside the cache dir where templates will |
||
39 | * be stored in compiled form. |
||
40 | */ |
||
41 | const COMPILE_DIR = 'templates'; |
||
42 | |||
43 | /** |
||
44 | * @constant string The subdirectory inside the compile dir where templates |
||
45 | * will be stored in compiled form. |
||
46 | */ |
||
47 | const COMPILE_SUBDIR = 'smarty'; |
||
48 | |||
49 | /** |
||
50 | * @constant string The directory inside the cache dir where cached content |
||
51 | * will be stored. |
||
52 | */ |
||
53 | const CACHE_DIR = 'content'; |
||
54 | |||
55 | /** |
||
56 | * @var Smarty Smarty template engine. |
||
57 | */ |
||
58 | protected $smarty = null; |
||
59 | |||
60 | /** |
||
61 | * @var string A string with the default template file extension, |
||
62 | * including the dot. |
||
63 | */ |
||
64 | protected $defaultExtension = '.tpl'; |
||
65 | |||
66 | /** |
||
67 | * @var bool Internal flag to indicate the Smarty version used. |
||
68 | */ |
||
69 | protected $isSmarty2 = true; |
||
70 | |||
71 | /** |
||
72 | * Pre-serialization callback. |
||
73 | * |
||
74 | * Excludes the Smarty instance to prevent excessive serialization load. |
||
75 | * |
||
76 | * @author David Zülke <[email protected]> |
||
77 | * @since 0.11.0 |
||
78 | */ |
||
79 | public function __sleep() |
||
85 | |||
86 | /** |
||
87 | * Create an instance of Smarty and initialize it correctly. |
||
88 | * |
||
89 | * @return Smarty The Smarty instance. |
||
90 | * |
||
91 | * @author David Zülke <[email protected]> |
||
92 | * @since 1.0.2 |
||
93 | */ |
||
94 | protected function createEngineInstance() |
||
108 | |||
109 | /** |
||
110 | * Grab a cleaned up smarty instance. |
||
111 | * |
||
112 | * @return Smarty A Smarty instance. |
||
113 | * |
||
114 | * @author David Zülke <[email protected]> |
||
115 | * @author TANAKA Koichi <[email protected]> |
||
116 | * @since 0.9.0 |
||
117 | */ |
||
118 | protected function getEngine() |
||
166 | |||
167 | /** |
||
168 | * Render the presentation and return the result. |
||
169 | * |
||
170 | * @param TemplateLayer $layer The template layer to render. |
||
171 | * @param array $attributes The template variables. |
||
172 | * @param array $slots The slots. |
||
173 | * @param array $moreAssigns Associative array of additional assigns. |
||
174 | * |
||
175 | * @return string A rendered result. |
||
176 | * |
||
177 | * @author David Zülke <[email protected]> |
||
178 | * @since 0.11.0 |
||
179 | */ |
||
180 | public function render(TemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array()) |
||
214 | } |
||
215 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: