PHP Annotated – January 2023

PHP Annotated Monthly

Greetings everyone!

Welcome to the January 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 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:

  • RFC: Dynamic class constant fetch
    PHP 8.3 will introduce a syntax for looking up class constants:

    class Foo {
        const BAR = 'bar';
    }
    $bar = 'BAR';
    
    // New syntax in PHP 8.3:
    echo Foo::{$bar};
        
  • RFC: More Appropriate Date/Time Exceptions
    As of PHP 8.3, when using Date/Time classes, PHP will throw more specific exceptions if something goes wrong.

    The procedural style of date/time functions is not affected, and will continue to use warnings and errors as it currently does.

  • 📊 RFC: Asymmetric Visibility
    Ilija Tovilo and Larry Garfield proposed adding Swift-like syntax to allow properties to have separate (“asymmetric”) visibility for read and write operations.

    class Foo {
        public private(set) string $bar;
    }
    

    Voting is currently taking place slowly, and the feature is not receiving enough votes to reach the 2/3 threshold.

  • 📣 RFC: Add SameSite cookie attribute parameter #PHP 8.3
    George Peter Banyard proposes to add a SameSite parameter to all relevant functions.
  • A set of 18 functions/changes to improve PHP core
    Thomas Hruska implemented cubiclesoft/php-ext-qolfuncs – a set of quality-of-life improvement functions designed for PHP core.

    The set has some pretty neat additions: str_splice(), str_realloc(), fread_mem(), is_reference(), refcount(), just to name a few. Looking forward to seeing a formal RFC.

Tools

  • amphp/amp 3.0.0 – The non-blocking concurrency framework for PHP applications has received a major update. It is now based on coroutines using Fibers instead of Generators and it uses revoltphp/event-loop.

    Updates have also been made to numerous Amphp ecosystem packages; here are just a few examples: amphp/pipeline and amphp/process.

  • PHP-DI 7.0 – This update for this dependency injection container package comes with PHP 8.0+ support, @Inject PHPDoc annotation replaced by #[Inject] attribute, PSR-11 2.0 compatibility, and other improvements.
  • php-ffi/var-dumper – A wrapper for symfony/var-dumper that allows dumping FFI types using the functions dd() and dump().
  • olvlvl/composer-attribute-collector – A convenient and near zero-cost way to retrieve targets of PHP 8 attributes.
  • PHPCSStandards/PHPCSExtra – A collection of extra rules for use with PHP_CodeSniffer.
  • cerbero90/enum – A PHP package to supercharge enum functionalities. Basically, it’s a trait you can add to your enums to give them a ton of useful functions.
  • NoiseByNorthwest/php-spx – A simple & straight-to-the-point PHP profiling extension with its built-in web UI.
  • PXP – A superset of PHP with extended syntax and runtime capabilities.

    Ryan Chandler started off by developing a PHP parser in Rust. The project grew to the whole idea of a superset language.

    There were a few attempts to build such a superset for PHP previously (marcioAlmada/yay or nunomaduro/plus-1), but this one looks quite promising.

    Apparently, there is another similar attempt, also developed in Rust:
    Ara Programming Language – a statically typed programming language that compiles directly to PHP.

Symfony

Laravel

Misc

Video

On php.net Events: February 2023 you can find the next PHP meetup near you


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, had a hand in creation of @The PHP Foundation.

Twitter | GitHub

image description