Skip to content

Conversation

@Dmitrev
Copy link
Contributor

@Dmitrev Dmitrev commented Sep 12, 2023

The current docs contains some unrecommended legacy PHP syntax to make types nullable.

See PHP docs for referencece:
https://www.php.net/manual/en/language.types.declarations.php

Note:

It is also possible to achieve nullable arguments by making null the default value. This is not recommended as if the default value is changed in a child class a type compatibility violation will be raised as the null type will need to be added to the type declaration.

Example #2 Old way to make arguments nullable

<?php
class C {}

function f(C $c = null) {
   var_dump($c);
}

f(new C);
f(null);
?>

@taylorotwell taylorotwell merged commit fca85ee into laravel:10.x Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants