8000 Modernize func_get_args() calls to variadic parameters · symfony/symfony@5b53613 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b53613

Browse files
committed
Modernize func_get_args() calls to variadic parameters
1 parent b22562f commit 5b53613

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ public static function fromPhp($phpFunctionName, $expressionFunctionName = null)
8585
throw new \InvalidArgumentException(sprintf('An expression function name must be defined when PHP function "%s" is namespaced.', $phpFunctionName));
8686
}
8787

88-
$compiler = function () use ($phpFunctionName) {
89-
return sprintf('\%s(%s)', $phpFunctionName, implode(', ', \func_get_args()));
88+
$compiler = function (...$args) use ($phpFunctionName) {
89+
return sprintf('\%s(%s)', $phpFunctionName, implode(', ', $args));
9090
};
9191

92-
$evaluator = function () use ($phpFunctionName) {
93-
return $phpFunctionName(...\array_slice(\func_get_args(), 1));
92+
$evaluator = function ($p, ...$args) use ($phpFunctionName) {
93+
return $phpFunctionName(...$args);
9494
};
9595

9696
return new self($expressionFunctionName ?: end($parts), $compiler, $evaluator);

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,14 +746,16 @@ private function getSchemeAndHierarchy(string $filename): array
746746
}
747747

748748
/**
749+
* @param mixed ...$args
750+
*
749751
* @return mixed
750752
*/
751-
private static function box(callable $func)
753+
private static function box(callable $func, ...$args)
752754
{
753755
self::$lastError = null;
754756
set_error_handler(__CLASS__.'::handleError');
755757
try {
756-
$result = $func(...\array_slice(\func_get_args(), 1));
758+
$result = $func(...$args);
757759
restore_error_handler();
758760

759761
return $result;

src/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,10 @@ public function testSetDefault()
2727
$this->assertSame('en_GB', $this->call('getDefault'));
2828
}
2929

30-
abstract protected function call($methodName);
30+
/**
31+
* @param mixed ...$args
32+
*
33+
* @return mixed
34+
*/
35+
abstract protected function call(string $methodName, ...$args);
3136
}

src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ public function testSetDefaultAcceptsEn()
139139
$this->assertSame('en', $this->call('getDefault'));
140140
}
141141

142-
protected function call($methodName)
142+
protected function call(string $methodName, ...$args)
143143
{
144-
$args = \array_slice(\func_get_args(), 1);
145-
146144
return Locale::{$methodName}(...$args);
147145
}
148146
}

src/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ protected function setUp(): void
2929
parent::setUp();
3030
}
3131

32-
protected function call($methodName)
32+
protected function call(string $methodName, ...$args)
3333
{
34-
$args = \array_slice(\func_get_args(), 1);
35-
3634
return \Locale::{$methodName}(...$args);
3735
}
3836
}

0 commit comments

Comments
 (0)
0