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 20aabf4 commit 2b1d14f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Methods/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ public function processNode(
}

$params = \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($params)) {
Expand Down Expand Up @@ -95,4 +91,13 @@ public function processNode(
->build();
}, $params));
}

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 2b1d14f

Please sign in to comment.