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 | class PermissionsCriterionHandler extends PermissionCriterionResolver |
||
21 | { |
||
22 | /** |
||
23 | * Adds content, read Permission criteria if needed and return false if no access at all. |
||
24 | * |
||
25 | * @uses \eZ\Publish\Core\Repository\Permission\PermissionCriterionResolver::getPermissionsCriterion() |
||
26 | * |
||
27 | * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion |
||
28 | * |
||
29 | * @return bool|\eZ\Publish\API\Repository\Values\Content\Query\Criterion |
||
30 | */ |
||
31 | View Code Duplication | public function addPermissionsCriterion(Criterion &$criterion) |
|
52 | } |
||
53 |
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: