PHP Core Roundup 9
Marcos Marcolin • February 5, 2023 • 2 min read
php phpfoundation opensource php-core-roundupAccording to Core Roundup #9, here are some improvements and RFCs for version 8.3, highlights from January:
RFC under vote: Readonly amendments
The proposed change is to allow regular classes to extend (inherit from) Readonly classes. Today, that's forbidden and throws a 'Fatal error'. It also allows re-initializing Readonly properties during cloning.
RFC implemented: Randomizer Additions
An improvement to PHP's new 'Random' extension, created to standardize random number generation. This RFC proposes adding the getBytesFromString() and getFloat()/nextFloat() methods, for generating random strings and floating-point numbers (float). These operations are usually implemented in userland, with some difficulty.
RFC under discussion: Path to Saner Increment/Decrement operators
A change to the increment ($v++) and decrement ($v--) operators, to standardize the output when used with an int or float type. Often, the output is unexpected.
The idea is for $v++ to be equal to $v += 1, and $v-- to $v -= 1.
RFC under discussion: Saner array_(sum|product)()
Here, the goal is to raise a warning when array_sum() and array_product() are used with an array containing incompatible types. This will introduce a backwards compatibility break.
RFC rejected: Asymmetric Visibility
This one would introduce a new syntax for declaring encapsulation of a class's properties, e.g.:
class Foo {
public private(set) string $bar;
}
In the snippet above, the getBar() operation would be public, while setBar() would be private.
Besides these and other RFCs, several performance improvements were implemented, mainly in the mbstring and random extensions.
I've been able to follow several PRs from December 2022 onward, and it's clear how much the language keeps evolving and improving, the PHP Foundation gave the language a real boost to keep evolving. 🙂