From 19357c0e1338a06a7b7923d62ec8c131d0c4e5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 13 Dec 2024 08:10:31 +0100 Subject: [PATCH] Enhancement: Extract method --- .../NoParameterWithNullDefaultValueRule.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Functions/NoParameterWithNullDefaultValueRule.php b/src/Functions/NoParameterWithNullDefaultValueRule.php index fdf6e76a..fae24d23 100644 --- a/src/Functions/NoParameterWithNullDefaultValueRule.php +++ b/src/Functions/NoParameterWithNullDefaultValueRule.php @@ -37,11 +37,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)) { @@ -68,4 +64,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(); + } }