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

ForLoopMultiple   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 31
rs 10
c 1
b 0
f 0
wmc 4
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 12 3
A getRegister() 0 6 1
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