| Conditions | 10 | 
| Paths | 9 | 
| Total Lines | 90 | 
| Code Lines | 55 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php | ||
| 187 | 	protected function render_blocks () { | ||
| 188 | $blocks = Config::instance()->components['blocks']; | ||
| 189 | /** | ||
| 190 | * It is frequent that there is no blocks - so, no need to to anything here | ||
| 191 | */ | ||
| 192 | 		if (!$blocks) { | ||
| 193 | return; | ||
| 194 | } | ||
| 195 | $Page = Page::instance(); | ||
| 196 | $blocks_array = [ | ||
| 197 | 'top' => '', | ||
| 198 | 'left' => '', | ||
| 199 | 'right' => '', | ||
| 200 | 'bottom' => '' | ||
| 201 | ]; | ||
| 202 | 		foreach ($blocks as $block) { | ||
| 203 | /** | ||
| 204 | * If there is no need to show block or it was rendered by even handler - skip further processing | ||
| 205 | */ | ||
| 206 | if ( | ||
| 207 | !$this->should_block_be_rendered($block) || | ||
| 208 | !Event::instance()->fire( | ||
| 209 | 'System/Index/block_render', | ||
| 210 | [ | ||
| 211 | 'index' => $block['index'], | ||
| 212 | 'blocks_array' => &$blocks_array | ||
| 213 | ] | ||
| 214 | ) || | ||
| 215 | !Event::instance()->fire( | ||
| 216 | 'System/App/block_render', | ||
| 217 | [ | ||
| 218 | 'index' => $block['index'], | ||
| 219 | 'blocks_array' => &$blocks_array | ||
| 220 | ] | ||
| 221 | ) | ||
| 222 | 			) { | ||
| 223 | /** | ||
| 224 | * Block was rendered by event handler | ||
| 225 | */ | ||
| 226 | continue; | ||
| 227 | } | ||
| 228 | $block['title'] = $this->ml_process($block['title']); | ||
| 229 | 			switch ($block['type']) { | ||
| 230 | default: | ||
| 231 | $block['content'] = ob_wrapper( | ||
| 232 | 						function () use ($block) { | ||
| 233 | include BLOCKS."/block.$block[type].php"; | ||
| 234 | } | ||
| 235 | ); | ||
| 236 | break; | ||
| 237 | case 'html': | ||
| 238 | case 'raw_html': | ||
| 239 | $block['content'] = $this->ml_process($block['content']); | ||
| 240 | break; | ||
| 241 | } | ||
| 242 | /** | ||
| 243 | * Template file will have access to `$block` variable, so it can use that | ||
| 244 | */ | ||
| 245 | $content = str_replace( | ||
| 246 | [ | ||
| 247 | '<!--id-->', | ||
| 248 | '<!--title-->', | ||
| 249 | '<!--content-->' | ||
| 250 | ], | ||
| 251 | [ | ||
| 252 | $block['index'], | ||
| 253 | $block['title'], | ||
| 254 | $block['content'] | ||
| 255 | ], | ||
| 256 | ob_wrapper( | ||
| 257 | 					function () use ($block) { | ||
| 258 | $template = file_exists(TEMPLATES."/blocks/block.$block[template]") ? $block['template'] : 'default.html'; | ||
| 259 | include TEMPLATES."/blocks/block.$template"; | ||
| 260 | } | ||
| 261 | ) | ||
| 262 | ); | ||
| 263 | 			if ($block['position'] == 'floating') { | ||
| 264 | $Page->replace( | ||
| 265 | "<!--block#$block[index]-->", | ||
| 266 | $content | ||
| 267 | ); | ||
| 268 | 			} else { | ||
| 269 | $blocks_array[$block['position']] .= $content; | ||
| 270 | } | ||
| 271 | } | ||
| 272 | $Page->Top .= $blocks_array['top']; | ||
| 273 | $Page->Left .= $blocks_array['left']; | ||
| 274 | $Page->Right .= $blocks_array['right']; | ||
| 275 | $Page->Bottom .= $blocks_array['bottom']; | ||
| 276 | } | ||
| 277 | /** | ||
| 316 | 
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: