Skip to content

Commit 4d0fe7f

Browse files
authored
非推奨となった関数の引数のnullable型について (#154)
1 parent c714175 commit 4d0fe7f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

language/functions.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 74976cdb263ef841c5fc2c3f91ca7e284adce552 Maintainer: takagi Status: ready -->
4-
<!-- CREDITS: hirokawa,mumumu -->
3+
<!-- EN-Revision: 489d46bc2598784bd3711454ccab8940107cde67 Maintainer: takagi Status: ready -->
4+
<!-- CREDITS: hirokawa,mumumu,jdkfx -->
55
<chapter xml:id="language.functions" xmlns="http://docbook.org/ns/docbook">
66
<title>関数</title>
77

@@ -456,10 +456,9 @@ Making a bowl of raspberry natural yogurt.
456456
<code>Type $param = null</code> と書かれた引数です。
457457
&null; をデフォルトにすることは、
458458
型が暗黙のうちに nullable であることを示しています。
459-
この書き方はまだ許可されていますが、
460-
以下のようにして 明示的に
459+
この使い方はPHP 8.4.0で非推奨となり、代わりに明示的な
461460
<link linkend="language.types.declarations.nullable">nullable 型</link>
462-
を使うことを推奨します:
461+
を使用する必要があります。
463462
<example>
464463
<title>デフォルト値を指定した引数は、必須の引数の後に宣言する</title>
465464
<programlisting role="php">
@@ -468,7 +467,9 @@ Making a bowl of raspberry natural yogurt.
468467
function foo($a = [], $b) {} // デフォルト値が使われないため、PHP 8.0.0 以降は推奨されません
469468
function foo($a, $b) {} // 上のコードと機能的には同じですが、推奨されない警告は発生しません。
470469
471-
function bar(A $a = null, $b) {} // まだ許可されています。$a は必須ですが、nullable です。
470+
// PHP 8.1.0以降、$a は暗黙的に必須(必須の引数の前にあるため)ですが、
471+
// デフォルトのパラメータ値が null であるため、暗黙的に nullable とみなされます(PHP 8.4.0で非推奨)。
472+
function bar(A $a = null, $b) {}
472473
function bar(?A $a, $b) {} // 推奨される書き方です。
473474
?>
474475
]]>

0 commit comments

Comments
 (0)