php-doc-en/appendices/migration56/incompatible.xml
2015-08-01 12:23:14 +00:00

143 lines
3.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="migration56.incompatible">
<title>Backward incompatible changes</title>
<simpara>
Although most existing PHP 5 code should work without changes, please take
note of some backward incompatible changes:
</simpara>
<sect2 xml:id="migration56.incompatible.array-keys">
<title>Array keys won't be overwritten when defining an array as a property of a class via an array literal</title>
<para>
Previously, arrays declared as class properties which mixed explicit and
implicit keys could have array elements silently overwritten if an explicit
key was the same as a sequential implicit key. For example:
</para>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
class C {
const ONE = 1;
public $array = [
self::ONE => 'foo',
'bar',
'quux',
];
}
var_dump((new C)->array);
?>
]]>
</programlisting>
&example.outputs.55;
<screen>
<![CDATA[
array(2) {
[0]=>
string(3) "bar"
[1]=>
string(4) "quux"
}
]]>
</screen>
&example.outputs.56;
<screen>
<![CDATA[
array(3) {
[1]=>
string(3) "foo"
[2]=>
string(3) "bar"
[3]=>
string(4) "quux"
}
]]>
</screen>
</informalexample>
</sect2>
<sect2 xml:id="migration56.incompatible.json-decode">
<title><function>json_decode</function> strictness</title>
<para>
<function>json_decode</function> now rejects non-lowercase variants of the
JSON literals <literal>true</literal>, <literal>false</literal> and
<literal>null</literal> at all times, as per the JSON specification, and
sets <function>json_last_error</function> accordingly. Previously, inputs
to <function>json_decode</function> that consisted solely of one of these
values in upper or mixed case were accepted.
</para>
<para>
This change will only affect cases where invalid JSON was being passed to
<function>json_decode</function>: valid JSON input is unaffected and will
continue to be parsed normally.
</para>
</sect2>
<sect2 xml:id="migration56.incompatible.peer-verification">
<title>Stream wrappers now verify peer certificates and host names by default when using SSL/TLS</title>
&migration56.openssl.peer-verification;
</sect2>
<sect2 xml:id="migration56.incompatible.gmp">
<title><link linkend="book.gmp">GMP</link> resources are now objects</title>
<para>
<link linkend="book.gmp">GMP</link> resources are now objects. The
functional API implemented in the GMP extension has not changed, and code
should run unmodified unless it checks explicitly for a resource using
<function>is_resource</function> or similar.
</para>
</sect2>
<sect2 xml:id="migration56.incompatible.mcrypt">
<title><link linkend="book.mcrypt">Mcrypt</link> functions now require valid keys and IVs</title>
<para>
<function>mcrypt_encrypt</function>, <function>mcrypt_decrypt</function>,
<function>mcrypt_cbc</function>, <function>mcrypt_cfb</function>,
<function>mcrypt_ecb</function>, <function>mcrypt_generic</function> and
<function>mcrypt_ofb</function> will no longer accept keys or IVs with
incorrect sizes, and block cipher modes that require IVs will now fail if
an IV isn't provided.
</para>
</sect2>
<sect2 xml:id="migration56.incompatible.curl">
<title><link linkend="book.curl">cURL</link> file uploads</title>
<para>
Uploads using the @file syntax now require CURLOPT_SAFE_UPLOAD to be set to
&false;. <classname>CURLFile</classname> 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
-->