PHP Core Roundup 11
Marcos Marcolin • April 11, 2023 • 2 min read
php phpfoundation opensource php-core-roundupImprovements for PHP 8.3 keep on coming!
The updates below cover last March in the language's core and are a summary of the #PHP Core Roundup #11 by PHP Foundation.
Before that, I need to mention that PHP 8.2.4 and 8.1.17 were released, both containing more than 45 bug fixes (and no security fixes).
RFCs
Implemented
- Saner array_(sum|product)() by George Peter Banyard
Proposed to change the current behavior of array_sum() and array_product() to properly handle non-numeric values. This results in additional warnings when these functions encounter unsupported types, such as certain objects, arrays, and resources.
- Typed class constants by Benas Seliuginas and Máté Kocsis
PHP's type system keeps improving, and it will now be possible to declare constant types. With this, you'll be able to define typed class constants, see the example below.
enum E {
const string TEST = "Test1";
}
trait T {
const string TEST = E::TEST;
}
interface I {
const string TEST = E::TEST;
}
class C {
const string TEST = E::TEST;
}
Under discussion
- Make
unserialize()emit a warning for trailing bytes by Tim Düsterhus
A warning should be emitted if bytes can be removed from the end of the input string without changing unserialize()'s return value.
- Define proper semantics for
range()function by George Peter Banyard
This RFC tries to eliminate several undesirable and unexpected behaviors from the range() function. Introduced in PHP 4, range() tries to work with several types, not only including integers, floats, and strings, but also other types.
Besides the RFCs, dozens of PRs were merged, proposing bug fixes and small improvements to PHP's code. You can check out the full list on the PHP Foundation's site.
To check out everything new this month, click here.