PHP Annotated – December 2022

PHP Annotated Monthly

Greetings everyone!

Welcome to the December installment of PHP Annotated, where we’ll catch up on the most exciting things that have happened in the PHP world over the last month, including curated news, articles, tools, and videos.

News

  • 🎉 PHP 8.2.0 released!

    PHP 8.2 is a major update of the PHP language.It contains new features, including readonly classes, DNF types, null/false/true as stand-alone types, a new randomizer API, and constant in traits.

    The release comes with a few deprecations, with the deprecated dynamic properties being probably the most significant one. There are also performance improvements, as usual.

    For a detailed list of what’s new in PHP 8.2, check out the release page.
    Also check out PHP 8.2 Highlights on PHP.Watch and a video overview of PHP 8.2 by my colleague Brent.

    Installing/Upgrading to PHP 8.2
  • ⚠️ PHP 7 has reached end of life
    PHP 7.4.33 was the last release of PHP 7. PHP 7 will no longer receive official security updates.

    However, major distributions like RedHat or Ubuntu will deliver security updates for PHP 7.4 as part of their LTS premise.

  • PHP 8.0.26 and PHP 8.1.13 have been released
    🐛 These are bug fix releases.

    The PHP 8.0 branch has ended active support, and will only receive security-fix updates.

  • 🎂 PHP Foundation turns 1 year
    The PHP Foundation was established a year ago.

    Over the past year, the PHP Foundation has supported the work of 6 core developers, and made a significant contribution to the PHP language.

    Check out the Impact and Transparency Report 2022 to learn what has been achieved and see the high-level goals for 2023.

    Consider supporting the PHP Foundation via OpenCollective.

  • PhpStorm 2022.3 is out
    This major update brings a preview of the new UI, complete PHP 8.2 support, Redis support in database tools, Code Vision for PHP, a quick-fix preview, Xdebug config validation, support for ParaTest, reader mode for PHPDoc, and many other features.
  • Symfony 6.2 is out
    Better emoji support, an access token authenticator, built-in Cache+Security+Template+Doctrine Attributes, improved enum support, and more.

    Check out the Curated New Features list to learn about the highlights of this new release.

  • 📺 PHP Annotated on YouTube
    In addition to this PHP Annotated Newsletter, we now also have a dedicated PHP Annotated channel on YouTube.

    The channel is all about PHP and community, and you can check out the first videos by Brent Roose.

  • PSR-20: Clock accepted
    The PHP-FIG group has accepted and tagged a PSR-20 with the recommended ClockInterface for date and time.
  • 🎉 Psalm 5 is out
    There are a few new features available in this release: list{int, string, float}, properties-of, variable templates, and int-range<x, y>.
  • Xdebug 3.2.0 is out
    This release adds support for PHP 8.2, and drops support for PHP 7.2-7.4. It has the new ability to inspect function return values, and comes with better warning messages.
  • PHPStan 1.9.0 has been released
    The update brings PHPDoc asserts, list types, @param-out tag for parameters assigned by referencу, and other improvements.
  • Drupal 10 is available
    It requires Symfony 6.2 and PHP 8.1 and adds many improvements across all systems.

PHP Core

Most of the Core news is covered in detail in the PHP Core Roundup series from the PHP Foundation, so we’ll only mention it briefly:

  • 📣 PHP RFC: Dynamic class constant fetch #PHP 8.3
    Ilija Tovilo proposed introducing a syntax for looking up class constants.

    class Foo {    
        const BAR = 'bar';
    }
    $bar = 'BAR';
     
    // This is currently a syntax error
    echo Foo::{$bar}; 
     
    // Instead, the `constant` function must be used
    echo constant(Foo::class . '::' . $bar);
    
  • 📣 RFC: Arbitrary static variable initializers #PHP 8.3
    Ilija Tovilo proposed extending the syntax that allows the static variable initializer to contain arbitrary expressions.

    function bar() {    
        echo "bar() called\n";
        return 1;
    }
     
    function foo() {
        static $i = bar();
        echo $i++, "\n";
    }
     
    foo();
    
  • 📣 RFC: Readonly amendments #PHP 8.3
    Nicolas Grekas and Máté Kocsis proposed improving readonly properties and classes, allowing non-readonly classes to extend readonly classes and allowing readonly properties to reinitialize during cloning:

    readonly class Foo {
        public function __construct(
            public DateTime $bar
        ) {}
     
        public function __clone()
        {
            $this->bar = clone $this->bar;
        }
    }
     
    $foo = new Foo(new DateTime());
    $foo2 = clone $foo;
    
  • 📊 RFC: More Appropriate Date/Time Exceptions #PHP 8.3
    Derick Rethans proposed introducing Date/Time extension specific exceptions and errors where this makes sense.
  • 📣 RFC: List\unique() and Assoc\unique() #PHP 8.3
    Ilija Tovilo proposed adding two new functions for the cases that are not supported by array_unique():

    List\unique([1, 2, 3, 1, '2', 3.0, new Foo, ['bar']]);
    // > [1, 2, 3, '2', 3.0, Foo, ['bar']]
    
    Assoc\unique(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'foo']);
    // > ['foo' => 'foo', 'bar' => 'bar']
            
  • 📣 RFC: Unicode Text Processing #PHP 8.3
    Derick Rethans suggests introducing a new Text class to make using and processing Unicode text significantly more developer friendly and without having to know all the intricacies of Unicode text processing.

    $content = new Text('नमस्ते दुनिया');
    if ($content->toLower()->startsWith('नमस्ते')) {
      // ...
    }
    

Tools

  • Marcel Pociot built a neat GitHub bot that evaluates PHP code blocks in GH issues if you mention it @phptinker:
  • ramsey/uuid – A new version of package for generating universally unique identifiers comes with support for UUID v8 and custom UUIDs.
  • loophp/collection – A memory friendly and modular collection class released a new major version, 7.0.0.
  • php-rust-tools/parser – A work-in-progress PHP parser written in Rust by Ryan Chandler and Saif Eddin.

    You may also be interested in phper, a tool that allows writing PHP extensions using pure and safe Rust whenever possible.

  • ScriptFUSION/Porter – Durable and asynchronous data imports for consuming data at scale and publishing testable SDKs.
  • ChatGPT is taking over everything, so you may want to check out the PHP client for OpenAI:
  • qossmic/deptrac 1.0 – Project architecture analysis tool for determining dependencies between application layers.
  • revoltphp/event-loop 1.0.0 – This event loop is a joint effort between ReactPHP and Amphp maintainers. It is now ready for production use, has been tested in various different applications and scenarios, and fully supports fibers.
  • rob893/emoji-cache – LRU cache implementation, but all identifiers are emojis.

Symfony

Laravel

Other Frameworks

Misc

Video

Conferences


Happy holidays, PHPers! 🎄🐘

If you have any interesting or useful links to share via PHP Annotated, please leave a comment on this post or send me a tweet.

Subscribe
to PHP Annotated

Roman Pronskiy

Product marketing manager for @PhpStorm, helped to launch @The PHP Foundation.

Twitter | GitHub

image description