Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

Commit fd783c9

Browse files
author
Sergei Filonich
committed
Fix issue with checking nullable return statements.
1 parent 687bb03 commit fd783c9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Check/ReturnCheck.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function check(FileInfo $file)
4949
if ($method['docblock']['return'] !== $method['return']) {
5050
if ($method['return'] === 'array' && substr($method['docblock']['return'], -2) === '[]') {
5151
// Do nothing because this is fine.
52-
} else {
52+
} elseif (!is_array($method['return']) || !$this->checkMultipleReturnStatements($method)) {
5353
$this->fileStatus->add(
5454
new ReturnMismatchWarning(
5555
$file->getFileName(),
@@ -73,4 +73,16 @@ public function enabled()
7373
{
7474
return !$this->config->isSkipSignatures();
7575
}
76+
77+
/**
78+
* @param array $method
79+
* @return bool
80+
*/
81+
private function checkMultipleReturnStatements(array $method): bool
82+
{
83+
$dockReturn = explode('|', $method['docblock']['return']);
84+
$methodReturn = $method['return'];
85+
86+
return count(array_diff($dockReturn, $methodReturn)) == 0 && count(array_diff($methodReturn, $dockReturn)) == 0;
87+
}
7688
}

0 commit comments

Comments
 (0)