GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — migrate-to-friendsofphp/php-cs... ( 0b5a57...4a9bcb )
by Cees-Jan
02:20
created

EmptyLineAboveDocblocksFixer::isCandidate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ApiClients\Tools\ResourceGenerator;
4
5
use PhpCsFixer\AbstractFixer;
6
use PhpCsFixer\FixerDefinition\CodeSample;
7
use PhpCsFixer\FixerDefinition\FixerDefinition;
8
use PhpCsFixer\Tokenizer\Tokens;
9
10
class EmptyLineAboveDocblocksFixer extends AbstractFixer
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function getName()
16
    {
17
        return 'ApiClients/empty_line_above_docblocks';
18
    }
19
20
    public function getDefinition()
21
    {
22
        return new FixerDefinition(
23
            'Ensure there is an empty line behind abstract or interface methods.',
24
            [
25
                new CodeSample(
26
                    $this->BOM.'<?php
0 ignored issues
show
Bug introduced by
The property BOM does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
27
            
28
            echo "Hello!";
29
            '
30
                ),
31
            ]
32
        );
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getPriority()
39
    {
40
        return 1;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function isCandidate(Tokens $tokens)
47
    {
48
        return true;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    protected function applyFix(\SplFileInfo $file, Tokens $tokens)
55
    {
56
        for ($index = 2; $index < count($tokens); $index++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
57
            $token = $tokens[$index];
58
            $previousToken = $tokens[$index - 1];
59
            $sndPreviousToken = $tokens[$index - 2];
60
            if ($sndPreviousToken->getContent() !== '{' &&
61
                substr($token->getContent(), 0, 3) === '/**' /*&&
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
62
                $previousToken->getLine() === $token->getLine() - 1*/
63
            ) {
64
                $previousToken->setContent(PHP_EOL . $previousToken->getContent());
65
            }
66
        }
67
    }
68
}
69