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

[11.x] Explicit nullable parameter declarations to fix PHP 8.4 deprecation #50922

Merged
merged 1 commit into from
Apr 4, 2024
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
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/Access/AuthorizationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AuthorizationException extends Exception
* @param \Throwable|null $previous
* @return void
*/
public function __construct($message = null, $code = null, Throwable $previous = null)
public function __construct($message = null, $code = null, ?Throwable $previous = null)
{
parent::__construct($message ?? 'This action is unauthorized.', 0, $previous);

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function __construct(Container $container,
array $policies = [],
array $beforeCallbacks = [],
array $afterCallbacks = [],
callable $guessPolicyNamesUsingCallback = null)
?callable $guessPolicyNamesUsingCallback = null)
{
$this->policies = $policies;
$this->container = $container;
Expand Down Expand Up @@ -224,7 +224,7 @@ public function define($ability, $callback)
* @param array|null $abilities
* @return $this
*/
public function resource($name, $class, array $abilities = null)
public function resource($name, $class, ?array $abilities = null)
{
$abilities = $abilities ?: [
'viewAny' => 'viewAny',
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/Passwords/PasswordBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(TokenRepositoryInterface $tokens, UserProvider $user
* @param \Closure|null $callback
* @return string
*/
public function sendResetLink(array $credentials, Closure $callback = null)
public function sendResetLink(array $credentials, ?Closure $callback = null)
{
// First we will check to see if we found a user at the given credentials and
// if we did not we will redirect back to this current URI with a piece of
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Auth/RequestGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RequestGuard implements Guard
* @param \Illuminate\Contracts\Auth\UserProvider|null $provider
* @return void
*/
public function __construct(callable $callback, Request $request, UserProvider $provider = null)
public function __construct(callable $callback, Request $request, ?UserProvider $provider = null)
{
$this->request = $request;
$this->callback = $callback;
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/SessionGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
public function __construct($name,
UserProvider $provider,
Session $session,
Request $request = null,
Timebox $timebox = null,
?Request $request = null,
?Timebox $timebox = null,
bool $rehashOnLogin = true)
{
$this->name = $name;
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Broadcasting/BroadcastManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct($app)
* @param array|null $attributes
* @return void
*/
public function routes(array $attributes = null)
public function routes(?array $attributes = null)
{
if ($this->app instanceof CachesRoutes && $this->app->routesAreCached()) {
return;
Expand All @@ -86,7 +86,7 @@ public function routes(array $attributes = null)
* @param array|null $attributes
* @return void
*/
public function userRoutes(array $attributes = null)
public function userRoutes(?array $attributes = null)
{
if ($this->app instanceof CachesRoutes && $this->app->routesAreCached()) {
return;
Expand All @@ -110,7 +110,7 @@ public function userRoutes(array $attributes = null)
* @param array|null $attributes
* @return void
*/
public function channelRoutes(array $attributes = null)
public function channelRoutes(?array $attributes = null)
{
$this->routes($attributes);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Bus/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public function delete()
* @param \Throwable|null $e
* @return void
*/
protected function invokeHandlerCallback($handler, Batch $batch, Throwable $e = null)
protected function invokeHandlerCallback($handler, Batch $batch, ?Throwable $e = null)
{
try {
return $handler($batch, $e);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Bus/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Dispatcher implements QueueingDispatcher
* @param \Closure|null $queueResolver
* @return void
*/
public function __construct(Container $container, Closure $queueResolver = null)
public function __construct(Container $container, ?Closure $queueResolver = null)
{
$this->container = $container;
$this->queueResolver = $queueResolver;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/RedisTagSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RedisTagSet extends TagSet
* @param string $updateWhen
* @return void
*/
public function addEntry(string $key, int $ttl = null, $updateWhen = null)
public function addEntry(string $key, ?int $ttl = null, $updateWhen = null)
{
$ttl = is_null($ttl) ? -1 : Carbon::now()->addSeconds($ttl)->getTimestamp();

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static function exists($array, $key)
* @param TFirstDefault|(\Closure(): TFirstDefault) $default
* @return TValue|TFirstDefault
*/
public static function first($array, callable $callback = null, $default = null)
public static function first($array, ?callable $callback = null, $default = null)
{
if (is_null($callback)) {
if (empty($array)) {
Expand Down Expand Up @@ -221,7 +221,7 @@ public static function first($array, callable $callback = null, $default = null)
* @param mixed $default
* @return mixed
*/
public static function last($array, callable $callback = null, $default = null)
public static function last($array, ?callable $callback = null, $default = null)
{
if (is_null($callback)) {
return empty($array) ? value($default) : end($array);
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public function except($keys)
* @param (callable(TValue, TKey): bool)|null $callback
* @return static
*/
public function filter(callable $callback = null)
public function filter(?callable $callback = null)
{
if ($callback) {
return new static(Arr::where($this->items, $callback));
Expand All @@ -399,7 +399,7 @@ public function filter(callable $callback = null)
* @param TFirstDefault|(\Closure(): TFirstDefault) $default
* @return TValue|TFirstDefault
*/
public function first(callable $callback = null, $default = null)
public function first(?callable $callback = null, $default = null)
{
return Arr::first($this->items, $callback, $default);
}
Expand Down Expand Up @@ -747,7 +747,7 @@ public function keys()
* @param TLastDefault|(\Closure(): TLastDefault) $default
* @return TValue|TLastDefault
*/
public function last(callable $callback = null, $default = null)
public function last(?callable $callback = null, $default = null)
{
return Arr::last($this->items, $callback, $default);
}
Expand Down
20 changes: 10 additions & 10 deletions src/Illuminate/Collections/Enumerable.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function make($items = []);
* @param callable|null $callback
* @return static
*/
public static function times($number, callable $callback = null);
public static function times($number, ?callable $callback = null);

/**
* Create a collection with the given range.
Expand Down Expand Up @@ -297,7 +297,7 @@ public function except($keys);
* @param (callable(TValue): bool)|null $callback
* @return static
*/
public function filter(callable $callback = null);
public function filter(?callable $callback = null);

/**
* Apply the callback if the given "value" is (or resolves to) truthy.
Expand All @@ -309,7 +309,7 @@ public function filter(callable $callback = null);
* @param (callable($this): TWhenReturnType)|null $default
* @return $this|TWhenReturnType
*/
public function when($value, callable $callback = null, callable $default = null);
public function when($value, ?callable $callback = null, ?callable $default = null);

/**
* Apply the callback if the collection is empty.
Expand All @@ -320,7 +320,7 @@ public function when($value, callable $callback = null, callable $default = null
* @param (callable($this): TWhenEmptyReturnType)|null $default
* @return $this|TWhenEmptyReturnType
*/
public function whenEmpty(callable $callback, callable $default = null);
public function whenEmpty(callable $callback, ?callable $default = null);

/**
* Apply the callback if the collection is not empty.
Expand All @@ -331,7 +331,7 @@ public function whenEmpty(callable $callback, callable $default = null);
* @param (callable($this): TWhenNotEmptyReturnType)|null $default
* @return $this|TWhenNotEmptyReturnType
*/
public function whenNotEmpty(callable $callback, callable $default = null);
public function whenNotEmpty(callable $callback, ?callable $default = null);

/**
* Apply the callback if the given "value" is (or resolves to) truthy.
Expand All @@ -343,7 +343,7 @@ public function whenNotEmpty(callable $callback, callable $default = null);
* @param (callable($this): TUnlessReturnType)|null $default
* @return $this|TUnlessReturnType
*/
public function unless($value, callable $callback, callable $default = null);
public function unless($value, callable $callback, ?callable $default = null);

/**
* Apply the callback unless the collection is empty.
Expand All @@ -354,7 +354,7 @@ public function unless($value, callable $callback, callable $default = null);
* @param (callable($this): TUnlessEmptyReturnType)|null $default
* @return $this|TUnlessEmptyReturnType
*/
public function unlessEmpty(callable $callback, callable $default = null);
public function unlessEmpty(callable $callback, ?callable $default = null);

/**
* Apply the callback unless the collection is not empty.
Expand All @@ -365,7 +365,7 @@ public function unlessEmpty(callable $callback, callable $default = null);
* @param (callable($this): TUnlessNotEmptyReturnType)|null $default
* @return $this|TUnlessNotEmptyReturnType
*/
public function unlessNotEmpty(callable $callback, callable $default = null);
public function unlessNotEmpty(callable $callback, ?callable $default = null);

/**
* Filter items by the given key value pair.
Expand Down Expand Up @@ -477,7 +477,7 @@ public function whereInstanceOf($type);
* @param TFirstDefault|(\Closure(): TFirstDefault) $default
* @return TValue|TFirstDefault
*/
public function first(callable $callback = null, $default = null);
public function first(?callable $callback = null, $default = null);

/**
* Get the first item by the given key value pair.
Expand Down Expand Up @@ -645,7 +645,7 @@ public function keys();
* @param TLastDefault|(\Closure(): TLastDefault) $default
* @return TValue|TLastDefault
*/
public function last(callable $callback = null, $default = null);
public function last(?callable $callback = null, $default = null);

/**
* Run a map over each of the items.
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Collections/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public function except($keys)
* @param (callable(TValue, TKey): bool)|null $callback
* @return static
*/
public function filter(callable $callback = null)
public function filter(?callable $callback = null)
{
if (is_null($callback)) {
$callback = fn ($value) => (bool) $value;
Expand All @@ -452,7 +452,7 @@ public function filter(callable $callback = null)
* @param TFirstDefault|(\Closure(): TFirstDefault) $default
* @return TValue|TFirstDefault
*/
public function first(callable $callback = null, $default = null)
public function first(?callable $callback = null, $default = null)
{
$iterator = $this->getIterator();

Expand Down Expand Up @@ -732,7 +732,7 @@ public function keys()
* @param TLastDefault|(\Closure(): TLastDefault) $default
* @return TValue|TLastDefault
*/
public function last(callable $callback = null, $default = null)
public function last(?callable $callback = null, $default = null)
{
$needle = $placeholder = new stdClass;

Expand Down
10 changes: 5 additions & 5 deletions src/Illuminate/Collections/Traits/EnumeratesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static function empty()
* @param (callable(int): TTimesValue)|null $callback
* @return static<int, TTimesValue>
*/
public static function times($number, callable $callback = null)
public static function times($number, ?callable $callback = null)
{
if ($number < 1) {
return new static;
Expand Down Expand Up @@ -530,7 +530,7 @@ public function sum($callback = null)
* @param (callable($this): TWhenEmptyReturnType)|null $default
* @return $this|TWhenEmptyReturnType
*/
public function whenEmpty(callable $callback, callable $default = null)
public function whenEmpty(callable $callback, ?callable $default = null)
{
return $this->when($this->isEmpty(), $callback, $default);
}
Expand All @@ -544,7 +544,7 @@ public function whenEmpty(callable $callback, callable $default = null)
* @param (callable($this): TWhenNotEmptyReturnType)|null $default
* @return $this|TWhenNotEmptyReturnType
*/
public function whenNotEmpty(callable $callback, callable $default = null)
public function whenNotEmpty(callable $callback, ?callable $default = null)
{
return $this->when($this->isNotEmpty(), $callback, $default);
}
Expand All @@ -558,7 +558,7 @@ public function whenNotEmpty(callable $callback, callable $default = null)
* @param (callable($this): TUnlessEmptyReturnType)|null $default
* @return $this|TUnlessEmptyReturnType
*/
public function unlessEmpty(callable $callback, callable $default = null)
public function unlessEmpty(callable $callback, ?callable $default = null)
{
return $this->whenNotEmpty($callback, $default);
}
Expand All @@ -572,7 +572,7 @@ public function unlessEmpty(callable $callback, callable $default = null)
* @param (callable($this): TUnlessNotEmptyReturnType)|null $default
* @return $this|TUnlessNotEmptyReturnType
*/
public function unlessNotEmpty(callable $callback, callable $default = null)
public function unlessNotEmpty(callable $callback, ?callable $default = null)
{
return $this->whenEmpty($callback, $default);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Conditionable/Traits/Conditionable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait Conditionable
* @param (callable($this, TWhenParameter): TWhenReturnType)|null $default
* @return $this|TWhenReturnType
*/
public function when($value = null, callable $callback = null, callable $default = null)
public function when($value = null, ?callable $callback = null, ?callable $default = null)
{
$value = $value instanceof Closure ? $value($this) : $value;

Expand Down Expand Up @@ -50,7 +50,7 @@ public function when($value = null, callable $callback = null, callable $default
* @param (callable($this, TUnlessParameter): TUnlessReturnType)|null $default
* @return $this|TUnlessReturnType
*/
public function unless($value = null, callable $callback = null, callable $default = null)
public function unless($value = null, ?callable $callback = null, ?callable $default = null)
{
$value = $value instanceof Closure ? $value($this) : $value;

Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ protected function unresolvablePrimitive(ReflectionParameter $parameter)
* @param \Closure|null $callback
* @return void
*/
public function beforeResolving($abstract, Closure $callback = null)
public function beforeResolving($abstract, ?Closure $callback = null)
{
if (is_string($abstract)) {
$abstract = $this->getAlias($abstract);
Expand All @@ -1160,7 +1160,7 @@ public function beforeResolving($abstract, Closure $callback = null)
* @param \Closure|null $callback
* @return void
*/
public function resolving($abstract, Closure $callback = null)
public function resolving($abstract, ?Closure $callback = null)
{
if (is_string($abstract)) {
$abstract = $this->getAlias($abstract);
Expand All @@ -1180,7 +1180,7 @@ public function resolving($abstract, Closure $callback = null)
* @param \Closure|null $callback
* @return void
*/
public function afterResolving($abstract, Closure $callback = null)
public function afterResolving($abstract, ?Closure $callback = null)
{
if (is_string($abstract)) {
$abstract = $this->getAlias($abstract);
Expand Down Expand Up @@ -1419,7 +1419,7 @@ public static function getInstance()
* @param \Illuminate\Contracts\Container\Container|null $container
* @return \Illuminate\Contracts\Container\Container|static
*/
public static function setInstance(ContainerContract $container = null)
public static function setInstance(?ContainerContract $container = null)
{
return static::$instance = $container;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Contracts/Auth/Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function define($ability, $callback);
* @param array|null $abilities
* @return $this
*/
public function resource($name, $class, array $abilities = null);
public function resource($name, $class, ?array $abilities = null);

/**
* Define a policy class for a given class type.
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Contracts/Auth/PasswordBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface PasswordBroker
* @param \Closure|null $callback
* @return string
*/
public function sendResetLink(array $credentials, Closure $callback = null);
public function sendResetLink(array $credentials, ?Closure $callback = null);

/**
* Reset the password for the given token.
Expand Down
Loading