PHP 8.0 migration guide

Co-authored-by: Nikita Popov <nikita.ppv@googlemail.com>


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351500 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Christoph Michael Becker 2020-11-22 18:25:14 +00:00
parent 6970f8fa7b
commit d7a2a4e3f7
5 changed files with 2941 additions and 0 deletions

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<appendix xml:id="migration80" xmlns="http://docbook.org/ns/docbook" xmlns:phd="http://www.php.net/ns/phd">
<title>Migrating from PHP 7.4.x to PHP 8.0.x</title>
&appendices.migration80.new-features;
&appendices.migration80.incompatible;
&appendices.migration80.deprecated;
&appendices.migration80.other-changes;
<sect1 phd:chunk="false" xml:id="migration80.intro">
<para>
This new major version brings with it a number of
<link linkend="migration80.new-features">new features</link> and
<link linkend="migration80.incompatible">some incompatibilities</link>
that should be tested for before switching PHP versions in production
environments.
</para>
<para>
&manual.migration.seealso;
<link linkend="migration70">7.0.x</link>,
<link linkend="migration71">7.1.x</link>,
<link linkend="migration72">7.2.x</link>,
<link linkend="migration73">7.3.x</link>.
<link linkend="migration74">7.4.x</link>.
</para>
</sect1>
</appendix>
<!-- 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
-->

View file

@ -0,0 +1,258 @@
<?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.
</para>
</sect2>
<sect2 xml:id="migration80.deprecated.pgsql">
<title>PGSQL / PDO PGSQL</title>
<itemizedlist>
<listitem>
<para>
The constant <constant>PG_VERSION_STR</constant> now has the same value as
<constant>PG_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
-->

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,640 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="migration80.new-features" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>New Features</title>
<sect2 xml:id="migration80.new-features.core">
<title>PHP Core</title>
<sect3 xml:id="migration80.new-features.core.named-arguments">
<title>Named Arguments</title>
<para>
<!-- RFC: https://wiki.php.net/rfc/named_params -->
</para>
</sect3>
<sect3 xml:id="migration80.new-features.core.attributes">
<title>Attributes</title>
<para>
Support for Attributes has been added.
<!-- RFC: https://wiki.php.net/rfc/attributes_v2 -->
<!-- RFC: https://wiki.php.net/rfc/attribute_amendments -->
<!-- RFC: https://wiki.php.net/rfc/shorter_attribute_syntax -->
<!-- RFC: https://wiki.php.net/rfc/shorter_attribute_syntax_change -->
</para>
</sect3>
<sect3 xml:id="migration80.new-features.core.property-promotion">
<title>Constructor Property Promotion</title>
<para>
Support for constructor property promotion (declaring properties in the constructor signature)
has been added.
<!-- RFC: https://wiki.php.net/rfc/constructor_promotion -->
</para>
</sect3>
<sect3 xml:id="migration80.new-features.core.union-types">
<title>Union Types</title>
<para>
Support for <link linkend="language.types.declarations.union">union types</link> has been added.
<!-- RFC: https://wiki.php.net/rfc/union_types_v2 -->
</para>
</sect3>
<sect3 xml:id="migration80.new-features.core.match">
<title>Match Expression</title>
<para>
Support for <link linkend="control-structures.match"><literal>match</literal> expressions</link> has been added.
<!-- RFC: https://wiki.php.net/rfc/match_expression_v2 -->
</para>
</sect3>
<sect3 xml:id="migration80.new-features.core.nullsafe-operator">
<title>Nullsafe Operator</title>
<para>
Support for the nullsafe operator (<literal>?-></literal>) has been added.
<!-- RFC: https://wiki.php.net/rfc/nullsafe_operator -->
</para>
</sect3>
<sect3 xml:id="migration80.new-features.core.others">
<title>Other new Features</title>
<itemizedlist>
<listitem>
<para>
<!-- we cannot use <classname>WeakMap</classname> because that would link to the wrong class -->
The <literal>WeakMap</literal> class has been added.
<!-- RFC: https://wiki.php.net/rfc/weak_maps -->
</para>
</listitem>
<listitem>
<para>
The <classname>ValueError</classname> class has been added.
</para>
</listitem>
<listitem>
<para>
Any number of function parameters may now be replaced by a variadic argument, as long as the
types are compatible. For example, the following code is now allowed:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
class A {
public function method(int $many, string $parameters, $here) {}
}
class B extends A {
public function method(...$everything) {}
}
?>
]]>
</programlisting>
</para>
</listitem>
<listitem>
<para>
<type>static</type> (as in "late static binding") can now be used as a return type:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
class Test {
public function create(): static {
return new static();
}
}
?>
]]>
</programlisting>
<!-- RFC: https://wiki.php.net/rfc/static_return_type -->
</para>
</listitem>
<listitem>
<para>
It is now possible to fetch the class name of an object using
<code>$object::class</code>. The result is the same as <code>get_class($object)</code>.
<!-- RFC: https://wiki.php.net/rfc/class_name_literal_on_object -->
</para>
</listitem>
<listitem>
<para>
&new; and &instanceof; can now be used with arbitrary expressions,
using <code>new (expression)(...$args)</code> and <code>$obj instanceof (expression)</code>.
<!-- RFC: https://wiki.php.net/rfc/variable_syntax_tweaks -->
</para>
</listitem>
<listitem>
<para>
Some consistency fixes to variable syntax have been applied, for example writing
<code>Foo::BAR::$baz</code> is now allowed.
<!-- RFC: https://wiki.php.net/rfc/variable_syntax_tweaks -->
</para>
</listitem>
<listitem>
<para>
Added <interfacename>Stringable</interfacename> interface, which is automatically implemented if
a class defines a <link linkend="object.tostring">__toString()</link> method.
<!-- RFC: https://wiki.php.net/rfc/stringable -->
</para>
</listitem>
<listitem>
<para>
Traits can now define abstract private methods.
Such methods must be implemented by the class using the trait.
<!-- RFC: https://wiki.php.net/rfc/abstract_trait_method_validation -->
</para>
</listitem>
<listitem>
<para>
<literal>throw</literal> can now be used as an expression.
That allows usages like:
<programlisting role="php">
<![CDATA[
<?php
$fn = fn() => throw new Exception('Exception in arrow function');
$user = $session->user ?? throw new Exception('Must have user');
]]>
</programlisting>
<!-- RFC: https://wiki.php.net/rfc/throw_expression -->
</para>
</listitem>
<listitem>
<para>
An optional trailing comma is now allowed in parameter lists.
<programlisting role="php">
<![CDATA[
<?php
function functionWithLongSignature(
Type1 $parameter1,
Type2 $parameter2, // <-- This comma is now allowed.
) {
}
]]>
</programlisting>
<!-- RFC: https://wiki.php.net/rfc/trailing_comma_in_parameter_list -->
</para>
</listitem>
<listitem>
<para>
It is now possible to write <code>catch (Exception)</code> to catch an exception without storing
it in a variable.
<!-- RFC: https://wiki.php.net/rfc/non-capturing_catches -->
</para>
</listitem>
<listitem>
<para>
Support for <type>mixed</type> type has been added.
<!-- RFC: https://wiki.php.net/rfc/mixed_type_v2 -->
</para>
</listitem>
<listitem>
<para>
Private methods declared on a parent class no longer enforce any inheritance rules on the methods
of a child class (with the exception of final private constructors).
The following example illustrates which restrictions have been removed:
<programlisting role="php">
<![CDATA[
<?php
class ParentClass {
private function method1() {}
private function method2() {}
private static function method3() {}
// Throws a warning, as "final" no longer has an effect:
private final function method4() {}
}
class ChildClass extends ParentClass {
// All of the following are now allowed, even though the modifiers aren't
// the same as for the private methods in the parent class.
public abstract function method1() {}
public static function method2() {}
public function method3() {}
public function method4() {}
}
?>
]]>
</programlisting>
<!-- RFC: https://wiki.php.net/rfc/inheritance_private_methods -->
</para>
</listitem>
<listitem>
<para>
<function>get_resource_id</function> has been added, which returns the same value as
<code>(int) $resource</code>. It provides the same functionality under a clearer API.
</para>
</listitem>
</itemizedlist>
</sect3>
</sect2>
<sect2 xml:id="migration80.new-features.date">
<title>Date and Time</title>
<itemizedlist>
<listitem>
<para>
<methodname>DateTime::createFromInterface</methodname> and
<methodname>DateTimeImmutable::createFromInterface</methodname> have been added.
</para>
</listitem>
<listitem>
<para>
The DateTime format specifier <literal>p</literal> has been added, which is the same as
<literal>P</literal> but returns <literal>Z</literal> rather than <literal>+00:00</literal>
for UTC.
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.new-features.dom">
<title>DOM</title>
<para>
<interfacename>DOMParentNode</interfacename> and <interfacename>DOMChildNode</interfacename> with
new traversal and manipulation APIs have been added.
<!-- RFC: https://wiki.php.net/rfc/dom_living_standard_api-->
</para>
</sect2>
<sect2 xml:id="migration80.new-features.filter">
<title>Filter</title>
<para>
<constant>FILTER_VALIDATE_BOOL</constant> has been added as an alias for
<constant>FILTER_VALIDATE_BOOLEAN</constant>. The new name is preferred, as it uses the canonical
type name.
</para>
</sect2>
<sect2 xml:id="migration80.new-features.enchant">
<title>Enchant</title>
<para>
<function>enchant_dict_add</function>, <function>enchant_dict_is_added</function>, and
<constant>LIBENCHANT_VERSION</constant> have been added.
</para>
</sect2>
<sect2 xml:id="migration80.new-features.fpm">
<title>FPM</title>
<para>
Added a new option <literal>pm.status_listen</literal> that allows getting the status from
different endpoint (e.g. port or UDS file) which is useful for getting the status when all
children are busy with serving long running requests.
</para>
</sect2>
<sect2 xml:id="migration80.new-features.hash">
<title>Hash</title>
<para>
<classname>HashContext</classname> objects can now be serialized.
</para>
</sect2>
<sect2 xml:id="migration80.new-features.intl">
<title>Internationalization Functions</title>
<para>
The <constant>IntlDateFormatter::RELATIVE_FULL</constant>,
<constant>IntlDateFormatter::RELATIVE_LONG</constant>,
<constant>IntlDateFormatter::RELATIVE_MEDIUM</constant>, and
<constant>IntlDateFormatter::RELATIVE_SHORT</constant>
constants have been added.
</para>
</sect2>
<sect2 xml:id="migration80.new-features.ldap">
<title>LDAP</title>
<para>
<function>ldap_count_references</function> has been added, which returns the number
of reference messages in a search result.
</para>
</sect2>
<sect2 xml:id="migration80.new-features.opcache">
<title>OPcache</title>
<para>
If the <!--<link linkend="ini.opcache.record-warnings">-->opcache.record_warnings<!--</link>--> ini setting is
enabled, OPcache will record compile-time warnings and replay them on the next include, even if
it is served from cache.
</para>
</sect2>
<sect2 xml:id="migration80.new-features.openssl">
<title>OpenSSL</title>
<para>
Added Cryptographic Message Syntax (CMS) (<link xlink:href="&url.rfc;5652">RFC 5652</link>)
support composed of functions for encryption, decryption, signing, verifying and reading. The API
is similar to the API for PKCS #7 functions with an addition of new encoding constants:
<constant>OPENSSL_ENCODING_DER</constant>, <constant>OPENSSL_ENCODING_SMIME</constant>
and <constant>OPENSSL_ENCODING_PEM</constant>:
<simplelist>
<member>
<function>openssl_cms_encrypt</function> encrypts the message in the file with the certificates
and outputs the result to the supplied file.
</member>
<member>
<function>openssl_cms_decrypt</function> that decrypts the S/MIME message in the file and outputs
the results to the supplied file.
</member>
<member>
<function>openssl_cms_read</function> that exports the CMS file to an array of PEM certificates.
</member>
<member>
<function>openssl_cms_sign</function> that signs the MIME message in the file with a cert and key
and output the result to the supplied file.
</member>
<member>
<function>openssl_cms_verify</function> that verifies that the data block is intact, the signer
is who they say they are, and returns the certs of the signers.
</member>
</simplelist>
</para>
</sect2>
<sect2 xml:id="migration80.new-features.pcre">
<title>Regular Expressions (Perl-Compatible)</title>
<para>
<function>preg_last_error_msg</function> has been added, which returns a human-readable message for the last
PCRE error. It complements <function>preg_last_error</function>, which returns an integer enum value
instead.
</para>
</sect2>
<sect2 xml:id="migration80.new-features.reflection">
<title>Reflection</title>
<itemizedlist>
<listitem>
<para>
The following methods can now return information about default values of
parameters of internal functions:
</para>
<para>
<simplelist>
<member><methodname>ReflectionParameter::isDefaultValueAvailable</methodname></member>
<member><methodname>ReflectionParameter::getDefaultValue</methodname></member>
<member><methodname>ReflectionParameter::isDefaultValueConstant</methodname></member>
<member><methodname>ReflectionParameter::getDefaultValueConstantName</methodname></member>
</simplelist>
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.new-features.sqlite3">
<title>SQLite3</title>
<para>
<methodname>SQLite3::setAuthorizer</methodname> and respective class constants have been added
to set a userland callback that will be used to authorize or not an action on the database.
<!-- PR: https://github.com/php/php-src/pull/4797 -->
</para>
</sect2>
<sect2 xml:id="migration80.new-features.standard">
<title>Standard Library</title>
<itemizedlist>
<listitem>
<para>
<function>str_contains</function>, <function>str_starts_with</function> and
<function>str_ends_with</function> have been added, which check whether <parameter>haystack</parameter> contains,
starts with or ends with <parameter>needle</parameter>, respectively.
<!-- RFC: https://wiki.php.net/rfc/str_contains -->
<!-- RFC: https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions -->
</para>
</listitem>
<listitem>
<para>
<function>fdiv</function> has been added, which performs a floating-point division under IEEE 754 semantics.
Division by zero is considered well-defined and will return one of <literal>Inf</literal>,
<literal>-Inf</literal> or <literal>NaN</literal>.
</para>
</listitem>
<listitem>
<para>
<function>get_debug_type</function> has been added, which returns a type useful for error messages. Unlike
<function>gettype</function>, it uses canonical type names, returns class names for objects, and
indicates the resource type for resources.
<!-- RFC: https://wiki.php.net/rfc/get_debug_type -->
</para>
</listitem>
<listitem>
<para>
<function>printf</function> and friends now support the <literal>%h</literal> and
<literal>%H</literal> format specifiers. These are the same as <literal>%g</literal> and
<literal>%G</literal>, but always use <literal>"."</literal> as the decimal separator, rather
than determining it through the <constant>LC_NUMERIC</constant> locale.
</para>
</listitem>
<listitem>
<para>
<function>printf</function> and friends now support using <literal>"*"</literal> as width or
precision, in which case the width/precision is passed as an argument to printf. This also allows
using precision <literal>-1</literal> with <literal>%g</literal>, <literal>%G</literal>,
<literal>%h</literal> and <literal>%H</literal>. For example, the following code can be used to
reproduce PHP's default floating point formatting:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
printf("%.*H", (int) ini_get("precision"), $float);
printf("%.*H", (int) ini_get("serialize_precision"), $float);
?>
]]>
</programlisting>
</para>
</listitem>
<listitem>
<para>
<function>proc_open</function> now supports pseudo-terminal (PTY) descriptors. The following
attaches <literal>stdin</literal>, <literal>stdout</literal> and <literal>stderr</literal> to the
same PTY:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
$proc = proc_open($command, [['pty'], ['pty'], ['pty']], $pipes);
?>
]]>
</programlisting>
</para>
</listitem>
<listitem>
<para>
<function>proc_open</function> now supports socket pair descriptors. The following attaches a
distinct socket pair to <literal>stdin</literal>, <literal>stdout</literal> and
<literal>stderr</literal>:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
$proc = proc_open($command, [['socket'], ['socket'], ['socket']], $pipes);
?>
]]>
</programlisting>
</para>
<para>
Unlike pipes, sockets do not suffer from blocking I/O issues on Windows. However, not all
programs may work correctly with stdio sockets.
</para>
</listitem>
<listitem>
<para>
Sorting functions are now stable, which means that equal-comparing elements will retain their
original order.
<!-- RFC: https://wiki.php.net/rfc/stable_sorting -->
</para>
</listitem>
<listitem>
<para>
<function>array_diff</function>, <function>array_intersect</function> and their variations can
now be used with a single array as argument. This means that usages like the following are now
possible:
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
// OK even if $excludes is empty:
array_diff($array, ...$excludes);
// OK even if $arrays only contains a single array:
array_intersect(...$arrays);
?>
]]>
</programlisting>
</para>
</listitem>
<listitem>
<para>
The <parameter>flag</parameter> parameter of <function>ob_implicit_flush</function> was changed
to accept a <type>bool</type> rather than an <type>int</type>.
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.new-features.tokenizer">
<title>Tokenizer</title>
<para>
<classname>PhpToken</classname> adds an object-based interface to the tokenizer. It provides a
more uniform and ergonomic representation, while being more memory efficient and faster.
<!-- RFC: https://wiki.php.net/rfc/token_as_object -->
</para>
</sect2>
<sect2 xml:id="migration80.new-features.zip">
<title>Zip</title>
<itemizedlist>
<listitem>
<para>
The Zip extension has been updated to version 1.19.1.
</para>
</listitem>
<listitem>
<para>
New <methodname>ZipArchive::setMtimeName</methodname> and
<methodname>ZipArchive::setMtimeIndex</methodname> to set the modification time of an entry.
</para>
</listitem>
<listitem>
<para>
New <methodname>ZipArchive::setProgressCallback</methodname> to provide updates during archive close.
</para>
</listitem>
<listitem>
<para>
New <methodname>ZipArchive::setCancelCallback</methodname> to allow cancellation during archive
close.
</para>
</listitem>
<listitem>
<para>
New <methodname>ZipArchive::replaceFile</methodname> to replace an entry content.
</para>
</listitem>
<listitem>
<para>
New <methodname>ZipArchive::isCompressionMethodSupported</methodname> to check optional compression
features.
</para>
</listitem>
<listitem>
<para>
New <methodname>ZipArchive::isEncryptionMethodSupported</methodname> to check optional encryption
features.
</para>
</listitem>
<listitem>
<para>
The <varname>ZipArchive::lastId</varname> property to get the index value of
the last added entry has been added.
</para>
</listitem>
<listitem>
<para>
Errors can now be checked after an archive has been closed using the
<varname>ZipArchive::status</varname> and
<varname>ZipArchive::statusSys</varname> properties, or the
<methodname>ZipArchive::getStatusString</methodname> method.
</para>
</listitem>
<listitem>
<para>
The <literal>'remove_path'</literal> option of <methodname>ZipArchive::addGlob</methodname> and
<methodname>ZipArchive::addPattern</methodname> is now treated as an arbitrary string prefix (for
consistency with the <literal>'add_path'</literal> option), whereas formerly it was treated as a
directory name.
</para>
</listitem>
<listitem>
<para>
Optional compression / encryption features are now listed in phpinfo.
</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
-->

View file

@ -0,0 +1,323 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="migration80.other-changes" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Other Changes</title>
<sect2 xml:id="migration80.other-changes.sapi">
<title>Changes in SAPI Modules</title>
<sect3 xml:id="migration80.other-changes.sapi.apache2handler">
<title>Apache2Handler</title>
<para>
The PHP module has been renamed from <literal>php7_module</literal> to
<literal>php_module</literal>.
</para>
</sect3>
</sect2>
<sect2 xml:id="migration80.other-changes.functions">
<title>Changed Functions</title>
<sect3 xml:id="migration80.other-changes.functions.reflection">
<title>Reflection</title>
<para>
<methodname>ReflectionClass::getConstants</methodname> and
<methodname>ReflectionClass::getReflectionConstants</methodname> results can be now filtered via
a new parameter <parameter>filter</parameter>. Three new constants were added to be used with it:
</para>
<para>
<simplelist>
<member><constant>ReflectionClassConstant::IS_PUBLIC</constant></member>
<member><constant>ReflectionClassConstant::IS_PROTECTED</constant></member>
<member><constant>ReflectionClassConstant::IS_PRIVATE</constant></member>
</simplelist>
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.functions.zip">
<title>Zip</title>
<itemizedlist>
<listitem>
<para>
The <methodname>ZipArchive::addGlob</methodname> and
<methodname>ZipArchive::addPattern</methodname> methods accept more values in the
<parameter>options</parameter> array argument:
</para>
<para>
<simplelist>
<member><literal>flags</literal></member>
<member><literal>comp_method</literal></member>
<member><literal>comp_flags</literal></member>
<member><literal>env_method</literal></member>
<member><literal>enc_password</literal></member>
</simplelist>
</para>
</listitem>
<listitem>
<para>
<methodname>ZipArchive::addEmptyDir</methodname>, <methodname>ZipArchive::addFile</methodname>
and <methodname>ZipArchive::addFromString</methodname>
methods have a new <parameter>flags</parameter> argument. This allows managing name encoding
(<constant>ZipArchive::FL_ENC_*</constant>) and entry replacement
(<constant>ZipArchive::FL_OVERWRITE</constant>).
</para>
</listitem>
<listitem>
<para>
<methodname>ZipArchive::extractTo</methodname> now restores the file modification time.
</para>
</listitem>
</itemizedlist>
</sect3>
</sect2>
<sect2 xml:id="migration80.other-changes.extensions">
<title>Other Changes to Extensions</title>
<sect3 xml:id="migration80.other-changes.extensions.curl">
<title>CURL</title>
<itemizedlist>
<listitem>
<para>
The CURL extension now requires at least libcurl 7.29.0.
</para>
</listitem>
<listitem>
<para>
The deprecated parameter <parameter>version</parameter> of <function>curl_version</function> has
been removed.
</para>
</listitem>
</itemizedlist>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.date">
<title>Date and Time</title>
<para>
<classname>DatePeriod</classname> now implements <interfacename>IteratorAggregate</interfacename>
(instead of <interfacename>Traversable</interfacename>).
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.dom">
<title>DOM</title>
<para>
<classname>DOMNamedNodeMap</classname> and <classname>DOMNodeList</classname> now implement
<interfacename>IteratorAggregate</interfacename> (instead of
<interfacename>Traversable</interfacename>).
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.intl">
<title>Intl</title>
<para>
<classname>IntlBreakIterator</classname> and <classname>ResourceBundle</classname> now implement
<interfacename>IteratorAggregate</interfacename> (instead of <interfacename>Traversable</interfacename>).
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.enchant">
<title>Enchant</title>
<para>
The enchant extension now uses libenchant-2 by default when available. libenchant version 1 is
still supported but is deprecated and could be removed in the future.
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.gd">
<title>GD</title>
<itemizedlist>
<listitem>
<para>
The <parameter>num_points</parameter> parameter of <function>imagepolygon</function>,
<function>imageopenpolygon</function> and <function>imagefilledpolygon</function> is now
optional, i.e. these functions may be called with either 3 or 4 arguments. If the argument is
omitted, it is calculated as <code>count($points)/2</code>.
</para>
</listitem>
<listitem>
<para>
The function <function>imagegetinterpolation</function> to get the current interpolation method
has been added.
</para>
</listitem>
</itemizedlist>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.json">
<title>JSON</title>
<para>
The JSON extension cannot be disabled anymore and is always an integral part of any PHP build,
similar to the date extension.
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.mbstring">
<title>MBString</title>
<para>
The Unicode data tables have been updated to version 13.0.0.
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.pdo">
<title>PDO</title>
<para>
<classname>PDOStatement</classname> now implements
<interfacename>IteratorAggregate</interfacename> (instead of
<interfacename>Traversable</interfacename>).
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.libxml">
<title>LibXML</title>
<para>
The minimum required libxml version is now 2.9.0. This means that external entity loading is now
guaranteed to be disabled by default, and no extra steps need to be taken to protect against XXE
attacks.
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.mysqli">
<title>MySQLi / PDO MySQL</title>
<itemizedlist>
<listitem>
<para>
When mysqlnd is not used (which is the default and recommended option), the minimum supported
libmysqlclient version is now 5.5.
</para>
</listitem>
<listitem>
<para>
<classname>mysqli_result</classname> now implements
<interfacename>IteratorAggregate</interfacename> (instead of
<interfacename>Traversable</interfacename>).
</para>
</listitem>
</itemizedlist>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.pgsql">
<title>PGSQL / PDO PGSQL</title>
<para>
The PGSQL and PDO PGSQL extensions now require at least libpq 9.1.
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.readline">
<title>Readline</title>
<para>
Calling <function>readline_completion_function</function> before the interactive prompt starts
(e.g. in <link linkend="ini.auto-prepend-file">auto_prepend_file</link>) will now override the
default interactive prompt completion function. Previously,
<function>readline_completion_function</function> only worked when called after starting the
interactive prompt.
</para>
</sect3>
<sect3 xml:id="migration80.other-changes.extensions.simplexml">
<title>SimpleXML</title>
<para>
<classname>SimpleXMLElement</classname> now implements
<interfacename>RecursiveIterator</interfacename> and absorbed the functionality of
<classname>SimpleXMLIterator</classname>. <classname>SimpleXMLIterator</classname> is an empty
extension of <classname>SimpleXMLElement</classname>.
</para>
</sect3>
</sect2>
<sect2 xml:id="migration80.other-changes.ini">
<title>Changes to INI File Handling</title>
<itemizedlist>
<listitem>
<para>
<!--<link linkend="ini.com.dotnet-version">-->com.dotnet_version<!--</link>-->
is a new INI directive to choose the version of the .NET framework to use for
<classname>dotnet</classname> objects.
</para>
</listitem>
<listitem>
<para>
<!--<link linkend="ini.zend.exception-string-param-max-len">-->zend.exception_string_param_max_len<!--</link>-->
is a new INI directive to set the maximum string length in an argument of a stringified
stack strace.
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="migration80.other-changes.ebcdic">
<title>EBCDIC</title>
<para>
EBCDIC targets are no longer supported, though it's unlikely that they were still working in the
first place.
</para>
</sect2>
<sect2 xml:id="migration80.other-changes.performance">
<title>Performance</title>
<itemizedlist>
<listitem>
<para>
A Just-In-Time (JIT) compiler has been added to the opcache extension.
<!-- https://wiki.php.net/rfc/jit -->
</para>
</listitem>
<listitem>
<para>
<function>array_slice</function> on an array without gaps will no longer scan the whole array
to find the start offset. This may significantly reduce the runtime of the function with large
offsets and small lengths.
</para>
</listitem>
<listitem>
<para>
<function>strtolower</function> now uses a SIMD implementation when using the
<literal>"C"</literal> <constant>LC_CTYPE</constant> locale (which is the default).
</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
-->