appendices/migration81/incompatible.xml
497c40ac164d5873fd87f622dfdeb5206392b446
...
...
@@ -55,6 +55,63 @@ var_dump(B::counter()); // int(4), previously int(2)
55
55
</para>
56
56
</sect3>
57
57

58
+
<sect3 xml:id="migration81.incompatible.core.optional-before-required">
59
+
<title>Optional parameters specified before required parameters</title>
60
+

61
+
<para>
62
+
An <link linkend="functions.arguments.default">optional parameter</link>
63
+
specified before required parameters is now always treated as required,
64
+
even when called using
65
+
<link linkend="functions.named-arguments">named arguments</link>.
66
+
As of PHP 8.0.0, but prior to PHP 8.1.0, the below emits a deprecation notice
67
+
on the definition, but runs successfully when called. As of PHP 8.1.0, an error
68
+
of class <classname>ArgumentCountError</classname> is thrown, as it would be when
69
+
called with positional arguments.
70
+

71
+
<informalexample>
72
+
<programlisting role="php">
73
+
<![CDATA[
74
+
<?php
75
+
function makeyogurt($container = "bowl", $flavour)
76
+
{
77
+
return "Making a $container of $flavour yogurt.\n";
78
+
}
79
+
try
80
+
{
81
+
echo makeyogurt(flavour: "raspberry");
82
+
}
83
+
catch (Error $e)
84
+
{
85
+
echo get_class($e), ' - ', $e->getMessage(), "\n";
86
+
}
87
+
?>
88
+
]]>
89
+
</programlisting>
90
+
&example.outputs.80;
91
+
<screen>
92
+
<![CDATA[
93
+
Deprecated: Required parameter $flavour follows optional parameter $container
94
+
in example.php on line 3
95
+
Making a bowl of raspberry yogurt.
96
+
]]>
97
+
</screen>
98
+
&example.outputs.81;
99
+
<screen>
100
+
<![CDATA[
101
+
Deprecated: Optional parameter $container declared before required parameter
102
+
$flavour is implicitly treated as a required parameter in example.php on line 3
103
+
ArgumentCountError - makeyogurt(): Argument #1 ($container) not passed
104
+
]]>
105
+
</screen>
106
+
</informalexample>
107
+
</para>
108
+
<para>
109
+
Note that a default value of &null; can be used before required parameters to
110
+
specify a <link linkend="language.types.declarations.nullable">nullable type</link>,
111
+
but the parameter will still be required.
112
+
</para>
113
+
</sect3>
114
+

58
115
<sect3 xml:id="migration81.incompatible.core.type-compatibility-internal">
59
116
<title>Return Type Compatibility with Internal Classes</title>
60
117

...
...
@@ -64,11 +121,22 @@ var_dump(B::counter()); // int(4), previously int(2)
64
121
inheritance validation.
65
122
In case the return type cannot be declared for an overriding method due to
66
123
PHP cross-version compatibility concerns,
67
-
a <code>#[ReturnTypeWillChange]</code> attribute can be added to silence
124
+
a <classname>ReturnTypeWillChange</classname> attribute can be added to silence
68
125
the deprecation notice.
69
126
</para>
70
127
</sect3>
71
128

129
+
<sect3 xml:id="migration81.incompatible.core.new-keywords">
130
+
<title>New Keywords</title>
131
+
<para>
132
+
<literal>readonly</literal> is a keyword now. However, it still may be used
133
+
as function name.
134
+
</para>
135
+
<para>
136
+
<literal>never</literal> is now a reserved word, so it cannot be used to name a class,
137
+
interface or trait, and is also prohibited from being used in namespaces.
138
+
</para>
139
+
</sect3>
72
140
</sect2>
73
141

74
142
<sect2 xml:id="migration81.incompatible.resource2object">
...
...
@@ -81,78 +149,78 @@ var_dump(B::counter()); // int(4), previously int(2)
81
149
<itemizedlist>
82
150
<listitem>
83
151
<para>
84
-
The <link linkend="book.fileinfo">FileInfo</link> functions now accept and return,
85
-
respectively, <classname>finfo</classname> objects instead of
152
+
The <link linkend="book.fileinfo">FileInfo</link> functions now accept and return
153
+
<classname>finfo</classname> objects instead of
86
154
<literal>fileinfo</literal> &resource;s.
87
155
</para>
88
156
</listitem>
89
157
<listitem>
90
158
<para>
91
-
The <link linkend="book.ftp">FTP</link> functions now accept and return,
92
-
respectively, <classname>FTP\Connection</classname> objects instead of
159
+
The <link linkend="book.ftp">FTP</link> functions now accept and return
160
+
<classname>FTP\Connection</classname> objects instead of
93
161
<literal>ftp</literal> &resource;s.
94
162
</para>
95
163
</listitem>
96
164
<listitem>
97
165
<para>
98
-
The <link linkend="book.imap">IMAP</link> functions now accept and return,
99
-
respectively, <classname>IMAP\Connection</classname> objects instead of
166
+
The <link linkend="book.imap">IMAP</link> functions now accept and return
167
+
<classname>IMAP\Connection</classname> objects instead of
100
168
<literal>imap</literal> &resource;s.
101
169
</para>
102
170
</listitem>
103
171
<listitem>
104
172
<para>
105
-
The <link linkend="book.ldap">LDAP</link> functions now accept and return,
106
-
respectively, <classname>LDAP\Connection</classname> objects instead of
173
+
The <link linkend="book.ldap">LDAP</link> functions now accept and return
174
+
<classname>LDAP\Connection</classname> objects instead of
107
175
<literal>ldap link</literal> &resource;s.
108
176
</para>
109
177
</listitem>
110
178
<listitem>
111
179
<para>
112
-
The <link linkend="book.ldap">LDAP</link> functions now accept and return,
113
-
respectively, <classname>LDAP\Result</classname> objects instead of
180
+
The <link linkend="book.ldap">LDAP</link> functions now accept and return
181
+
<classname>LDAP\Result</classname> objects instead of
114
182
<literal>ldap result</literal> &resource;s.
115
183
</para>
116
184
</listitem>
117
185
<listitem>
118
186
<para>
119
-
The <link linkend="book.ldap">LDAP</link> functions now accept and return,
120
-
respectively, <classname>LDAP\ResultEntry</classname> objects instead of
187
+
The <link linkend="book.ldap">LDAP</link> functions now accept and return
188
+
<classname>LDAP\ResultEntry</classname> objects instead of
121
189
<literal>ldap result entry</literal> &resource;s.
122
190
</para>
123
191
</listitem>
124
192
<listitem>
125
193
<para>
126
-
The <link linkend="book.pgsql">PgSQL</link> functions now accept and return,
127
-
respectively, <classname>PgSql\Connection</classname> objects instead of
194
+
The <link linkend="book.pgsql">PgSQL</link> functions now accept and return
195
+
<classname>PgSql\Connection</classname> objects instead of
128
196
<literal>pgsql link</literal> &resource;s.
129
197
</para>
130
198
</listitem>
131
199
<listitem>
132
200
<para>
133
-
The <link linkend="book.pgsql">PgSQL</link> functions now accept and return,
134
-
respectively, <classname>PgSql\Result</classname> objects instead of
201
+
The <link linkend="book.pgsql">PgSQL</link> functions now accept and return
202
+
<classname>PgSql\Result</classname> objects instead of
135
203
<literal>pgsql result</literal> &resource;s.
136
204
</para>
137
205
</listitem>
138
206
<listitem>
139
207
<para>
140
-
The <link linkend="book.pgsql">PgSQL</link> functions now accept and return,
141
-
respectively, <classname>PgSql\Lob</classname> objects instead of
208
+
The <link linkend="book.pgsql">PgSQL</link> functions now accept and return
209
+
<classname>PgSql\Lob</classname> objects instead of
142
210
<literal>pgsql large object</literal> &resource;s.
143
211
</para>
144
212
</listitem>
145
213
<listitem>
146
214
<para>
147
-
The <link linkend="book.pspell">PSpell</link> functions now accept and return,
148
-
respectively, <classname>PSpell\Dictionary</classname> objects instead of
215
+
The <link linkend="book.pspell">PSpell</link> functions now accept and return
216
+
<classname>PSpell\Dictionary</classname> objects instead of
149
217
<literal>pspell</literal> &resource;s.
150
218
</para>
151
219
</listitem>
152
220
<listitem>
153
221
<para>
154
-
The <link linkend="book.pspell">PSpell</link> functions now accept and return,
155
-
respectively, <classname>PSpell\Config</classname> objects instead of
222
+
The <link linkend="book.pspell">PSpell</link> functions now accept and return
223
+
<classname>PSpell\Config</classname> objects instead of
156
224
<literal>pspell config</literal> &resource;s.
157
225
</para>
158
226
</listitem>
...
...
@@ -198,7 +266,7 @@ var_dump(B::counter()); // int(4), previously int(2)
198
266

199
267
<para>
200
268
Classes extending <methodname>mysqli_stmt::execute</methodname>
201
-
are now required to specify the additional mandatory parameter.
269
+
are now required to specify the additional optional parameter.
202
270
</para>
203
271
</sect2>
204
272

...
...
@@ -216,7 +284,7 @@ var_dump(B::counter()); // int(4), previously int(2)
216
284
<title>OpenSSL</title>
217
285

218
286
<para>
219
-
EC private keys will now be exported in PKCS#8 format rather than
287
+
EC private keys will now be exported in <acronym>PKCS</acronym>#8 format rather than
220
288
traditional format, just like all other keys.
221
289
</para>
222
290
<para>
223
291