PHP Digest # 201 (15 - 29 March 2021)



Fresh selection with links to news and materials. In the release: everything about fibers and asynchronous PHP, as well as new lambdas, type intersections and other proposals for PHP 8.1. Upcoming events, a portion of useful tools, articles, podcasts, videos and PHP Digest Stream.



Enjoy reading!









news





Async PHP



  • [RFC] Fibers β€” PHP 8.1



    Swoole - .



    β€” , ( ). , . PHP.



    $fiber = new Fiber(function (): void {
        $value = Fiber::suspend('suspend');
        echo "Value used to resume fiber: ", $value, "\n";
    });
    
    $value = $fiber->start();
    
    echo "Value from fiber suspending: ", $value, "\n";
    
    $fiber->resume('resume');
    
    >   :
    Value from fiber suspending: suspend
    Value used to resume fiber: resume
    
          
          





    , PHP 8.1 ?

    . ReactPHP, Amp . , , .



    :

    β€’ Fibers β€” PHP 8.1 β€” RFC PHP.Watch.

    β€’ PHP: PHP? β€” ReactPHP .

     

    PHP 8.1 ext-fiber. , PHP 7.2.



  • PHP β€” : , , /. , PHP Β«- Β».
  • Asynchronous PHP β€” Multiprocessing, Multithreading & Coroutines β€” PHP core team Laravel.


PHP Internals



  • [RFC] Auto-capturing multi-statement closures

    Larry Garfield Nuno Moduro .



    .



    :

    $y = 1;
    
    $fn1 = fn($x) => $x + $y;
    
          
          





    :

    $fn2 = function ($x) use ($y): int {
       // ...
       return $x + $y;
    };
    
          
          





    :

    $c = 1;
    $foo = fn($a, $b):int {
      // ...
      $val = $a * $b;
      return $val * $c;
    };
    
          
          





  • [RFC] Short Functions

    RFC .



    // 
    function add(int $a, int $b): int
    {
        return $a + $b;
    }
    
    // 
    function add(int $a, int $b): int => $a + $b;
    
          
          





    :
    class Person
    {
        public function __construct(
            private string $firstName,
            private string $lastName,
        ) {}
    
        public function getFirstName(): string => $this->firstName;
    
        public function getLastName(): string => $this->lastName;
    
        public function getFullName(): string => $this->firstName . ' ' . $this->lastName;
    }
    
          
          





    , PHP
    β€’ =>



    (, , , match).

    β€’ { ... }



    , return



    .

    β€’ function



    .

    β€’ fn



    , .

    β€’ , .


  • [RFC] Deprecations for PHP 8.1

    . PHP 8.1 dreprecation notice, PHP 9 .



    : mysqli::init()



    , key(), current(), next(), prev(), and reset() , .
  • [RFC] Pure intersection types

    PHP 8.0 , RFC .



    TypeA&TypeB



    , instanceof TypeA



    instanceof TypeB



    .



    class A {
        private Traversable&Countable $countableIterator;
    
        public function setIterator(Traversable&Countable $countableIterator): void {
            $this->countableIterator = $countableIterator;
        }
    
        public function getIterator(): Traversable&Countable {
            return $this->countableIterator;
        }
    }
    
          
          





    pure intersection types, union .
  • [Draft] Add FPM early bootstrapping mode

    Benjamin Eberlei ( PHP 8) fpm.bootstrap_file



    . , FPM . , FPM-, .



    , , , , , , .





    - auto_prepend_file.

  • PHP JIT/arm64 port β€” ARM PHP JIT ARM-.
  • [RFC] mysqli bind in execute β€” .






Symfony





Laravel





Yii









/







  • phpday:








A stream based on the PHP Digest will be hosted by Petr Myazin, the author of the Pyatiminutka PHP podcast, with me today .



We will analyze the news and links from the issue with details and details, and talk with the guest about the plugin for PhpStorm i18n Ally.



Beginning at 19:00 Moscow, Minsk, Kiev.












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 β„– 200




All Articles