Backward Incompatible Changes
PHP Core
$GLOBALS Access Restrictions
Access to the $GLOBALS array is now subject to
a number of restrictions.
Read and write access to individual array elements like
$GLOBALS['var'] continues to work as-is.
Read-only access to the entire $GLOBALS array also
continues to be supported.
However, write access to the entire $GLOBALS array
is no longer supported. For example, array_pop($GLOBALS)
will result in an error.
Usage of static Variables in Inherited Methods
When a method using static variables is inherited (but not overridden), the
inherited method will now share static variables with the parent method.
This means that static variables in methods now behave the same way as
static properties.
Optional parameters specified before required parameters
An optional parameter
specified before required parameters is now always treated as required,
even when called using
named arguments.
As of PHP 8.0.0, but prior to PHP 8.1.0, the below emits a deprecation notice
on the definition, but runs successfully when called. As of PHP 8.1.0, an error
of class ArgumentCountError is thrown, as it would be when
called with positional arguments.
Note that a default value of null can be used before required parameters to
specify a nullable type,
but the parameter will still be required.
Return Type Compatibility with Internal Classes
Most non-final internal methods now require overriding methods to declare
a compatible return type, otherwise a deprecated notice is emitted during
inheritance validation.
In case the return type cannot be declared for an overriding method due to
PHP cross-version compatibility concerns,
a ReturnTypeWillChange attribute can be added to silence
the deprecation notice.
New Keywords
readonly is a keyword now. However, it still may be used
as function name.
never 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.
MySQLnd
The mysqlnd.fetch_data_copy
INI directive has been removed.
This should not result in user-visible behavior changes.
OpenSSL
EC private keys will now be exported in PKCS#8 format rather than
traditional format, just like all other keys.
openssl_pkcs7_encrypt() and
openssl_cms_encrypt() will now default to using
AES-128-CBC rather than RC2-40. The RC2-40 cipher is considered
insecure and not enabled by default by OpenSSL 3.
PHP Data Objects
PDO::ATTR_STRINGIFY_FETCHES now stringifies values
of type bool to "0" or
"1". Previously bools were not stringified.
Calling PDOStatement::bindColumn() with
PDO::PARAM_LOB will now constantly bind a stream
result when PDO::ATTR_STRINGIFY_FETCHES is not enabled.
Previously, the result would either be a stream or a string depending on
the used database driver and the time the binding is performed.
MySQL Driver
Integers and floats in result sets will now be returned using native
PHP types instead of strings when using emulated prepared statements.
This matches the behavior of native prepared statements.
The previous behaviour can be restored by enabling the
PDO::ATTR_STRINGIFY_FETCHES option.
SQLite Driver
Integers and floats in results sets will now be returned using native
PHP types.
The previous behaviour can be restored by enabling the
PDO::ATTR_STRINGIFY_FETCHES option.