diff --git a/src/Check/ReturnCheck.php b/src/Check/ReturnCheck.php index 85c7431..ee17c7b 100644 --- a/src/Check/ReturnCheck.php +++ b/src/Check/ReturnCheck.php @@ -50,16 +50,18 @@ public function check(FileInfo $file) if ($method['return'] === 'array' && substr($method['docblock']['return'], -2) === '[]') { // Do nothing because this is fine. } else { - $this->fileStatus->add( - new ReturnMismatchWarning( - $file->getFileName(), - $name, - $method['line'], - $name, - $method['return'], - $method['docblock']['return'] - ) - ); + if (!is_array($method['return']) || !$this->checkMultipleReturnStatements($method)) { + $this->fileStatus->add( + new ReturnMismatchWarning( + $file->getFileName(), + $name, + $method['line'], + $name, + $method['return'], + $method['docblock']['return'] + ) + ); + } } } } @@ -73,4 +75,16 @@ public function enabled() { return !$this->config->isSkipSignatures(); } + + /** + * @param array $method + * @return bool + */ + private function checkMultipleReturnStatements(array $method): bool + { + $dockReturn = explode('|', $method['docblock']['return']); + $methodReturn = $method['return']; + + return count(array_diff($dockReturn, $methodReturn)) == 0 && count(array_diff($methodReturn, $dockReturn)) == 0; + } }