Skip to content
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

[6.x] Provisional support for PHP 8.0 #34884

Merged
merged 1 commit into from Oct 19, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions composer.json
Expand Up @@ -20,13 +20,13 @@
"ext-mbstring": "*",
"ext-openssl": "*",
"doctrine/inflector": "^1.4|^2.0",
"dragonmantank/cron-expression": "^2.0",
"dragonmantank/cron-expression": "^2.3.1",
"egulias/email-validator": "^2.1.10",
"league/commonmark": "^1.3",
"league/flysystem": "^1.0.34",
"league/flysystem": "^1.1",
GrahamCampbell marked this conversation as resolved.
Show resolved Hide resolved
"monolog/monolog": "^1.12|^2.0",
"nesbot/carbon": "^2.0",
"opis/closure": "^3.1",
"nesbot/carbon": "^2.31",
"opis/closure": "^3.6",
"psr/container": "^1.0",
"psr/simple-cache": "^1.0",
"ramsey/uuid": "^3.7",
Expand Down Expand Up @@ -79,14 +79,14 @@
"require-dev": {
"aws/aws-sdk-php": "^3.0",
"doctrine/dbal": "^2.6",
"filp/whoops": "^2.4",
"filp/whoops": "^2.8",
"guzzlehttp/guzzle": "^6.3|^7.0",
"league/flysystem-cached-adapter": "^1.0",
"mockery/mockery": "^1.3.1",
"mockery/mockery": "~1.3.3|^1.4.2",
"moontoast/math": "^1.1",
"orchestra/testbench-core": "^4.0",
"pda/pheanstalk": "^4.0",
"phpunit/phpunit": "^7.5.15|^8.4|^9.0",
"phpunit/phpunit": "^7.5.15|^8.4|^9.3.3",
"predis/predis": "^1.1.1",
"symfony/cache": "^4.3.4"
},
Expand Down Expand Up @@ -121,7 +121,7 @@
"ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).",
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6).",
"filp/whoops": "Required for friendly error pages in development (^2.4).",
"filp/whoops": "Required for friendly error pages in development (^2.8).",
"fzaninotto/faker": "Required to use the eloquent factory builder (^1.9.1).",
"guzzlehttp/guzzle": "Required to use the Mailgun mail driver and the ping methods on schedules (^6.0|^7.0).",
"laravel/tinker": "Required to use the tinker console command (^2.0).",
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/RedisTaggedCache.php
Expand Up @@ -179,7 +179,7 @@ protected function deleteValues($referenceKey)

if (count($values) > 0) {
foreach (array_chunk($values, 1000) as $valuesChunk) {
call_user_func_array([$this->store->connection(), 'del'], $valuesChunk);
$this->store->connection()->del(...$valuesChunk);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Concerns/HasParameters.php
Expand Up @@ -21,15 +21,15 @@ protected function specifyParameters()
if ($arguments instanceof InputArgument) {
$this->getDefinition()->addArgument($arguments);
} else {
call_user_func_array([$this, 'addArgument'], $arguments);
$this->addArgument(...array_values($arguments));
}
}

foreach ($this->getOptions() as $options) {
if ($options instanceof InputOption) {
$this->getDefinition()->addOption($options);
} else {
call_user_func_array([$this, 'addOption'], $options);
$this->addOption(...array_values($options));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Console/composer.json
Expand Up @@ -31,7 +31,7 @@
}
},
"suggest": {
"dragonmantank/cron-expression": "Required to use scheduler (^2.0).",
"dragonmantank/cron-expression": "Required to use scheduler (^2.3.1).",
"guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.0|^7.0).",
"illuminate/bus": "Required to use the scheduled job dispatcher (^6.0)",
"illuminate/container": "Required to use the scheduler (^6.0)",
Expand Down
6 changes: 2 additions & 4 deletions src/Illuminate/Container/BoundMethod.php
Expand Up @@ -28,9 +28,7 @@ public static function call($container, $callback, array $parameters = [], $defa
}

return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) {
return call_user_func_array(
$callback, static::getMethodDependencies($container, $callback, $parameters)
);
return $callback(...static::getMethodDependencies($container, $callback, $parameters));
GrahamCampbell marked this conversation as resolved.
Show resolved Hide resolved
});
}

Expand Down Expand Up @@ -121,7 +119,7 @@ protected static function getMethodDependencies($container, $callback, array $pa
static::addDependencyForCallParameter($container, $parameter, $parameters, $dependencies);
}

return array_merge($dependencies, $parameters);
return array_merge($dependencies, array_values($parameters));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cookie/CookieJar.php
Expand Up @@ -143,7 +143,7 @@ public function queue(...$parameters)
if (head($parameters) instanceof Cookie) {
$cookie = head($parameters);
} else {
$cookie = call_user_func_array([$this, 'make'], $parameters);
$cookie = $this->make(...array_values($parameters));
}

if (! isset($this->queued[$cookie->getName()])) {
Expand Down
18 changes: 11 additions & 7 deletions src/Illuminate/Database/Eloquent/Builder.php
Expand Up @@ -1359,14 +1359,16 @@ public function __call($method, $parameters)
}

if (static::hasGlobalMacro($method)) {
if (static::$macros[$method] instanceof Closure) {
return call_user_func_array(static::$macros[$method]->bindTo($this, static::class), $parameters);
$callable = static::$macros[$method];

if ($callable instanceof Closure) {
$callable = $callable->bindTo($this, static::class);
}

return call_user_func_array(static::$macros[$method], $parameters);
return $callable(...$parameters);
}

if (method_exists($this->model, $scope = 'scope'.ucfirst($method))) {
if ($this->model !== null && method_exists($this->model, $scope = 'scope'.ucfirst($method))) {
return $this->callScope([$this->model, $scope], $parameters);
}

Expand Down Expand Up @@ -1404,11 +1406,13 @@ public static function __callStatic($method, $parameters)
static::throwBadMethodCallException($method);
}

if (static::$macros[$method] instanceof Closure) {
return call_user_func_array(Closure::bind(static::$macros[$method], null, static::class), $parameters);
$callable = static::$macros[$method];

if ($callable instanceof Closure) {
$callable = $callable->bindTo(null, static::class);
}

return call_user_func_array(static::$macros[$method], $parameters);
return $callable(...$parameters);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Collection.php
Expand Up @@ -451,7 +451,7 @@ public function keys()
*/
public function zip($items)
{
return call_user_func_array([$this->toBase(), 'zip'], func_get_args());
return $this->toBase()->zip(...func_get_args());
}

/**
Expand Down
Expand Up @@ -537,11 +537,11 @@ public function newPivotQuery()
$query = $this->newPivotStatement();

foreach ($this->pivotWheres as $arguments) {
call_user_func_array([$query, 'where'], $arguments);
$query->where(...$arguments);
}

foreach ($this->pivotWhereIns as $arguments) {
call_user_func_array([$query, 'whereIn'], $arguments);
$query->whereIn(...$arguments);
}

return $query->where($this->foreignPivotKey, $this->parent->{$this->parentKey});
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/MigrationServiceProvider.php
Expand Up @@ -102,7 +102,7 @@ protected function registerCreator()
protected function registerCommands(array $commands)
{
foreach (array_keys($commands) as $command) {
call_user_func_array([$this, "register{$command}Command"], []);
$this->{"register{$command}Command"}();
}

$this->commands(array_values($commands));
Expand Down
15 changes: 14 additions & 1 deletion src/Illuminate/Database/Schema/Grammars/RenameColumn.php
Expand Up @@ -61,9 +61,22 @@ protected static function getRenamedDiff(Grammar $grammar, Blueprint $blueprint,
protected static function setRenamedColumns(TableDiff $tableDiff, Fluent $command, Column $column)
{
$tableDiff->renamedColumns = [
$command->from => new Column($command->to, $column->getType(), $column->toArray()),
$command->from => new Column($command->to, $column->getType(), self::getWritableColumnOptions($column)),
];

return $tableDiff;
}

/**
* Get the writable column options.
*
* @param \Doctrine\DBAL\Schema\Column $column
* @return array
*/
private static function getWritableColumnOptions(Column $column)
{
return array_filter($column->toArray(), function (string $name) use ($column) {
return method_exists($column, 'set'.$name);
}, ARRAY_FILTER_USE_KEY);
}
}
12 changes: 5 additions & 7 deletions src/Illuminate/Events/CallQueuedListener.php
Expand Up @@ -89,17 +89,15 @@ public function handle(Container $container)
$this->job, $container->make($this->class)
);

call_user_func_array(
[$handler, $this->method], $this->data
);
$handler->{$this->method}(...array_values($this->data));
}

/**
* Set the job instance of the given class if necessary.
*
* @param \Illuminate\Contracts\Queue\Job $job
* @param mixed $instance
* @return mixed
* @param object $instance
* @return object
*/
protected function setJobInstanceIfNecessary(Job $job, $instance)
{
Expand All @@ -124,10 +122,10 @@ public function failed($e)

$handler = Container::getInstance()->make($this->class);

$parameters = array_merge($this->data, [$e]);
$parameters = array_merge(array_values($this->data), [$e]);

if (method_exists($handler, 'failed')) {
call_user_func_array([$handler, 'failed'], $parameters);
$handler->failed(...$parameters);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Events/Dispatcher.php
Expand Up @@ -384,9 +384,9 @@ public function createClassListener($listener, $wildcard = false)
return call_user_func($this->createClassCallable($listener), $event, $payload);
}

return call_user_func_array(
$this->createClassCallable($listener), $payload
);
$callable = $this->createClassCallable($listener);

return $callable(...array_values($payload));
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Filesystem/FilesystemAdapter.php
Expand Up @@ -739,6 +739,6 @@ protected function parseVisibility($visibility)
*/
public function __call($method, array $parameters)
{
return call_user_func_array([$this->driver, $method], $parameters);
return $this->driver->{$method}(...array_values($parameters));
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Filesystem/composer.json
Expand Up @@ -31,7 +31,7 @@
},
"suggest": {
"ext-ftp": "Required to use the Flysystem FTP driver.",
"league/flysystem": "Required to use the Flysystem local and FTP drivers (^1.0.34).",
"league/flysystem": "Required to use the Flysystem local and FTP drivers (^1.1).",
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/QueuedCommand.php
Expand Up @@ -37,6 +37,6 @@ public function __construct($data)
*/
public function handle(KernelContract $kernel)
{
call_user_func_array([$kernel, 'call'], $this->data);
$kernel->call(...array_values($this->data));
}
}
Expand Up @@ -168,7 +168,7 @@ public function register()
protected function registerCommands(array $commands)
{
foreach (array_keys($commands) as $command) {
call_user_func_array([$this, "register{$command}Command"], []);
$this->{"register{$command}Command"}();
}

$this->commands(array_values($commands));
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Http/ResponseTrait.php
Expand Up @@ -96,7 +96,7 @@ public function withHeaders($headers)
*/
public function cookie($cookie)
{
return call_user_func_array([$this, 'withCookie'], func_get_args());
return $this->withCookie(...func_get_args());
}

/**
Expand All @@ -108,7 +108,7 @@ public function cookie($cookie)
public function withCookie($cookie)
{
if (is_string($cookie) && function_exists('cookie')) {
$cookie = call_user_func_array('cookie', func_get_args());
$cookie = cookie(...func_get_args());
}

$this->headers->setCookie($cookie);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/composer.json
Expand Up @@ -23,7 +23,7 @@
"illuminate/filesystem": "^6.0",
"illuminate/pipeline": "^6.0",
"illuminate/support": "^6.0",
"opis/closure": "^3.1",
"opis/closure": "^3.6",
"symfony/debug": "^4.3.4",
"symfony/process": "^4.3.4"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Redis/Connections/PredisConnection.php
Expand Up @@ -42,7 +42,7 @@ public function createSubscription($channels, Closure $callback, $method = 'subs
{
$loop = $this->pubSubLoop();

call_user_func_array([$loop, $method], (array) $channels);
$loop->{$method}(...array_values((array) $channels));

foreach ($loop as $message) {
if ($message->kind === 'message' || $message->kind === 'pmessage') {
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/Controller.php
Expand Up @@ -51,7 +51,7 @@ public function getMiddleware()
*/
public function callAction($method, $parameters)
{
return call_user_func_array([$this, $method], $parameters);
return $this->{$method}(...array_values($parameters));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/Pipeline.php
Expand Up @@ -50,7 +50,7 @@ protected function handleException($passable, Exception $e)

$response = $handler->render($passable, $e);

if (method_exists($response, 'withException')) {
if (is_object($response) && method_exists($response, 'withException')) {
$response->withException($e);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Routing/Route.php
Expand Up @@ -790,9 +790,9 @@ public function gatherMiddleware()

$this->computedMiddleware = [];

return $this->computedMiddleware = array_unique(array_merge(
return $this->computedMiddleware = Router::uniqueMiddleware(array_merge(
$this->middleware(), $this->controllerMiddleware()
), SORT_REGULAR);
));
}

/**
Expand Down
23 changes: 23 additions & 0 deletions src/Illuminate/Routing/Router.php
Expand Up @@ -1273,6 +1273,29 @@ public function setRoutes(RouteCollection $routes)
$this->container->instance('routes', $this->routes);
}

/**
* Remove any duplicate middleware from the given array.
*
* @param array $middleware
* @return array
*/
public static function uniqueMiddleware(array $middleware)
{
$seen = [];
$result = [];

foreach ($middleware as $value) {
$key = \is_object($value) ? \spl_object_id($value) : $value;

if (! isset($seen[$key])) {
$seen[$key] = true;
$result[] = $value;
}
}

return $result;
}

/**
* Dynamically handle calls into the router instance.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/SortedMiddleware.php
Expand Up @@ -62,7 +62,7 @@ protected function sortMiddleware($priorityMap, $middlewares)
}
}

return array_values(array_unique($middlewares, SORT_REGULAR));
return Router::uniqueMiddleware($middlewares);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Collection.php
Expand Up @@ -1210,7 +1210,7 @@ public function zip($items)
return new static(func_get_args());
}, $this->items], $arrayableItems);

return new static(call_user_func_array('array_map', $params));
return new static(array_map(...$params));
}

/**
Expand Down