php-doc-en/appendices/migration74/deprecated.xml
2020-12-17 18:00:58 +00:00

291 lines
8.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="migration74.deprecated">
<title>Deprecated Features</title>
<sect2 xml:id="migration74.deprecated.core">
<title>PHP Core</title>
<sect3 xml:id="migration74.deprecated.core.nested-ternary">
<title>Nested ternary operators without explicit parentheses</title>
<para>
Nested ternary operations must explicitly use parentheses
to dictate the order of the operations. Previously, when used
without parentheses, the left-associativity would not result
in the expected behaviour in most cases.
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
1 ? 2 : 3 ? 4 : 5; // deprecated
(1 ? 2 : 3) ? 4 : 5; // ok
1 ? 2 : (3 ? 4 : 5); // ok
?>
]]>
</programlisting>
</informalexample>
</para>
<para>
Parentheses are <emphasis>not</emphasis> required when nesting into the middle operand,
as this is always unambiguous and not affected by associativity:
<informalexample>
<programlisting role="php">
<![CDATA[
1 ? 2 ? 3 : 4 : 5 // ok
]]>
</programlisting>
</informalexample>
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.array-string-access-curly-brace">
<title>Array and string offset access using curly braces</title>
<para>
The array and string offset access syntax using curly braces is
deprecated. Use <literal>$var[$idx]</literal> instead of
<literal>$var{$idx}</literal>.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.real">
<title>(real) cast and <function>is_real</function> function</title>
<para>
The <literal>(real)</literal> cast is deprecated,
use <literal>(float)</literal> instead.
</para>
<para>
The <function>is_real</function> function is also deprecated,
use <function>is_float</function> instead.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.unbind-this">
<title>Unbinding <literal>$this</literal> when <literal>$this</literal> is used</title>
<para>
Unbinding <literal>$this</literal> of a non-static closure
that uses <literal>$this</literal> is deprecated.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.parent">
<title><literal>parent</literal> keyword without parent class</title>
<para>
Using <literal>parent</literal> inside a class without a parent
is deprecated, and will throw a compile-time error in the future.
Currently an error will only be generated if/when the parent is
accessed at run-time.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.allow-url-include">
<title>allow_url_include INI option</title>
<para>
The <link linkend="ini.allow-url-include">allow_url_include</link>
ini directive is deprecated. Enabling it will generate
a deprecation notice at startup.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.invalid-base-characters">
<title>Invalid characters in base conversion functions</title>
<para>
Passing invalid characters to <function>base_convert</function>,
<function>bindec</function>, <function>octdec</function> and
<function>hexdec</function> will now generate a deprecation notice.
The result will still be computed as if the invalid characters did not exist.
Leading and trailing whitespace, as well as prefixes of type 0x (depending on base)
continue to be allowed.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.array-key-exists-objects">
<title>Using <function>array_key_exists</function> on objects</title>
<para>
Using <function>array_key_exists</function> on objects is deprecated.
Instead either <function>isset</function> or <function>property_exists</function>
should be used.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.magic-quotes-functions">
<title>Magic quotes functions</title>
<para>
The <function>get_magic_quotes_gpc</function> and <function>get_magic_quotes_runtime</function>
functions are deprecated. They always return &false;.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.hebrevc">
<title><function>hebrevc</function> function</title>
<para>
The <function>hebrevc</function> function is deprecated.
It can be replaced with <literal>nl2br(hebrev($str))</literal> or,
preferably, the use of Unicode RTL support.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.convert-cyr-string">
<title><function>convert_cyr_string</function> function</title>
<para>
The <function>convert_cyr_string</function> function is deprecated.
It can be replaced by one of <function>mb_convert_string</function>,
<function>iconv</function> or <classname>UConverter</classname>.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.money-format">
<title><function>money_format</function> function</title>
<para>
The <function>money_format</function> function is deprecated.
It can be replaced by the intl <classname>NumberFormatter</classname> functionality.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.ezmlm-hash">
<title><function>ezmlm_hash</function> function</title>
<para>
The <function>ezmlm_hash</function> function is deprecated.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.restore-include-path">
<title><function>restore_include_path</function> function</title>
<para>
The <function>restore_include_path</function> function is deprecated.
It can be replaced by <literal>ini_restore('include_path')</literal>.
</para>
</sect3>
<sect3 xml:id="migration74.deprecated.core.implode-reverse-parameters">
<title>Implode with historical parameter order</title>
<para>
Passing parameters to <function>implode</function> in reverse order
is deprecated, use <literal>implode($glue, $parts)</literal>
instead of <literal>implode($parts, $glue)</literal>.
</para>
</sect3>
</sect2>
<sect2 xml:id="migration74.deprecated.com">
<title>COM</title>
<para>
Importing type libraries with case-insensitive constant
registering has been deprecated.
</para>
</sect2>
<sect2 xml:id="migration74.deprecated.filter">
<title>Filter</title>
<para>
<constant>FILTER_SANITIZE_MAGIC_QUOTES</constant> is deprecated,
use <constant>FILTER_SANITIZE_ADD_SLASHES</constant> instead.
</para>
</sect2>
<sect2 xml:id="migration74.deprecated.mbstring">
<title>Multibyte String</title>
<para>
Passing a non-string pattern to <function>mb_ereg_replace</function>
is deprecated. Currently, non-string patterns are interpreted as
ASCII codepoints. In PHP 8, the pattern will be interpreted as a
string instead.
</para>
<para>
Passing the encoding as 3rd parameter to <function>mb_strrpos</function>
is deprecated. Instead pass a 0 offset, and encoding as 4th parameter.
</para>
</sect2>
<sect2 xml:id="migration74.deprecated.ldap">
<title>Lightweight Directory Access Protocol</title>
<para>
<function>ldap_control_paged_result_response</function> and
<function>ldap_control_paged_result</function> are deprecated.
Pagination controls can be sent along with
<function>ldap_search</function> instead.
</para>
</sect2>
<sect2 xml:id="migration74.deprecated.reflection">
<title>Reflection</title>
<para>
Calls to <methodname>ReflectionType::__toString</methodname> now generate
a deprecation notice. This method has been deprecated in favor of
<methodname>ReflectionNamedType::getName</methodname> in the documentation
since PHP 7.1, but did not throw a deprecation notice for technical reasons.
</para>
<para>
The <literal>export()</literal> methods on all <classname>Reflection</classname>
classes are deprecated. Construct a <classname>Reflection</classname> object and
convert it to string instead:
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
// ReflectionClass::export(Foo::class, false) is:
echo new ReflectionClass(Foo::class), "\n";
// $str = ReflectionClass::export(Foo::class, true) is:
$str = (string) new ReflectionClass(Foo::class);
?>
]]>
</programlisting>
</informalexample>
</para>
</sect2>
<sect2 xml:id="migration74.deprecated.socket">
<title>Socket</title>
<para>
The <constant>AI_IDN_ALLOW_UNASSIGNED</constant> and
<constant>AI_IDN_USE_STD3_ASCII_RULES</constant> flags for
<function>socket_addrinfo_lookup</function> are deprecated,
due to an upstream deprecation in glibc.
</para>
</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
-->