Skip to content

Commit e7cdcc1

Browse files
[TypeDeclaration] Speed up StrictArrayParamDimFetchRector with cheap param pre-check (#8606)
Co-authored-by: GitHub Action <actions@github.com>
1 parent e54efe3 commit e7cdcc1

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ public function getNodeTypes(): array
9393
*/
9494
public function refactor(Node $node): ?Node
9595
{
96+
// cheap bail - nothing to add, skip costly parent reflection guards below
97+
$hasUntypedParam = array_any(
98+
$node->getParams(),
99+
static fn (Param $param): bool => ! $param->type instanceof Node && ! $param->variadic
100+
);
101+
if (! $hasUntypedParam) {
102+
return null;
103+
}
104+
96105
$hasChanged = false;
97106
if ($node instanceof ClassMethod && $this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node)) {
98107
return null;

0 commit comments

Comments
 (0)