diff --git a/phpstan.neon b/phpstan.neon index 0081acb6394..0fa129bc3c1 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -176,11 +176,6 @@ parameters: message: '#Cannot call method (.*?)\(\) on (.*?)\\ProcessPool\|null#' path: src/Parallel/Application/ParallelFileProcessor.php - - - identifier: missingType.callable - message: '#Method Rector\\Util\\ArrayParametersMerger\:\:mergeLeftToRightWithCallable\(\) has parameter \$mergeCallback with no signature specified for callable#' - path: src/Util/ArrayParametersMerger.php - # required generics on interface array, not helpful - identifier: missingType.generics @@ -205,12 +200,6 @@ parameters: identifier: offsetAccess.nonArray path: src/PhpParser/NodeTraverser/RectorNodeTraverser.php - # known non-empty class method - - - identifier: offsetAccess.notFound - message: '#Offset 0 might not exist on array\|null#' - path: rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php - - identifier: offsetAccess.notFound message: '#Offset float\|int\|string might not exist on string#' diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php index bfa5189aed0..e08ade20c24 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php @@ -209,6 +209,10 @@ private function matchParentConstructorCallArgs(Stmt $stmt): ?array private function isParameterAndArgCountAndOrderIdentical(ClassMethod $classMethod): bool { + if ($classMethod->stmts === null || ! isset($classMethod->stmts[0])) { + return false; + } + $soleStmt = $classMethod->stmts[0]; $parentCallArgs = $this->matchParentConstructorCallArgs($soleStmt); diff --git a/src/Util/ArrayParametersMerger.php b/src/Util/ArrayParametersMerger.php index ba14218111f..b48684e72fb 100644 --- a/src/Util/ArrayParametersMerger.php +++ b/src/Util/ArrayParametersMerger.php @@ -32,6 +32,7 @@ public function merge(mixed $left, mixed $right): mixed /** * @param array $left * @param array $right + * @param callable(mixed, mixed): mixed $mergeCallback * @return mixed[] */ private function mergeLeftToRightWithCallable(array $left, array $right, callable $mergeCallback): array