Completed
Pull Request — master (#231)
by
unknown
04:17
created

StupidUnaryOperators::getRegister()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 1
b 0
f 0
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
9
class StupidUnaryOperators implements AnalyzerPassInterface
10
{
11
    /**
12
     * @param Expr $expr
13
     * @param Context $context
14
     * @return bool
15
     */
16 11
    public function pass(Expr $expr, Context $context)
17
    {
18 11
        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...
19 11
            $context->notice(
20 11
                'stupid_unary_operators',
21 11
                'You are using single plus unary operator. This has no effect',
22
                $expr
23 11
            );
24 11
            return true;
25
        }
26
27 1
        return false;
28
    }
29
30
    /**
31
     * @return array
32
     */
33 1
    public function getRegister()
34
    {
35
        return [
36 1
            Expr\UnaryPlus::class,
37 1
        ];
38
    }
39
}
40