Welcome back to the PHP Core Roundup series, where we make regular updates on the improvements made to PHP by the PHP Foundation and other contributors.
In this edition, we have news about PHP 8.2 that is only three weeks away from its feature-freeze, and several improvements made by the PHP Foundation team and contributors.
You donβt necessarily have to be a PHP Foundation backer to follow the PHP Roundup. Weβll be publishing the posts on our website, and you can subscribe to the newsletter:
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.
Things marked with π are done by the PHP Foundation team.
The upcoming PHP 8.2 version is scheduled to be released on November 24. The newly elected PHP 8.2 release managers made the first QA release of PHP 8.2 β PHP 8.2 Alpha 1 β on June 09, and the second alpha release on June 23.
These alpha releases are not meant for any production servers, but serve as point releases for testing environments and local development setups.
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.
July 19 is the PHP 8.2 Feature-Freeze date. The window for submitting major changes to PHP 8.2 ends on this date. PHP follows a two week discussion period and a two week voting period. All RFCs must be voted (and passed) before the feature-freeze to be included in PHP 8.2.
Following are the RFCs discussed, voted, and implemented since our last update.
Implemented: Allow null and false as stand-alone types π
RFC by Gina Peter Banyard proposed to allow null and false as standalone types in PHP. With the addition of Union Types in PHP 8.0, it was possible to declare a Union Type with null
and false
, but not as stand-alone types. With this change, it is now possible to declare class properties, parameters, and return types with null
and false
as stand-alone types. They are already reserved keywords in PHP, and this change is highly unlikely to cause any backwards compatibility issues.
Learn more about this RFC in PHP Internals News Podcast #99 π, hosted by Derick Rethans, and on PHP.Watch.
Implemented: Add true type π
Another RFC by Gina Peter Banyard proposes to add true
as a valid and standalone type to PHP. This RFC, along with RFC to allow null
and false
as standalone types, makes PHPβs type system more expressive and precise.
Learn more about this RFC in PHP Internals News Podcast #102, hosted by Derick Rethans, and on PHP.Watch.
Accepted: Random Extension 5.x
Random Extension 5.x RFC, as the name implies, is the fifth iteration of the RFC proposed by Go Kudo to improve PHPβs Random Number Generator (RNG). It proposes a series of changes starting from moving the RNG to a separate PHP extension, and providing multiple choices of the RNGs in an object-oriented API pattern. It does not propose to change the existing user-land random_int
and random_bytes
functions, but rather refactor the internals of the RNG.
There is a follow-up RFC currently being discussed to make further improvements to it.
Accepted: Expand deprecation notice scope for partially supported callables
Juliette Reinders Folmerβs RFC that follows up on the Deprecate partially supported callables RFC (implemented in PHP 8.2) to widen the scope of the deprecation to include is_callable
function and when type verification is executed on the callable
type was accepted.
Learn more about this RFC from the PHP Internals News Podcast #101 hosted by Derick Rethans.
Accepted: Disjunctive Normal Form Types π
Yet another RFC by Gina Peter Banyard that proposes to add Disjunctive Normal Form types to the language.
PHP has support for Union Types (foo|bar
) since PHP 8.0, and Intersection Types (foo&bar
) since PHP 8.1. The DNF Types RFC proposes to add support for combining Union and Intersection types to declare a type in a canonical form.
This RFC is currently in voting, with a majority of votes in favor. With only two days left on the vote, it is highly likely that this RFC will pass.
Learn more about this RFC from the PHP Internals News Podcast #103 hosted by Derick Rethans.
Under Discussion: New Curl URL API
RFC by Pierrick Charron discusses improvements to the Curl extension including the possibility to introduce a new CurlUrl
class to build, query, and validate a URL using the same mechanisms Curl uses.
Under Discussion: Fetch properties of enums in const expressions π
Ilija Tovilo proposes to add support to fetch Enum properties in constant expressions. In PHP Enums, each enumerated member has name and value properties.
const VALUE = 'value';
const C = E::Foo->name;
const C = E::Foo->{VALUE};
function foo($param = E::Foo->value) {}
#[Attr(E::Foo->name)]
class C {}
The RFC is to allow expressions above and other similar patterns, which are not currently allowed.
Under Discussion: PDO driver specific sub-classes
RFC by Dan Ackroyd proposes to add new subclasses (with PDO as the parent) for individual database drivers so they can introduce their own additions to the PDO class easily. Some of the use cases mentioned in the RFC include PostgreSQL and Sqlite drivers that could declare methods to functionality that are unique to that software.
Under Discussion: Make the iterator_*() family accept all iterables
RFC by Tim DΓΌsterhus proposes to widen the type of $iterator parameter of iterator_to_array()
and iterator_count()
functions to iterable, from the current type \Traversable. The difference is that the iterable
type includes array type as well (i.e \Traversable|array
). By widening the parameter type, these functions will be able to handle array
values as well.
Under Discussion: Constants in Traits
Shinji Igarashi proposes in this RFC to allow declaring constants in PHP traits. The proposal details that direct access to the constants with trait name will not be allowed (i.e MyTrait::FOO
), and enforces some additional composing rules. Constants declared in traits will also suppose visibility and final constants too.
Under Discussion: Auto-implement Stringable for string backed enums π
In this RFC, Ilija Tovilo and Nicolas Grekas propose that string-backed enums auto-implement Stringable
, while continuing to disallow user-land implementations of the method (__toString()
). One of the use cases this RFC intends to solve is with Symfonyβs use of attributes that the attribute expects a string value, but it is not possible to to pass the name or value property of Enums directly. The Fetch properties of enums in const expressions RFC might also solve this problem with a different approach.
Under Discussion: Short Closures 2.0 π
Originally this RFC was co-authored by Nuno Maduro and Larry Garfield. Now Arnaud Le Blanc took over and significantly reworked the implementation. It proposes to allow multiple statements in anonymous functions using the short function syntax. For example, the following snippet will be valid, should the RFC is voted on and implemented:
$guests = array_filter($users, fn ($user) {
$guest = $repository->findByUserId($user->id);
return $guest !== null && in_array($guest->id, $guestsIds);
});
Currently, the fn
syntax does not allow multiple statements inside the function body, and this RFC proposes to remove this limitation.
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.
DateTimeImmutable
in commit 973c3f6date.timezone=UTC
to work in commit 242b943VERIFY_RETURN_TYPE
in commit fa75bd07accel_remap_huge_pages
to use zend_result in commit 0429159accel_remap_huge_pages
in commit 1380b65dmbfl_strlen
does not need to use old conversion filters any more in commit 9468fa7fmb_check_encoding
in commit 950a7db9php_mb_ord
in commit 880803a2Deprecate zend_atol()
/ add zend_ini_parse_quantity()
in PR #7951 by Sara Golemon and Arnaud Le Blanc π
Note that this introduces warnings on INI values for data sizes that PHP used to parse without any prior warnings. Some of the examples of these patterns are β123GB
β (interpretted as β123
β, although the caller likely meant 123 Gigabytes) and β123KMG
β as "123G
" -> 132070244352β. This is because zend_atol()
/ add zend_ini_parse_quantity()
functions accept 'K', 'M', or 'G' as a unit multiplier, but ignore all other non-numeric characters in between.
SensitiveParameter
attribute new in PHP 8.2, RFC) in several PHP extensions in PR #8352 by Tim DΓΌsterhuszend_execute_ex
has been overridden in commit 5bfc1608, so that debugging continues working well by Derick Rethans π_GNU_SOURCE
by default in commit 2c166647 by Derick Rethans πfseek
for zip stream when possible with libzip 1.9.1 in commit 2223853c by Remi ColletZipArchive::close
deletes zip file without updating stat cache in commit 390538a by Remi Colletfpm_evaluate_full_path
in PR #8796 by Heiko Webersyslog.indent
does not work in PR #8780 by Jakub Zelenka πreallocarray
implementation in PR #8871 by David CARLIERDirectory.c
PR #8837 by Gina Peter Banyard πthis
' pointer instead of ZEND_THIS
in PR #8854 by Gina Peter Banyard πSplFileinfo
methods in PR #8861 by M. Vondano and Gina Peter Banyard πimagecopyresized()
error refers to the wrong argument in commit 9405f43b by Christoph M. Becker#[\AllowDynamicProperties]
attribute in stubs in PR #8776 by Tim DΓΌsterhussapi_getenv()
in PR #8786 by Heiko Weber$count
range check of array_fill() in PR #8804 by Christoph M. BeckerZVAL_BOOL()
with ZVAL_TRUE()
orZVAL_FALSE()
where the value is fixed in PR #8815 by Yurunseek()
on SplFileObject
and SplTempFileObject
in commit #6f87a5c6 by Gina Peter Banyard πPR_SET_VMA_ANON_NAME
(Linux 5.17) in PR #8234 by Max Kellermannphp_binary_init()
in PR #8791 by Heiko Weberpoll()
when MSG_DONTWAIT
is available in PR #8092 by Max Kellermannimagecreatefromavif()
memory leak in PR #8812 by Christoph M. Beckerclean_module_functions()
in PR #8763 by @twoseeget_active_function_or_method_name()
for zend_forbid_dynamic_call()
in PR #8762 by @twoseeiconv_mime_encode()
for input-charset and output-charset in PR #8766 by Christoph M. BeckerZend/Optimizer/zend_func_infos.h
in commit bbc0c4c5 by Pierrick Charron.h
files generated by gen_stub
in commit 6fd2b393 by Pierrick CharronZSTR_VAL
condition in php_date.c
in PR #8753 by Ilija Tovilo πSO_SETFIB
FreeBSD socket option constant in PR #8742 by David CARLIER. This is a follow-up to several of Davidβs contributions to the Sockets extension.HAVE_GCC_GLOBAL_REGS
in PR #8359 by Joe Rowellzend_std_compare_objects
in PR #8710 by Ilija Tovilo πfirebird_fetch_blob
in commit a6a13139 by Ben Ramseypg_query_params()
leading to RCE in commit 55f6895f by Christoph M. BeckerReflectionEnum::getBackingType
in PR #8687 by Sam=?>
for keeping trailing newline, started by Shinji IgarashiAt 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.