File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
tests/PHPStan/Rules/Variables/data Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -3798,15 +3798,24 @@ private function processArgs(
3798
3798
$ assignByReference = false ;
3799
3799
$ parameter = null ;
3800
3800
$ parameterType = null ;
3801
+ $ parameterNativeType = null ;
3801
3802
if (isset ($ parameters ) && $ parametersAcceptor !== null ) {
3802
3803
if (isset ($ parameters [$ i ])) {
3803
3804
$ assignByReference = $ parameters [$ i ]->passedByReference ()->createsNewVariable ();
3804
3805
$ parameterType = $ parameters [$ i ]->getType ();
3806
+
3807
+ if ($ parameters [$ i ] instanceof ParameterReflectionWithPhpDocs) {
3808
+ $ parameterNativeType = $ parameters [$ i ]->getNativeType ();
3809
+ }
3805
3810
$ parameter = $ parameters [$ i ];
3806
3811
} elseif (count ($ parameters ) > 0 && $ parametersAcceptor ->isVariadic ()) {
3807
3812
$ lastParameter = $ parameters [count ($ parameters ) - 1 ];
3808
3813
$ assignByReference = $ lastParameter ->passedByReference ()->createsNewVariable ();
3809
3814
$ parameterType = $ lastParameter ->getType ();
3815
+
3816
+ if ($ lastParameter instanceof ParameterReflectionWithPhpDocs) {
3817
+ $ parameterNativeType = $ lastParameter ->getNativeType ();
3818
+ }
3810
3819
$ parameter = $ lastParameter ;
3811
3820
}
3812
3821
}
@@ -3822,7 +3831,7 @@ private function processArgs(
3822
3831
}
3823
3832
if (
3824
3833
$ isBuiltin
3825
- || ($ parameterType === null || !$ parameterType ->isNull ()->no ())
3834
+ || ($ parameterNativeType === null || !$ parameterNativeType ->isNull ()->no ())
3826
3835
) {
3827
3836
$ scope = $ this ->lookForSetAllowedUndefinedExpressions ($ scope , $ arg ->value );
3828
3837
$ lookForUnset = true ;
Original file line number Diff line number Diff line change @@ -34,3 +34,39 @@ public function test()
34
34
}
35
35
36
36
}
37
+
38
+ class FooPhpDocs
39
+ {
40
+
41
+ /**
42
+ * @param mixed $test
43
+ */
44
+ public function doFooMixedType (&$ test )
45
+ {
46
+
47
+ }
48
+
49
+ /**
50
+ * @param int $test
51
+ */
52
+ public function doFooIntType (&$ test )
53
+ {
54
+
55
+ }
56
+
57
+ /**
58
+ * @param int|null $test
59
+ */
60
+ public function doFooNullableType (&$ test )
61
+ {
62
+
63
+ }
64
+
65
+ public function test ()
66
+ {
67
+ $ this ->doFooMixedType ($ two );
68
+ $ this ->doFooIntType ($ three );
69
+ $ this ->doFooNullableType ($ four );
70
+ }
71
+
72
+ }
You can’t perform that action at this time.
0 commit comments