Skip to content

Commit

Permalink
[10.x] PHP 8.4 Code Compatibility (#53612)
Browse files Browse the repository at this point in the history
* [10.x] PHP 8.4 Code Compatibility

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* Apply fixes from StyleCI

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
  • Loading branch information
crynobone and StyleCIBot authored Nov 21, 2024
1 parent a0da1ea commit f4cb362
Show file tree
Hide file tree
Showing 111 changed files with 207 additions and 205 deletions.
2 changes: 2 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
php:
preset: laravel
version: 8.1
enabled:
- nullable_type_declarations
finder:
not-name:
- bad-syntax-strategy.php
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"nyholm/psr7": "^1.2",
"orchestra/testbench-core": "^8.23.4",
"pda/pheanstalk": "^4.0",
"phpstan/phpstan": "^1.4.7",
"phpstan/phpstan": "~1.11.11",
"phpunit/phpunit": "^10.0.7",
"predis/predis": "^2.0.2",
"symfony/cache": "^6.2",
Expand Down
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 @@ -123,8 +123,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)
{
$this->name = $name;
$this->session = $session;
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 @@ -185,7 +185,7 @@ public static function exists($array, $key)
* @param mixed $default
* @return mixed
*/
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 @@ -216,7 +216,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 @@ -382,7 +382,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 @@ -400,7 +400,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 @@ -748,7 +748,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 @@ -296,7 +296,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 @@ -308,7 +308,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 @@ -319,7 +319,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 @@ -330,7 +330,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 @@ -342,7 +342,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 @@ -353,7 +353,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 @@ -364,7 +364,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 @@ -476,7 +476,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 @@ -618,7 +618,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 @@ -164,7 +164,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 @@ -534,7 +534,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 @@ -548,7 +548,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 @@ -562,7 +562,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 @@ -576,7 +576,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 @@ -1148,7 +1148,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 @@ -1168,7 +1168,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 @@ -1188,7 +1188,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 @@ -1427,7 +1427,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
Loading

0 comments on commit f4cb362

Please sign in to comment.