Completed
Pull Request — master (#1)
by David
04:47
created

MissingTypeHintInFunctionRule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getNodeType() 0 4 1
A getContext() 0 7 2
1
<?php
2
3
4
namespace TheCodingMachine\PHPStan\Rules\TypeHints;
5
6
use BetterReflection\Reflection\ReflectionFunction;
7
use BetterReflection\Reflection\ReflectionFunctionAbstract;
8
use BetterReflection\Reflection\ReflectionMethod;
9
use BetterReflection\Reflection\ReflectionParameter;
10
use PhpParser\Node;
11
12
class MissingTypeHintInFunctionRule extends AbstractMissingTypeHintRule
13
{
14
    public function getNodeType(): string
15
    {
16
        return Node\Stmt\Function_::class;
17
    }
18
19
    /**
20
     * @param ReflectionFunctionAbstract|ReflectionParameter $reflection
21
     * @return string
22
     */
23
    public function getContext($reflection): string
24
    {
25
        if ($reflection instanceof ReflectionParameter) {
26
            $reflection = $reflection->getDeclaringFunction();
27
        }
28
        return 'In function "'.$reflection->getName().'"';
29
    }
30
}
31