This repository was archived by the owner on Feb 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,16 +50,18 @@ public function check(FileInfo $file)
5050 if ($ method ['return ' ] === 'array ' && substr ($ method ['docblock ' ]['return ' ], -2 ) === '[] ' ) {
5151 // Do nothing because this is fine.
5252 } 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+ }
6365 }
6466 }
6567 }
@@ -73,4 +75,16 @@ public function enabled()
7375 {
7476 return !$ this ->config ->isSkipSignatures ();
7577 }
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+ }
7690}
You can’t perform that action at this time.
0 commit comments