其他变更
核心变更
现在 iterable 类型是内置编译时
array|Traversable
的别名。因此与 iterable
相关的错误消息现在将使用
array|Traversable
。类型反射将会保留单个 iterable
(和 ?iterable
)以生成名为 iterable
的
ReflectionNamedType,然而,在联合类型中使用 iterable
将会转换为 array|Traversable
。
发送 Cookie 的日期格式现在为 'D, d M Y H:i:s \G\M\T'
;
以前是 'D, d-M-Y H:i:s T'
。
SAPI 模块变更
CLI
STDOUT、STDERR 和 STDIN 流不会在资源销毁时关闭,而是在 CLI 销毁时关闭。但仍然可以使用 fclose() 和类似的方法显式关闭这些流。
函数变更
核心
strcmp()、strcasecmp()、strncmp()、strncasecmp()
和 substr_compare() 函数,使用二进制安全字符串比较,在字符串长度不想等时不再保证返回 strlen($string1) -
strlen($string2)
。但现在可能会返回 -1
或 1
。返回值不应依赖于任何具体值,而应与
0
进行比较。
DBA
dba_open() 和 dba_popen() 现在具有以下强制签名:
string
$path
,string
$mode
,?string
$handler
= null
,int
$permission
= 0644,int
$map_size
= 0,?int
$flags
= null
): resource|false
dba_fetch() 的可选 skip 参数现在位于末尾,符合 PHP 用户态语义。现在签名是:
重载签名: 仍可接受,但建议使用新的标准变体。Random
random_bytes() 和 random_int() 现在在 CSPRNG 失败时会抛出 \Random\RandomException。之前将抛出普通的 \Exception。
SPL
iterator_to_array() 和 iterator_count() 的
iterator
参数从 Iterator 扩展为
iterable,允许传递数组。
其它扩展变更
Date
DatePeriod 的属性现在已经正确声明。
Intl
IntlBreakIterator、IntlRuleBasedBreakIterator、IntlCodePointBreakIterator、 IntlPartsIterator、IntlCalendar、Collator、 IntlIterator、UConverter、IntlDateFormatter、 IntlDatePatternGenerator、MessageFormatter、ResourceBundle、 Spoofchecker、IntlTimeZone 和 Transliterator 的实例不再可序列化。之前可以对其序列化,但反序列化时会产生无效对象或者失败。
MySQLi
移除对 libmysql 的支持,不能再用 libmysql 编译 mysqli。从现在起,mysqli 扩展只能用 mysqlnd 编译。mysqlnd 中所有不能用的 libmysql 功能已被移除:
- mysqli_driver 的 reconnect 属性
- mysqli.reconnect INI 指令
- 弃用
MYSQLI_IS_MARIADB
常量
OCI8
Oracle Client 库最低版本现在是 11.2。
PCRE
现在模式字符串支持 NUL 字符(\0
)。
Session
当 Session 已经启用或者已经发送输出时,尝试更改 session.cookie_samesite INI 指令会失败且发出异常。该行为与所有其它 INI 设置保持一致。
SQLite3
标准
getimagesize() 现在报告 AVIF 图像的实际尺寸、位和通道。之前尺寸报告为 0x0,位和通道根本就不报告。
Tidy
tidy 类的属性现在已正确声明且为只读(readonly)。
Zip
Zip 扩展升级到版本 1.20.0,新增以下方法:
INI 文件处理更变
整数 INI 设置中新增对二进制(0b
/0B
)和八进制(0o
/0O
)的前缀支持。以
0
开头的整数 INI 设置将继续解释为八进制整数。
解析一些格式错误的值现在将抛出警告,以前会默默忽略。为了向后兼容,这些值的解释并没有改变。会影响以下设置:
- bcmath.scale
- com.code_page
- default_socket_timeout
- fiber.stack_size
- hard_timeout
- intl.error_level
- ldap.max_links
- max_input_nesting_level
- max_input_vars
- mbstring.regex_retry_limit
- mbstring.regex_stack_limit
- mysqli.allow_local_infile
- mysqli.allow_persistent
- mysqli.default_port
- mysqli.max_links
- mysqli.max_persistent
- mysqli.rollback_on_cached_plink
- mysqlnd.log_mask
- mysqlnd.mempool_default_size
- mysqlnd.net_read_buffer_size
- mysqlnd.net_read_timeout
- oci8.default_prefetch
- oci8.max_persistent
- oci8.persistent_timeout
- oci8.ping_interval
- oci8.prefetch_lob_size
- oci8.privileged_connect
- oci8.statement_cache_size
- odbc.allow_persistent
- odbc.check_persistent
- odbc.max_persistent
- odbc.max_links
- odbc.defaultbinmode
- odbc.default_cursortype
- odbc.defaultlrl
- opcache.consistency_checks
- opcache.file_update_protection
- opcache.force_restart_timeout
- opcache.interned_strings_buffer
- opcache.jit_bisect_limit
- opcache.jit_blacklist_root_trace
- opcache.jit_blacklist_side_trace
- opcache.jit_debug
- opcache.jit_hot_func
- opcache.jit_hot_loop
- opcache.jit_hot_return
- opcache.jit_hot_side_exit
- opcache.jit_max_exit_counters
- opcache.jit_max_loop_unrolls
- opcache.jit_max_polymorphic_calls
- opcache.jit_max_recursive_calls
- opcache.jit_max_recursive_returns
- opcache.jit_max_root_traces
- opcache.jit_max_side_traces
- opcache.log_verbosity_level
- opcache.max_file_size
- opcache.opt_debug_level
- opcache.optimization_level
- opcache.revalidate_freq
- output_buffering
- pcre.backtrack_limit
- pcre.recursion_limit
- pgsql.max_links
- pgsql.max_persistent
- post_max_size
- realpath_cache_size
- realpath_cache_ttl
- session.cache_expire
- session.cookie_lifetime
- session.gc_divisor
- session.gc_maxlifetime
- session.gc_probability
- soap.wsdl_cache_limit
- soap.wsdl_cache_ttl
- unserialize_max_depth
- upload_max_filesize
- user_ini.cache_ttl
- xmlrpc_error_number
- zend.assertions
- zlib.output_compression_level
用户贡献的备注
备份地址:http://www.lvesu.com/blog/php/migration82.other-changes.php