PHP Core Roundup #3
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:
Subscribe to PHP Core Roundup 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.
PHP 8.2 QA Releases and Feature-freeze
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.
RFC Updates
Following are the RFCs discussed, voted, and implemented since our last update.
Implemented: Allow null and false as stand-alone types π
RFC by George 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
andfalse
, but not as stand-alone types. With this change, it is now possible to declare class properties, parameters, and return types withnull
andfalse
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 George Peter Banyard proposes to add
true
as a valid and standalone type to PHP. This RFC, along with RFC to allownull
andfalse
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
andrandom_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 thecallable
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 George 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()
anditerator_count()
functions to iterable, from the current type \Traversable. The difference is that theiterable
type includes array type as well (i.e\Traversable|array
). By widening the parameter type, these functions will be able to handlearray
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.
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.
- Bug fixes and improvements in Date extension by Derick Rethans π
- Bug #80047: DatePeriod doesn't warn with custom
DateTimeImmutable
in commit 973c3f6 - Bug #77243: Weekdays are calculated incorrectly for negative years in PR #8740
- Fixed tests that relied on
date.timezone=UTC
to work in commit 242b943 - Bug #73239: DateTime shows strange error message with invalid timezone in PR #8594
- Bug #80047: DatePeriod doesn't warn with custom
- Bug fixes and improvements in Opcache by Dmitry Stogov, Ilija Tovilo, and Derick Rethans π
- Bug GH-8863: RW operation on readonly property doesn't throw with JIT in commit ad40fffd
- Fix incorrect constant propagation for
VERIFY_RETURN_TYPE
in commit fa75bd07 - JIT: Fix incorrect reference-counting in commit 971b07ea
- JIT: Fix missing register store in commit 1cd8074
- Memory leak fixes in commits 229e80c6, 088e5677fb, 3a8912fb7c9, f135ed9a, and 229e80c6.
- Type inference fixes in commits 05375602a, b86c6245, 1b45efb6fb9dd, and 729be469
- JIT: Add Indirect Branch Tracking (IBT) support with Chen, Hu in PR #8774
- Fully convert
accel_remap_huge_pages
to use zend_result in commit 0429159 - Remove redundant address comparison in
accel_remap_huge_pages
in commit 1380b65d - Fixed bug GH-8847: PHP hanging infinitely at 100% cpu when check php syntaxes of a valid file in commit 7cf6f173
- Several improvements in the Curl extension by Pierrick Charron
- Several improvements Mbstring extension by Alex Dowad
mbfl_strlen
does not need to use old conversion filters any more in commit 9468fa7f- Use fast text conversion filters to implement
mb_check_encoding
in commit 950a7db9 - Use fast conversion filters to implement
php_mb_ord
in commit 880803a2 - Assert minimum size of wchar buffer in text conversion filters in commit 8533fccd
- Fully use available buffer space where converting Base64 in commit 871e61f
- Restore backwards-compatible mappings of 0x5C and 0x7E in SJIS in commit 2dc9026c
- Fast text conversion interfaces for several character encodings
Deprecate
zend_atol()
/ addzend_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 becausezend_atol()
/ addzend_ini_parse_quantity()
functions accept 'K', 'M', or 'G' as a unit multiplier, but ignore all other non-numeric characters in between.- Mark parameters as sensitive (using
SensitiveParameter
attribute new in PHP 8.2, RFC) in several PHP extensions in PR #8352 by Tim DΓΌsterhus - Don't shortcut empty oparray executions if
zend_execute_ex
has been overridden in commit 5bfc1608, so that debugging continues working well by Derick Rethans π - Fix phpize to include
_GNU_SOURCE
by default in commit 2c166647 by Derick Rethans π - Zip extension: Implement
fseek
for zip stream when possible with libzip 1.9.1 in commit 2223853c by Remi Collet - Zip extension: Fix GH-8781
ZipArchive::close
deletes zip file without updating stat cache in commit 390538a by Remi Collet - FPM: Fixed zlog message prepend, free on incorrect address in commit 325ca31d by Heiko Weber and David CARLIER
- FPM: Fix use after free in
fpm_evaluate_full_path
in PR #8796 by Heiko Weber - FPM: Fix
syslog.indent
does not work in PR #8780 by Jakub Zelenka π - com_dotnet: Increase test portability in PR #8879 by Christoph M. Becker
- Add
reallocarray
implementation in PR #8871 by David CARLIER - Convert return type of various object handlers from int to zend_result in PR #8755 by Ilija Tovilo π
- Multiple bug fixes related Enums in commits bc03deec, d9e1871c, 912c22cc, 45210b47, and 76fcd70c by Ilija Tovilo π
- Allow arbitrary constant expressions in backed enums in PR #8190 by Ilija Tovilo π
- Get rid of duplicated rotr3 implementation in PR #8853 by Ilija Tovilo π
- Declare constants in stubs for several extensions by MΓ‘tΓ© Kocsis π
- Fix lineno in backtrace of multi-line function calls, fixing GH-8810 in PR #8818 by Ilija Tovilo π
- Refactoring part of SPL
Directory.c
PR #8837 by George Peter Banyard π - Use the passed '
this
' pointer instead ofZEND_THIS
in PR #8854 by George Peter Banyard π - Fixed GH-8861: correctly handle string lengths in
SplFileinfo
methods in PR #8861 by M. Vondano and George Peter Banyard π - Fix GH-8848:
imagecopyresized()
error refers to the wrong argument in commit 9405f43b by Christoph M. Becker - Convert iterable into an internal alias for Traversable|array PR #7309 by George Peter Banyard π
- Use same type error wording for alias iterable in ZPP in PR #8838 by George Peter Banyard π
- Support the
#[\AllowDynamicProperties]
attribute in stubs in PR #8776 by Tim DΓΌsterhus - Refactor
sapi_getenv()
in PR #8786 by Heiko Weber - Specify unit in out of memory error in PR #8820 by Ilija Tovilo π
- Tweak
$count
range check of array_fill() in PR #8804 by Christoph M. Becker - Fix GH-8827: Intentionally closing std handles no longer possible in commit a8437d08 by Christoph M. Becker
- Introduction of timing attack safe bcmp implementation in commit bfe6f9e6 by David CARLIER
- Replace the use of
ZVAL_BOOL()
withZVAL_TRUE()
orZVAL_FALSE()
where the value is fixed in PR #8815 by Yurun - intl ICU C++ code modernisation, making it closer to C++11 in PR #8650 by David CARLIER
- Fix GH-8563 Different results for
seek()
onSplFileObject
andSplTempFileObject
in commit #6f87a5c6 by George Peter Banyard π - Zend, ext/opcache: use
PR_SET_VMA_ANON_NAME
(Linux 5.17) in PR #8234 by Max Kellermann - Fixed potential use after free in
php_binary_init()
in PR #8791 by Heiko Weber - Implemented: Declare true return types in PR #8759 by MΓ‘tΓ© Kocsis π
- streams/xp_socket: eliminate
poll()
whenMSG_DONTWAIT
is available in PR #8092 by Max Kellermann - Fix GH-8778: Integer arithmetic with large number variants fails in PR #8779 by Christoph M. Becker
- Fixed #77726: Allow null character in regex patterns in PR #8114 by @tobil4sk
- Fix
imagecreatefromavif()
memory leak in PR #8812 by Christoph M. Becker - Add
clean_module_functions()
in PR #8763 by @twosee - Use
get_active_function_or_method_name()
forzend_forbid_dynamic_call()
in PR #8762 by @twosee - Use HTTPS URLs in resource files in commit 9e9141f7 by Christoph M. Becker
- Add test for
iconv_mime_encode()
for input-charset and output-charset in PR #8766 by Christoph M. Becker - Regen missing
Zend/Optimizer/zend_func_infos.h
in commit bbc0c4c5 by Pierrick Charron - Indent with TAB in
.h
files generated bygen_stub
in commit 6fd2b393 by Pierrick Charron - PDO ODBC: Fix handling of single-key connection strings in PR #8748 by Calvin Buckley
- Fix redundant
ZSTR_VAL
condition inphp_date.c
in PR #8753 by Ilija Tovilo π - Add
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. - Fix GH-8661: Nullsafe in coalesce triggers undefined variable warning in PR #8690 by Ilija Tovilo π
- Add function exposing
HAVE_GCC_GLOBAL_REGS
in PR #8359 by Joe Rowell - Fix GH-8691: Add required extensions for redirected tests in commit c05c96b3 by George Peter Banyard π
- Remove code duplication in
zend_std_compare_objects
in PR #8710 by Ilija Tovilo π - Fix Bug #76452: Crash while parsing blob data in
firebird_fetch_blob
in commit a6a13139 by Ben Ramsey - Fix #81720: Uninitialized array in
pg_query_params()
leading to RCE in commit 55f6895f by Christoph M. Becker - Fix detection of unknown gcc function attributes in PR #8483 by Athos Ribeiro
- Better return types for
ReflectionEnum::getBackingType
in PR #8687 by Sam
Mailing List Discussions
- Discussion about new Curl URL API and ext/curl improvements, started by Pierrick Charron
- The future of objects and operators, started by Jordan LeDoux
- Adding new closing tag
=?>
for keeping trailing newline, started by Shinji Igarashi
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.