PHP Core Roundup #4

Published on by

PHP Core Roundup is a series of posts where we make regular updates on improvements, fixes, and new features made to PHP by the PHP Foundation and other contributors. Welcome to the fourth edition in the series, which brings updates about the upcoming PHP 8.2, discussions on a face-lift for the php.net home page, and more.

We’ll be publishing the posts on our website, and you can subscribe to a newsletter; You don’t necessarily have to be a PHP Foundation backer to follow PHP Core Roundup.

Subscribe to PHP Core Roundup newsletter
We care about your data. Read our privacy policy.

The PHP Foundation currently supports six part-time PHP contributors who work on both maintenance and new features for PHP. Maintenance is not limited to fixing bugs, but also includes work to reduce technical debt, making life easier for everyone working on PHP. The contributors funded by the PHP Foundation collaborate with other contributors on code, documentation, and discussions.

PHP 8.2 Feature-Freeze

On July 19, PHP 8.2 branch reached its feature-freeze. As the name suggests, the list of features we plan to ship with PHP 8.2 is now frozen. Contributors who wish to make substantial changes to PHP should now target the next PHP version, PHP 8.3.

In the coming weeks, the PHP Foundation members, the PHP development team, and contributors will be making improvements to get PHP 8.2 ready for production release.

Release managers elected for PHP 8.2, Ben Ramsey, Pierrick Charron, and Sergey Panteleev will have the final say in case a major change must be made to the PHP 8.2.

PHP 8.2 Beta Release

The first beta release of PHP 8.2 was released last week. Now would be an ideal time to test your PHP applications on PHP 8.2.

Compiled Windows binaries are available at windows.php.net/qa, Docker images are available at Docker Hub, and source code at php/php-src repository on GitHub to compile yourself. On Homebrew, PHP 8.2-dev packages are available from shivammathur/php tap.

CI/CD platforms that use Docker images can use the PHP 8.2 docker images available with various base images. GitHub Actions can also make use of shivammathur/setup-php action, which supports PHP 8.2 builds.

Recent RFCs, Merged PRs, and Commits

Changes and improvements to PHP are discussed, reported, and voted on by the PHP Foundation Team, the PHP development team, and contributors. Bug reports are made to the PHP issue tracker, changes are discussed in mailing lists, minor code changes are proposed as pull requests, and major changes are discussed in detail and voted on as PHP RFCs. Documentation and the php.net web site changes are also discussed and improved at their relevant Git repositories on GitHub.

Hundreds of awesome PHP contributors put their efforts into improvements to the PHP code base, improving documentation and the php.net web site, and more on a daily basis. Here is a summary of some of the changes made by the people behind PHP. Things marked with 💜 are done by the PHP Foundation team.

PHP 8.2 Release Page and a face-lift to php.net homepage

Sergey Panteleev, one of the release managers for PHP 8.2, made a pull-request for the upcoming PHP 8.2 release page on php.net. It is still in its early stage, but the idea is to create a similar page highlighting new features in the new version, similar to the release pages for PHP 8.1 and PHP 8.0.

There is also a new proposal to refresh the php.net web site home page by Mike van Riel, with a relevant Twitter thread here and a WIP PR in here.

RFC Updates

Following are the RFCs discussed, voted, and implemented since our last update.

  • Implemented: Random Extension and a follow-up RFC by Go Kudo

    Go Kudo first-proposed Object scoped RNG, back in 2020, and proposed a series of RFCs to improve PHP’s Random Number Generator. The RFCs voted and implemented in PHP 8.2 now refactors PHP functions such as random_int(), random_bytes(), rand(), mt_rand() to a new extension called random. This is merely an internal refactor, and it is not possible to compile PHP without the extension.

    There is a new PHP class called \Random\Randomizer, that can be instantiated with a class object that implements the \Random\Engine interface. The extension provides a few implementations built-in, such as \Random\Engine\Mt19937, PcgOneseq128XslRr64, and Xoshiro256StarStar.

  • Implemented: Disjunctive Normal Form Types RFC by Larry Garfield and Gina Peter Banyard 💜

    Disjunctive Normal Form (DNF) is now supported in PHP type declarations. It allows combining Union types (PHP 8.0) and Intersection types (PHP 8.1) to precisely declare a type.

    For example, the it is now possible to declare functions with types like this:

     function showBanner(string|(Stringable&SafeString)|int $value) {}
    

    In the snipet above, showBanner function's $value parameter accepts a string, OR Intersection type Stringable&SafeString, OR int.

  • Implemented: Fetch properties of enums in const expressions by Ilija Tovilo 💜

    This RFC proposes to allow the use of ->/?-> to fetch properties of enums in constant expressions. The primary motivation for this change is to allow fetching the name and value properties in places where enum objects aren't allowed, like array keys. There is currently no way to express this without repeating the value of the enum case.

    With this change implemented in PHP 8.2, it will be possible to declare expressions like the following:

    enum E: string {
       case Foo = 'foo';
    }
    
    // Constants
    const C = E::Foo->name;  
    
    // Static variables
    function f() {
       static $v = E::Foo->value;
    }
    
    
    // Attributes
    #[Attr(E::Foo->name)]
    class C {} 
    
    
    // Parameter default values
    function f($p = E::Foo->value) {}
    
    // Property default values
    class C {
       public string $p = E::Foo->name;
    }
    
    // The rhs of -> allows other constant expressions
    const VALUE = 'value';
    class C {
        const C = E::Foo->{VALUE};
    }
    
  • Declined: New Curl URL API by Pierrick Charron

  • Declined: json_encode indentation by Timon de Groot
  • Declined: Short Closures 2.0 by Nuno Maduro, Larry Garfield, and Arnaud Le Blanc The RFC missed the 2/3 vote with 27 votes in favor and 16 against.

    It proposed a short syntax for closures, inheriting the features of arrow functions (auto-capture), with multiple statements.

    This received a lot of feedback. Some of which can be addressed, so there is still hope for this feature to land in a future version.

    Some of the authors may propose a new version in PHP 8.3.

Merged PRs and Commits

Following are some of the changes that did not go through an RFC process because they are either planned, bug fixes, or progressive enhancements. There are automated unit and integration tests for each of these changes, and all pull requests are reviewed by the PHP core developers.

  • JIT and Opcache fixes by Dmitry Stogov
  • Improvements in Mbstring extension by Alex Dowad
  • Fixes and improvements in the Date extension by Derick Rethans 💜
  • Add error_log_mode setting in ffdf25a270 by Mikhail Galanin
  • Add FILTER_FLAG_GLOBAL_RANGE to filter Global IPs as per RFC 6890 in d8fc05c05e by @ vnsavage
  • Do not send X-Powered-By if headers sent in GH-9039 in 922371f3b1 by Eric Norris
  • Fixed bug #65069: GlobIterator incorrect handling of open_basedir check by Jakub Zelenka 💜
  • Series of commits by Máté Kocsis 💜 to declare extension constants in stubs: ext/mysqli in GH-8811, ext/odbc in GH-9045, ext/openssl in GH-9046, ext/pcre in GH-9077, ext/pdo in GH-9078, ext/pspell in GH-9096, ext/posix in GH-9095, ext/phar in GH-9094, ext/random in GH-9109, ext/session in GH-9112, ext/readline in GH-9110, ext/reflection in GH-9111, ext/sysvmsg in GH-9125, ext/soap in GH-9124, ext/zend_test in GH-9135, ext/xml in GH-9131, ext/xsl in GH-9134, ext/xmlreader in GH-9133, ext/snmp in GH-9113, ext/zlib in GH-9147, ext/pgsql in GH-9092, and ext/sqlite3 in GH-9181
  • Fix zend_atomic_bool_exchange_ex() in HAVE_NO_ATOMICS case in GH-8801 in b09420e3a8 by twosee
  • main/streams/plain_wrapper: skip lseek(SEEK_CUR) for newly opened files in e2bd3b1e99 by Max Kellermann
  • Improve tests on 32bit in GH-8448 by Michael Voříšek
  • streams/xp_socket: fix clang build error with enum usage on bool condition in 7ceae66182 by David Carlier
  • Add test for backtrace with aliased trait in GH-8705 in f26f6d9479 by Michael Voříšek
  • Use bool and rename variable for ease of comprehension in ps_title.c in b468d6fb54 by Gina Peter Banyard 💜
  • Use size_t for get_ps_title() length parameter in 9a7d37ac66 by Gina Peter Banyard 💜
  • Adds TCP_CONGESTION socket option for Linux/FreeBSD in a193427333 by David Carlier
  • Fix the crypt sha apis build (with recent clang versions) in b3569865b3 by David Carlier
  • Disallow assigning reference to unset readonly property in GH-7942 by Ilija Tovilo 💜
  • Abort LMDB transaction when trying to delete non-existing key in 8fce70ae7b and 1d0c287b90 by Gina Peter Banyard 💜
  • Add php_register_known_variable() for known var names in 55908db007 by Gina Peter Banyard 💜
  • Refactor registration of variables for the CLI SAPI in b37245b8da and by Gina Peter Banyard 💜
  • Pre-compute remote address length in CLI SAPI in 1c753a958b by Gina Peter Banyard 💜
  • Fix labeler selection of SAPIs in 583cc01e9e by Jakub Zelenka 💜
  • Fix GH-8907: Document forgotten API changes in fdc09e302a by David Carlier
  • Use safe_*erealloc* flavor in few places to mitigate possible overflows in dfbb425295 by David Carlier
  • Update FreeBSD CI image in 4f4457a6e9 and f2d6e175fe by David Carlier
  • Fix #81723: Memory corruption in finfo_buffer() in ca6d511fa5 by Christoph M. Becker
  • Allow for arbitrary (class) attributes in stubs in 9f29e2d7e9 by Bob Weinand
  • Fix GH-8842 don’t set sensitive param in legacy arginfo in b45cd10238 by Remi Collet
  • Implement mysqli_execute_query() in GH-8660 in 1dc51c7b90 by Kamil Tekiela
  • intl extension, build fix for icu >= 71.x release in b22d2bf589 by David Carlier
  • Improve contrast for dark mode phpinfo in GH-8893 in d9c49ae1c1 by Levi Morrison
  • Fixed bug GH-8943 Reflection::getModifiersNames() with readonly modifier in c650e67c90 by Pierrick Charron
  • FPM add routing view global option (for FreeBSD for now) in 5174ee2353 by David CARLIER
  • Update mime-db from 1.45.0 to 1.52.0 in d3c86527a5 by Ayesh Karunaratne
  • Remove silent argument to spl_filesystem_file_read_line() / spl_filesystem_file_read_line_ex() in a055c54801 and bb3d0933af by Gina Peter Banyard 💜
  • Use true/false and comment when arg correspond to silent arg in 247de8a4de by Gina Peter Banyard 💜
  • Make php_fgetcsv() return a HashTale instead of in-out zval param in GH-8936 in 4ccf0b0181 by Gina Peter Banyard 💜
  • FPM: Fix possible double free on configuration load failure in bd6793372b by Heiko Weber
  • Add upgrading internals entry for fgetcsv() changes in eacf6f43ed by Gina Peter Banyard 💜
  • Reduce memory allocated by var_export, json_encode, serialize, and other in GH-8902 in 4df3dd7679 by Arnaud Le Blanc 💜
  • Fix GH-8924 str_split of empty string must return empty array in e80925445c by Michael Voříšek
  • intl extension, build fix for icu >= 69.x release. ubrk/ucnv_safeClone had been deprecated in favor of ubrk/ucnv_clone which does not use user provided stacks but remain thread safe in 7c3dfbb845 by David Carlier
  • Fix GH-8952: std streams can not be deliberately closed in GH-8953 in 2dbde18b29 by Arnaud Le Blanc 💜
  • Add ini_parse_quantity function to convert ini quantities shorthand notation to int in GH-8454 in by Dennis Snell
  • Fix “%f” regex in run-tests.php in GH-8965 in 6cd5bd1bcd by Michael Voříšek
  • sockets introduces socket_set_option SO_ZEROCOPY and MSG_ZEROCOPY for the socket_send* functions. it avoids copy b/w userland and kernel for both TCP and UDP protocols in dedad408fe by David Carlier
  • FPM: Implement access log filtering in GH-8174 by Mark Gallagher
  • QA - Test Cov - ext:pcntl - pcntl_signal() - max signal allowed in GH-8956 in 23654a172e by Juan Morales
  • Add zend_array_to_list() in GH-8976 in 75a9a5f311 by Tim Düsterhus
  • gdbinit: Update print_ht for new compact packed arrays representation in GH-8966 in c654973c02 by Arnaud Le Blanc 💜
  • Update to libpcre2 10.40 in 32cceb75bf by Christoph M. Becker
  • Make the ABI compatibility of generated arginfo files configurable in GH-8931 in 0bddbab084 by Máté Kocsis 💜
  • Require zend_constants.stub.php from zend_exceptions.stubs.php in bb5be650c6 by Máté Kocsis 💜
  • Fix GH-8576: Bad interpretation of length when char is UTF-8 in GH-8926 by Christoph M. Becker
  • Support the actual #[\SensitiveParameter] attribute in stubs in GH-8836 in 342e18f105 by Tim Düsterhus
  • Fix parameter order in gen_stub.php in 227a8576d2 by Máté Kocsis 💜
  • Fix GH-8923: error_log on Windows can hold the file write lock in GH-8925 by Christoph M. Becker
  • add compatibility for tentative-return-type in 6e24c16c4a by Remi Collet
  • Fix GH-8750: Can not create VT_ERROR variant type in GH-8886 by Christoph M. Becker
  • INI parser: Fix typo /multipler/multiplier in GH-8987 by Ayesh Karunaratne
  • QA - pcntl_exec - check stringable parameters error in GH-8990 by Juan Morales
  • Prevent potential buffer overflow for large value of php_cli_server_workers_max in 789a37f144 by guoyiyuan
  • QA - pcntl_signal - error when handler is int and not SIG_DFL or SIG_IGN in GH-9001 by Juan Morales
  • QA - ftp_connect - error behavior when connection fails in GH-9002 by Juan Morales
  • Extend deprecation notices to is_callable($foo) and callable $foo in GH-8823 by Rowan Tommins
  • Fix RC func info of str_split in GH-9016 in 63912b5ecd by Ilija Tovilo 💜
  • Fix WeakMap object reference offset causing TypeError in GH-8995 in ede92a86f2 by Tobias Bachert
  • random: whitelist arc4random_buf if glibc in 3be9118662 by Cristian Rodríguez
  • random extension macOs handling update in d830a1f6f0 by David CARLIER
  • QA - mb_http_input - function returns FALSE for type ‘L’ or ‘l’ in GH-9018 by jcm
  • opcache JIT: Adds initial support for macOs Instruments performance measurement in c56e183226 by David CARLIER
  • QA -mb_convert_encoding_array - error for object item in array in GH-9023 by jcm
  • QA - ftp_rawlist - check list return value in GH-9012 by jcm
  • Prevent fiber switching in tick function and signal handlers in GH-9028 in 2bc6025c2c by Aaron Piotrowski
  • Add SensitiveParameter as known string and use it in arginfo in 55a88f36b6 by Remi Collet
  • Allow to not close stream on rscr dtor in PHP CLII SAPI in 0a4a55fd44 by Jakub Zelenka 💜
  • Fix JIT crash with large number of match/switch arms in GH-8961 in f2381ae4ba by Arnaud Le Blanc 💜
  • cleanup unused in ee1d6188cf by Remi Collet
  • no need for attributes on legacy in af72d6e5d9 by Remi Collet
  • in f0d536844f by Máté Kocsis 💜
  • FPM: Downgrade occasional “failed to acquire scoreboard” warning in 3040f75f43, db5f6713ee by Felix Wiedemann
  • Fix possible crash in case of exception in c6eb5dc5fd by Dmitry Stogov
  • Update request startup error messages in 09237f6126 by Eric Norris
  • DatePeriod properties cannot be made readonly in GH-9013 in e13d60c039 by Máté Kocsis 💜
  • Drop support for SQLITE_COPY in authorizer callback in GH-9041 by Christoph M. Becker
  • Deprecate MYSQLI_IS_MARIADB in GH-8919 by Kamil Tekiela
  • Port standard/crc32 for windows arm64 in GH-7703 by dixyes
  • Do not assert SSE/AVX resolvers at windows arm64 in GH-7704 by dixyes
  • opcache JIT support improvements attempts on macOs in 1416961505 by David CARLIER
  • Rename @cname to @cvalue in stubs in GH-9043 in e328c68305 by Máté Kocsis 💜
  • RFC: Make the iterator_*() family accept all iterables in GH-8819 in 7ae7df5b46 by Tim Düsterhus
  • Fix GH-9017: php_stream_sock_open_from_socket could return NULL in GH-9020 by Heiko Weber
  • opcache find best candidate near .text segment for large maps on FreeBSD. Follow up on #8890 using similar workflow, we go through the php binary mapping per address boundaries in 1977ef92de by David CARLIER
  • Fix --CGI-- support of run-tests.php in GH-9061 by Christoph M. Becker
  • Fix GH-9008: mb_detect_encoding(): wrong results with null $encodings in GH-9063 by Christoph M. Becker
  • phpinfo HTML Output: Make module title names clickable and link to the URL fragment in GH-9054 by Ayesh Karunaratne
  • Fix segmentation fault in Randomizer::getBytes() if a user engine throws in GH-9055 in 998ede7123 by Tim Düsterhus
  • Fix byte expansion in rand_rangeXX() in GH-9056 in 804c3fc821 by Tim Düsterhus
  • Fix GH-9067: random extension is not thread safe in GH-9070 by Christoph M. Becker
  • Port win32/codepage.c codes for windows arm64 in GH-7702 by dixyes
  • Sockets disable zerocopy test on ppc based arch in 067a3022f8 by David Carlier
  • Fix rc info of iterator_to_array in GH-9080 in d4a9cc8856 by Ilija Tovilo 💜
  • Fix memory leak in LMDB driver in 5b83b3a933 by Gina Peter Banyard 💜
  • Fix RC debug of stub attribute in GH-9082 in 41a5b46e7d by Ilija Tovilo 💜
  • Remove unnecessary include in SPL in 11c424c9fb by Gina Peter Banyard 💜
  • Re-add MSAN in nightly in ad136e6a6d by Ilija Tovilo 💜
  • Assert all test files are cleaned up in CI in GH-8977 in b5ab0e06b8 by Ilija Tovilo 💜
  • Fix SPL test cleanup in 3962f00b01 by Ilija Tovilo 💜
  • Avoid signed integer overflow in php_random_range() in GH-9066 in 133b9b08da by Go Kudo
  • Convert client->request.request_uri to zend_string in GH-9086 in c8f4801382 by Gina Peter Banyard 💜
  • Fix shift in rand_rangeXX() in GH-9088 in ab5491f505 by Tim Düsterhus
  • [run-tests.php] Improve non-optimal nested if/elseif/else blocks with happy path optimizations in 51447fb47d by Ayesh Karunaratne
  • [run-tests.php] Minor optimizations in if blocks by placing simple expressions first in 056afc8daf by Ayesh Karunaratne
  • [run-tests.php] Merge multiple unset() calls to a single call in f958701dad by Ayesh Karunaratne
  • [run-tests.php] Replace backtick operator string literals with shell_exec() calls in c83a10d8db by Ayesh Karunaratne
  • [run-tests.php] Combine multiple str_replace calls to a single strtr call in 3483a1f170 by Ayesh Karunaratne
  • [run-tests.php] echo call performance optimization in 0490f082e9 by Gina Peter Banyard 💜
  • crc32 Aarch64 add crc feature to crc32_aarch64 from clang Closes #8916 in 77bd39a116 by David CARLIER
  • Add support for stubs to declare intersection type class properties in GH-8751 in 4457dba1fb by Gina Peter Banyard 💜
  • Fix memory leak in fiber constructor by throwing an error in GH-9098 in 0adbf9c2d4 by Martin Schröder
  • Fix typo in lob_prefetch_ini.phpt test in GH-9099 in fc42098c23 by Michael Voříšek
  • Use -1 “precision” in gen_stub.php in GH-8734 by Michael Voříšek
  • Remove dead code in ext/random/random.c in GH-9114 in 395b6a9674 by Tim Düsterhus
  • Add comment in GDBM informing to what param the 0 org corresponds to in c8ba00f627 by Gina Peter Banyard 💜
  • Remove personalisation from write on readonly db DBA error message in 0887a1d7ab by Gina Peter Banyard 💜
  • Pass MDB_RDONLY to the LMDB environment for readonly DBs in 79d831ff9f by Gina Peter Banyard 💜
  • Add support to pass driver flags to DBA handlers in 3c372901bd by Gina Peter Banyard 💜
  • Fix memory leak on Randomizer::__construct() call twice in GH-9091 in 34b352d121 by Go Kudo
  • Improve error reporting in random extension in GH-9071 in 60f149f7ad by Tim Düsterhus
  • zend defines attribute malloc for Win32 as returned pointer are not aliased Closes #9118 in 53ae24e435 by David Carlier
  • Fix GH-9033: Loading blacklist file can fail due to negative length in GH-9036 by Christoph M. Becker
  • Initialize blacklist_path_length in GH-9129 by Christoph M. Becker
  • sockets ext for solaris update in 9090e2602e by David Carlier
  • Skip locale tests /w musl libc in GH-9141 in 60189aa96a by Michael Voříšek
  • Amend DBA error message to use standard messaging in 04f6fe4b25 by Gina Peter Banyard 💜
  • Remove ->last_unsafe from php_random_status in GH-9132 in 5c693c770a by Tim Düsterhus
  • The hashvalue/index of a bucket is a zend_ulong in bdf5a4e478 by Gina Peter Banyard 💜
  • Use uint32_t in Z_PARAM_VARIADIC_WITH_NAMED in 9115211ebf by Gina Peter Banyard 💜
  • Restrict range of buffer_length on all platforms to INT_MAX in GH-9126 by Christoph M. Becker
  • Fix #69181: READ_CSV|DROP_NEW_LINE drops newlines within fields in GH-7618 by Christoph M. Becker
  • Use ValueError if an invalid mode is passed to Mt19937 in GH-9159 in d058acb4ac by Tim Düsterhus
  • GH-9157: opcache fix build on older macOs releases. Closes #9158 in 099b16800c by David CARLIER
  • Fix GH-9090: Support assigning function pointers in FFI in GH-9107 by Adam Saponara
  • Tweak openssl_random_pseudo_bytes() upper bound error message in 5d62cfbc7d by Christoph M. Becker
  • Fix GH-9155: dba_open(“non-existing”, “c-”, “flatfile”) segfaults in GH-9156 by Christoph M. Becker
  • Fix GH-9032: SQLite3 authorizer crashes on NULL values in GH-9040 by Christoph M. Becker
  • Fix get/set priority - error handling for MacOS and extra tests in GH-9044 by jcm
  • Avoid using a stack allocated zend_function in Closure::call, to avoid prevent crashes on bailout in b576bb901e by Bob Weinand
  • Fix property fetch on magic constants in constant expressions in GH-9136 by Ilija Tovilo 💜
  • Escape \U and \u in generated stubs in GH-9154 by Andreas Braun
  • Drop Windows specific implementation of openssl_random_pseudo_bytes() in GH-9153 by Christoph M. Becker
  • Do not add inherited interface methods to the class synopsis page in b56492be9c by Máté Kocsis 💜
  • Improve error messages in php_random_bytes() in GH-9169 by Tim Düsterhus
  • Improve DBA test suite in GH-8904 by Gina Peter Banyard 💜
  • Refactor code handling file.current_zval in GH-8934 by Gina Peter Banyard 💜

Support PHP Foundation

At PHP Foundation, we support, promote, and advance the PHP language. We financially support six part-time PHP core developers to contribute to the PHP project. You can help support PHP Foundation at OpenCollective.

A big thanks to all our sponsors — PHP Foundation is all of us!

A special mention goes to mailcoach.app for providing us with a platform for the newsletter.

Follow us on Twitter @ThePHPF to get the latest updates from the Foundation.

💜️ 🐘

PHP Roundup is prepared by Ayesh Karunaratne from PHP.Watch, a source for PHP News, Articles, Upcoming Changes, and more.