Skip to content

Commit 3581d0a

Browse files
authored
Merge pull request #36 from magento-gl/Hammer_PlatForm_Health_246_Scope_14102022
[Hammer]_Platform_Health_246_Scope_14102022
2 parents 98eb6df + 4911b9d commit 3581d0a

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"bin": ["bin/svc"],
1010
"require": {
11-
"php": "~7.4.0||~8.1.0",
11+
"php": "~7.4.0||~8.1.0||~8.2.0",
1212
"ext-json": "*",
1313
"laminas/laminas-dependency-plugin": "^2.2.0",
1414
"laminas/laminas-stdlib": "~3.6.0",

composer.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Analyzer/ClassMethodAnalyzer.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
use Magento\SemanticVersionChecker\Operation\ExtendableClassConstructorOptionalParameterAdded;
2525
use Magento\SemanticVersionChecker\Operation\Visibility\MethodDecreased as VisibilityMethodDecreased;
2626
use Magento\SemanticVersionChecker\Operation\Visibility\MethodIncreased as VisibilityMethodIncreased;
27-
use PhpParser\Node\NullableType;
2827
use PhpParser\Node\Name;
28+
use PhpParser\Node\NullableType;
2929
use PhpParser\Node\Stmt\Class_;
3030
use PhpParser\Node\Stmt\ClassLike;
3131
use PhpParser\Node\Stmt\ClassMethod;
32+
use PhpParser\Node\UnionType;
3233
use PHPSemVerChecker\Comparator\Implementation;
3334
use PHPSemVerChecker\Operation\ClassMethodAdded;
3435
use PHPSemVerChecker\Operation\ClassMethodImplementationChanged;
@@ -410,12 +411,24 @@ private function isDeclarationReturnTypeChanged(ClassMethod $methodBefore, Class
410411
if (!$this->isReturnsEqualByNullability($methodBefore, $methodAfter)) {
411412
return true;
412413
}
413-
$beforeMethodReturnType = $methodBefore->returnType instanceof NullableType
414-
? (string) $methodBefore->returnType->type
415-
: (string) $methodBefore->returnType;
416-
$afterMethodReturnType = $methodAfter->returnType instanceof NullableType
417-
? (string) $methodAfter->returnType->type
418-
: (string) $methodAfter->returnType;
414+
415+
$methodBeforeReturnType = $methodBefore->returnType;
416+
if ($methodBeforeReturnType instanceof NullableType) {
417+
$beforeMethodReturnType = (string)$methodBeforeReturnType->type;
418+
} elseif ($methodBeforeReturnType instanceof UnionType) {
419+
$beforeMethodReturnType = implode('&', $methodBeforeReturnType->types);
420+
} else {
421+
$beforeMethodReturnType = (string)$methodBeforeReturnType;
422+
}
423+
424+
$methodAfterReturnType = $methodAfter->returnType;
425+
if ($methodAfterReturnType instanceof NullableType) {
426+
$afterMethodReturnType = (string)$methodAfterReturnType->type;
427+
} elseif ($methodAfterReturnType instanceof UnionType) {
428+
$afterMethodReturnType = implode('&', $methodAfterReturnType->types);
429+
} else {
430+
$afterMethodReturnType = (string)$methodAfterReturnType;
431+
}
419432

420433
return $beforeMethodReturnType !== $afterMethodReturnType;
421434
}

0 commit comments

Comments
 (0)