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

MissingTypeHintInFunctionRule::getNodeType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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