Skip to content

Commit

Permalink
Enhancement: Extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 13, 2024
1 parent bcb1b2d commit 68b55f6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Closures/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ public function processNode(
}

$parametersWithNullDefaultValue = \array_values(\array_filter($node->params, static function (Node\Param $node): bool {
if (!$node->default instanceof Node\Expr\ConstFetch) {
return false;
}

return 'null' === $node->default->name->toLowerString();
return self::hasNullDefaultValue($node);
}));

if (0 === \count($parametersWithNullDefaultValue)) {
Expand All @@ -65,4 +61,13 @@ public function processNode(
->build();
}, $parametersWithNullDefaultValue);
}

private static function hasNullDefaultValue(Node\Param $node): bool
{
if (!$node->default instanceof Node\Expr\ConstFetch) {
return false;
}

return 'null' === $node->default->name->toLowerString();
}
}

0 comments on commit 68b55f6

Please sign in to comment.