php-doc-en/appendices/migration73/incompatible.xml
Christoph Michael Becker 86e6094e86 Use canonical type names
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351133 c90b9560-bf6c-de11-be94-00142212c4b1
2020-11-02 15:39:04 +00:00

340 lines
11 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="migration73.incompatible" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Backward Incompatible Changes</title>
<sect2 xml:id="migration73.incompatible.core">
<title>PHP Core</title>
<sect3 xml:id="migration73.incompatible.core.heredoc-nowdoc">
<title>Heredoc/Nowdoc Ending Label Interpretation</title>
<para>
Due to the introduction of <link
linkend="migration73.new-features.core.heredoc">flexible heredoc/nowdoc
syntax</link>, doc strings that contain the ending label inside their body
may cause syntax errors or change in interpretation. For example in:
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$str = <<<FOO
abcdefg
FOO
FOO;
?>
]]>
</programlisting>
</informalexample>
the indented occurrence of <literal>FOO</literal> did not previously have any
special meaning. Now it will be interpreted as the end of the heredoc string
and the following <literal>FOO;</literal> will cause a syntax error. This issue can
always be resolved by choosing an ending label that does not occur within the
contents of the string.
</para>
</sect3>
<sect3 xml:id="migration73.incompatible.core.continue-targeting-switch">
<title>Continue Targeting Switch issues Warning</title>
<para>
<literal>continue</literal> statements targeting <literal>switch</literal>
control flow structures will now generate a warning. In PHP such
<literal>continue</literal> statements are equivalent to
<literal>break</literal>, while they behave as <literal>continue 2</literal>
in other languages.
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
while ($foo) {
switch ($bar) {
case "baz":
continue;
// Warning: "continue" targeting switch is equivalent to
// "break". Did you mean to use "continue 2"?
}
}
?>
]]>
</programlisting>
</informalexample>
</para>
</sect3>
<sect3 xml:id="migration73.incompatible.core.arrayaccess">
<title>Strict Interpretation of Integer String Keys on ArrayAccess</title>
<para>
Array accesses of type <literal>$obj["123"]</literal>, where
<literal>$obj</literal> implements <classname>ArrayAccess</classname> and
<literal>"123"</literal> is an integer <type>string</type> literal will no
longer result in an implicit conversion to integer, i.e.,
<literal>$obj->offsetGet("123")</literal> will be called instead of
<literal>$obj->offsetGet(123)</literal>. This matches existing behavior for
non-literals. The behavior of arrays is not affected in any way, they
continue to implicitly convert integral string keys to integers.
</para>
</sect3>
<sect3 xml:id="migration73.incompatible.core.static-properties">
<title>Static Properties no longer separated by Reference Assignment</title>
<para>
In PHP, static properties are shared between inheriting classes, unless the
static property is explicitly overridden in a child class. However, due to an
implementation artifact it was possible to separate the static properties by
assigning a reference. This loophole has been fixed.
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
class Test {
public static $x = 0;
}
class Test2 extends Test { }
Test2::$x = &$x;
$x = 1;
var_dump(Test::$x, Test2::$x);
// Previously: int(0), int(1)
// Now: int(1), int(1)
?>
]]>
</programlisting>
</informalexample>
</para>
</sect3>
<sect3 xml:id="migration73.incompatible.core.reference-unwrapping">
<title>References returned by Array and Property Accesses are immediately unwrapped</title>
<para>
References returned by array and property accesses are now unwrapped as part
of the access. This means that it is no longer possible to modify the
reference between the access and the use of the accessed value:
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$arr = [1];
$ref =& $arr[0];
var_dump($arr[0] + ($arr[0] = 2));
// Previously: int(4), Now: int(3)
?>
]]>
</programlisting>
</informalexample>
This makes the behavior of references and non-references consistent. Please
note that reading and writing a value inside a single expression remains
undefined behavior and may change again in the future.
</para>
</sect3>
<sect3 xml:id="migration73.incompatible.core.traversable-unpacking">
<title>Argument Unpacking of Traversables with non-Integer Keys no longer supported</title>
<para>
Argument unpacking stopped working with <classname>Traversable</classname>s
with non-integer keys. The following code worked in PHP 5.6-7.2 by accident.
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
function foo(...$args) {
var_dump($args);
}
function gen() {
yield 1.23 => 123;
}
foo(...gen());
?>
]]>
</programlisting>
</informalexample>
</para>
</sect3>
<sect3 xml:id="migration73.incompatible.core.misc">
<title>Miscellaneous</title>
<para>
The <filename>ext_skel</filename> utility has been completely redesigned with
new options and some old options removed. This is now written in PHP and has
no external dependencies.
</para>
<para>
Support for BeOS has been dropped.
</para>
<para>
Exceptions thrown due to automatic conversion of warnings into exceptions in
<literal>EH_THROW</literal> mode (e.g. some <classname>DateTime</classname>
exceptions) no longer populate <function>error_get_last</function> state. As
such, they now work the same way as manually thrown exceptions.
</para>
<para>
<classname>TypeError</classname> now reports wrong types as
<literal>int</literal> and <literal>bool</literal> instead of
<literal>integer</literal> and <literal>boolean</literal>, respectively.
</para>
<para>
Undefined variables passed to <function>compact</function> will now be
reported as a notice.
</para>
<para>
<function>getimagesize</function> and related functions now report the mime
type of BMP images as <literal>image/bmp</literal> instead of
<literal>image/x-ms-bmp</literal>, since the former has been registered with
the IANA (see <link xlink:href="&url.rfc;7903">RFC 7903</link>).
</para>
<para>
<function>stream_socket_get_name</function> will now return IPv6 addresses
wrapped in brackets. For example <literal>"[::1]:1337"</literal> will be
returned instead of <literal>"::1:1337"</literal>.
</para>
</sect3>
</sect2>
<sect2 xml:id="migration73.incompatible.bc">
<title>BCMath Arbitrary Precision Mathematics</title>
<para>
All warnings thrown by <link linkend="ref.bc">BCMath functions</link> are
now using PHP's error handling. Formerly some warnings have directly been
written to stderr.
</para>
<para>
<function>bcmul</function> and <function>bcpow</function> now return numbers
with the requested scale. Formerly, the returned numbers may have omitted
trailing decimal zeroes.
</para>
</sect2>
<sect2 xml:id="migration73.incompatible.imap">
<title>IMAP, POP3 and NNTP</title>
<para>
<command>rsh</command>/<command>ssh</command> logins are disabled by default.
Use <link
linkend="ini.imap.enable-insecure-rsh">imap.enable_insecure_rsh</link> if you
want to enable them. Note that the IMAP library does not filter mailbox names
before passing them to the <command>rsh</command>/<command>ssh</command>
command, thus passing untrusted data to this function with
<command>rsh</command>/<command>ssh</command> enabled is insecure.
</para>
</sect2>
<sect2 xml:id="migration73.incompatible.mbstring">
<title>Multibyte String</title>
<para>
Due to added support for named captures, <literal>mb_ereg_*()</literal>
patterns using named captures will behave differently. In particular named
captures will be part of matches and <function>mb_ereg_replace</function>
will interpret additional syntax. See <link
linkend="migration73.new-features.mbstring.named-captures">Named
Captures</link> for more information.
</para>
</sect2>
<sect2 xml:id="migration73.incompatible.mysqli">
<title>MySQL Improved Extension</title>
<para>
Prepared statements now properly report the fractional seconds for
<literal>DATETIME</literal>, <literal>TIME</literal> and
<literal>TIMESTAMP</literal> columns with decimals specifier (e.g.
<literal>TIMESTAMP(6)</literal> when using microseconds). Formerly, the
fractional seconds part was simply omitted from the returned values.
</para>
</sect2>
<sect2 xml:id="migration73.incompatible.pdo-mysql">
<title>MySQL Functions (PDO_MYSQL)</title>
<para>
Prepared statements now properly report the fractional seconds for
<literal>DATETIME</literal>, <literal>TIME</literal> and
<literal>TIMESTAMP</literal> columns with decimals specifier (e.g.
<literal>TIMESTAMP(6)</literal> when using microseconds). Formerly, the
fractional seconds part was simply omitted from the returned values. Please
note that this only affects the usage of <link
linkend="ref.pdo-mysql">PDO_MYSQL</link> with emulated prepares turned off
(e.g. using the native preparation functionality). Statements using
connections having <constant>PDO::ATTR_EMULATE_PREPARES</constant>=&true;
(which is the default) were not affected by the bug fixed and have already
been getting the proper fractional seconds values from the engine.
</para>
</sect2>
<sect2 xml:id="migration73.incompatible.reflection">
<title>Reflection</title>
<para>
<link linkend="book.reflection">Reflection</link> export to string now uses
<literal>int</literal> and <literal>bool</literal> instead of
<literal>integer</literal> and <literal>boolean</literal>, respectively.
</para>
</sect2>
<sect2 xml:id="migration73.incompatible.spl">
<title>Standard PHP Library (SPL)</title>
<para>
If an <link linkend="book.spl">SPL</link> autoloader throws an exception,
following autoloaders will not be executed. Previously all autoloaders were
executed and exceptions were chained.
</para>
</sect2>
<sect2 xml:id="migration73.incompatible.simplexml">
<title>SimpleXML</title>
<para>
Mathematic operations involving <link
linkend="book.simplexml">SimpleXML</link> objects will now treat the text as
an <type>int</type> or <type>float</type>, whichever is more appropriate.
Previously values were treated as <type>int</type>s unconditionally.
</para>
</sect2>
<sect2 xml:id="migration73.incompatible.cookie-decode">
<title>Incoming Cookies</title>
<para>
As of PHP 7.3.23, the <emphasis>names</emphasis> of incoming cookies are no
longer url-decoded for security reasons.
</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
-->