This repository was archived by the owner on Feb 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +24
-10
lines changed Expand file tree Collapse file tree 1 file changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -50,16 +50,18 @@ public function check(FileInfo $file)
50
50
if ($ method ['return ' ] === 'array ' && substr ($ method ['docblock ' ]['return ' ], -2 ) === '[] ' ) {
51
51
// Do nothing because this is fine.
52
52
} else {
53
- $ this ->fileStatus ->add (
54
- new ReturnMismatchWarning (
55
- $ file ->getFileName (),
56
- $ name ,
57
- $ method ['line ' ],
58
- $ name ,
59
- $ method ['return ' ],
60
- $ method ['docblock ' ]['return ' ]
61
- )
62
- );
53
+ if (!is_array ($ method ['return ' ]) || !$ this ->checkMultipleReturnStatements ($ method )) {
54
+ $ this ->fileStatus ->add (
55
+ new ReturnMismatchWarning (
56
+ $ file ->getFileName (),
57
+ $ name ,
58
+ $ method ['line ' ],
59
+ $ name ,
60
+ $ method ['return ' ],
61
+ $ method ['docblock ' ]['return ' ]
62
+ )
63
+ );
64
+ }
63
65
}
64
66
}
65
67
}
@@ -73,4 +75,16 @@ public function enabled()
73
75
{
74
76
return !$ this ->config ->isSkipSignatures ();
75
77
}
78
+
79
+ /**
80
+ * @param array $method
81
+ * @return bool
82
+ */
83
+ private function checkMultipleReturnStatements (array $ method ): bool
84
+ {
85
+ $ dockReturn = explode ('| ' , $ method ['docblock ' ]['return ' ]);
86
+ $ methodReturn = $ method ['return ' ];
87
+
88
+ return count (array_diff ($ dockReturn , $ methodReturn )) == 0 && count (array_diff ($ methodReturn , $ dockReturn )) == 0 ;
89
+ }
76
90
}
You can’t perform that action at this time.
0 commit comments