Completed
Push — master ( 1c1274...4171d4 )
by David
23s queued 21s
created

PrefixGenerator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generatePrefix() 0 12 3
1
<?php
2
3
4
namespace TheCodingMachine\PHPStan\Utils;
5
6
7
use PHPStan\Analyser\Scope;
8
use PHPStan\Reflection\FunctionReflection;
9
use PHPStan\Reflection\MethodReflection;
10
11
class PrefixGenerator
12
{
13
    public static function generatePrefix(Scope $scope): string
14
    {
15
        $function = $scope->getFunction();
16
        $prefix = '';
17
        if ($function instanceof MethodReflection) {
0 ignored issues
show
Bug introduced by
The class PHPStan\Reflection\MethodReflection does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
18
            $prefix = 'In method "'.$function->getDeclaringClass()->getName().'::'.$function->getName().'", ';
19
        } elseif ($function instanceof FunctionReflection) {
0 ignored issues
show
Bug introduced by
The class PHPStan\Reflection\FunctionReflection does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
20
            $prefix = 'In function "'.$function->getName().'", ';
21
        }
22
23
        return $prefix;
24
    }
25
}