Completed
Pull Request — master (#232)
by
unknown
05:28
created

CheckLNumberKind::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 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 0
b 0
f 0
1
<?php
2
3
namespace PHPSA\Analyzer\Pass\Scalar;
4
5
use PhpParser\Node\Scalar;
6
use PHPSA\Analyzer\Helper\DefaultMetadataPassTrait;
7
use PHPSA\Analyzer\Pass\AnalyzerPassInterface;
8
use PHPSA\Context;
9
10
class CheckLNumberKind implements AnalyzerPassInterface
11
{
12
    use DefaultMetadataPassTrait;
13
14
    /**
15
     * @param Scalar\LNumber $lNum
16
     * @param Context $context
17
     * @return bool
18
     */
19
    public function pass(Scalar\LNumber $lNum, Context $context)
20
    {
21
        error_log('*************************');
22
        var_dump($lNum->getAttribute('kind'));
0 ignored issues
show
Security Debugging Code introduced by
var_dump($lNum->getAttribute('kind')); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
23
        if ($lNum->getAttribute('kind') != Scalar\LNumber::KIND_DEC) {
24
            $context->notice(
25
                'l_number_kind',
26
                'Avoid using octal, hexadecimal or binary',
27
                $lNum
28
            );
29
            return true;
30
        }
31
32
        return true;
33
    }
34
35
    /**
36
     * @return array
37
     */
38 1
    public function getRegister()
39
    {
40
        return [
41 1
            Scalar\LNumber::class,
42 1
        ];
43
    }
44
}
45