Completed
Pull Request — master (#245)
by
unknown
19:23 queued 07:52
created

ForLoopMultiple::pass()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
nc 2
nop 2
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace PHPSA\Analyzer\Pass\Statement;
4
5
use PhpParser\Node;
6
use PhpParser\Node\Stmt\For_;
7
use PHPSA\Analyzer\Helper\DefaultMetadataPassTrait;
8
use PHPSA\Analyzer\Pass;
9
use PHPSA\Context;
10
11
class ForLoopMultiple implements Pass\AnalyzerPassInterface
12
{
13
    use DefaultMetadataPassTrait;
14
15
    /**
16
     * @param Property $prop
0 ignored issues
show
Bug introduced by
There is no parameter named $prop. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
17
     * @param Context $context
18
     * @return bool
19
     */
20
    public function pass($stmt, Context $context)
21
    {
22
        if ($stmt instanceof For_ && count($stmt->cond) > 1) {
23
            $context->notice(
24
                'for_loop_multiple',
25
                'Number of conditions in for larger than one.Merge them using && symbol.',
26
                $stmt
27
            );
28
            return true;
29
        }
30
        return false;
31
    }
32
    /**
33
     * @return array
34
     */
35
    public function getRegister()
36
    {
37
        return [
38
            For_::class,
39
        ];
40
    }
41
}
42