diff --git a/rules-tests/Php83/Rector/FuncCall/CombineHostPortLdapUriRector/Fixture/fixture.php.inc b/rules-tests/Php83/Rector/FuncCall/CombineHostPortLdapUriRector/Fixture/fixture.php.inc new file mode 100644 index 00000000000..bfa8b5cf1f1 --- /dev/null +++ b/rules-tests/Php83/Rector/FuncCall/CombineHostPortLdapUriRector/Fixture/fixture.php.inc @@ -0,0 +1,27 @@ + +----- + \ No newline at end of file diff --git a/rules-tests/Php83/Rector/FuncCall/CombineHostPortLdapUriRector/Fixture/fixture.phpWZHjI6 b/rules-tests/Php83/Rector/FuncCall/CombineHostPortLdapUriRector/Fixture/fixture.phpWZHjI6 new file mode 100644 index 00000000000..3cadd69f602 --- /dev/null +++ b/rules-tests/Php83/Rector/FuncCall/CombineHostPortLdapUriRector/Fixture/fixture.phpWZHjI6 @@ -0,0 +1,13 @@ + diff --git a/rules/Php83/Rector/FuncCall/CombineHostPortLdapUriRector.php b/rules/Php83/Rector/FuncCall/CombineHostPortLdapUriRector.php index e06f6b68e23..8bb0fa2967c 100644 --- a/rules/Php83/Rector/FuncCall/CombineHostPortLdapUriRector.php +++ b/rules/Php83/Rector/FuncCall/CombineHostPortLdapUriRector.php @@ -6,6 +6,8 @@ use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; +use PhpParser\Node\Scalar\LNumber; +use PhpParser\Node\Scalar\String_; use Rector\Core\Rector\AbstractRector; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; @@ -53,6 +55,27 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + + $args = $node->getArgs(); + if (count($args) !== 2) { + return null; + } + + $firstArg = $args[0]->value; + $secondArg = $args[1]->value; + + if ($firstArg instanceof String_ && $secondArg instanceof LNumber) { + $args[0]->value = new String_($firstArg->value . ':' . $secondArg->value); + + unset($args[1]); + $node->args = $args; + + return $node; + } + return null; }