Early Look at PHP 8.2
It's a month before the feature freeze so we can predict what the release will look like. So far it seems like an underwhelming release without any killer features. It still has very nice language improvements.
These are the things I would like to highlight:
Main headache
Deprecate dynamic properties (implemented)
No more undeclared properties on objects unless they descend from the stdClass
or are marked with #[AllowDynamicProperties]
. In theory it's an awesome feature that will help to catch many bugs. In practice, well, it was a feature from the olden times and who knows what the depths of vendor
hide?
Still not as disruptive as PHP 8.1 and its strict internal functions.
Example from the RFC:
<?php class User { public $name; } $user = new User; // Assigns declared property User::$name. $user->name = "foo"; // Oops, a typo: $user->nane = "foo"; // PHP <= 8.1: Silently creates dynamic $user->nane property. // PHP 8.2: Raises deprecation warning, still creates dynamic property. // PHP 9.0: Throws Error exception.
Nice features
Redacting parameters in back traces (implemented).
No more need to regex traces to hide passwords and stuff. Example from the RFC:
<?php function test( $foo, #[\SensitiveParameter] $bar, $baz ) { throw new \Exception('Error'); } test('foo', 'bar', 'baz'); /* Fatal error: Uncaught Exception: Error in test.php:8 Stack trace: #0 test.php(11): test('foo', Object(SensitiveParameterValue), 'baz') #1 {main} thrown in test.php on line 8 */
Random Extension / Random Extension Improvement (under discussion but likely to be accepted)
Not for everybody but it would be a good upgrade for MonsterID. It also is a great improvement over all the randomness mess in the current PHP.
Forget and never use please
Disjunctive Normal Form Types (voting, likely to be accepted)
Like intersection types weren't enough.
Comments
Comments powered by Disqus