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

MultipleUnaryOperators   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 34
ccs 14
cts 14
cp 1
rs 10
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 13 2
A getRegister() 0 9 1
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