PHP Digest # 201 (15-29 mars 2021)



Nouvelle sélection avec des liens vers des nouvelles et des documents. Dans la version: tout sur les fibres et PHP asynchrone, ainsi que les nouveaux lambdas, les intersections de types et autres propositions pour PHP 8.1. Événements à venir, une partie d'outils utiles, articles, podcasts, vidéos et PHP Digest Stream.



Bonne lecture!









nouvelles





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:








Un flux basé sur PHP Digest sera hébergé par Petr Myazin, l'auteur du podcast PHP Five-Minute , avec moi aujourd'hui .



Nous analyserons les nouvelles et les liens du problème avec des détails et des détails, et parlerons avec l'invité du plugin pour PhpStorm i18n Ally.



À partir de 19h00 Moscou, Minsk, Kiev.












Si vous remarquez une erreur ou une inexactitude, veuillez nous en informer dans un habr personnel ou un télégramme .





Plus d'actualités et de commentaires sur la chaîne PHP Digest Telegram .



Envoyer le lien

Rechercher des liens dans tous les résumés

Numéro précédent: PHP-Digest № 200




All Articles