File tree 6 files changed +8
-37
lines changed
6 files changed +8
-37
lines changed Original file line number Diff line number Diff line change 6
6
use PHPStan \Analyser \Scope ;
7
7
use PHPStan \Internal \SprintfHelper ;
8
8
use PHPStan \Node \InFunctionNode ;
9
- use PHPStan \Reflection \Php \PhpFunctionFromParserNodeReflection ;
10
9
use PHPStan \Rules \FunctionDefinitionCheck ;
11
10
use PHPStan \Rules \Rule ;
12
11
use function sprintf ;
@@ -28,15 +27,11 @@ public function getNodeType(): string
28
27
29
28
public function processNode (Node $ node , Scope $ scope ): array
30
29
{
31
- if (!$ scope ->getFunction () instanceof PhpFunctionFromParserNodeReflection) {
32
- return [];
33
- }
34
-
35
- $ functionName = SprintfHelper::escapeFormatString ($ scope ->getFunction ()->getName ());
30
+ $ functionName = SprintfHelper::escapeFormatString ($ node ->getFunctionReflection ()->getName ());
36
31
37
32
return $ this ->check ->checkFunction (
38
33
$ node ->getOriginalNode (),
39
- $ scope -> getFunction (),
34
+ $ node -> getFunctionReflection (),
40
35
sprintf (
41
36
'Parameter $%%s of function %s() has invalid type %%s. ' ,
42
37
$ functionName ,
Original file line number Diff line number Diff line change 8
8
use PHPStan \Reflection \FunctionReflection ;
9
9
use PHPStan \Reflection \ParameterReflection ;
10
10
use PHPStan \Reflection \ParametersAcceptorSelector ;
11
- use PHPStan \Reflection \Php \PhpFunctionFromParserNodeReflection ;
12
11
use PHPStan \Rules \MissingTypehintCheck ;
13
12
use PHPStan \Rules \Rule ;
14
13
use PHPStan \Rules \RuleError ;
@@ -37,11 +36,7 @@ public function getNodeType(): string
37
36
38
37
public function processNode (Node $ node , Scope $ scope ): array
39
38
{
40
- $ functionReflection = $ scope ->getFunction ();
41
- if (!$ functionReflection instanceof PhpFunctionFromParserNodeReflection) {
42
- return [];
43
- }
44
-
39
+ $ functionReflection = $ node ->getFunctionReflection ();
45
40
$ messages = [];
46
41
47
42
foreach (ParametersAcceptorSelector::selectSingle ($ functionReflection ->getVariants ())->getParameters () as $ parameterReflection ) {
Original file line number Diff line number Diff line change 6
6
use PHPStan \Analyser \Scope ;
7
7
use PHPStan \Node \InFunctionNode ;
8
8
use PHPStan \Reflection \ParametersAcceptorSelector ;
9
- use PHPStan \Reflection \Php \PhpFunctionFromParserNodeReflection ;
10
9
use PHPStan \Rules \MissingTypehintCheck ;
11
10
use PHPStan \Rules \Rule ;
12
11
use PHPStan \Rules \RuleErrorBuilder ;
@@ -34,11 +33,7 @@ public function getNodeType(): string
34
33
35
34
public function processNode (Node $ node , Scope $ scope ): array
36
35
{
37
- $ functionReflection = $ scope ->getFunction ();
38
- if (!$ functionReflection instanceof PhpFunctionFromParserNodeReflection) {
39
- return [];
40
- }
41
-
36
+ $ functionReflection = $ node ->getFunctionReflection ();
42
37
$ returnType = ParametersAcceptorSelector::selectSingle ($ functionReflection ->getVariants ())->getReturnType ();
43
38
44
39
if ($ returnType instanceof MixedType && !$ returnType ->isExplicitMixed ()) {
Original file line number Diff line number Diff line change @@ -27,11 +27,7 @@ public function getNodeType(): string
27
27
28
28
public function processNode (Node $ node , Scope $ scope ): array
29
29
{
30
- $ functionReflection = $ scope ->getFunction ();
31
- if ($ functionReflection === null ) {
32
- return [];
33
- }
34
-
30
+ $ functionReflection = $ node ->getFunctionReflection ();
35
31
$ functionName = $ functionReflection ->getName ();
36
32
37
33
return $ this ->varianceCheck ->checkParametersAcceptor (
Original file line number Diff line number Diff line change 6
6
use PHPStan \Analyser \Scope ;
7
7
use PHPStan \Node \InFunctionNode ;
8
8
use PHPStan \Rules \Rule ;
9
- use PHPStan \ShouldNotHappenException ;
10
9
use function count ;
11
10
12
11
/**
@@ -26,11 +25,7 @@ public function getNodeType(): string
26
25
27
26
public function processNode (Node $ node , Scope $ scope ): array
28
27
{
29
- $ function = $ scope ->getFunction ();
30
- if ($ function === null ) {
31
- throw new ShouldNotHappenException ();
32
- }
33
-
28
+ $ function = $ node ->getFunctionReflection ();
34
29
$ variants = $ function ->getVariants ();
35
30
if (count ($ variants ) !== 1 ) {
36
31
return [];
Original file line number Diff line number Diff line change 6
6
use PHPStan \Analyser \Scope ;
7
7
use PHPStan \Node \InFunctionNode ;
8
8
use PHPStan \Rules \Rule ;
9
- use PHPStan \ShouldNotHappenException ;
10
9
use function count ;
11
10
12
11
/**
@@ -26,12 +25,8 @@ public function getNodeType(): string
26
25
27
26
public function processNode (Node $ node , Scope $ scope ): array
28
27
{
29
- $ method = $ scope ->getFunction ();
30
- if ($ method === null ) {
31
- throw new ShouldNotHappenException ();
32
- }
33
-
34
- $ variants = $ method ->getVariants ();
28
+ $ function = $ node ->getFunctionReflection ();
29
+ $ variants = $ function ->getVariants ();
35
30
if (count ($ variants ) !== 1 ) {
36
31
return [];
37
32
}
You can’t perform that action at this time.
0 commit comments