Alpha testing of PHP 8.2 has begun

The first alpha release of the new branch of the PHP programming language 8.2 has been introduced. The release is scheduled for November 24. Key innovations that are already available for testing or planned for implementation in PHP 8.2 include:

  • Separate types 'false' and 'null' have been added, which can be used, for example, to return a function's completion status with an error or an empty value. Previously, 'false' and 'null' could only be used in conjunction with other types (for example, 'string|false'), but now they can be used separately: function alwaysFalse(): false { return false; }
  • A feature has been added to mark a class as read-only. Properties in such classes can only be set once and will not be available for modification afterward. Previously, only individual properties could be marked as read-only, but now this mode can be applied to all properties of a class at once. Specifying the 'readonly' flag at the class level also prevents dynamic property addition to the class. readonly class Post { public function __construct( public string $title, public Author $author, ) {} } $post = new Post(/* … */); $post->unknown = 'wrong'; // Error: Cannot create dynamic property Post::$unknown
  • The ability to dynamically create properties in a class (like 'post->unknown' in the example above) has been declared deprecated. In PHP 9.0, accessing properties that are not originally defined in the class will result in an error (ErrorException). Classes providing __get and __set methods for property creation, or dynamic properties in stdClass, will continue to work unchanged; only implicit handling of non-existent properties will be discontinued to protect developers from hidden errors. To maintain compatibility with legacy code, the attribute '#[AllowDynamicProperties]' has been proposed to allow the use of dynamic properties.
  • The ability to filter sensitive parameters in stack trace data output during errors has been provided. Removing specific information may be necessary when error details are automatically sent to third-party services that track and report issues to developers. For example, parameters that include usernames, passwords, and environment variables can be excluded from the trace.function test( $foo, #[\SensitiveParameter] $password, $baz ) { throw new Exception('Error'); } test('foo', 'password', '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
  • The ability to substitute variable values in strings using expressions '${var}' and ${(var)} has been deprecated. Support for the commonly used substitutions '{$var}' and '$var' has been retained. For example:'Hello {$world}'; OK 'Hello $world'; OK 'Hello ${world}'; Deprecated: Using ${} in strings is deprecated
  • Partially supported callable objects that can be called using 'call_user_func($callable)' but do not support calling in the form '$callable()' have been declared deprecated:'self::method' 'parent::method' 'static::method' ['self', 'method'] ['parent', 'method'] ['static', 'method'] ['Foo', 'Bar::method'] [new Foo, 'Bar::method']
  • Locale-independent case conversion has been implemented. Functions like strtolower() and strtoupper() now always convert the case of characters in the ASCII range regardless of the 'C' locale setting.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster