Completed
Push — master ( 2d5a91...5e6a60 )
by André
72:09 queued 53:20
created

PermissionsCriterionHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
rs 9.4285
1
<?php
2
3
/**
4
 * File containing the eZ\Publish\Core\Repository\PermissionsCriterionHandler class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Repository;
10
11
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
12
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\LogicalAnd;
13
use eZ\Publish\Core\Repository\Permission\PermissionCriterionResolver;
14
15
/**
16
 * Handler for permissions Criterion.
17
 *
18
 * @deprecated 6.7.7
19
 */
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)
32
    {
33
        $permissionCriterion = $this->getPermissionsCriterion();
34
        if ($permissionCriterion === true || $permissionCriterion === false) {
35
            return $permissionCriterion;
36
        }
37
38
        // Merge with original $criterion
39
        if ($criterion instanceof LogicalAnd) {
40
            $criterion->criteria[] = $permissionCriterion;
41
        } else {
42
            $criterion = new LogicalAnd(
43
                array(
0 ignored issues
show
Documentation introduced by
array($criterion, $permissionCriterion) is of type array<integer,object<eZ\...t\\Query\\Criterion>"}>, but the function expects a array<integer,object<eZ\...ntent\Query\Criterion>>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
44
                    $criterion,
45
                    $permissionCriterion,
46
                )
47
            );
48
        }
49
50
        return true;
51
    }
52
}
53