其他变更

核心变更

现在 iterable 类型是内置编译时 array|Traversable 的别名。因此与 iterable 相关的错误消息现在将使用 array|Traversable。类型反射将会保留单个 iterable (和 ?iterable)以生成名为 iterableReflectionNamedType,然而,在联合类型中使用 iterable 将会转换为 array|Traversable

SAPI 模块变更

CLI

The STDOUT, STDERR and STDIN streams are no longer closed on resource destruction which is mostly when the CLI finishes. It is however still possible to explicitly close those streams using fclose() and similar.

函数变更

核心

strcmp()strcasecmp()strncmp()strncasecmp()substr_compare() 函数,使用二进制安全字符串比较。现在返回 -101

DBA

dba_open()dba_popen() 现在具有以下强制签名:

dba_open(
    string $path,
    string $mode,
    ?string $handler = null,
    int $permission = 0644,
    int $map_size = 0,
    ?int $flags = null
): resource|false

dba_fetch() 的可选 skip 参数现在位于末尾,符合 PHP 用户态语义。现在签名是:

dba_fetch(string|array $key, resource $handle, int $skip): string|false
重载签名:
dba_fetch(string|array $key, int $skip, resource $handle): string|false
仍可接受,但建议使用新的标准变体。

Random

random_bytes()random_int() 现在在 CSPRNG 失败时会抛出 \Random\RandomException。之前将抛出普通的 \Exception

SPL

iterator_to_array()iterator_count()iterator 参数从 Iterator 扩展为 iterable,允许传递数组。

其它扩展变更

Date

DatePeriod 的属性现在已经正确声明。

Intl

IntlBreakIteratorIntlRuleBasedBreakIteratorIntlCodePointBreakIteratorIntlPartsIteratorIntlCalendarIntlCalendarCollatorIntlIteratorUConverterIntlDateFormatterIntlDatePatternGeneratorMessageFormatterResourceBundleSpoofcheckerIntlTimeZone, 和 Transliterator 的实例不再可序列化。之前可以对其序列化,但反序列化时会产生无效对象或者失败。

MySQLi

移除对 libmysql 的支持,不能再用 libmysql 编译 mysqli。从现在起,mysqli 扩展只能用 mysqlnd 编译。mysqlnd 中所有不能用的 libmysql 功能已被移除:

OCI8

Oracle Client 库最低版本现在是 11.2。

PCRE

现在模式字符串支持 NUL 字符(\0)。

Session

当 Session 已经启用或者已经发送输出时,尝试更改 session.cookie_samesite INI 指令会失败且发出异常。该行为与所有其它 INI 设置保持一致。

SQLite3

sqlite3.defensive 现在是 PHP_INI_USER

标准

getimagesize() 现在报告 AVIF 图像的实际尺寸、位和通道。之前尺寸报告为 0x0,位和通道根本就不报告。

Tidy

tidy 类的属性现在已正确声明且为只读(readonly)。

Zip

Zip 扩展升级到版本 1.20.0,新增以下方法:

INI 文件处理更变

整数 INI 设置中新增对二进制(0b/0B)和八进制(0o/0O)的前缀支持。以 0 开头的整数 INI 设置将继续解释为八进制整数。

解析一些格式错误的值现在将抛出警告,以前会默默忽略。为了向后兼容,这些值的解释并没有改变。会影响以下设置: