PHP Digest # 195 (December 14 - 28, 2020)



Fresh selection with links to news and materials. In this issue: Fibers for asynchronous PHP, first native attributes, short match and other RFC proposals for PHP 8.1, tools, many videos, articles and podcasts.



Happy reading and Happy New Year!









PHP Internals



  • [RFC] Fibers - A great proposal for asynchronous PHP. More details were in the Telegram channel . In short, this is an improved version of generators, which will allow you to write asynchronous code based on libraries like ReactPHP / Amp much easier and more understandable.





    Amp v3 is still in development, but already uses fibers instead of promises. Here's an example of what the async / await analog looks like:
    use Amp\Delayed;
    use Amp\Loop;
    use function Amp\async;
    use function Amp\await;
    
    //  ,    int  ,     ,      .
    $callback = function (int $id): int {
        return await(new Delayed(1000, $id)); // Await promise resolution.
    };
    
    //  $callback  int, but is executed asynchronously.
    $result = $callback(1); //      ,  1 .
    \var_dump($result);
    
    //      ,        .
    $result = await([  //  ,    1 .
        async($callback, 2),
        async($callback, 3),
    ]);
    \var_dump($result); //   2     .
          
          



  • [RFC] #[Deprecated] Attribute โ€” PHP 8 , . โ€” #[Deprecated]



    . , #[Deprecated]



    , PHP E_DEPRECATED



    .



    , , .



    , PhpStorm 2020.3. , . , - final, .
  • [RFC] #[NamedParameterAlias] Attribute โ€” PHP 8.1.



    , โ€” . , API .



    RFC: Named Parameters explicit opt in.



    โ€” , , .
    <?php
    
    use NamedParameterAlias;
    
    // Old function signature:
    function log($arg1) {}
    
    // New function signature introduces better name
    function log(#[NamedParameterAlias("arg1")] $message) {}
    
    log(arg1: "Hello World!");
    log(message: "Hello World!");
    
          
          



    Attribute::IS_REPEATABLE



    . , .
  • [RFC] Short match โ€” match



    PHP 8 switch



    .



    switch(true) { ...



    , if-elseif-...else



    . match(true)



    .



    RFC match



    match(true)



    .

    PHP 8.0:
    $a = 3;
    
    print match (true) {
      $a < 2 => 'small',
      $a == 3 => 'medium',
      default => 'large',
    };
    
          
          



    :
    $a = 3;
    
    print match {
      $a < 2 => 'small',
      $a == 3 => 'medium',
      default => 'large',
    };
    
          
          



    ยซยป.
  • [RFC] Configurable callback to dump results of expressions in `php -a` โ€” Tyson Andre php -a



    .



    bobthecow/psysh, PHP . .
  • [RFC] Add is_list(mixed $value): bool โ€” RFC Tyson Andre. is_list()



    , true



    , 0, 1, 2 ... count($value)-1



    .

  • [PR] Add support for property initialization during cloning โ€” - .
    class Foo
    {
        public $bar;
        public $baz;
    
        public function withProperties($bar, $baz)
        {
            $self = clone $this;
            $self->bar = $bar;
            $self->baz = $baz;
    
            return $self;
        }
    }
    
    class Foo
    {
        public $bar;
        public $baz;
    
        public function withProperties($bar, $baz)
        {
            return clone $this with {
                bar: $bar,
                baz: $baz,
            };
        }
    }
    
          
          







  • Rector 0.9 โ€” , , PHP 8.
  • FriendsOfPHP/proxy-manager-lts โ€” Ocramius/ProxyManager/ PHP >=7.1.
  • fullpipe/check-them โ€” . fullpipe1.
  • multiavatar/multiavatar-php โ€” (). 'php':

  • dantleech/maestro2 โ€” PHP- โ€” ansible PHP . GitHub Actions. .
  • matomo-org/matomo 4.0 โ€” Google Analytics PHP. Piwik.
  • jolicode/JoliNotif โ€” PHP-. Win, macOS, Linux.
  • skrtdev/NovaGram โ€” API -.


Symfony



  • Symfony #729 (14-20 2020)
  • video Symfony HttpClient API


Laravel



  • Laravel
  • Blackfire Laravel Vapor
  • habr Laravel,
  • video Freek Murzee,
  • video Laravel Internals #3 โ€” Laravel .
  • video Laravel Snippet #24: Fortify, Jetstream, Breeze


Yii



  • Yii 2.0.40
  • yiisoft/test-support โ€” , PSR-.




  • , PHP โ€” Matt Brown, Psalm, PHP Vimeo.
  • โ€“ , โ€” GitHub Git.
  • Flysystem 2.0 .
  • habr Magento 2
  • habr - PHP 8
  • ru Xdebug 2 Xdebug 3




  • 2020 Freek Van der Herten
  • Phalcon v5 โ€” PHP
  • PHP-FIG Discord




  • videoru PHP โ€” ? 1 (), 2 ()
  • videoru :
  • videoru : PHP- []
  • videoru PHP : , , []
  • videoru Highload PHP Redis ( , ManyChat).
  • videoru PHP 8 โ€” . PHP .
  • video PHP code review: upload-to-s3-webhook - Public code review by Mathew Napoli, author of Bref .
  • video About the modes of operation in Xdebug 3 - Video from the author of Xdebug about the configuration of the debugger / profiler / coverage collector.


Entertaining



  • elephpant PHP8: InPHPinity is born - The new elephant PHP 8 is available for pre-order:












Today there will be the second PHP Digest stream. All news and links from the issue + more details, an overview of what was sent, interesting but not included in the issue, the results of the drawing and a new contest with elephants.

Beginning at 20:00 Moscow, Minsk / 19:00 Kiev.



Poll: Summing Up PHP Year and Playing the Elephant






If you notice an error or inaccuracy, please let us know in a personal habr or telegram .





More news and comments on the PHP Digest Telegram channel .



Send link

Search links in all digests

โ† Previous issue: PHP Digest # 194




All Articles