php-doc-en/appendices/migration72/deprecated.xml
2017-11-30 16:07:20 +00:00

197 lines
6.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="migration72.deprecated">
<title>Deprecated features in PHP 7.2.x</title>
<sect2 xml:id="migration72.deprecated.unquoted-strings">
<title>Unquoted strings</title>
<para>
Unquoted strings that are non-existent global constants are taken to be
strings of themselves. This behaviour used to emit an
<constant>E_NOTICE</constant>, but will now emit an
<constant>E_WARNING</constant>. In the next major version of PHP, an
<classname>Error</classname> exception will be thrown instead.
</para>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
var_dump(NONEXISTENT);
/* Output:
Warning: Use of undefined constant NONEXISTENT - assumed 'NONEXISTENT' (this will throw an Error in a future version of PHP) in %s on line %d
string(11) "NONEXISTENT"
*/
]]>
</programlisting>
</informalexample>
</sect2>
<sect2 xml:id="migration72.deprecated.png2wbmp-jpeg2wbmp">
<title><function>png2wbmp</function> and <function>jpeg2wbmp</function></title>
<para>
The <function>png2wbmp</function> and <function>jpeg2wbmp</function>
functions from the GD extension have now been deprecated and will be removed
in the next major version of PHP.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.INTL_IDNA_VARIANT_2003-variant">
<title><constant>INTL_IDNA_VARIANT_2003</constant> variant</title>
<para>
The Intl extension has deprecated the
<constant>INTL_IDNA_VARIANT_2003</constant> variant, which is currently
being used as the default for <function>idn_to_ascii</function> and
<function>idn_to_utf8</function>. PHP 7.4 will see these defaults changed to
<constant>INTL_IDNA_VARIANT_UTS46</constant>, and the next major version of
PHP will remove <constant>INTL_IDNA_VARIANT_2003</constant> altogether.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.__autoload-method">
<title><function>__autoload</function> method</title>
<para>
The <function>__autoload</function> method has been deprecated because it is
inferior to <function>spl_autoload_register</function> (due to it not being
able to chain autoloaders), and there is no interoperability between the two
autoloading styles.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.track_errors-and-php_errormsg">
<title><parameter>track_errors</parameter> ini setting and <literal>$php_errormsg</literal> variable</title>
<para>
When the <parameter>track_errors</parameter> ini setting is enabled, a
<literal>$php_errormsg</literal> variable is created in the local scope when
a non-fatal error occurs. Given that the preferred way of retrieving such
error information is by using <function>error_get_last</function>, this
feature has been deprecated.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.create_function-function">
<title><function>create_function</function> function</title>
<para>
Given the security issues of this function (being a thin wrapper around
<function>eval</function>), this dated function has now been deprecated.
The preferred alternative is to use <link linkend="functions.anonymous">anonymous functions</link>.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.mbstringfunc_overload-ini-setting">
<title><parameter>mbstring.func_overload</parameter> ini setting</title>
<para>
Given the interoperability problems of string-based functions being used in
environments with this setting enabled, it has now been deprecated.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.unset-cast">
<title><literal>(unset)</literal> cast</title>
<para>
Casting any expression to this type will always result in &null;, and so
this superfluous casting type has now been deprecated.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.parse_str-no-second-arg">
<title><function>parse_str</function> without a second argument</title>
<para>
Without the second argument to <function>parse_str</function>, the query
string parameters would populate the local symbol table.
Given the security implications of this, using
<function>parse_str</function> without a second argument has now been
deprecated. The function should always be used with two arguments, as the
second argument causes the query string to be parsed into an array.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.gmp_random-function">
<title><function>gmp_random</function> function</title>
<para>
This function generates a random number based upon a range that is
calculated by an unexposed, platform-specific limb size. Because of this,
the function has now been deprecated. The preferred way of generating a
random number using the GMP extension is by
<function>gmp_random_bits</function> and
<function>gmp_random_range</function>.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.each-function">
<title><function>each</function> function</title>
<para>
This function is far slower at iteration than a normal
<literal>foreach</literal>, and causes implementation issues for some
language changes. It has therefore been deprecated.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.assert-string-arg">
<title><function>assert</function> with a string argument</title>
<para>
Using <function>assert</function> with a string argument required the string
to be <function>eval</function>'ed. Given the potential for remote code
execution, using <function>assert</function> with a string argument has now
been deprecated in favour of using boolean expressions.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.errcontext-arg-of-error-handlers">
<title><literal>$errcontext</literal> argument of error handlers</title>
<para>
The <literal>$errcontext</literal> argument contains all local variables of
the error site. Given its rare usage, and the problems it causes with
internal optimisations, it has now been deprecated.
Instead, a debugger should be used to retrieve
information on local variables at the error site.
</para>
</sect2>
<sect2 xml:id="migration72.deprecated.read_exif_data-function">
<title><function>read_exif_data</function> function</title>
<para>
The <function>read_exif_data</function> alias has been deprecated.
The <function>exif_read_data</function> function should be used instead.
</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
-->