Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Modernize func_get_args() calls to variadic parameters #40157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ public static function fromPhp($phpFunctionName, $expressionFunctionName = null)
throw new \InvalidArgumentException(sprintf('An expression function name must be defined when PHP function "%s" is namespaced.', $phpFunctionName));
}

$compiler = function () use ($phpFunctionName) {
return sprintf('\%s(%s)', $phpFunctionName, implode(', ', \func_get_args()));
$compiler = function (...$args) use ($phpFunctionName) {
return sprintf('\%s(%s)', $phpFunctionName, implode(', ', $args));
};

$evaluator = function () use ($phpFunctionName) {
return $phpFunctionName(...\array_slice(\func_get_args(), 1));
$evaluator = function ($p, ...$args) use ($phpFunctionName) {
return $phpFunctionName(...$args);
};

return new self($expressionFunctionName ?: end($parts), $compiler, $evaluator);
Expand Down
6 changes: 4 additions & 2 deletions 6 src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -746,14 +746,16 @@ private function getSchemeAndHierarchy(string $filename): array
}

/**
* @param mixed ...$args
*
* @return mixed
*/
private static function box(callable $func)
private static function box(callable $func, ...$args)
{
self::$lastError = null;
set_error_handler(__CLASS__.'::handleError');
try {
$result = $func(...\array_slice(\func_get_args(), 1));
$result = $func(...$args);
restore_error_handler();

return $result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ public function testSetDefault()
$this->assertSame('en_GB', $this->call('getDefault'));
}

abstract protected function call($methodName);
/**
* @param mixed ...$args
*
* @return mixed
*/
abstract protected function call(string $methodName, ...$args);
}
4 changes: 1 addition & 3 deletions 4 src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ public function testSetDefaultAcceptsEn()
$this->assertSame('en', $this->call('getDefault'));
}

protected function call($methodName)
protected function call(string $methodName, ...$args)
{
$args = \array_slice(\func_get_args(), 1);

return Locale::{$methodName}(...$args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ protected function setUp(): void
parent::setUp();
}

protected function call($methodName)
protected function call(string $methodName, ...$args)
{
$args = \array_slice(\func_get_args(), 1);

return \Locale::{$methodName}(...$args);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.