Skip to content

Mention deprecation of implicit nullable types in function docs #4008

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

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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
7 changes: 4 additions & 3 deletions language/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,9 @@ Making a bowl of raspberry natural yogurt.
dropping the default value, since it will never be used.
One exception to this rule are arguments of the form
<code>Type $param = null</code>, where the &null; default makes the type implicitly
nullable. This usage remains allowed, though it is recommended to use an
explicit <link linkend="language.types.declarations.nullable">nullable type</link> instead.
nullable. This usage is deprecated as of PHP 8.4.0, and an explicit
<link linkend="language.types.declarations.nullable">nullable type</link>
should be used instead.
<example>
<title>Declaring optional arguments after mandatory arguments</title>
<programlisting role="php">
Expand All @@ -464,7 +465,7 @@ Making a bowl of raspberry natural yogurt.
function foo($a = [], $b) {} // Default not used; deprecated as of PHP 8.0.0
function foo($a, $b) {} // Functionally equivalent, no deprecation notice

function bar(A $a = null, $b) {} // Still allowed; $a is required but nullable
function bar(A $a = null, $b) {} // Deprecated as of PHP 8.4.0; $a is required but nullable
function bar(?A $a, $b) {} // Recommended
?>
]]>
Expand Down