php-doc-en/appendices/migration80/deprecated.xml

262 lines
8.9 KiB
XML
Raw Permalink Normal View History

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="migration80.deprecated">
<title>Deprecated Features</title>
<sect2 xml:id="migration80.deprecated.core">
<title>PHP Core</title>
<itemizedlist>
<listitem>
<para>
If a parameter with a default value is followed by a required parameter, the default value has
no effect. This is deprecated as of PHP 8.0.0 and can generally be resolved by dropping the
default value, without a change in functionality:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
function test($a = [], $b) {} // Before
function test($a, $b) {} // After
?>
]]>
</programlisting>
</para>
<para>
One exception to this rule are parameters of the form <code>Type $param = null</code>, where
the null default makes the type implicitly nullable. This usage remains allowed, but it is
recommended to use an explicit nullable type instead:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
function test(A $a = null, $b) {} // Still allowed
function test(?A $a, $b) {} // Recommended
?>
]]>
</programlisting>
</para>
</listitem>
<listitem>
<para>
Calling <function>get_defined_functions</function> with <parameter>exclude_disabled</parameter>
explicitly set to &false; is deprecated and no longer has an effect.
<function>get_defined_functions</function> will never include disabled functions.
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.deprecated.enchant">
<title>Enchant</title>
<itemizedlist>
<listitem>
<para>
<function>enchant_broker_set_dict_path</function> and
<function>enchant_broker_get_dict_path</function>
are deprecated, because that functionality is neither available in libenchant &lt; 1.5 nor in
libenchant-2.
</para>
</listitem>
<listitem>
<para>
<function>enchant_dict_add_to_personal</function> is deprecated; use
<function>enchant_dict_add</function> instead.
</para>
</listitem>
<listitem>
<para>
<function>enchant_dict_is_in_session</function> is deprecated; use
<function>enchant_dict_is_added</function> instead.
</para>
</listitem>
<listitem>
<para>
<function>enchant_broker_free</function> and <function>enchant_broker_free_dict</function> are
deprecated; unset the object instead.
</para>
</listitem>
<listitem>
<para>
The <constant>ENCHANT_MYSPELL</constant> and <constant>ENCHANT_ISPELL</constant> constants are
deprecated.
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.deprecated.libxml">
<title>LibXML</title>
<para>
<function>libxml_disable_entity_loader</function> has been deprecated. As libxml 2.9.0 is now
required, external entity loading is guaranteed to be disabled by default, and this function is
no longer needed to protect against XXE attacks, unless the (still vulnerable)
<constant>LIBXML_NOENT</constant> is used.
In that case, it is recommended to refactor the code using
<function>libxml_set_external_entity_loader</function> to suppress loading of external entities.
</para>
</sect2>
<sect2 xml:id="migration80.deprecated.pgsql">
<title>PGSQL / PDO PGSQL</title>
<itemizedlist>
<listitem>
<para>
The constant <constant>PGSQL_LIBPQ_VERSION_STR</constant> now has the same value as
<constant>PGSQL_LIBPQ_VERSION</constant>, and thus is deprecated.
</para>
</listitem>
<listitem>
<para>
Function aliases in the pgsql extension have been deprecated.
See the following list for which functions should be used instead:
</para>
<para>
<simplelist>
<member><function>pg_errormessage</function><function>pg_last_error</function></member>
<member><function>pg_numrows</function><function>pg_num_rows</function></member>
<member><function>pg_numfields</function><function>pg_num_fields</function></member>
<member><function>pg_cmdtuples</function><function>pg_affected_rows</function></member>
<member><function>pg_fieldname</function><function>pg_field_name</function></member>
<member><function>pg_fieldsize</function><function>pg_field_size</function></member>
<member><function>pg_fieldtype</function><function>pg_field_type</function></member>
<member><function>pg_fieldnum</function><function>pg_field_num</function></member>
<member><function>pg_result</function><function>pg_fetch_result</function></member>
<member><function>pg_fieldprtlen</function><function>pg_field_prtlen</function></member>
<member><function>pg_fieldisnull</function><function>pg_field_is_null</function></member>
<member><function>pg_freeresult</function><function>pg_free_result</function></member>
<member><function>pg_getlastoid</function><function>pg_last_oid</function></member>
<member><function>pg_locreate</function><function>pg_lo_create</function></member>
<member><function>pg_lounlink</function><function>pg_lo_unlink</function></member>
<member><function>pg_loopen</function><function>pg_lo_open</function></member>
<member><function>pg_loclose</function><function>pg_lo_close</function></member>
<member><function>pg_loread</function><function>pg_lo_read</function></member>
<member><function>pg_lowrite</function><function>pg_lo_write</function></member>
<member><function>pg_loreadall</function><function>pg_lo_read_all</function></member>
<member><function>pg_loimport</function><function>pg_lo_import</function></member>
<member><function>pg_loexport</function><function>pg_lo_export</function></member>
<member><function>pg_setclientencoding</function><function>pg_set_client_encoding</function></member>
<member><function>pg_clientencoding</function> -> <function>pg_client_encoding</function></member>
</simplelist>
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.deprecated.standard">
<title>Standard Library</title>
<itemizedlist>
<listitem>
<para>
Sort comparison functions that return &true; or &false; will now throw a deprecation warning, and
should be replaced with an implementation that returns an integer less than, equal to, or greater
than zero.
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
// Replace
usort($array, fn($a, $b) => $a > $b);
// With
usort($array, fn($a, $b) => $a <=> $b);
?>
]]>
</programlisting>
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.deprecated.zip">
<title>Zip</title>
<itemizedlist>
<listitem>
<para>
Using an empty file as ZipArchive is deprecated. Libzip 1.6.0 does not accept empty files as
valid zip archives any longer. The existing workaround will be removed in the next version.
</para>
</listitem>
<listitem>
<para>
The procedural API of Zip is deprecated. Use <classname>ZipArchive</classname> instead.
Iteration over all entries can be accomplished using <methodname>ZipArchive::statIndex</methodname>
and a <link linkend="control-structures.for">for</link> loop:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
// iterate using the procedural API
assert(is_resource($zip));
while ($entry = zip_read($zip)) {
echo zip_entry_name($entry);
}
// iterate using the object-oriented API
assert($zip instanceof ZipArchive);
for ($i = 0; $entry = $zip->statIndex($i); $i++) {
echo $entry['name'];
}
?>
]]>
</programlisting>
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.deprecated.reflection">
<title>Reflection</title>
<itemizedlist>
<listitem>
<para>
<methodname>ReflectionFunction::isDisabled</methodname> is deprecated, as it is no longer
possible to create a <classname>ReflectionFunction</classname> for a disabled function. This
method now always returns &false;.
</para>
</listitem>
<listitem>
<para>
<methodname>ReflectionParameter::getClass</methodname>,
<methodname>ReflectionParameter::isArray</methodname>, and
<methodname>ReflectionParameter::isCallable</methodname> are deprecated.
<methodname>ReflectionParameter::getType</methodname> and the
<classname>ReflectionType</classname> APIs should be used instead.
</para>
</listitem>
</itemizedlist>
</sect2>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->