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(); |
||
12 | |||
13 | public function __construct( $identifier, $tabs=array()){ |
||
22 | |||
23 | protected function createItem($value){ |
||
37 | |||
38 | public function activate($index){ |
||
43 | |||
44 | public function addPanel($title,$content){ |
||
47 | |||
48 | /** |
||
49 | * render the content of $controller::$action and set the response to a new panel |
||
50 | * @param JsUtils $js |
||
51 | * @param string $title The panel title |
||
52 | * @param Controller $initialController |
||
53 | * @param string $controller a Phalcon controller |
||
54 | * @param string $action a Phalcon action |
||
55 | * @param array $params |
||
56 | */ |
||
57 | public function forwardPanel(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
||
60 | |||
61 | /** |
||
62 | * render the content of an existing view : $controller/$action and set the response to a new panel |
||
63 | * @param JsUtils $js |
||
64 | * @param string $title The panel title |
||
65 | * @param Controller $initialController |
||
66 | * @param string $viewName |
||
67 | * @param $params The parameters to pass to the view |
||
68 | */ |
||
69 | public function renderViewPanel(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
||
72 | |||
73 | /* |
||
74 | * (non-PHPdoc) |
||
75 | * @see BaseHtml::run() |
||
76 | */ |
||
77 | public function run(JsUtils $js) { |
||
83 | } |
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: