新增管道(|>)运算法.
<?php
$result = "Hello World" |> strlen(...);
print $result . PHP_EOL; // Prints "11"新增了 NoDiscard 注解,用于表示函数的返回值是重要的,应当使用它。
同时,新增 (void) 转换以表明不使用某个值是故意的。(void)
转换本身对程序执行没有任何影响,但可以用来抑制 #[\NoDiscard] 发出的警告,也可能用于消除外部
IDE 或静态分析工具发出的诊断信息。
<?php
#[\NoDiscard]
function concat(string $a, string $b): string {
return a + b;
}
// concat() 的返回值应要么被使用,要么通过在 xxx.php 中将其强制转换为 (void) 来有意忽略。
concat("a", "b");
// 不会发出警告,因为返回值已被赋值操作使用。
$results = concat("a", "b");
// 不会发出警告,因为使用了 (void) 转换。
(void)concat("a", "b");#[\DelayedTargetValidation] 注解新增的 DelayedTargetValidation 注解可用于抑制在无效目标上使用核心(或扩展)注解时产生的编译时错误。这些错误会在调用 ReflectionAttribute::newInstance() 时于运行时报告(如果需要)。
#[\Override]Override 注解现在可应用于属性。
新增对静态属性的非对称可见性支持。
Fatal Error(例如超出最大执行时间)现在包含回溯信息。
构造方法属性提升现在可以用于最终属性。
新增对常量表达式中类型转换的支持。
<?php
const T1 = (int) 0.3; // 之前:“Fatal error: Constant expression contains invalid operations”
print T1 . PHP_EOL; // 打印“0”clone 语言结构现在是函数,并通过新的 $withProperties 参数支持在克隆期间重新分配(只读)属性。
新增对多个 PHP 请求之间持久化的共享句柄的支持,从而安全地实现更高效的连接复用。
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.
Added support for OffsetTime* Exif tags.
Added support for HEIF/HEIC.
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.
Added class constants NumberFormatter::CURRENCY_ISO,
NumberFormatter::CURRENCY_PLURAL,
NumberFormatter::CASH_CURRENCY,
and NumberFormatter::CURRENCY_STANDARD
for various currency-related number formats.
Added Locale::addLikelySubtags() and Locale::minimizeSubtags() to handle likely tags on a given locale.
Added IntlListFormatter class to format, order,
and punctuate a list of items with a given locale,
IntlListFormatter::TYPE_AND,
IntlListFormatter::TYPE_OR,
IntlListFormatter::TYPE_UNITS operands and
IntlListFormatter::WIDTH_WIDE,
IntlListFormatter::WIDTH_SHORT and
IntlListFormatter::WIDTH_NARROW widths.
It is supported from icu 67.
Added class constant Pdo\Sqlite::ATTR_BUSY_STATEMENT.
Added class constants Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT,
Pdo\Sqlite::EXPLAIN_MODE_PREPARED,
Pdo\Sqlite::EXPLAIN_MODE_EXPLAIN,
Pdo\Sqlite::EXPLAIN_MODE_EXPLAIN_QUERY_PLAN.
Added Pdo\Sqlite::ATTR_TRANSACTION_MODE connection attribute
with possible values Pdo\Sqlite::TRANSACTION_MODE_DEFERRED,
Pdo\Sqlite::TRANSACTION_MODE_IMMEDIATE,
and Pdo\Sqlite::TRANSACTION_MODE_EXCLUSIVE,
allowing to configure the transaction mode to use when calling beginTransaction().
session_set_cookie_params(),
session_get_cookie_params(),
and session_start() now support partitioned cookies via the
"partitioned" key.
Enumeration cases are now dumped in SoapClient::__getTypes().
Added support for Soap 1.2 Reason Text xml:lang attribute.
The signature of SoapFault::__construct() and
SoapServer::fault() therefore
now have an optional $lang parameter.
This support solves compatibility with .NET SOAP clients.
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.
An always enabled uri extension is added that can be used for handling URIs and URLs according to RFC 3986 and WHATWG URL.
The $namespace argument of XSLTProcessor::getParameter(),
XSLTProcessor::setParameter() and
XSLTProcessor::removeParameter() now actually works
instead of being treated as empty.
This only works if the $name argument does not use Clark notation and is not a
QName because in those cases the namespace is taken from the namespace href or
prefix respectively.
flock() is now supported on zlib streams. Previously, this always failed to perform any locking action.