File tree Expand file tree Collapse file tree 4 files changed +28
-6
lines changed
Expand file tree Collapse file tree 4 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -101,11 +101,16 @@ public function process(File $phpcsFile, $stackPtr)
101101 continue ;
102102 }
103103
104- if ($ valueNode ->type instanceof UnionTypeNode) {
105- $ types = $ valueNode ->type ->types ;
106- } elseif ($ valueNode ->type instanceof ArrayTypeNode) {
107- $ types = [$ valueNode ->type ];
104+ if (isset ($ valueNode ->type )) {
105+ if ($ valueNode ->type instanceof UnionTypeNode) {
106+ $ types = $ valueNode ->type ->types ;
107+ } elseif ($ valueNode ->type instanceof ArrayTypeNode) {
108+ $ types = [$ valueNode ->type ];
109+ } else {
110+ continue ;
111+ }
108112 } else {
113+ $ phpcsFile ->addWarning ('@param type hint is missing ' , $ tag , 'MissingParamType ' );
109114 continue ;
110115 }
111116
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ class Foo
2222 public function testFunctionAnotations ()
2323 {
2424 }
25+
26+ /**
27+ * @param $test
28+ * @return void
29+ */
30+ public function testNoParamTypeHint (string $ test )
31+ {
32+ }
2533}
2634
2735function test ()
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ class Foo
2222 public function testFunctionAnotations()
2323 {
2424 }
25+
26+ /**
27+ * @param $test
28+ * @return void
29+ */
30+ public function testNoParamTypeHint(string $test)
31+ {
32+ }
2533}
2634
2735function test()
Original file line number Diff line number Diff line change @@ -29,8 +29,9 @@ public function getWarningList($testFile = '')
2929 9 => 1 ,
3030 12 => 1 ,
3131 15 => 1 ,
32- 29 => 1 ,
33- 34 => 1 ,
32+ 27 => 1 ,
33+ 37 => 1 ,
34+ 42 => 1 ,
3435 ];
3536
3637 default :
You can’t perform that action at this time.
0 commit comments