New Features
PHP Core
Closure in constant expressions
Added support for Closures and
first class callables
in constant expressions. This includes:
- Attribute parameters.
- Default values of properties and parameters.
- Constants and Class Constants.
#[\NoDiscard] attribute
Added the NoDiscard attribute to indicate that a
function's return value is important and should be consumed.
Also, added the (void) cast to indicate that not using a value is intentional.
The (void) cast has no effect on the program's execution by itself, but
it can be used to suppress warnings emitted by #[\NoDiscard] and possibly
also diagnostics emitted by external IDEs or static analysis tools.
Attributes on Constants
Added support for attributes on compile-time non-class constants
(e.g. const MY_CONST = 1; rather than
define('MY_CONST', 1);).
The Deprecated attribute can now be used on constants.
#[\DelayedTargetValidation] attribute
The new DelayedTargetValidation attribute can be used
to suppress compile-time errors from core (or extension) attributes that are
used on invalid targets. These errors are instead reported at runtime if and
when ReflectionAttribute::newInstance() is called.
#[\Override] for properties
Override attribute can now be applied to properties.
Backtraces for Fatal Errors
Fatal Errors (such as an exceeded maximum execution time) now include a
backtrace.
Casts in constant expressions
Added support for casts in constant expressions.
Clone function
The clone language construct
is now a function and supports reassigning (readonly) properties during
cloning via the new $withProperties parameter.
cURL
Added support for
share handles
that are persisted across multiple PHP requests, safely allowing for
more effective connection reuse.
Added support for CURLINFO_USED_PROXY (libcurl >= 8.7.0),
CURLINFO_HTTPAUTH_USED,
and CURLINFO_PROXYAUTH_USED (libcurl >= 8.12.0)
to the curl_getinfo() function.
When curl_getinfo() returns an array, the same information
is available as "used_proxy",
"httpauth_used", and "proxyauth_used"
keys.
CURLINFO_USED_PROXY gets zero set if no proxy was used in the
previous transfer or a non-zero value if a proxy was used.
CURLINFO_HTTPAUTH_USED and
CURLINFO_PROXYAUTH_USED get bitmasks
indicating the HTTP and proxy authentication methods that were
used in the previous request.
See CURLAUTH_* constants for
possible values.
Added CURLOPT_INFILESIZE_LARGE Curl option, which is a safe
replacement for CURLOPT_INFILESIZE. On certain systems,
CURLOPT_INFILESIZE only accepts a 32-bit signed integer as
the file size (2.0 GiB) even on 64-bit systems.
CURLOPT_INFILESIZE_LARGE accepts the largest integer value
the system can handle.
Added CURLFOLLOW_OBEYCODE,
CURLFOLLOW_FIRSTONLY and CURLFOLLOW_ALL
values for CURLOPT_FOLLOWLOCATION
curl_setopt() option.
CURLFOLLOW_OBEYCODE to follow more strictly in regard to
redirect if they are allowed.
CURLFOLLOW_FIRSTONLY to follow only the first redirect thus
if there is any follow up redirect, it won't go any further.
CURLFOLLOW_ALL is equivalent to setting
CURLOPT_FOLLOWLOCATION to true.
Added support for CURLINFO_CONN_ID (libcurl >= 8.2.0)
to the curl_getinfo() function. This constant allows retrieving
the unique ID of the connection used by a cURL transfer. It is primarily
useful when connection reuse or connection pooling logic is needed in
PHP-level applications. When curl_getinfo() returns an array,
this value is available as the "conn_id" key.
Added support for CURLINFO_QUEUE_TIME_T (libcurl >= 8.6.0)
to the curl_getinfo() function. This constant allows
retrieving the time (in microseconds) that the request spent in libcurl’s
connection queue before it was sent.
This value can also be retrieved by passing
CURLINFO_QUEUE_TIME_T to the curl_getinfo()
option parameter.
Added support for CURLOPT_SSL_SIGNATURE_ALGORITHMS to
specify the signature algorithms to use for TLS.
EXIF
Added support for OffsetTime* Exif tags.
Added support for HEIF/HEIC.
Filter
Added new FILTER_THROW_ON_FAILURE flag which can be
passed to the filter functions and will force an exception to be triggered
when validation fails.
The new flag cannot be combined with
FILTER_NULL_ON_FAILURE; trying to do so will result
in a ValueError being thrown.
Standard
mail() now returns the actual sendmail error and detects
if the sendmail process was terminated unexpectedly.
In such cases, a warning is emitted and the function returns false.
Previously, these errors were silently ignored.
This change affects only the sendmail transport.
getimagesize() now supports HEIF/HEIC images.
getimagesize() now supports SVG images when ext-libxml
is also loaded.
Similarly, image_type_to_extension() and
image_type_to_mime_type()
now also handle IMAGETYPE_SVG.
The array returned by getimagesize() now has two additional entries:
"width_unit" and "height_unit" to indicate in
which units the dimensions are expressed. These units are px by default. They are not
necessarily the same (just to give one example: one may be cm and the other may be px).
setcookie() and setrawcookie() now support the
"partitioned" key.
URI
An always enabled uri extension is added that can be used for handling
URIs and URLs according to RFC 3986 and WHATWG URL.
Zlib
flock() is now supported on zlib streams. Previously,
this always failed to perform any locking action.