Skip to content

Commit 3eb58f1

Browse files
[11.x] Improves PHP 8.4 compatibility (#53182)
* [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]>
1 parent a13614f commit 3eb58f1

File tree

8 files changed

+14
-12
lines changed

8 files changed

+14
-12
lines changed

.styleci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
php:
22
preset: laravel
33
version: 8.2
4+
enabled:
5+
- nullable_type_declarations
46
finder:
57
not-name:
68
- bad-syntax-strategy.php

src/Illuminate/Database/Eloquent/Relations/Concerns/SupportsInverseRelations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ trait SupportsInverseRelations
1414
*
1515
* @var string|null
1616
*/
17-
protected string|null $inverseRelationship = null;
17+
protected ?string $inverseRelationship = null;
1818

1919
/**
2020
* Instruct Eloquent to link the related models back to the parent after the relationship query has run.
@@ -61,7 +61,7 @@ public function chaperone(?string $relation = null)
6161
*
6262
* @return string|null
6363
*/
64-
protected function guessInverseRelation(): string|null
64+
protected function guessInverseRelation(): ?string
6565
{
6666
return Arr::first(
6767
$this->getPossibleInverseRelations(),

src/Illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ public function terminate()
14261426
/**
14271427
* Get the service providers that have been loaded.
14281428
*
1429-
* @return array<string, boolean>
1429+
* @return array<string, bool>
14301430
*/
14311431
public function getLoadedProviders()
14321432
{

src/Illuminate/Foundation/Console/ExceptionMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Symfony\Component\Console\Input\InputOption;
99
use Symfony\Component\Console\Output\OutputInterface;
1010

11-
use function Laravel\Prompts\{confirm};
11+
use function Laravel\Prompts\confirm;
1212

1313
#[AsCommand(name: 'make:exception')]
1414
class ExceptionMakeCommand extends GeneratorCommand

src/Illuminate/Queue/Console/WorkCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected function listenForEvents()
199199
* @param Throwable|null $exception
200200
* @return void
201201
*/
202-
protected function writeOutput(Job $job, $status, Throwable $exception = null)
202+
protected function writeOutput(Job $job, $status, ?Throwable $exception = null)
203203
{
204204
$this->outputUsingJson()
205205
? $this->writeOutputAsJson($job, $status, $exception)
@@ -260,7 +260,7 @@ protected function writeOutputForCli(Job $job, $status)
260260
* @param Throwable|null $exception
261261
* @return void
262262
*/
263-
protected function writeOutputAsJson(Job $job, $status, Throwable $exception = null)
263+
protected function writeOutputAsJson(Job $job, $status, ?Throwable $exception = null)
264264
{
265265
$log = array_filter([
266266
'level' => $status === 'starting' || $status === 'success' ? 'info' : 'warning',

src/Illuminate/Support/Onceable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Onceable
1717
*/
1818
public function __construct(
1919
public string $hash,
20-
public object|null $object,
20+
public ?object $object,
2121
public $callable
2222
) {
2323
//

src/Illuminate/Support/ValidatedInput.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function missing($keys)
9393
* @param callable|null $default
9494
* @return $this|mixed
9595
*/
96-
public function whenMissing($key, callable $callback, callable $default = null)
96+
public function whenMissing($key, callable $callback, ?callable $default = null)
9797
{
9898
if ($this->missing($key)) {
9999
return $callback(data_get($this->all(), $key)) ?: $this;
@@ -212,7 +212,7 @@ public function all()
212212
* @param callable|null $default
213213
* @return $this|mixed
214214
*/
215-
public function whenHas($key, callable $callback, callable $default = null)
215+
public function whenHas($key, callable $callback, ?callable $default = null)
216216
{
217217
if ($this->has($key)) {
218218
return $callback(data_get($this->all(), $key)) ?: $this;
@@ -290,7 +290,7 @@ public function anyFilled($keys)
290290
* @param callable|null $default
291291
* @return $this|mixed
292292
*/
293-
public function whenFilled($key, callable $callback, callable $default = null)
293+
public function whenFilled($key, callable $callback, ?callable $default = null)
294294
{
295295
if ($this->filled($key)) {
296296
return $callback(data_get($this->all(), $key)) ?: $this;

types/Support/Helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
}));
4242
assertType('Illuminate\Support\HigherOrderTapProxy', tap(new User()));
4343

44-
function testThrowIf(float|int $foo, DateTime $bar = null): void
44+
function testThrowIf(float|int $foo, ?DateTime $bar = null): void
4545
{
4646
assertType('never', throw_if(true, Exception::class));
4747
assertType('bool', throw_if(false, Exception::class));
@@ -59,7 +59,7 @@ function testThrowIf(float|int $foo, DateTime $bar = null): void
5959
assertType('never', throw_if('foo', Exception::class));
6060
}
6161

62-
function testThrowUnless(float|int $foo, DateTime $bar = null): void
62+
function testThrowUnless(float|int $foo, ?DateTime $bar = null): void
6363
{
6464
assertType('bool', throw_unless(true, Exception::class));
6565
assertType('never', throw_unless(false, Exception::class));

0 commit comments

Comments
 (0)