mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00
1711 lines
61 KiB
XML
1711 lines
61 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- $Revision$ -->
|
||
|
||
<sect1 xml:id="migration80.incompatible" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
<title>Backward Incompatible Changes</title>
|
||
|
||
<sect2 xml:id="migration80.incompatible.core">
|
||
<title>PHP Core</title>
|
||
|
||
<sect3 xml:id="migration80.incompatible.core.string-number-comparision">
|
||
<title>String to Number Comparison</title>
|
||
|
||
<para>
|
||
Non-strict comparisons between numbers and non-numeric strings now work by casting the number to
|
||
string and comparing the strings. Comparisons between numbers and numeric strings continue to
|
||
work as before. Notably, this means that <code>0 == "not-a-number"</code> is considered false
|
||
now.
|
||
<informaltable>
|
||
<tgroup cols="3">
|
||
<thead>
|
||
<row>
|
||
<entry>Comparison</entry>
|
||
<entry>Before</entry>
|
||
<entry>After</entry>
|
||
</row>
|
||
</thead>
|
||
<tbody>
|
||
<row>
|
||
<entry><code>0 == "0"</code></entry>
|
||
<entry>&true;</entry>
|
||
<entry>&true;</entry>
|
||
</row>
|
||
<row>
|
||
<entry><code>0 == "0.0"</code></entry>
|
||
<entry>&true;</entry>
|
||
<entry>&true;</entry>
|
||
</row>
|
||
<row>
|
||
<entry><code>0 == "foo"</code></entry>
|
||
<entry>&true;</entry>
|
||
<entry>&false;</entry>
|
||
</row>
|
||
<row>
|
||
<entry><code>0 == ""</code></entry>
|
||
<entry>&true;</entry>
|
||
<entry>&false;</entry>
|
||
</row>
|
||
<row>
|
||
<entry><code>42 == " 42"</code></entry>
|
||
<entry>&true;</entry>
|
||
<entry>&true;</entry>
|
||
</row>
|
||
<row>
|
||
<entry><code>42 == "42foo"</code></entry>
|
||
<entry>&true;</entry>
|
||
<entry>&false;</entry>
|
||
</row>
|
||
</tbody>
|
||
</tgroup>
|
||
</informaltable>
|
||
<!-- RFC: https://wiki.php.net/rfc/string_to_number_comparison -->
|
||
</para>
|
||
</sect3>
|
||
|
||
<sect3 xml:id="migration80.incompatible.core.other">
|
||
<title>Other incompatible Changes</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
<literal>match</literal> is now a reserved keyword.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<literal>mixed</literal> is now a reserved word, so it cannot be used to name a class, interface or trait, and is also prohibited from being used in namespaces.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Assertion failures now throw by default. If the old behavior is desired,
|
||
<code>assert.exception=0</code> can be set in the INI settings.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Methods with the same name as the class are no longer interpreted as constructors. The
|
||
<link linkend="object.construct">__construct()</link> method should be used instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The ability to call non-static methods statically has been removed. Thus
|
||
<function>is_callable</function> will fail when checking for a non-static method with a classname
|
||
(must check with an object instance).
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <code>(real)</code> and <code>(unset)</code> casts have been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <link linkend="ini.track-errors">track_errors</link> ini directive has been removed. This
|
||
means that <varname>php_errormsg</varname> is no longer available. The
|
||
<function>error_get_last</function> function may be used instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The ability to define case-insensitive constants has been removed. The third argument to
|
||
<function>define</function> may no longer be &true;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The ability to specify an autoloader using an <function>__autoload</function> function has been
|
||
removed. <function>spl_autoload_register</function> should be used instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>errcontext</parameter> argument will no longer be passed to custom error handlers
|
||
set with <function>set_error_handler</function>.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>create_function</function> has been removed. Anonymous functions may be used instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>each</function> has been removed. &foreach; or <classname>ArrayIterator</classname>
|
||
should be used instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The ability to unbind <varname>this</varname> from closures that were created from a method,
|
||
using <methodname>Closure::fromCallable</methodname> or
|
||
<methodname>ReflectionMethod::getClosure</methodname>, has been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The ability to unbind <varname>this</varname> from proper closures that contain uses of
|
||
<varname>this</varname> has also been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The ability to use <function>array_key_exists</function> with objects has been removed.
|
||
<function>isset</function> or <function>property_exists</function> may be used instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The behavior of <function>array_key_exists</function> regarding the type of the
|
||
<parameter>key</parameter> parameter has been made consistent with <function>isset</function> and
|
||
normal array access. All key types now use the usual coercions and array/object keys throw a
|
||
<classname>TypeError</classname>.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Any array that has a number <replaceable>n</replaceable> as its first numeric key will use
|
||
<replaceable>n+1</replaceable> for its next implicit key, even if <replaceable>n</replaceable> is
|
||
negative.
|
||
<!-- RFC: https://wiki.php.net/rfc/negative_array_index -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The default error_reporting level is now <constant>E_ALL</constant>. Previously it excluded
|
||
<constant>E_NOTICE</constant> and <constant>E_DEPRECATED</constant>.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<link linkend="ini.display-startup-errors">display_startup_errors</link> is now enabled by
|
||
default.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Using <type>parent</type> inside a class that has no parent will now result in a fatal
|
||
compile-time error.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <literal>@</literal> operator will no longer silence fatal errors
|
||
(<constant>E_ERROR</constant>, <constant>E_CORE_ERROR</constant>,
|
||
<constant>E_COMPILE_ERROR</constant>, <constant>E_USER_ERROR</constant>,
|
||
<constant>E_RECOVERABLE_ERROR</constant>, <constant>E_PARSE</constant>). Error handlers that
|
||
expect error_reporting to be <literal>0</literal> when <literal>@</literal> is used, should be
|
||
adjusted to use a mask check instead:
|
||
</para>
|
||
<para>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
// Replace
|
||
function my_error_handler($err_no, $err_msg, $filename, $linenum) {
|
||
if (error_reporting() == 0) {
|
||
return false;
|
||
}
|
||
// ...
|
||
}
|
||
|
||
// With
|
||
function my_error_handler($err_no, $err_msg, $filename, $linenum) {
|
||
if (!(error_reporting() & $err_no)) {
|
||
return false;
|
||
}
|
||
// ...
|
||
}
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</para>
|
||
<para>
|
||
Additionally, care should be taken that error messages are not displayed in production
|
||
environments, which can result in information leaks. Please ensure that
|
||
<code>display_errors=Off</code> is used in conjunction with error logging.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<literal>#[</literal> is no longer interpreted as the start of a comment,
|
||
as this syntax is now used for attributes.
|
||
<!-- RFC: https://wiki.php.net/rfc/shorter_attribute_syntax_change -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Inheritance errors due to incompatible method signatures (LSP violations) will now always
|
||
generate a fatal error. Previously a warning was generated in some cases.
|
||
<!-- RFC: https://wiki.php.net/rfc/lsp_errors -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The precedence of the concatenation operator has changed relative to bitshifts and addition as
|
||
well as subtraction.
|
||
</para>
|
||
<para>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
echo "Sum: " . $a + $b;
|
||
// was previously interpreted as:
|
||
echo ("Sum: " . $a) + $b;
|
||
// is now interpreted as:
|
||
echo "Sum:" . ($a + $b);
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
<!-- RFC: https://wiki.php.net/rfc/concatenation_precedence -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Arguments with a default value that resolves to &null; at runtime will no longer implicitly mark
|
||
the argument type as nullable. Either an explicit nullable type, or an explicit &null; default
|
||
value has to be used instead.
|
||
</para>
|
||
<para>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
// Replace
|
||
function test(int $arg = CONST_RESOLVING_TO_NULL) {}
|
||
// With
|
||
function test(?int $arg = CONST_RESOLVING_TO_NULL) {}
|
||
// Or
|
||
function test(int $arg = null) {}
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
A number of warnings have been converted into <classname>Error</classname> exceptions:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member>
|
||
Attempting to write to a property of a non-object. Previously this
|
||
implicitly created an stdClass object for null, false and empty strings.
|
||
</member>
|
||
<member>
|
||
Attempting to append an element to an array for which the PHP_INT_MAX key
|
||
is already used.
|
||
</member>
|
||
<member>
|
||
Attempting to use an invalid type (array or object) as an array key or
|
||
string offset.
|
||
</member>
|
||
<member>Attempting to write to an array index of a scalar value.</member>
|
||
<member>Attempting to unpack a non-array/Traversable.</member>
|
||
<member>
|
||
Attempting to access unqualified constants which are undefined.
|
||
Previously, unqualified constant accesses resulted in a warning and were interpreted as strings.
|
||
</member>
|
||
</simplelist>
|
||
</para>
|
||
<para>
|
||
A number of notices have been converted into warnings:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member>Attempting to read an undefined variable.</member>
|
||
<member>Attempting to read an undefined property.</member>
|
||
<member>Attempting to read an undefined array key.</member>
|
||
<member>Attempting to read a property of a non-object.</member>
|
||
<member>Attempting to access an array index of a non-array.</member>
|
||
<member>Attempting to convert an array to string.</member>
|
||
<member>Attempting to use a resource as an array key.</member>
|
||
<member>Attempting to use null, a boolean, or a float as a string offset.</member>
|
||
<member>Attempting to read an out-of-bounds string offset.</member>
|
||
<member>Attempting to assign an empty string to a string offset.</member>
|
||
</simplelist>
|
||
<!-- RFC: https://wiki.php.net/rfc/engine_warnings -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Attempting to assign multiple bytes to a string offset will now emit a warning.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Unexpected characters in source files (such as NUL bytes outside of strings) will now result in a
|
||
<classname>ParseError</classname> exception instead of a compile warning.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Uncaught exceptions now go through "clean shutdown", which means that destructors will be called
|
||
after an uncaught exception.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The compile time fatal error "Only variables can be passed by reference" has been delayed until
|
||
runtime, and converted into an "Argument cannot be passed by reference"
|
||
<classname>Error</classname> exception.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Some "Only variables should be passed by reference" notices have been converted to "Argument
|
||
cannot be passed by reference" exception.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The generated name for anonymous classes has changed. It will now include the name of the first
|
||
parent or interface:
|
||
</para>
|
||
<para>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
new class extends ParentClass {};
|
||
// -> ParentClass@anonymous
|
||
new class implements FirstInterface, SecondInterface {};
|
||
// -> FirstInterface@anonymous
|
||
new class {};
|
||
// -> class@anonymous
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</para>
|
||
<para>
|
||
The name shown above is still followed by a NUL byte and a unique suffix.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Non-absolute trait method references in trait alias adaptations are now required to be
|
||
unambiguous:
|
||
</para>
|
||
<para>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
class X {
|
||
use T1, T2 {
|
||
func as otherFunc;
|
||
}
|
||
function func() {}
|
||
}
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</para>
|
||
<para>
|
||
If both <code>T1::func()</code> and <code>T2::func()</code> exist, this code was previously
|
||
silently accepted, and func was assumed to refer to <code>T1::func</code>. Now it will generate a
|
||
fatal error instead, and either <code>T1::func</code> or <code>T2::func</code> needs to be
|
||
written explicitly.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The signature of abstract methods defined in traits is now checked against the implementing class
|
||
method:
|
||
</para>
|
||
<para>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
trait MyTrait {
|
||
abstract private function neededByTrait(): string;
|
||
}
|
||
|
||
class MyClass {
|
||
use MyTrait;
|
||
|
||
// Error, because of return type mismatch.
|
||
private function neededByTrait(): int { return 42; }
|
||
}
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
<!-- RFC: https://wiki.php.net/rfc/abstract_trait_method_validation -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Disabled functions are now treated exactly like non-existent functions. Calling a disabled
|
||
function will report it as unknown, and redefining a disabled function is now possible.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<literal>data://</literal> stream wrappers are no longer writable, which matches the documented
|
||
behavior.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The arithmetic and bitwise operators <literal>+</literal>, <literal>-</literal>,
|
||
<literal>*</literal>, <literal>/</literal>, <literal>**</literal>, <literal>%</literal>,
|
||
<literal><<</literal>, <literal>>></literal>, <literal>&</literal>,
|
||
<literal>|</literal>, <literal>^</literal>, <literal>~</literal>, <literal>++</literal>,
|
||
<literal>--</literal> will now consistently throw a <classname>TypeError</classname> when one of
|
||
the operands is an &array;, &resource; or non-overloaded &object;. The only exception to this is
|
||
the array <literal>+</literal> array merge operation, which remains supported.
|
||
<!-- RFC: https://wiki.php.net/rfc/arithmetic_operator_type_checks -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Float to string casting will now always behave locale-independently.
|
||
</para>
|
||
<para>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
setlocale(LC_ALL, "de_DE");
|
||
$f = 3.14;
|
||
echo $f, "\n";
|
||
// Previously: 3,14
|
||
// Now: 3.14
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</para>
|
||
<para>
|
||
See <function>printf</function>, <function>number_format</function> and
|
||
<methodname>NumberFormatter</methodname> for ways to customize number formatting.
|
||
<!-- RFC: https://wiki.php.net/rfc/locale_independent_float_to_string -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Support for deprecated curly braces for offset access has been removed.
|
||
</para>
|
||
<para>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
// Instead of:
|
||
$array{0};
|
||
$array{"key"};
|
||
// Write:
|
||
$array[0];
|
||
$array["key"];
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
<!-- RFC: https://wiki.php.net/rfc/deprecate_curly_braces_array_access -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Applying the final modifier on a private method will now produce a warning unless that method is
|
||
the constructor.
|
||
<!-- FC: https://wiki.php.net/rfc/inheritance_private_methods -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
If an object constructor <function>exit</function>s, the object destructor will no longer be
|
||
called. This matches the behavior when the constructor throws.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Namespaced names can no longer contain whitespace: While <code>Foo\Bar</code> will be recognized
|
||
as a namespaced name, <code>Foo \ Bar</code> will not. Conversely, reserved keywords are now
|
||
permitted as namespace segments, which may also change the interpretation of code:
|
||
<code>new\x</code> is now the same as <code>constant('new\x')</code>, not
|
||
<code>new \x()</code>.
|
||
<!-- RFC: https://wiki.php.net/rfc/namespaced_names_as_token -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Nested ternaries now require explicit parentheses.
|
||
<!-- RFC: https://wiki.php.net/rfc/ternary_associativity -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>debug_backtrace</function> and <methodname>Exception::getTrace</methodname> will no
|
||
longer provide references to arguments. It will not be possible to change function arguments
|
||
through the backtrace.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Numeric string handling has been altered to be more intuitive and less error-prone. Trailing
|
||
whitespace is now allowed in numeric strings for consistency with how leading whitespace is
|
||
treated. This mostly affects:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member>The <function>is_numeric</function> function</member>
|
||
<member>String-to-string comparisons</member>
|
||
<member>Type declarations</member>
|
||
<member>Increment and decrement operations</member>
|
||
</simplelist>
|
||
</para>
|
||
<para>
|
||
The concept of a "leading-numeric string" has been mostly dropped; the cases where this remains
|
||
exist in order to ease migration. Strings which emitted an <constant>E_NOTICE</constant> "A non
|
||
well-formed numeric value encountered" will now emit an <constant>E_WARNING</constant> "A
|
||
non-numeric value encountered" and all strings which emitted an <constant>E_WARNING</constant> "A
|
||
non-numeric value encountered" will now throw a
|
||
<classname>TypeError</classname>. This mostly affects:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member>Arithmetic operations</member>
|
||
<member>Bitwise operations</member>
|
||
</simplelist>
|
||
</para>
|
||
<para>
|
||
This <constant>E_WARNING</constant> to <classname>TypeError</classname> change also affects the
|
||
<constant>E_WARNING</constant> "Illegal string offset 'string'" for illegal string offsets. The
|
||
behavior of explicit casts to int/float from strings has not been changed.
|
||
<!-- RFC: https://wiki.php.net/rfc/saner-numeric-strings -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Magic Methods will now have their arguments and return types checked if they have them declared.
|
||
The signatures should match the following list:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><code>__call(string $name, array $arguments): mixed</code></member>
|
||
<member><code>__callStatic(string $name, array $arguments): mixed</code></member>
|
||
<member><code>__clone(): void</code></member>
|
||
<member><code>__debugInfo(): ?array</code></member>
|
||
<member><code>__get(string $name): mixed</code></member>
|
||
<member><code>__invoke(mixed $arguments): mixed</code></member>
|
||
<member><code>__isset(string $name): bool</code></member>
|
||
<member><code>__serialize(): array</code></member>
|
||
<member><code>__set(string $name, mixed $value): void</code></member>
|
||
<member><code>__set_state(array $properties): object</code></member>
|
||
<member><code>__sleep(): array</code></member>
|
||
<member><code>__unserialize(array $data): void</code></member>
|
||
<member><code>__unset(string $name): void</code></member>
|
||
<member><code>__wakeup(): void</code></member>
|
||
</simplelist>
|
||
<!-- RFC: https://wiki.php.net/rfc/magic-methods-signature -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>call_user_func_array</function> array keys will now be interpreted as parameter names,
|
||
instead of being silently ignored.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Declaring a function called <literal>assert()</literal> inside a namespace is
|
||
no longer allowed, and issues <constant>E_COMPILE_ERROR</constant>.
|
||
The <function>assert</function> function is subject to special handling by the engine,
|
||
which may lead to inconsistent behavior when defining a namespaced function with the same name.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect3>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.resource2object">
|
||
<title>Resource to Object Migration</title>
|
||
|
||
<para>
|
||
Several &resource;s have been migrated to &object;s.
|
||
Return value checks using <function>is_resource</function> should be replaced with checks for &false;.
|
||
</para>
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
<function>curl_init</function> will now return a <classname>CurlHandle</classname> object rather
|
||
than a &resource;. The <function>curl_close</function> function no longer has an effect,
|
||
instead the <classname>CurlHandle</classname> instance is automatically destroyed if it is no
|
||
longer referenced.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>curl_multi_init</function> will now return a <classname>CurlMultiHandle</classname>
|
||
object rather than a &resource;. The <function>curl_multi_close</function> function no
|
||
longer has an effect, instead the <classname>CurlMultiHandle</classname> instance is
|
||
automatically destroyed if it is no longer referenced.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>curl_share_init</function> will now return a <classname>CurlShareHandle</classname>
|
||
object rather than a &resource;. The <function>curl_share_close</function> function no
|
||
longer has an effect, instead the <classname>CurlShareHandle</classname> instance is
|
||
automatically destroyed if it is no longer referenced.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>enchant_broker_init</function> will now return an <classname>EnchantBroker</classname>
|
||
object rather than a &resource;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>enchant_broker_request_dict</function> and
|
||
<function>enchant_broker_request_pwl_dict</function> will now return an
|
||
<classname>EnchantDictionary</classname> object rather than a &resource;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The GD extension now uses <classname>GdImage</classname> objects as the underlying data structure
|
||
for images, rather than &resource;s.
|
||
The <function>imagedestroy</function> function no longer has an effect; instead the
|
||
<classname>GdImage</classname> instance is automatically destroyed if it is no longer referenced.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>openssl_x509_read</function> and <function>openssl_csr_sign</function> will now return
|
||
an <classname>OpenSSLCertificate</classname> object rather than a &resource;.
|
||
The <function>openssl_x509_free</function> function is deprecated and no longer has an effect,
|
||
instead the <classname>OpenSSLCertificate</classname> instance is automatically destroyed if it
|
||
is no longer referenced.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>openssl_csr_new</function> will now return an
|
||
<classname>OpenSSLCertificateSigningRequest</classname> object rather than a &resource;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>openssl_pkey_new</function> will now return an
|
||
<classname>OpenSSLAsymmetricKey</classname> object rather than a &resource;.
|
||
The <function>openssl_pkey_free</function> function is deprecated and no longer has an effect,
|
||
instead the <classname>OpenSSLAsymmetricKey</classname> instance is automatically destroyed if it
|
||
is no longer referenced.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>shmop_open</function> will now return a <classname>Shmop</classname> object rather than
|
||
a &resource;. The <function>shmop_close</function> function no longer has an effect, and is
|
||
deprecated; instead the <classname>Shmop</classname> instance is automatically destroyed if it is
|
||
no longer referenced.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>socket_create</function>, <function>socket_create_listen</function>,
|
||
<function>socket_accept</function>, <function>socket_import_stream</function>,
|
||
<function>socket_addrinfo_connect</function>, <function>socket_addrinfo_bind</function>, and
|
||
<function>socket_wsaprotocol_info_import</function> will now return a
|
||
<classname>Socket</classname> object rather than a &resource;.
|
||
<function>socket_addrinfo_lookup</function> will now return an array of
|
||
<classname>AddressInfo</classname> objects rather than &resource;s.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>msg_get_queue</function> will now return an <classname>SysvMessageQueue</classname>
|
||
object rather than a &resource;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>sem_get</function> will now return an <classname>SysvSemaphore</classname> object
|
||
rather than a &resource;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>shm_attach</function> will now return an <classname>SysvSharedMemory</classname> object
|
||
rather than a &resource;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>xml_parser_create</function> and <function>xml_parser_create_ns</function> will now
|
||
return an <classname>XMLParser</classname> object rather than a &resource;. The
|
||
<function>xml_parser_free</function> function no longer has an effect, instead the XMLParser
|
||
instance is automatically destroyed if it is no longer referenced.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <link linkend="book.xmlwriter">XMLWriter</link> functions now accept and return, respectively,
|
||
<classname>XMLWriter</classname> objects instead of &resource;s.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>inflate_init</function> will now return an <classname>InflateContext</classname> object
|
||
rather than a &resource;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>deflate_init</function> will now return a <classname>DeflateContext</classname> object
|
||
rather than a &resource;.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.com">
|
||
<title>COM and .Net (Windows)</title>
|
||
|
||
<para>
|
||
The ability to import case-insensitive constants from type libraries has been removed.
|
||
The second argument to <function>com_load_typelib</function> may no longer be false;
|
||
<link linkend="ini.com.autoregister-casesensitive">com.autoregister_casesensitive</link>
|
||
may no longer be disabled; case-insensitive markers in
|
||
<link linkend="ini.com.typelib-file">com.typelib_file</link> are ignored.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.curl">
|
||
<title>CURL</title>
|
||
|
||
<para>
|
||
<constant>CURLOPT_POSTFIELDS</constant> no longer accepts objects as arrays. To
|
||
interpret an object as an array, perform an explicit <code>(array)</code> cast. The
|
||
same applies to other options accepting arrays as well.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.datetime">
|
||
<title>Date and Time</title>
|
||
|
||
<para>
|
||
<function>mktime</function> and <function>gmmktime</function> now require at least one
|
||
argument. <function>time</function> can be used to get the current timestamp.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.dom">
|
||
<title>DOM</title>
|
||
|
||
<para>
|
||
Unimplemented classes from the DOM extension that had no behavior and contained test
|
||
data have been removed. These classes have also been removed in the latest version of
|
||
the DOM standard:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><classname>DOMNameList</classname></member>
|
||
<member><classname>DomImplementationList</classname></member>
|
||
<member><classname>DOMConfiguration</classname></member>
|
||
<member><classname>DomError</classname></member>
|
||
<member><classname>DomErrorHandler</classname></member>
|
||
<member><classname>DOMImplementationSource</classname></member>
|
||
<member><classname>DOMLocator</classname></member>
|
||
<member><classname>DOMUserDataHandler</classname></member>
|
||
<member><classname>DOMTypeInfo</classname></member>
|
||
<member><classname>DOMStringExtend</classname></member>
|
||
</simplelist>
|
||
</para>
|
||
<para>
|
||
Unimplemented methods from the DOM extension that had no behavior have been removed:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><methodname>DOMNamedNodeMap::setNamedItem</methodname></member>
|
||
<member><methodname>DOMNamedNodeMap::removeNamedItem</methodname></member>
|
||
<member><methodname>DOMNamedNodeMap::setNamedItemNS</methodname></member>
|
||
<member><methodname>DOMNamedNodeMap::removeNamedItemNS</methodname></member>
|
||
<member><methodname>DOMText::replaceWholeText</methodname></member>
|
||
<member><methodname>DOMNode::compareDocumentPosition</methodname></member>
|
||
<member><methodname>DOMNode::isEqualNode</methodname></member>
|
||
<member><methodname>DOMNode::getFeature</methodname></member>
|
||
<member><methodname>DOMNode::setUserData</methodname></member>
|
||
<member><methodname>DOMNode::getUserData</methodname></member>
|
||
<member><methodname>DOMDocument::renameNode</methodname></member>
|
||
</simplelist>
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.enchant">
|
||
<title>Enchant</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
<function>enchant_broker_list_dicts</function>, <function>enchant_broker_describe</function> and
|
||
<function>enchant_dict_suggest</function> will now return an empty array instead of &null;.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.exif">
|
||
<title>Exif</title>
|
||
|
||
<para>
|
||
<function>read_exif_data</function> has been removed; <function>exif_read_data</function>
|
||
should be used instead.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.filter">
|
||
<title>Filter</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The <constant>FILTER_FLAG_SCHEME_REQUIRED</constant> and
|
||
<constant>FILTER_FLAG_HOST_REQUIRED</constant> flags for the
|
||
<constant>FILTER_VALIDATE_URL</constant> filter have been removed. The <literal>scheme</literal>
|
||
and <literal>host</literal> are (and have been) always required.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <constant>INPUT_REQUEST</constant> and <constant>INPUT_SESSION</constant> source for
|
||
<function>filter_input</function> etc. have been removed. These were never implemented and their
|
||
use always generated a warning.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.gd">
|
||
<title>GD</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The deprecated function <function>image2wbmp</function> has been removed.
|
||
<!-- RFC: https://wiki.php.net/rfc/image2wbmp -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The deprecated functions <function>png2wbmp</function> and <function>jpeg2wbmp</function> have
|
||
been removed.
|
||
<!-- RFC: https://wiki.php.net/rfc/deprecate-png-jpeg-2wbmp -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The default <parameter>mode</parameter> parameter of <function>imagecropauto</function> no longer
|
||
accepts <literal>-1</literal>. <constant>IMG_CROP_DEFAULT</constant> should be used instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
On Windows, <filename>php_gd2.dll</filename> has been renamed to <filename>php_gd.dll</filename>.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.gmp">
|
||
<title>GMP</title>
|
||
|
||
<para>
|
||
<function>gmp_random</function> has been removed. One of <function>gmp_random_range</function> or
|
||
<function>gmp_random_bits</function> should be used instead.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.iconv">
|
||
<title>Iconv</title>
|
||
|
||
<para>
|
||
iconv implementations which do not properly set <varname>errno</varname> in case of errors are no
|
||
longer supported.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.imap">
|
||
<title>IMAP</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The unused <parameter>default_host</parameter> argument of <function>imap_headerinfo</function>
|
||
has been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <function>imap_header</function> function which is an alias of
|
||
<function>imap_headerinfo</function> has been removed.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.intl">
|
||
<title>Internationalization Functions</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The deprecated constant <constant>INTL_IDNA_VARIANT_2003</constant> has been removed.
|
||
<!-- RFC: https://wiki.php.net/rfc/deprecate-and-remove-intl_idna_variant_2003 -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The deprecated <constant>Normalizer::NONE</constant> constant has been removed.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.ldap">
|
||
<title>LDAP</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The deprecated functions <function>ldap_sort</function>,
|
||
<function>ldap_control_paged_result</function> and
|
||
<function>ldap_control_paged_result_response</function> have been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The interface of <function>ldap_set_rebind_proc</function> has changed; the
|
||
<parameter>callback</parameter> parameter does not accept empty strings anymore; &null; should be
|
||
used instead.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.mbstring">
|
||
<title>MBString</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The <link linkend="ini.mbstring.func-overload">mbstring.func_overload</link> directive has been
|
||
removed. The related <constant>MB_OVERLOAD_MAIL</constant>,
|
||
<constant>MB_OVERLOAD_STRING</constant>, and <constant>MB_OVERLOAD_REGEX</constant> constants
|
||
have also been removed. Finally, the <literal>"func_overload"</literal> and
|
||
<literal>"func_overload_list"</literal> entries in <function>mb_get_info</function> have been
|
||
removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>mb_parse_str</function> can no longer be used without specifying a result array.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
A number of deprecated mbregex aliases have been removed. See the following
|
||
list for which functions should be used instead:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><function>mbregex_encoding</function> → <function>mb_regex_encoding</function></member>
|
||
<member><function>mbereg</function> → <function>mb_ereg</function></member>
|
||
<member><function>mberegi</function> → <function>mb_eregi</function></member>
|
||
<member><function>mbereg_replace</function> → <function>mb_ereg_replace</function></member>
|
||
<member><function>mberegi_replace</function> → <function>mb_eregi_replace</function></member>
|
||
<member><function>mbsplit</function> → <function>mb_split</function></member>
|
||
<member><function>mbereg_match</function> → <function>mb_ereg_match</function></member>
|
||
<member><function>mbereg_search</function> → <function>mb_ereg_search</function></member>
|
||
<member><function>mbereg_search_pos</function> → <function>mb_ereg_search_pos</function></member>
|
||
<member><function>mbereg_search_regs</function> → <function>mb_ereg_search_regs</function></member>
|
||
<member><function>mbereg_search_init</function> → <function>mb_ereg_search_init</function></member>
|
||
<member><function>mbereg_search_getregs</function> → <function>mb_ereg_search_getregs</function></member>
|
||
<member><function>mbereg_search_getpos</function> → <function>mb_ereg_search_getpos</function></member>
|
||
<member><function>mbereg_search_setpos</function> → <function>mb_ereg_search_setpos</function></member>
|
||
</simplelist>
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <literal>e</literal> modifier for <function>mb_ereg_replace</function> has been removed.
|
||
<function>mb_ereg_replace_callback</function> should be used instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
A non-string pattern argument to <function>mb_ereg_replace</function> will now be interpreted as
|
||
a string instead of an ASCII codepoint. The previous behavior may be restored with an explicit
|
||
call to <function>chr</function>.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>needle</parameter> argument for <function>mb_strpos</function>,
|
||
<function>mb_strrpos</function>, <function>mb_stripos</function>,
|
||
<function>mb_strripos</function>, <function>mb_strstr</function>,
|
||
<function>mb_stristr</function>, <function>mb_strrchr</function> and
|
||
<function>mb_strrichr</function> can now be empty.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>is_hex</parameter> parameter, which was not used internally, has been removed from
|
||
<function>mb_decode_numericentity</function>.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The legacy behavior of passing the encoding as the third argument instead of an offset for the
|
||
<function>mb_strrpos</function> function has been removed; an explicit <literal>0</literal>
|
||
offset with the encoding should be provided as the fourth argument instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <literal>ISO_8859-*</literal> character encoding aliases have been replaced by
|
||
<literal>ISO8859-*</literal> aliases for better interoperability with the iconv extension. The
|
||
mbregex ISO 8859 aliases with underscores (<literal>ISO_8859_*</literal> and
|
||
<literal>ISO8859_*</literal>) have also been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>mb_ereg</function> and <function>mb_eregi</function> will now return boolean &true; on
|
||
a successful match. Previously they returned integer <literal>1</literal> if
|
||
<parameter>matches</parameter> was not passed, or <code>max(1, strlen($matches[0]))</code> if
|
||
<parameter>matches</parameter> was passed.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.oci8">
|
||
<title>OCI8</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The <classname>OCI-Lob</classname> class is now called <classname>OCILob</classname>, and the
|
||
<classname>OCI-Collection</classname> class is now called <classname>OCICollection</classname>
|
||
for name compliance enforced by PHP 8 arginfo type annotation tooling.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Several alias functions have been marked as deprecated.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>oci_internal_debug</function> and its alias <function>ociinternaldebug</function> have
|
||
been removed.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.odbc">
|
||
<title>ODBC</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
<function>odbc_connect</function> no longer reuses connections.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The unused <parameter>flags</parameter> parameter of <function>odbc_exec</function> has been
|
||
removed.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.openssl">
|
||
<title>OpenSSL</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
<function>openssl_seal</function> and <function>openssl_open</function> now require
|
||
<parameter>method</parameter> to be passed, as the previous default of <literal>"RC4"</literal>
|
||
is considered insecure.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.pcre">
|
||
<title>Regular Expressions (Perl-Compatible)</title>
|
||
|
||
<para>
|
||
When passing invalid escape sequences they are no longer interpreted as literals. This behavior
|
||
previously required the <literal>X</literal> modifier – which is now ignored.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.pdo">
|
||
<title>PHP Data Objects</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The default error handling mode has been changed from "silent" to "exceptions". See
|
||
<link linkend="pdo.error-handling">Errors and error handling</link> for details.
|
||
<!-- RFC: https://wiki.php.net/rfc/pdo_default_errmode -->
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The signatures of some PDO methods have changed:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><code>PDO::query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs)</code></member>
|
||
<member><code>PDOStatement::setFetchMode(int $mode, mixed ...$args)</code></member>
|
||
</simplelist>
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.pdo-odbc">
|
||
<title>PDO ODBC</title>
|
||
|
||
<para>
|
||
The &php.ini; directive
|
||
<link linkend="ini.pdo-odbc.db2-instance-name">pdo_odbc.db2_instance_name</link> has been
|
||
removed.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.pdo-mysql">
|
||
<title>PDO MySQL</title>
|
||
|
||
<para>
|
||
<methodname>PDO::inTransaction</methodname> now reports the actual transaction state of
|
||
the connection, rather than an approximation maintained by PDO. If a query that is
|
||
subject to "implicit commit" is executed, <methodname>PDO::inTransaction</methodname>
|
||
will subsequently return &false;, as a transaction is no longer active.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.pgsql">
|
||
<title>PostgreSQL</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The deprecated <function>pg_connect</function> syntax using multiple parameters instead of a
|
||
connection string is no longer supported.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The deprecated <function>pg_lo_import</function> and <function>pg_lo_export</function> signature
|
||
that passes the connection as the last argument is no longer supported. The connection should be
|
||
passed as first argument instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>pg_fetch_all</function> will now return an empty array instead of &false; for result
|
||
sets with zero rows.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.phar">
|
||
<title>Phar</title>
|
||
|
||
<para>
|
||
Metadata associated with a phar will no longer be automatically unserialized, to fix potential
|
||
security vulnerabilities due to object instantiation, autoloading, etc.
|
||
<!-- RFC: https://wiki.php.net/rfc/phar_stop_autoloading_metadata -->
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.reflection">
|
||
<title>Reflection</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The method signatures
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><code>ReflectionClass::newInstance($args)</code></member>
|
||
<member><code>ReflectionFunction::invoke($args)</code></member>
|
||
<member><code>ReflectionMethod::invoke($object, $args)</code></member>
|
||
</simplelist>
|
||
</para>
|
||
<para>
|
||
have been changed to:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><code>ReflectionClass::newInstance(...$args)</code></member>
|
||
<member><code>ReflectionFunction::invoke(...$args)</code></member>
|
||
<member><code>ReflectionMethod::invoke($object, ...$args)</code></member>
|
||
</simplelist>
|
||
</para>
|
||
<para>
|
||
Code that must be compatible with both PHP 7 and PHP 8 can use the following
|
||
signatures to be compatible with both versions:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><code>ReflectionClass::newInstance($arg = null, ...$args)</code></member>
|
||
<member><code>ReflectionFunction::invoke($arg = null, ...$args)</code></member>
|
||
<member><code>ReflectionMethod::invoke($object, $arg = null, ...$args)</code></member>
|
||
</simplelist>
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <methodname>ReflectionType::__toString</methodname> method will now return a complete debug
|
||
representation of the type, and is no longer deprecated. In particular the result will include a
|
||
nullability indicator for nullable types. The format of the return value is not stable and may
|
||
change between PHP versions.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Reflection export() methods have been removed.
|
||
Instead reflection objects can be cast to string.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<methodname>ReflectionMethod::isConstructor</methodname> and
|
||
<methodname>ReflectionMethod::isDestructor</methodname> now also return &true; for
|
||
<link linkend="object.construct">__construct()</link> and
|
||
<link linkend="object.destruct">__destruct()</link> methods of interfaces.
|
||
Previously, this would only be true for methods of classes and traits.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<methodname>ReflectionType::isBuiltin</methodname> method has been moved to
|
||
<classname>ReflectionNamedType</classname>. <classname>ReflectionUnionType</classname> does not
|
||
have it.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.sockets">
|
||
<title>Sockets</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The deprecated <constant>AI_IDN_ALLOW_UNASSIGNED</constant> and
|
||
<constant>AI_IDN_USE_STD3_ASCII_RULES</constant> <parameter>flags</parameter> for
|
||
<function>socket_addrinfo_lookup</function> have been removed.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.spl">
|
||
<title>Standard PHP Library (SPL)</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
<methodname>SplFileObject::fgetss</methodname> has been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<methodname>SplFileObject::seek</methodname> now always seeks to the beginning of the line.
|
||
Previously, positions <literal>>=1</literal> sought to the beginning of the next line.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<methodname>SplHeap::compare</methodname> now specifies a method signature. Inheriting classes
|
||
implementing this method will now have to use a compatible method signature.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<methodname>SplDoublyLinkedList::push</methodname>,
|
||
<methodname>SplDoublyLinkedList::unshift</methodname> and
|
||
<methodname>SplQueue::enqueue</methodname> now return <type>void</type> instead of &true;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>spl_autoload_register</function> will now always throw a
|
||
<classname>TypeError</classname> on invalid arguments, therefore the second argument
|
||
<parameter>do_throw</parameter> is ignored and a notice will be emitted if it is set to &false;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<classname>SplFixedArray</classname> is now an <interfacename>IteratorAggregate</interfacename>
|
||
and not an <interfacename>Iterator</interfacename>.
|
||
<methodname>SplFixedArray::rewind</methodname>, <methodname>SplFixedArray::current</methodname>,
|
||
<methodname>SplFixedArray::key</methodname>, <methodname>SplFixedArray::next</methodname>, and
|
||
<methodname>SplFixedArray::valid</methodname> have been removed. In their place,
|
||
<methodname>SplFixedArray::getIterator</methodname> has been added. Any code which uses explicit
|
||
iteration over SplFixedArray must now obtain an
|
||
<interfacename>Iterator</interfacename> through
|
||
<methodname>SplFixedArray::getIterator</methodname>. This means that
|
||
<classname>SplFixedArray</classname> is now safe to use in nested loops.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.standard">
|
||
<title>Standard Library</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
<function>assert</function> will no longer evaluate string arguments, instead they will be
|
||
treated like any other argument. <code>assert($a == $b)</code> should be used instead of
|
||
<code>assert('$a == $b')</code>. The <link
|
||
linkend="ini.assert.quiet-eval">assert.quiet_eval</link> ini directive and the
|
||
<constant>ASSERT_QUIET_EVAL</constant> constant have also been removed, as they would no longer
|
||
have any effect.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>parse_str</function> can no longer be used without specifying a result array.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <link linkend="filters.string.strip_tags">string.strip_tags</link> filter has been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>needle</parameter> argument of <function>strpos</function>,
|
||
<function>strrpos</function>, <function>stripos</function>, <function>strripos</function>,
|
||
<function>strstr</function>, <function>strchr</function>, <function>strrchr</function>, and
|
||
<function>stristr</function> will now always be interpreted as a string. Previously non-string
|
||
needles were interpreted as an ASCII code point. An explicit call to <function>chr</function> can
|
||
be used to restore the previous behavior.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>needle</parameter> argument for <function>strpos</function>,
|
||
<function>strrpos</function>, <function>stripos</function>, <function>strripos</function>,
|
||
<function>strstr</function>, <function>stristr</function> and <function>strrchr</function> can
|
||
now be empty.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>length</parameter> argument for <function>substr</function>,
|
||
<function>substr_count</function>, <function>substr_compare</function>, and
|
||
<function>iconv_substr</function> can now be &null;. &null; values will behave as if no length
|
||
argument was provided and will therefore return the remainder of the string instead of an empty
|
||
string.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>length</parameter> argument for <function>array_splice</function> can now be
|
||
&null;. &null; values will behave identically to omitting the argument, thus removing everything
|
||
from the <parameter>offset</parameter> to the end of the array.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>args</parameter> argument of <function>vsprintf</function>,
|
||
<function>vfprintf</function>, and <function>vprintf</function> must now be an array. Previously
|
||
any type was accepted.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <literal>'salt'</literal> option of <function>password_hash</function> is no longer
|
||
supported. If the <literal>'salt'</literal> option is used a warning is generated, the provided
|
||
salt is ignored, and a generated salt is used instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The <function>quotemeta</function> function will now return an empty string if an empty string
|
||
was passed. Previously &false; was returned.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The following functions have been removed:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><function>hebrevc</function></member>
|
||
<member><function>convert_cyr_string</function></member>
|
||
<member><function>money_format</function></member>
|
||
<member><function>ezmlm_hash</function></member>
|
||
<member><function>restore_include_path</function></member>
|
||
<member><function>get_magic_quotes_gpc</function></member>
|
||
<member><function>get_magic_quotes_runtime</function></member>
|
||
<member><function>fgetss</function></member>
|
||
</simplelist>
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<constant>FILTER_SANITIZE_MAGIC_QUOTES</constant> has been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Calling <function>implode</function> with parameters in a reverse order <code>($pieces,
|
||
$glue)</code> is no longer supported.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>parse_url</function> will now distinguish absent and empty queries and fragments:
|
||
</para>
|
||
<para>
|
||
<simplelist>
|
||
<member><code>http://example.com/foo → query = null, fragment = null</code></member>
|
||
<member><code>http://example.com/foo? → query = "", fragment = null</code></member>
|
||
<member><code>http://example.com/foo# → query = null, fragment = ""</code></member>
|
||
<member><code>http://example.com/foo?# → query = "", fragment = ""</code></member>
|
||
</simplelist>
|
||
Previously all cases resulted in query and fragment being &null;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>var_dump</function> and <function>debug_zval_dump</function> will now print
|
||
floating-point numbers using <link linkend="ini.serialize-precision">serialize_precision</link>
|
||
rather than <link linkend="ini.precision">precision</link>. In a default configuration, this
|
||
means that floating-point numbers are now printed with full accuracy by these debugging
|
||
functions.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
If the array returned by <link linkend="object.sleep">__sleep()</link> contains non-existing
|
||
properties, these are now silently ignored. Previously, such properties would have been
|
||
serialized as if they had the value &null;.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The default locale on startup is now always <literal>"C"</literal>. No locales are inherited from
|
||
the environment by default. Previously, <constant>LC_ALL</constant> was set to
|
||
<literal>"C"</literal>, while <constant>LC_CTYPE</constant> was inherited from the environment.
|
||
However, some functions did not respect the inherited locale without an explicit
|
||
<function>setlocale</function> call. An explicit <function>setlocale</function> call is now
|
||
always required if a locale component should be changed from the default.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The deprecated DES fallback in <function>crypt</function> has been removed. If an unknown salt
|
||
format is passed to <function>crypt</function>, the function will fail with <literal>*0</literal>
|
||
instead of falling back to a weak DES hash now.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Specifying out of range rounds for SHA256/SHA512 <function>crypt</function> will now fail with
|
||
<literal>*0</literal> instead of clamping to the closest limit. This matches glibc behavior.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The result of sorting functions may have changed, if the array contains elements that compare as
|
||
equal.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Any functions accepting callbacks that are not explicitly specified to accept parameters by
|
||
reference will now warn if a callback with reference parameters is used. Examples include
|
||
<function>array_filter</function> and <function>array_reduce</function>. This was already the
|
||
case for most, but not all, functions previously.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
The HTTP stream wrapper as used by functions like <function>file_get_contents</function>
|
||
now advertises HTTP/1.1 rather than HTTP/1.0 by default. This does not change the behavior of the
|
||
client, but may cause servers to respond differently. To retain the old behavior, set the
|
||
<literal>'protocol_version'</literal> stream context option, e.g.
|
||
</para>
|
||
<para>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
$ctx = stream_context_create(['http' => ['protocol_version' => '1.0']]);
|
||
echo file_get_contents('http://example.org', false, $ctx);
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Calling <function>crypt</function> without an explicit salt is no longer supported. If you would
|
||
like to produce a strong hash with an auto-generated salt, use
|
||
<function>password_hash</function> instead.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<function>substr</function>, <function>mb_substr</function>, <function>iconv_substr</function> and
|
||
<function>grapheme_substr</function> now consistently clamp out-of-bounds offsets to the string
|
||
boundary. Previously, &false; was returned instead of the empty string in some cases.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
On Windows, the program execution functions (<function>proc_open</function>, <function>exec</function>,
|
||
<function>popen</function> etc.) using the shell, now consistently execute <command>%comspec% /s
|
||
/c "$commandline"</command>, which has the same effect as executing
|
||
<command>$commandline</command> (without additional quotes).
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.sysvsem">
|
||
<title>Sysvsem</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>auto_release</parameter> parameter of <function>sem_get</function> was changed to
|
||
accept bool values rather than int.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.tidy">
|
||
<title>Tidy</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
The <parameter>use_include_path</parameter> parameter, which was not used internally, has been
|
||
removed from <function>tidy_repair_string</function>.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<methodname>tidy::repairString</methodname> and <methodname>tidy::repairFile</methodname> became
|
||
static methods.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.tokenizer">
|
||
<title>Tokenizer</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
<literal>T_COMMENT</literal> tokens will no longer include a trailing newline. The newline will
|
||
instead be part of a following <literal>T_WHITESPACE</literal> token. It should be noted that
|
||
<literal>T_COMMENT</literal> is not always followed by whitespace, it may also be followed by
|
||
<literal>T_CLOSE_TAG</literal> or end-of-file.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
Namespaced names are now represented using the <literal>T_NAME_QUALIFIED</literal>
|
||
(<code>Foo\Bar</code>), <literal>T_NAME_FULLY_QUALIFIED</literal> (<code>\Foo\Bar</code>) and
|
||
<literal>T_NAME_RELATIVE</literal> (<code>namespace\Foo\Bar</code>) tokens.
|
||
<literal>T_NS_SEPARATOR</literal> is only used for standalone namespace separators, and only
|
||
syntactially valid in conjunction with group use declarations.
|
||
<!-- RFC: https://wiki.php.net/rfc/namespaced_names_as_token -->
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.xmlreader">
|
||
<title>XMLReader</title>
|
||
|
||
<para>
|
||
<methodname>XMLReader::open</methodname> and <methodname>XMLReader::xml</methodname> are now
|
||
static methods. They can still be called as instance methods, but inheriting classes need to declare them
|
||
as static if they override these methods.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.xmlrpc">
|
||
<title>XML-RPC</title>
|
||
|
||
<para>
|
||
The XML-RPC extension has been moved to PECL and is no longer part of the PHP
|
||
distribution.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.zip">
|
||
<title>Zip</title>
|
||
|
||
<para>
|
||
<constant>ZipArchive::OPSYS_Z_CPM</constant> has been removed (this name was a typo). Use
|
||
<constant>ZipArchive::OPSYS_CPM</constant> instead.
|
||
</para>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.zlib">
|
||
<title>Zlib</title>
|
||
|
||
<itemizedlist>
|
||
<listitem>
|
||
<para>
|
||
<function>gzgetss</function> has been removed.
|
||
</para>
|
||
</listitem>
|
||
<listitem>
|
||
<para>
|
||
<link linkend="ini.zlib.output-compression">zlib.output_compression</link> is no longer
|
||
automatically disabled for <literal>Content-Type: image/*</literal>.
|
||
</para>
|
||
</listitem>
|
||
</itemizedlist>
|
||
</sect2>
|
||
|
||
<sect2 xml:id="migration80.incompatible.php-test-packs">
|
||
<title>Windows PHP Test Packs</title>
|
||
|
||
<para>
|
||
The test runner has been renamed from <filename>run-test.php</filename> to
|
||
<filename>run-tests.php</filename>, to match its name in php-src.
|
||
</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
|
||
-->
|