Skip to content

Commit

Permalink
[11.x] Improves PHP 8.4 compatibility (#53182)
Browse files Browse the repository at this point in the history
* [11.x] Improves PHP 8.4 compatibility

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Apply fixes from StyleCI

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
crynobone and StyleCIBot authored Oct 16, 2024
1 parent a13614f commit 3eb58f1
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 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.2
enabled:
- nullable_type_declarations
finder:
not-name:
- bad-syntax-strategy.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait SupportsInverseRelations
*
* @var string|null
*/
protected string|null $inverseRelationship = null;
protected ?string $inverseRelationship = null;

/**
* Instruct Eloquent to link the related models back to the parent after the relationship query has run.
Expand Down Expand Up @@ -61,7 +61,7 @@ public function chaperone(?string $relation = null)
*
* @return string|null
*/
protected function guessInverseRelation(): string|null
protected function guessInverseRelation(): ?string
{
return Arr::first(
$this->getPossibleInverseRelations(),
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ public function terminate()
/**
* Get the service providers that have been loaded.
*
* @return array<string, boolean>
* @return array<string, bool>
*/
public function getLoadedProviders()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/ExceptionMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

use function Laravel\Prompts\{confirm};
use function Laravel\Prompts\confirm;

#[AsCommand(name: 'make:exception')]
class ExceptionMakeCommand extends GeneratorCommand
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Queue/Console/WorkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ protected function listenForEvents()
* @param Throwable|null $exception
* @return void
*/
protected function writeOutput(Job $job, $status, Throwable $exception = null)
protected function writeOutput(Job $job, $status, ?Throwable $exception = null)
{
$this->outputUsingJson()
? $this->writeOutputAsJson($job, $status, $exception)
Expand Down Expand Up @@ -260,7 +260,7 @@ protected function writeOutputForCli(Job $job, $status)
* @param Throwable|null $exception
* @return void
*/
protected function writeOutputAsJson(Job $job, $status, Throwable $exception = null)
protected function writeOutputAsJson(Job $job, $status, ?Throwable $exception = null)
{
$log = array_filter([
'level' => $status === 'starting' || $status === 'success' ? 'info' : 'warning',
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Onceable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Onceable
*/
public function __construct(
public string $hash,
public object|null $object,
public ?object $object,
public $callable
) {
//
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Support/ValidatedInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function missing($keys)
* @param callable|null $default
* @return $this|mixed
*/
public function whenMissing($key, callable $callback, callable $default = null)
public function whenMissing($key, callable $callback, ?callable $default = null)
{
if ($this->missing($key)) {
return $callback(data_get($this->all(), $key)) ?: $this;
Expand Down Expand Up @@ -212,7 +212,7 @@ public function all()
* @param callable|null $default
* @return $this|mixed
*/
public function whenHas($key, callable $callback, callable $default = null)
public function whenHas($key, callable $callback, ?callable $default = null)
{
if ($this->has($key)) {
return $callback(data_get($this->all(), $key)) ?: $this;
Expand Down Expand Up @@ -290,7 +290,7 @@ public function anyFilled($keys)
* @param callable|null $default
* @return $this|mixed
*/
public function whenFilled($key, callable $callback, callable $default = null)
public function whenFilled($key, callable $callback, ?callable $default = null)
{
if ($this->filled($key)) {
return $callback(data_get($this->all(), $key)) ?: $this;
Expand Down
4 changes: 2 additions & 2 deletions types/Support/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}));
assertType('Illuminate\Support\HigherOrderTapProxy', tap(new User()));

function testThrowIf(float|int $foo, DateTime $bar = null): void
function testThrowIf(float|int $foo, ?DateTime $bar = null): void
{
assertType('never', throw_if(true, Exception::class));
assertType('bool', throw_if(false, Exception::class));
Expand All @@ -59,7 +59,7 @@ function testThrowIf(float|int $foo, DateTime $bar = null): void
assertType('never', throw_if('foo', Exception::class));
}

function testThrowUnless(float|int $foo, DateTime $bar = null): void
function testThrowUnless(float|int $foo, ?DateTime $bar = null): void
{
assertType('bool', throw_unless(true, Exception::class));
assertType('never', throw_unless(false, Exception::class));
Expand Down

0 comments on commit 3eb58f1

Please sign in to comment.