Completed
Push — 2.x ( ae114c...98cb65 )
by Akihito
27s queued 11s
created

src/Matcher/AnnotatedWithMatcher.php (4 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Aop\Matcher;
6
7
use Doctrine\Common\Annotations\AnnotationReader;
8
use Ray\Aop\AbstractMatcher;
9
10
final class AnnotatedWithMatcher extends AbstractMatcher
11
{
12
    /**
13
     * @var AnnotationReader
14
     */
15
    private $reader;
16
17
    /**
18
     * @throws \Doctrine\Common\Annotations\AnnotationException
19
     */
20
    public function __construct()
21 5
    {
22
        parent::__construct();
23 5
        $this->reader = new AnnotationReader();
24 5
    }
25 5
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function matchesClass(\ReflectionClass $class, array $arguments) : bool
30 2
    {
31
        /** @var array<string> $arguments */
32 2
        [$annotation] = $arguments;
0 ignored issues
show
The variable $annotation seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
33 2
        $annotation = $this->reader->getClassAnnotation($class, $annotation);
0 ignored issues
show
The variable $annotation seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
34
35 2
        return $annotation ? true : false;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 3
    public function matchesMethod(\ReflectionMethod $method, array $arguments) : bool
42
    {
43 3
        /** @var array<string> $arguments */
44 3
        [$annotation] = $arguments;
0 ignored issues
show
The variable $annotation seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
45
        $annotation = $this->reader->getMethodAnnotation($method, $annotation);
0 ignored issues
show
The variable $annotation seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
46 3
47
        return $annotation ? true : false;
48
    }
49
}
50