PHP 8.7 UPGRADE NOTES 1. Backward Incompatible Changes 2. New Features 3. Changes in SAPI modules 4. Deprecated Functionality 5. Changed Functions 6. New Functions 7. New Classes and Interfaces 8. Removed Extensions and SAPIs 9. Other Changes to Extensions 10. New Global Constants 11. Changes to INI File Handling 12. Windows Support 13. Other Changes 14. Performance Improvements ======================================== 1. Backward Incompatible Changes ======================================== - Core: . Block declaration support for the encoding declare has been removed as it did not function properly. . Float to string conversion no longer leaves a trailing zero when rounding an exact tie down: sprintf('%.3G', 370500.0) now returns "3.7E+5". - Curl: . curl_multi_exec() now throws a TypeError when $still_running cannot be converted to an int. . Nested arrays in CURLOPT_POSTFIELDS now throw a TypeError, instead of being silently converted to the string "Array". . Negative values for CURLOPT_POSTREDIR are now rejected, making curl_setopt() return false, instead of being silently interpreted as a combination of redirect types. - DOM: . While DOMXPath or Dom\XPath evaluates an expression with PHP functions registered, the nodes it can reach are read-only: the tree of the evaluated document, the tree of every node a php:function() callback returned, and the detached subtree of the context node or of a node passed to a callback. Modifying such a node throws a DOMException with code DOM_NO_MODIFICATION_ALLOWED_ERR (a warning when strictErrorChecking is disabled), and modifying it through SimpleXML throws an Error. Creating and modifying new nodes and setting document properties such as formatOutput or documentURI are still allowed. Transforming the evaluated document with XSLTProcessor throws the same exception, unless the processor copies the document (cloneDocument set to true before importStylesheet() is called). - Intl: . UConverter::setSubstChars() now rejects substitution strings longer than 127 bytes. Previously, the length could be truncated and only a prefix of the string used for substitution. - PDO: . PDOStatement::bindColumn() now throws a ValueError when the column name is not present in the result set. It previously reported the condition through PDO::ATTR_ERRMODE and returned false. - Reflection: . The public $name and $class properties of ReflectionClass, ReflectionClassConstant, ReflectionProperty, ReflectionMethod, ReflectionFunctionAbstract, ReflectionParameter, ReflectionExtension, ReflectionZendExtension, ReflectionAttribute and ReflectionConstant are now readonly. - SOAP: . SoapClient no longer follows an HTTP redirect to a different origin (scheme, host, or port) and throws a SoapFault instead. Previously the request body and the configured credentials and headers were resent to the new origin. A redirect from http to https on the same host is still followed. Set the new follow_cross_origin_redirects option to true to restore the previous behavior. - Session: . Setting session.cookie_path to a value containing one of ";\r\n", or session.cookie_domain to a value containing one of ",; \t\r\n\013\014", now emits a warning and leaves the setting unchanged. Previously such a value was appended to the Set-Cookie header verbatim, which let an application terminate one attribute and append further ones. - Standard: . ini_get_all() now matches extension names case-insensitively using ASCII rules, independently of the current locale. Names that differ only in capitalization from a loaded extension now succeed instead of emitting a warning and returning false. RFC: https://wiki.php.net/rfc/case_insensitive_ini_get_all . bindec(), octdec(), hexdec() and base_convert() now throw an Exception when the passed string contains characters that are invalid for the specified number base. . The number of filters that can be chained in a php://filter URL is limited to 16 by default. Set the stream context option max_filter_count to change this. ======================================== 2. New Features ======================================== - Core: . The "Unknown named parameter" error now includes the declared name when the supplied name has a unique ASCII case-insensitive match and the matching parameter has yet to receive an argument. - Curl: . Multiple files can now be uploaded with the same field name by passing an array of CURLFile or CURLStringFile objects to CURLOPT_POSTFIELDS. . Support for upstream options CURLOPT_ECH, CURLOPT_HAPROXY_CLIENT_IP, and CURLOPT_SERVER_RESPONSE_TIMEOUT_MS. - Intl: . Added IntlRelativeDateTimeFormatter to format relative date and time offsets using locale-specific text, such as "yesterday" or "in 3 days". Its format() method uses a textual form when available and a numeric form otherwise, while formatNumeric() always uses a numeric form. combineDateAndTime() combines already formatted date and time strings according to the locale. The constructor accepts an optional NumberFormatter to customize numeric output; subsequent configuration changes to that object are reflected in formatting results. Styles, capitalization contexts, and units are selected using the IntlRelativeDateTimeFormatterStyle, IntlRelativeDateTimeFormatterCapitalization, and IntlRelativeDateTimeFormatterUnit enums, respectively. RFC: https://wiki.php.net/rfc/reldateformatter . Locale::acceptFromHttp() and locale_accept_from_http() now accept an optional $availableLocales array argument. When given, the Accept-Language header is matched against these locales instead of all locales known to ICU, and the matching entry is returned as passed. A ValueError is thrown if the array is empty or contains an invalid locale, and a TypeError if it contains a non-string value. - Streams: . The so_linger, so_rcvbuf and so_sndbuf stream socket context options are now also applied to unix and unix datagram sockets. ======================================== 3. Changes in SAPI modules ======================================== ======================================== 4. Deprecated Functionality ======================================== ======================================== 5. Changed Functions ======================================== - Sockets: . socket_accept() now records a failure on the listening socket, so that socket_last_error($socket) and socket_clear_error($socket) see it. - Standard: . stream_select() no longer fails once a watched descriptor exceeds FD_SETSIZE. The descriptor set now grows on demand on both POSIX (bitset) and Windows (winsock fd_set), so code watching many streams works without rebuilding PHP with --enable-fd-setsize. On Windows, selecting on more than 64 pipe or file handles no longer crashes; it fails with a warning, as that path remains bounded by WaitForMultipleObjects(). ======================================== 6. New Functions ======================================== - Intl: . Added Transliterator::toRules() and transliterator_to_rules() to export rules that can be used to recreate a transliterator. The optional $escapeUnprintable argument escapes unprintable characters when true. . Added Collator::getRules() and collator_get_rules() to retrieve collation tailoring rules as a UTF-8 string. These describe locale-specific adjustments to the root collation order; the full root/UCA rules are not included. An empty string is returned if no tailoring rules are available, or false if the rules cannot be converted to UTF-8. . Added IntlNumberFormatter::toSkeleton() to export the formatter settings as a normalized, locale-independent ICU number skeleton. . Added Spoofchecker::getChecks() to retrieve the enabled checks as a bitmask. . Added Spoofchecker::getAllowedLocales() to retrieve the configured locale list. . Added Spoofchecker::getRestrictionLevel() to retrieve the configured restriction level as one of the Spoofchecker restriction level constants. . Added grapheme_str_pad() to pad a string to a length counted in grapheme clusters, the grapheme counterpart of str_pad() and mb_str_pad(). RFC: https://wiki.php.net/rfc/grapheme_str_pad ======================================== 7. New Classes and Interfaces ======================================== - Intl: . IntlRelativeDateTimeFormatter . enum IntlRelativeDateTimeFormatterStyle . enum IntlRelativeDateTimeFormatterCapitalization . enum IntlRelativeDateTimeFormatterUnit RFC: https://wiki.php.net/rfc/reldateformatter . Added IntlNumberFormatter class to format a number with a given locale and ICU number skeleton, which also covers measurement units, e.g. "measure-unit/speed-kilometer-per-hour unit-width-full-name". IntlNumberFormatter::format() accepts an int, a float or a decimal string without exponent, the latter being formatted with arbitrary precision. IntlNumberFormatter::createFromSkeleton() rejects a scale/ option in exponent notation, e.g. "scale/1e3". It is supported from icu 63. ======================================== 8. Removed Extensions and SAPIs ======================================== ======================================== 9. Other Changes to Extensions ======================================== ======================================== 10. New Global Constants ======================================== - Curl: . New options: CURLOPT_ECH, CURLOPT_HAPROXY_CLIENT_IP, CURLOPT_SERVER_RESPONSE_TIMEOUT_MS. . CURLOPT_MAIL_RCPT_ALLOWFAILS is the correctly spelled alternative to CURLOPT_MAIL_RCPT_ALLLOWFAILS. ======================================== 11. Changes to INI File Handling ======================================== - Opcache: . opcache.max_accelerated_files now defaults to 16229 (previously 10000), accepts values up to 1048793 (previously 1000000), and logs a warning for values other than 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521 and 1048793. ======================================== 12. Windows Support ======================================== ======================================== 13. Other Changes ======================================== ======================================== 14. Performance Improvements ======================================== - Core: . A flat unkeyed list assignment from an array literal with one value per target, such as [$a, $b] = [$b, $a], no longer builds the array when the result is unused: the values are evaluated in order, a variable among them is copied, and they are assigned to the targets directly. A value its target does not keep is now released at that assignment instead of after the last one. . The garbage collector now raises its threshold when its runs traverse a large graph of live objects, so that it runs less often. Before, it traversed the whole graph again after every 10000 possible roots. . Improved performance of integer to string conversion (string casts, echo, implode(), json_encode(), serialize(), var_export() and others). . Improved performance of float to string conversion (string casts, sprintf(), number_format(), json_encode(), serialize(), var_export() and others) and of converting long numeric strings to float ((float) casts, json_decode(), unserialize() and others). - DOM: . Parsing HTML with Dom\HTMLDocument or innerHTML uses much less memory for small inputs. - PDO: . Improved performance of fetching rows with PDO::FETCH_OBJ. - Standard: . Improved performance of strcspn() and strpbrk() when searching longer strings with a single-byte character mask. . Improved performance of array_chunk() when not preserving keys. . Improved performance of array_splice() when inserting without removing elements. . Improved performance of str_replace() when the search string is longer than one byte and the replacement has a different length. . Improved performance of str_rot13(). . Improved performance of pack() for large strings using the a, A and Z formats. . Improved performance of htmlspecialchars(), htmlentities(), html_entity_decode() and get_html_translation_table(), especially with UTF-8. . htmlspecialchars() returns its input without copying it when nothing needs encoding. . Improved performance of in_array() and array_search() in strict mode when searching for a string. . Improved performance of the string.toupper and string.tolower stream filters. - JSON: . Improved performance of json_encode() for strings with non-ASCII characters. - MBString: . Improved performance of mb_strlen for UTF-8 strings. . Improved performance of mb_substr and mb_strpos for UTF-8 strings. . Improved performance of UTF-8 validation, used by mb_check_encoding() and by the UTF-8 fast paths of mb_strlen(), mb_substr() and other functions. It now uses AVX-512 on x86-64 when available, and NEON on ARM64. . Improved performance of mb_strtolower(), mb_strtoupper(), mb_convert_case() and the case-insensitive search functions (mb_stripos() and others) for UTF-8 strings that are ASCII or start with ASCII characters. - PDO: . Improved performance of fetching rows with PDO::FETCH_BOTH, the default fetch mode, for results with more than 4 columns. - PDO_PGSQL: . Improved performance of the SQL parser that handles placeholders in PDO::prepare() and, with emulated prepares, PDOStatement::execute(). . Improved performance of fetching integer columns.