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 |
||
| 20 | trait CompileWithContentArgumentAndRenderStatic |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Name of variable that contains the value to use |
||
| 24 | * instead of render children closure, if specified. |
||
| 25 | * If no name is provided here, the first variable |
||
| 26 | * registered in `initializeArguments` of the ViewHelper |
||
| 27 | * will be used. |
||
| 28 | * |
||
| 29 | * Note: it is significantly better practice to define |
||
| 30 | * this property in your ViewHelper class and so fix it |
||
| 31 | * to one particular argument instead of resolving, |
||
| 32 | * especially when your ViewHelper is called multiple |
||
| 33 | * times within an uncompiled template! |
||
| 34 | * |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | protected $contentArgumentName; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Default render method to render ViewHelper with |
||
| 41 | * first defined optional argument as content. |
||
| 42 | * |
||
| 43 | * @return string Rendered string |
||
| 44 | * @api |
||
| 45 | */ |
||
| 46 | public function render() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param string $argumentsName |
||
| 57 | * @param string $closureName |
||
| 58 | * @param string $initializationPhpCode |
||
| 59 | * @param ViewHelperNode $node |
||
| 60 | * @param TemplateCompiler $compiler |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | View Code Duplication | public function compile( |
|
| 80 | |||
| 81 | /** |
||
| 82 | * Helper which is mostly needed when calling renderStatic() from within |
||
| 83 | * render(). |
||
| 84 | * |
||
| 85 | * No public API yet. |
||
| 86 | * |
||
| 87 | * @return \Closure |
||
| 88 | */ |
||
| 89 | protected function buildRenderChildrenClosure() |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @return string |
||
| 108 | */ |
||
| 109 | protected function resolveContentArgumentName() |
||
| 126 | } |
||
| 127 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.