From 6f074320930da8400901a9bf139156e989a586ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=94=E7=8E=8B=E5=8D=B7=E5=AD=90?= Date: Thu, 19 Oct 2023 23:02:37 +0800 Subject: [PATCH] Update appendices --- appendices/migration82/incompatible.xml | 4 +- appendices/migration83.xml | 52 ++++ appendices/migration83/constants.xml | 338 +++++++++++++++++++++ appendices/migration83/deprecated.xml | 163 ++++++++++ appendices/migration83/incompatible.xml | 206 +++++++++++++ appendices/migration83/new-classes.xml | 40 +++ appendices/migration83/new-features.xml | 176 +++++++++++ appendices/migration83/new-functions.xml | 164 ++++++++++ appendices/migration83/windows-support.xml | 34 +++ language-snippets.ent | 8 +- 10 files changed, 1179 insertions(+), 6 deletions(-) create mode 100644 appendices/migration83.xml create mode 100644 appendices/migration83/constants.xml create mode 100644 appendices/migration83/deprecated.xml create mode 100644 appendices/migration83/incompatible.xml create mode 100644 appendices/migration83/new-classes.xml create mode 100644 appendices/migration83/new-features.xml create mode 100644 appendices/migration83/new-functions.xml create mode 100644 appendices/migration83/windows-support.xml diff --git a/appendices/migration82/incompatible.xml b/appendices/migration82/incompatible.xml index 72217eb21d..6ffe624212 100644 --- a/appendices/migration82/incompatible.xml +++ b/appendices/migration82/incompatible.xml @@ -1,5 +1,5 @@ - + 不向后兼容的变更 @@ -75,7 +75,7 @@ - var_export 不再省略导出类的开头斜线,也就是说,这些类现在完全合格。 + var_export 不再省略导出类的开头斜线,也就是说,这些类现在完全合格。 diff --git a/appendices/migration83.xml b/appendices/migration83.xml new file mode 100644 index 0000000000..222ba5bcb3 --- /dev/null +++ b/appendices/migration83.xml @@ -0,0 +1,52 @@ + + + + 从 PHP 8.2.x 移植到 PHP 8.3.x + + &appendices.migration83.new-features; + &appendices.migration83.new-classes; + &appendices.migration83.new-functions; + &appendices.migration83.constants; + &appendices.migration83.incompatible; + &appendices.migration83.deprecated; + &appendices.migration83.other-changes; + &appendices.migration83.windows-support; + + + + 新的次要版本带来了许多新功能和几个不兼容,在生产环境上切换 PHP 版本前需要做测试。 + + + + &manual.migration.seealso; + 7.1.x, + 7.2.x, + 7.3.x, + 7.4.x, + 8.0.x, + 8.1.x, + 8.2.x。 + + + + diff --git a/appendices/migration83/constants.xml b/appendices/migration83/constants.xml new file mode 100644 index 0000000000..43dcdecee2 --- /dev/null +++ b/appendices/migration83/constants.xml @@ -0,0 +1,338 @@ + + + + 新的全局常量 + + + cURL + + + + + CURLINFO_CAPATH (libcurl >= 7.84.0) + + + + + CURLINFO_CAINFO (libcurl >= 7.84.0) + + + + + CURLOPT_MIME_OPTIONS (libcurl >= 7.81.0) + + + + + CURLMIMEOPT_FORMESCAPE (libcurl >= 7.81.0) + + + + + CURLOPT_WS_OPTIONS (libcurl >= 7.86.0) + + + + + CURLWS_RAW_MODE (libcurl >= 7.86.0) + + + + + CURLOPT_SSH_HOSTKEYFUNCTION (libcurl >= 7.84.0) + + + + + CURLOPT_PROTOCOLS_STR (libcurl >= 7.85.0) + + + + + CURLOPT_REDIR_PROTOCOLS_STR (libcurl >= 7.85.0) + + + + + CURLOPT_CA_CACHE_TIMEOUT (libcurl >= 7.87.0) + + + + + CURLOPT_QUICK_EXIT (libcurl >= 7.87.0) + + + + + CURLKHMATCH_OK (libcurl >= 7.19.6) + + + + + CURLKHMATCH_MISMATCH (libcurl >= 7.19.6) + + + + + CURLKHMATCH_MISSING (libcurl >= 7.19.6) + + + + + CURLKHMATCH_LAST (libcurl >= 7.19.6) + + + + + + + Intl + + + + MIXED_NUMBERS + (Spoofchecker) + + + HIDDEN_OVERLAY + (Spoofchecker) + + + + + + OpenSSL + + + + OPENSSL_CMS_OLDMIMETYPE + + + PKCS7_NOOLDMIMETYPE + + + + + + PCNTL + + + + SIGINFO + + + + + + PDO_ODBC + + + + PDO_ODBC_TYPE + + + + + + Posix + + + + POSIX_SC_ARG_MAX + + + POSIX_SC_PAGESIZE + + + POSIX_SC_NPROCESSORS_CONF + + + POSIX_SC_NPROCESSORS_ONLN + + + POSIX_PC_LINK_MAX + + + POSIX_PC_MAX_CANON + + + POSIX_PC_MAX_INPUT + + + POSIX_PC_NAME_MAX + + + POSIX_PC_PATH_MAX + + + POSIX_PC_PIPE_BUF + + + POSIX_PC_CHOWN_RESTRICTED + + + POSIX_PC_NO_TRUNC + + + POSIX_PC_ALLOC_SIZE_MIN + + + POSIX_PC_SYMLINK_MAX + + + + + + Sockets + + + 如果已经支持,则已经定义下列 socket 选项: + + + + + SO_ATTACH_REUSEPORT_CBPF (Linux) + + + SO_DETACH_BPF (Linux) + + + SO_DETACH_FILTER (Linux) + + + TCP_QUICKACK (Linux) + + + IP_DONTFRAG (FreeBSD) + + + IP_MTU_DISCOVER (Linux) + + + IP_PMTUDISC_DO (Linux) + + + IP_PMTUDISC_DONT (Linux) + + + IP_PMTUDISC_WANT (Linux) + + + IP_PMTUDISC_PROBE (Linux) + + + IP_PMTUDISC_INTERFACE (Linux) + + + IP_PMTUDISC_OMIT (Linux) + + + AF_DIVERT (FreeBSD) + + + SOL_UDPLITE + + + UDPLITE_RECV_CSCOV + + + UDPLITE_SEND_CSCOV + + + + SO_RERROR (NetBSD) + + + SO_ZEROIZE (OpenBSD) + + + SO_SPLICE (OpenBSD) + + + TCP_REPAIR (Linux) + + + SO_REUSEPORT_LB (FreeBSD) + + + IP_BIND_ADDRESS_NO_PORT (Linux) + + + + + + Zip + + + + + ZipArchive::ER_DATA_LENGTH (libzip >= 1.10) + + + + + ZipArchive::ER_NOT_ALLOWED (libzip >= 1.10) + + + + + ZipArchive::AFL_RDONLY (libzip >= 1.10) + + + + + ZipArchive::AFL_IS_TORRENTZIP (libzip >= 1.10) + + + + + ZipArchive::AFL_WANT_TORRENTZIP (libzip >= 1.10) + + + + + ZipArchive::AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE + (libzip >= 1.10) + + + + + ZipArchive::FL_OPEN_FILE_NOW + + + + + ZipArchive::LENGTH_TO_END 是 + ZipArchive::addFile 和 + ZipArchive::replaceFile 的默认值 + + + + + ZipArchive::LENGTH_UNCHECKED (libzip >= 1.10) + + + + + + + diff --git a/appendices/migration83/deprecated.xml b/appendices/migration83/deprecated.xml new file mode 100644 index 0000000000..2edecb2f57 --- /dev/null +++ b/appendices/migration83/deprecated.xml @@ -0,0 +1,163 @@ + + + + 弃用功能 + + + PHP 核心 + + + 更健全的自增/自减运算符 + + + 现在已弃用在空、非数字和非字母数字字符串使用增量运算符(++)。此外,递增非数字字符串是软弃用。这意味着不会发出 + E_DEPRECATED 诊断,但创作新代码时不应使用此功能。应该使用新的 str_increment 函数。 + + + + 现在已对空字符串或非数字字符串使用减量运算符(--)。 + + + + + + 不带参数调用 get_class()/get_parent_class() + + + 现在已弃用不带参数调用 get_classget_parent_class。 + + + + + + DBA + + + 现在已弃用将 $dba 作为第三个参数调用 dba_fetch。 + + + + + FFI + + + 现在已弃用静态调用 FFI::castFFI::new + 和 FFI::type。 + + + + + Intl + + + 已弃用 U_MULTIPLE_DECIMAL_SEP*E*RATORS 常量,推荐使用 + U_MULTIPLE_DECIMAL_SEP*A*RATORS 常量替代。 + + + 已弃用 NumberFormatter::TYPE_CURRENCY 常量。 + + + + + LDAP + + + 已弃用使用单独的 $hostname$port 调用 ldap_connect。 + + + + + + MBString + + + 已弃用传递负 $width 给 + mb_strimwidth。 + + + + + Phar + + + 现在已弃用使用 $resource$length + 调用 Phar::setStub。这样的调用应该替换为 $phar->setStub(stream_get_contents($resource)); + + + + + Random + + + MT_RAND_PHP Mt19937 变种已弃用。 + + + + + + 反射 + + + 已弃用仅使用一个参数调用 ReflectionProperty::setValue。要设置静态属性,要将第一个参数设置为 &null;。 + + + + + 标准 + + + 现在已弃用 assert_options 函数。 + + + 已弃用 ASSERT_ACTIVEASSERT_BAILASSERT_CALLBACKASSERT_EXCEPTION + 和 ASSERT_WARNING 常量。 + + + + 已弃用 assert.* INI 设置。参阅 + INI 文件处理的变更页面获取更多信息。 + + + + + + SQLite3 + + + 现在首选使用异常,警告将在未来移除。调用 SQLite3::enableExceptions(false) + 将在此版本触发一个弃用警告。 + + + + + Zip + + + 已弃用 ZipArchive::FL_RECOMPRESS 常量,并将在 libzip + 的未来版本中移除。 + + + + + diff --git a/appendices/migration83/incompatible.xml b/appendices/migration83/incompatible.xml new file mode 100644 index 0000000000..a5970febe3 --- /dev/null +++ b/appendices/migration83/incompatible.xml @@ -0,0 +1,206 @@ + + + + 不向后兼容的变更 + + + PHP 核心 + + + + Programs that were very close to overflowing the call stack + + Programs that were very close to overflowing the call stack may now throw an + Error when using more than + zend.max_allowed_stack_size-zend.reserved_stack_size bytes of stack + (fiber.stack_size-zend.reserved_stack_size for fibers). + + + + + 多次执行 proc_get_status() + + 在 POSIX 系统上多次执行 proc_get_status 现在将始终返回正确的值。以前,函数只有在第一次调用时才会返回正确的值。proc_get_status + 之后执行 proc_close 现在也会返回正确的退出码。之前会返回 -1。 + 在内部,这是通过缓存 POSIX 系统的结果实现的。如果需要之前的行为,可以检测 proc_get_status + 返回数组中的 "cached" 键,以检查结果是否已经缓存。 + + + + + Zend Max Execution Timers + + 在 Linux 上, Zend Max Execution Timers 在 ZTS 编译中默认启用。 + + + + + Uses of traits with static properties + + 使用带静态属性的 trait 现在会重新声明从父类继承的静态属性。这将为当前类创建单独的静态属性存储。这与不使用 + trait 而将静态属性直接添加到当前类中类似。 + + + + + 赋值负数索引到空数组 + + 现在将负数索引 $n 赋值给空数组,将确保下一个索引为 $n+1 而不是 0。 + + + + + 类常量可见性差别检查 + + 从接口进行继承时,现在会正确的检查类常量的可见性差别。 + + + + + WeakMap entries whose key maps to itself + + WeakMap entries whose key maps to itself (possibly + transitively) may now be removed during cycle collection if the key is not + reachable except by iterating over the WeakMap (reachability via iteration is + considered weak). + Previously, such entries would never be automatically removed. + + + + + + Date + + + DateTime 扩展在 DateErrorDateException 层次结构下引入了特定于 + Date 扩展的 exception 和 error,而不是 warning 和通用 exception。这改善了错误处理,但需要检查 error 和 exception。 + + + + + DOM + + + 现在对于没有父节点的节点调用 DOMChildNode::afterDOMChildNode::before + 和 DOMChildNode::replaceWith 时不会有任何操作,不会抛出层级结构异常,这是 DOM 规范要求的行为。 + + + + 在没有文档的时候使用 DOMParentNodeDOMChildNode + 方法可以正常工作,而不会抛出 DOM_HIERARCHY_REQUEST_ERR + DOMException。这与 DOM 规范要求的行为一致。 + + + + 不带指定前缀就调用 DOMDocument::createAttributeNS + 将错误的创建默认命名空间,并将元素放入到命名空间而不是元素中。这个错误现在已经修复。 + + + + 当前缀已用于不同的 URI,DOMDocument::createAttributeNS 之前会错误的抛出 + DOM_NAMESPACE_ERRNAMESPACE_ERR + DOMException。现在当前缀名称存在冲突时,将会正确的选择不同前缀。 + + + + 为一些 DOM 类添加了新的方法和属性。如果用户空间类继承了这些类并声明了相同的属性和方法,则这些声明必须兼容。否则将会抛出典型的声明不兼容的编译错误。参阅新功能列表和新函数列表已获取新实现的方法和属性。 + + + + + FFI + + + 当 C 函数有 void 返回类型时,现在返回 &null;,而不是返回对象 object(FFI\CData:void) { } + + + + + Opcache + + + 移除了 opcache.consistency_checks INI 指令。此功能与 tracing JIT + 以及继承缓存不兼容,自 PHP 8.1.18 和 PHP 8.2.5 起,已禁用此功能,无法启用。脚本持久化后,因其检验和无效,导致 tracing JIT + 以及继承缓存会修改 shm。尝试修复可跳过的可修改指针,但由于复杂性而被拒绝。因此决定移除此功能。 + + + + + Phar + + + Phar 类常量的类型现在已声明。 + + + + + 标准 + + + range 函数已经进行了各种更改: + + 当传递 objectresourcearray 作为边界输入时,现在会抛出 TypeError + 当传递 0 作为 $step 时,现在会抛出更具描述性的 ValueError + 使用负数 $step 作为自增范围时现在会抛出 ValueError + 如果 $step 可以解释为整数的浮点数,那么现在就可以这样做。 + 如果任意参数是无穷大或者 NAN,现在会抛出 ValueError + 如果 $start$end 是空字符串,现在会触发 + E_WARNING。值将会转换为 0 + 如果 $start$end 超过 1 + 字节时,仅当其为非数字字符串时,现在会触发 E_WARNING + 如果 $start$end 因为其它边界输入是数字(例如 + range(5, 'z');)导致强制转换为整数,现在会触发 E_WARNING + 当尝试生成字符范围时,如果 $step 时浮点数,除非两个边界输入都是输字符串(例如 + range('5', '9', 0.5); 不会产生警告),否则会触发 E_WARNING + 如果其中一个边界是数字字符串,另一个边界输入不转换为数字(例如 range('9', 'A');),现在 + range 会生成字符列表。 + + + + +", "?", "@", "A"],自 PHP 8.3.0 起 +range('9', 'A'); // [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],PHP 8.3.0 之前 +?> +]]> + + + + + + file flags 错误检查现在可以捕获所有无效的 + flags。尤其是之前默默接受 FILE_APPEND。 + + + + + SNMP + + + SNMP 类常量的类型现在已声明。 + + + + + diff --git a/appendices/migration83/new-classes.xml b/appendices/migration83/new-classes.xml new file mode 100644 index 0000000000..b7f4ed21fe --- /dev/null +++ b/appendices/migration83/new-classes.xml @@ -0,0 +1,40 @@ + + + + + 新的类和接口 + + + Random + + + + + Random\IntervalBoundary + + + + + + + + diff --git a/appendices/migration83/new-features.xml b/appendices/migration83/new-features.xml new file mode 100644 index 0000000000..5029e72ef1 --- /dev/null +++ b/appendices/migration83/new-features.xml @@ -0,0 +1,176 @@ + + + + 新功能 + + + PHP 核心 + + + 只读修正 + + + 匿名类现在可以标记为 readonly。 + + + + 只读属性现在可以在克隆时重新初始化。 + + + + + + 类型化类常量 + + + 类、接口、trait 和 enum 常量现在支持类型声明。 + + + + + + 从魔术方法中创建的闭包 + + + 从魔术方法中创建的闭包现在接受命名参数。 + + + + + trait 中的方法使用 final 修饰符 + + + final 修饰符现在可以用于 trait 中的方法。 + + + + + Override 注解 + + + 新增 #[\Override] 注解用于检测方法是否在父类中存在或实现了接口。 + + + + + + 动态语法获取类常量 + + + 类常量现在可以使用 C::{$name} 语法动态访问。 + + + + + + Static variable Initializers + + + Static variable initializers can now contain arbitrary expressions. + + + + + + + + CLI + + + It is now possible to lint multiple files. + + + + + DOM + + + Added properties DOMElement::$className + and DOMElement::$id. + These are not binary-safe at the moment because of underlying limitations + of libxml2. + This means that the property values will be cut off at a NUL byte. + + + + Added properties DOMNode::$isConnected + and DOMNameSpaceNode::$isConnected. + + + + Added properties DOMNode::$parentElement + and DOMNameSpaceNode::$parentElement. + + + + + FFI + + + It is now possible to assign FFI\CData to other FFI\CData. + Meaning CData can now be assigned to structs and fields. + + + + + Opcache + + + opcache_get_status()['scripts'][n]['revalidate'] now contains + a Unix timestamp of when the next revalidation of the scripts timestamp is + due, dictated by the + opcache.revalidate_freq + INI directive. + + + + + POSIX + + + posix_getrlimit now takes an optional + $res parameter to allow fetching a single resource limit. + + + + posix_isatty now raises type warnings for integers + following the usual ZPP semantics. + + + + posix_ttyname now raises type warnings for integers + following the usual ZPP semantics and value warnings for invalid file + descriptor integers. + + + + + Streams + + + Streams can now emit the STREAM_NOTIFY_COMPLETED + notification. This was previously not implemented. + + + + + diff --git a/appendices/migration83/new-functions.xml b/appendices/migration83/new-functions.xml new file mode 100644 index 0000000000..44ee0d5fab --- /dev/null +++ b/appendices/migration83/new-functions.xml @@ -0,0 +1,164 @@ + + + + 新函数 + + + Date + + + DatePeriod::createFromISO8601String + + + + + DOM + + + DOMElement::getAttributeNames + + DOMElement::insertAdjacentElement + + DOMElement::insertAdjacentText + + DOMElement::toggleAttribute + + DOMNode::contains + + DOMNode::getRootNode + + DOMNode::isEqualNode + + DOMNameSpaceNode::contains + + DOMParentNode::replaceChildren + + + + + Intl + + + IntlCalendar::setDate + + IntlCalendar::setDateTime + + IntlGregorianCalendar::createFromDate + + IntlGregorianCalendar::createFromDateTime + + + + + JSON + + json_validate + + + + + + LDAP + + ldap_connect_wallet + ldap_exop_sync + + + + + MBString + + mb_str_pad + + + + + + Posix + + posix_sysconf + posix_pathconf + posix_fpathconf + posix_eaccess + + + + + PostgreSQL + + pg_set_error_context_visibility + (libpq >= 9.6) + pg_enter_pipeline_mode + pg_exit_pipeline_mode + pg_pipeline_sync + pg_pipeline_status + + + + + Random + + + + Random\Randomizer::getBytesFromString + + Random\Randomizer::nextFloat + + Random\Randomizer::getFloat + + + + + Reflection + + + ReflectionMethod::createFromMethodName + + + + + Sockets + + socket_atmark + + + + + Standard + + str_increment + str_decrement + + stream_context_set_options + + + + + Zip + + + ZipArchive::getArchiveFlag + + + + + diff --git a/appendices/migration83/windows-support.xml b/appendices/migration83/windows-support.xml new file mode 100644 index 0000000000..4cd30dd5e1 --- /dev/null +++ b/appendices/migration83/windows-support.xml @@ -0,0 +1,34 @@ + + + + Windows 支持 + + + 核心 + + + Windows 的最低支持版本已经升级到 Windows 8 或 Windows Server 2012 + + + + + diff --git a/language-snippets.ent b/language-snippets.ent index b18605d577..3ec898c91e 100644 --- a/language-snippets.ent +++ b/language-snippets.ent @@ -463,10 +463,10 @@ linkend="book.imap">IMAP,recode, 使用 SSL 时,Microsoft IIS -会违反协议不发送close_notify标记就关闭连接。PHP 会在到达数据尾端时报告“SSL: Fatal Protocol Error”。 -要解决此问题,error_reporting 应设定为降低级别至不包含警告。 -PHP 4.3.7 及更高版本可以在使用 https:// 包装器打开流时检测出有问题的 IIS 服务器软件 并抑制警告。在使用 -fsockopen 创建 ssl:// 套接字时, 开发者需检测并抑制此警告。'> +会违反协议不发送 close_notify 标记就关闭连接。PHP 会在到达数据尾端时报告“SSL: Fatal Protocol Error”。 +要解决此问题,error_reporting 应设定为降低级别至不包含警告。PHP +4.3.7 及更高版本可以在使用 https:// 包装器打开流时检测出有问题的 IIS 服务器软件 并抑制警告。在使用 +fsockopen 创建 ssl:// 套接字时,开发者需检测并抑制此警告。'>