Completed
Pull Request — master (#200)
by Enrico
04:08
created

MultipleUnaryOperators::pass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 13
ccs 8
cts 8
cp 1
crap 2
rs 9.4285
1
<?php
2
3
namespace PHPSA\Analyzer\Pass\Expression;
4
5
use PhpParser\Node\Expr;
6
use PHPSA\Analyzer\Pass\AnalyzerPassInterface;
7
use PHPSA\Context;
8
use PHPSA\CompiledExpression;
9
10
class MultipleUnaryOperators implements AnalyzerPassInterface
11
{
12
    /**
13
     * @param Expr $expr
14
     * @param Context $context
15
     * @return bool
16
     */
17 33
    public function pass(Expr $expr, Context $context)
18
    {
19 33
        if (get_class($expr->expr) == get_class($expr)) {
0 ignored issues
show
Bug introduced by
The property expr does not seem to exist in PhpParser\Node\Expr.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
20 1
            $context->notice(
21 1
                'multiple_unary_operators',
22 1
                "You are using multiple unary operators. This has no effect",
23
                $expr
24 1
            );
25 1
            return true;
26
        }
27
        
28 33
        return false;
29
    }
30
31
    /**
32
     * @return array
33
     */
34 1
    public function getRegister()
35
    {
36
        return [
37 1
            Expr\UnaryPlus::class,
38 1
            Expr\UnaryMinus::class,
39 1
            Expr\BitwiseNot::class,
40 1
            Expr\BooleanNot::class,
41 1
        ];
42
    }
43
}
44