PHP Conference Fukuoka 2025

不向后兼容的变更

Date

DateTime::createFromImmutable() 返回类型暂定为 static,之前是 DateTime

DateTimeImmutable::createFromMutable() 返回类型暂定为 static,之前是 DateTimeImmutable

相对格式number 符号不再接受多个符号,比如 +-2

ODBC

ODBC 扩展对于 connection 字符串和 username/password 一起传递时,会对 username 和 password 进行转义,并将其追加。之前,包含需要转义的用户值可能会创建格式错误的 connection 字符串,或从用户提供的数据中注入值。转义规则应与 .NET BCL DbConnectionOptions 的行为相同。

PDO_ODBC

当传递连接字符串时,PDO_ODBC 扩展也会转义用户名和密码。参阅 ODBC 扩展的更改获取更多相信信息。

标准

如果所有路径都受到 open_basedir 限制,现在 glob() 会返回空 array。此外,即便只有一些路径受到 open_basedir 限制,也会发出警告。

FilesystemIterator::__construct():在 PHP 8.2.0 之前,FilesystemIterator::SKIP_DOTS 常量始终设置且无法禁用。当使用 flags 参数时,为了保持之前的行为,常量必须显式设置。flags 参数的默认值并未修改。

strtolower()strtoupper()stristr()stripos()strripos()lcfirst()ucfirst()ucwords()str_ireplace() 不再对区域设置敏感。现在执行 ASCII 大小写转换,就好像区域设置是“C”一样。这些函数的本地化版本在 MBString 扩展 可以使用。此外 array_change_key_case() 使用 SORT_FLAG_CASE 排序现在也是用 ASCII 大小写转换。

str_split() 现在 string 将返回空 array。之前会返回带有一个空字符串条目的数组。mb_str_split() 不受更改的影响,因为它的行为就是如此。

ksort()krsort() 现在使用 PHP 8 标准规则在 SORT_REGULAR 下进行数字字符串比较。

var_export() 不再省略导出类的开头斜线,也就是说,这些类现在完全合格。

PHP 标准库(SPL)

下列方法现在强制执行其签名:

SplFileObject::hasChildren() 返回类型暂定为 false,之前是 bool

SplFileObject::getChildren() 返回类型暂定为 null,之前是 ?RecursiveIterator

如果所有路径都受到 open_basedir 的影响,GlobIterator 现在将返回空 array。之前返回 false。此外,即使只有一些路径受 open_basedir 限制,现在也会发出警告。

添加备注

用户贡献的备注 1 note

up
1
al dot turani at gmail dot com
20 days ago
Another backward incompatible change, not mentioned in the docs, is that function `date_default_timezone_get()` no longer returns current time zone.

Prior to 8.2, this function returned:
- Time zone set by `date_default_timezone_set()` (if set).
- Time zone specified in `date.timezone` (if set).
- Current time zone, if none of above applies.

From 8.2 onward, if neither of the first two variants applies, this function returns UTC. This breaks scenarios where current time zone shall be used.

See <https://github.com/php/php-src/issues/11496> for discussion.
To Top