Backward Incompatible Changes
PHP Core
By-reference foreach after array compaction
By-reference foreach
loops may now visit previously
skipped elements after array compaction.
Internal pointers on deleted elements now move to the next surviving
element during copy-on-write.
Null coalescing and empty() on magic properties
?? and empty() on a magic property
no longer call __get() when
__isset() has materialized the
property by writing into the property table.
The freshly-written value is returned directly.
isset() applied directly to the property is unaffected;
nested forms such as isset($o->p['k']) follow the same
path as ??.
array_intersect() with at least two arrays now converts
values to strings while scanning its inputs instead of during sort
comparisons.
This can change the number and order of conversion warnings and
__toString() calls, which conversion
exception is reached, and the result for stateful
__toString() implementations.
Argument types are validated before checking for empty arrays or
converting values, so an invalid later argument can suppress conversion
side effects from earlier arrays.
Values are not converted if any input array is empty.
New errors for invalid arguments
The following functions now raise a
ValueError when an invalid flag or mode
value is passed:
The following functions now raise a
ValueError when the given argument contains
NUL bytes:
The following functions now raise a
ValueError for out-of-range values instead
of silently clamping them or allowing them to overflow:
-
number_format(), when
decimals
is outside the integer range.
-
sleep(), when
seconds is
greater than UINT_MAX, or
UINT_MAX / 1000 on Windows.
-
usleep(), when
microseconds is
greater than UINT_MAX.
linkinfo() now raises a
ValueError when the
path argument is empty.
setlocale() now raises a
ValueError when a locale name contains
NUL bytes, instead of silently truncating it.
Arrays are now accepted only for the locales
argument.
Passing an array as a later variadic locale argument now throws a
TypeError.
Passing any additional locale arguments when
locales is an array now throws an
ArgumentCountError.
The following functions now raise a
ValueError when the
filename argument contains NUL
bytes:
Endianness modifiers in unpack() format names
unpack() now reads a < or
> immediately following a format code as an
endianness modifier rather than as the first character of the element
name.
Formats such as "s<value" now produce the key
"value" instead of "<value", and
"C>name" raises a
ValueError because the C
format code accepts no endianness modifier.
A name starting with these characters is unaffected when a repeater
precedes it, as in "s1<value".
See also the
new
endianness modifiers.
COM
It is no longer possible to clone variant objects,
because the cloning behavior was ill-defined.
GMP
gmp_fact() now throws a
ValueError if num
does not fit into an unsigned long.
gmp_pow(), gmp_binomial(),
gmp_root() and gmp_rootrem() now
throw a ValueError if their second argument
does not fit into an unsigned long.
The shift (<<, >>) and
exponentiation (**) operators on
GMP objects now throw a
ValueError when GMP
right operands are outside the unsigned long range, instead of silently
truncating them.
GMP integer string parsing now throws a
ValueError for strings containing
NUL bytes, instead of silently truncating them.
The message of the DivisionByZeroError
raised by gmp_powm() on modulo by zero now includes the
function name and argument index (modulus).
MBString
Unicode data tables have been updated to Unicode 18.0.
PCRE
preg_grep() now returns false instead of a partial
array when a PCRE execution error occurs (e.g. malformed
UTF-8 input with
the u modifier).
This is consistent with the other preg_* functions.
PGSQL
When pg_fetch_object() is given a non-empty
constructor_args for a class without a constructor,
the ValueError now refers to the
constructor_args argument instead of
class.
Errors raised when the requested class is not instantiable (abstract,
interface, enum) now surface before the row is fetched.
Phar
Phar::mungServer() now raises a
ValueError when an invalid argument value
is passed instead of being silently ignored.
Phar::addEmptyDir() now rejects
"/.phar" paths in addition to ".phar"
paths, and raises the same
BadMethodCallException for attempts to
create the reserved magic ".phar" directory through
that form.
Non-magic names that merely share the ".phar" prefix
are now treated as ordinary directories.
Files are only automatically interpreted as Phar archives when included if
".phar" occurs as an extension in the filename component
of their paths.
Previously, it could occur in a directory name or as part of an extension
such as ".pharma".
Shmop
shmop_open() now raises a
ValueError when the
key argument is outside the platform's
key_t range instead of passing a truncated key to the
operating system.
SimpleXML
SimpleXMLElement::__construct() now raises a
ValueError when the
data argument contains NUL
bytes, matching simplexml_load_file().
With dataIsURL set, it previously truncated the
path at the first NUL byte.
Without it, the string went to libxml, which with default options rejects
a NUL on current versions but accepts the truncated
document on older ones and under LIBXML_RECOVER.
SOAP
The "classmap" option of
SoapClient and SoapServer
now rejects arrays containing integer keys.
Previously, sparse integer-keyed and mixed-keyed arrays could be accepted.
SoapClient now throws a
TypeError for non-array
"classmap" options and a
ValueError for arrays containing integer
keys, also when the "exceptions" option is disabled.
WSDL/XML Schema parsing now rejects out-of-range integer values for
occurrence constraints and integer restriction facets.
Negative minOccurs and maxOccurs
values are rejected as well.
SOAP encoding errors now report the affected type or failing operation in
the error message instead of the generic
Encoding: Violation of encoding rules
message.
Code that compares the exact message may need to be updated.
Sysvshm
shm_attach() now raises a
ValueError when the
key argument is outside the platform's
key_t range instead of passing a truncated key to the
operating system.