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.
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.
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.
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.
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.
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.
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
json_encode
indentation by Timon de GrootDeclined: 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.
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.
FETCH_DI_UNSET
in bd30eff5defree()
during type persistence in f24548e217 and 34b11a7524mb_{de,en}code_numericentity
in 91969e908fmbfl_strwidth
does not need to use legacy conversion filters now in 30bfeef48dmb_decode_numericentity
converts entities which immediately follow a valid/invalid entity in 5d6bd557b3mb_convert_kana
in 9ac49c0dd3mb_decode_numericentity
decodes valid entities which are truncated at end of string in 76a92c26e3DatePeriod::__unserialise
in 0dbedb3dbdDateTime::diff
miscalculation is same time zone of different type in cc9c57722aDateTimeImmutable::diff
in 37d460b64aerror_log_mode
setting in ffdf25a270 by Mikhail GalaninFILTER_FLAG_GLOBAL_RANGE
to filter Global IPs as per RFC 6890 in d8fc05c05e by @ vnsavageX-Powered-By
if headers sent in GH-9039 in 922371f3b1 by Eric NorrisGlobIterator
incorrect handling of open_basedir
check by Jakub Zelenka 💜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-9181zend_atomic_bool_exchange_ex()
in HAVE_NO_ATOMICS case in GH-8801 in b09420e3a8 by twoseemain/streams/plain_wrapper
: skip lseek(SEEK_CUR)
for newly opened files in e2bd3b1e99 by Max Kellermannstreams/xp_socket
: fix clang build error with enum usage on bool condition in 7ceae66182 by David Carlierps_title.c
in b468d6fb54 by Gina Peter Banyard 💜size_t
for get_ps_title()
length parameter in 9a7d37ac66 by Gina Peter Banyard 💜TCP_CONGESTION
socket option for Linux/FreeBSD in a193427333 by David Carlierphp_register_known_variable()
for known var names in 55908db007 by Gina Peter Banyard 💜safe_*erealloc*
flavor in few places to mitigate possible overflows in dfbb425295 by David Carlierfinfo_buffer()
in ca6d511fa5 by Christoph M. Beckermysqli_execute_query()
in GH-8660 in 1dc51c7b90 by Kamil TekielaReflection::getModifiersNames()
with readonly modifier in c650e67c90 by Pierrick Charronspl_filesystem_file_read_line()
/ spl_filesystem_file_read_line_ex()
in a055c54801 and bb3d0933af by Gina Peter Banyard 💜php_fgetcsv()
return a HashTale
instead of in-out zval param in GH-8936 in 4ccf0b0181 by Gina Peter Banyard 💜fgetcsv()
changes in eacf6f43ed by Gina Peter Banyard 💜var_export
, json_encode
, serialize
, and other in GH-8902 in 4df3dd7679 by Arnaud Le Blanc 💜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 Carlierini_parse_quantity
function to convert ini quantities shorthand notation to int in GH-8454 in by Dennis Snell%f
” regex in run-tests.php
in GH-8965 in 6cd5bd1bcd by Michael Voříšeksocket_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 Carlierpcntl_signal()
- max signal allowed in GH-8956 in 23654a172e by Juan Moraleszend_array_to_list()
in GH-8976 in 75a9a5f311 by Tim Düsterhusprint_ht
for new compact packed arrays representation in GH-8966 in c654973c02 by Arnaud Le Blanc 💜zend_constants.stub.php
from zend_exceptions.stubs.php
in bb5be650c6 by Máté Kocsis 💜#[\SensitiveParameter]
attribute in stubs in GH-8836 in 342e18f105 by Tim Düsterhusgen_stub.php
in 227a8576d2 by Máté Kocsis 💜VT_ERROR
variant type in GH-8886 by Christoph M. Beckerpcntl_exec
- check stringable parameters error in GH-8990 by Juan Moralesphp_cli_server_workers_max
in 789a37f144 by guoyiyuanpcntl_signal
- error when handler is int and not SIG_DFL
or SIG_IGN
in GH-9001 by Juan Moralesftp_connect
- error behavior when connection fails in GH-9002 by Juan Moralesis_callable($foo)
and callable $foo
in GH-8823 by Rowan Tomminsstr_split
in GH-9016 in 63912b5ecd by Ilija Tovilo 💜WeakMap
object reference offset causing TypeError
in GH-8995 in ede92a86f2 by Tobias Bachertarc4random_buf
if glibc in 3be9118662 by Cristian Rodríguezmb_http_input
- function returns FALSE for type ‘L’ or ‘l’ in GH-9018 by jcmmb_convert_encoding_array
- error for object item in array in GH-9023 by jcmftp_rawlist
- check list return value in GH-9012 by jcmSensitiveParameter
as known string and use it in arginfo in 55a88f36b6 by Remi Colletmatch
/switch
arms in GH-8961 in f2381ae4ba by Arnaud Le Blanc 💜DatePeriod
properties cannot be made readonly in GH-9013 in e13d60c039 by Máté Kocsis 💜SQLITE_COPY
in authorizer callback in GH-9041 by Christoph M. BeckerMYSQLI_IS_MARIADB
in GH-8919 by Kamil Tekiela@cname
to @cvalue
in stubs in GH-9043 in e328c68305 by Máté Kocsis 💜iterator_*()
family accept all iterable
s in GH-8819 in 7ae7df5b46 by Tim Düsterhusphp_stream_sock_open_from_socket
could return NULL
in GH-9020 by Heiko Weber--CGI--
support of run-tests.php
in GH-9061 by Christoph M. Beckermb_detect_encoding()
: wrong results with null $encodings in GH-9063 by Christoph M. Beckerphpinfo
HTML Output: Make module title names clickable and link to the URL fragment in GH-9054 by Ayesh KarunaratneRandomizer::getBytes()
if a user engine throws in GH-9055 in 998ede7123 by Tim Düsterhusrand_rangeXX()
in GH-9056 in 804c3fc821 by Tim Düsterhuswin32/codepage.c
codes for windows arm64 in GH-7702 by dixyesphp_random_range()
in GH-9066 in 133b9b08da by Go Kudoclient->request.request_uri
to zend_string
in GH-9086 in c8f4801382 by Gina Peter Banyard 💜rand_rangeXX()
in GH-9088 in ab5491f505 by Tim Düsterhusrun-tests.php
] Improve non-optimal nested if
/elseif
/else
blocks with happy path optimizations in 51447fb47d by Ayesh Karunaratnerun-tests.php
] Minor optimizations in if
blocks by placing simple expressions first in 056afc8daf by Ayesh Karunaratnerun-tests.php
] Merge multiple unset()
calls to a single call in f958701dad by Ayesh Karunaratnerun-tests.php
] Replace backtick operator string literals with shell_exec()
calls in c83a10d8db by Ayesh Karunaratnerun-tests.php
] Combine multiple str_replace
calls to a single strtr
call in 3483a1f170 by Ayesh Karunaratnerun-tests.php
] echo call performance optimization in 0490f082e9 by Gina Peter Banyard 💜crc32_aarch64
from clang Closes #8916 in 77bd39a116 by David CARLIERlob_prefetch_ini.phpt
test in GH-9099 in fc42098c23 by Michael Voříšek-1
“precision” in gen_stub.php
in GH-8734 by Michael Voříšekext/random/random.c
in GH-9114 in 395b6a9674 by Tim Düsterhusreadonly
db DBA error message in 0887a1d7ab by Gina Peter Banyard 💜MDB_RDONLY
to the LMDB environment for readonly DBs in 79d831ff9f by Gina Peter Banyard 💜Randomizer::__construct()
call twice in GH-9091 in 34b352d121 by Go Kudoblacklist_path_length
in GH-9129 by Christoph M. Becker->last_unsafe
from php_random_status
in GH-9132 in 5c693c770a by Tim Düsterhuszend_ulong
in bdf5a4e478 by Gina Peter Banyard 💜uint32_t
in Z_PARAM_VARIADIC_WITH_NAMED
in 9115211ebf by Gina Peter Banyard 💜buffer_length
on all platforms to INT_MAX
in GH-9126 by Christoph M. BeckerREAD_CSV|DROP_NEW_LINE
drops newlines within fields in GH-7618 by Christoph M. BeckerValueError
if an invalid mode is passed to Mt19937
in GH-9159 in d058acb4ac by Tim Düsterhusopenssl_random_pseudo_bytes()
upper bound error message in 5d62cfbc7d by Christoph M. Beckerdba_open(“non-existing”, “c-”, “flatfile”)
segfaults in GH-9156 by Christoph M. Becker\U
and \u
in generated stubs in GH-9154 by Andreas Braunopenssl_random_pseudo_bytes()
in GH-9153 by Christoph M. Beckerphp_random_bytes()
in GH-9169 by Tim Düsterhusfile.current_zval
in GH-8934 by Gina Peter Banyard 💜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.