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 |
||
10 | class HtmlTab extends HtmlSemCollection{ |
||
11 | protected $params=array("debug"=>true); |
||
12 | |||
13 | public function __construct( $identifier, $tabs=array()){ |
||
20 | |||
21 | protected function createItem($value){ |
||
35 | |||
36 | public function activate($index){ |
||
41 | |||
42 | public function addPanel($title,$content){ |
||
45 | |||
46 | /** |
||
47 | * render the content of $controller::$action and set the response to a new panel |
||
48 | * @param JsUtils $js |
||
49 | * @param string $title The panel title |
||
50 | * @param Controller $initialController |
||
51 | * @param string $controller a Phalcon controller |
||
52 | * @param string $action a Phalcon action |
||
53 | * @param array $params |
||
54 | */ |
||
55 | public function forwardPanel(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
||
58 | |||
59 | /** |
||
60 | * render the content of an existing view : $controller/$action and set the response to a new panel |
||
61 | * @param JsUtils $js |
||
62 | * @param string $title The panel title |
||
63 | * @param Controller $initialController |
||
64 | * @param string $viewName |
||
65 | * @param $params The parameters to pass to the view |
||
66 | */ |
||
67 | public function renderViewPanel(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
||
70 | |||
71 | /* |
||
72 | * (non-PHPdoc) |
||
73 | * @see BaseHtml::run() |
||
74 | */ |
||
75 | public function run(JsUtils $js) { |
||
86 | } |
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: