diff --git a/phpstan.neon b/phpstan.neon index 1446fd13de6..88200efe56c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -194,12 +194,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..f58b8259d9c 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php @@ -209,7 +209,10 @@ private function matchParentConstructorCallArgs(Stmt $stmt): ?array private function isParameterAndArgCountAndOrderIdentical(ClassMethod $classMethod): bool { - $soleStmt = $classMethod->stmts[0]; + $soleStmt = $classMethod->stmts[0] ?? null; + if (! $soleStmt instanceof Stmt) { + return false; + } $parentCallArgs = $this->matchParentConstructorCallArgs($soleStmt); if ($parentCallArgs === null) {