PHP Digest # 199 (February 8 - 22, 2021)



PHP 8.1 will have an enum, and two more accepted, two rejected and three new RFCs for PHP 8.1. WordPress is used by 40% of sites. Why you need to remove strict_types, why you shouldn't use empty (), as well as tools, videos, articles, podcasts, and PHP Digest Live at 10:00 UTC .



Enjoy reading!









News and releases





PHP Internals



  • check [RFC] Enumerations

    44 7 . PHP 8.1 enum.



    enum RfcStatus {
        case Draft;
        case UnderDiscussion;
        case Accepted;
    }
    
    function setRfcStatus(RfcStatus $status) :void {
        // ...
    }
    
    setRFCStatus(RfcStatus::Accepted); // 
    setRFCStatus('Draft');                     // Deprecation notice  8.1, TypeError  9.0
    
          
          





    RFC php.watch.



    Symfony .
  • check [RFC] Deprecate passing null to non-nullable arguments of internal functions

    PHP null



    , nullable



    .



    PHP 8.1 TypeError



    . , str_contains("", null)



    . 3v4l.org/OVoa0A.



    : , PHP.
  • check [RFC] Array unpacking with string keys

    PHP 8.1 , :



    $array1 = ['a' => 'apple', 'p' => 'pear'];
    $array2 = ['b' => 'banana', 'o' => 'orange'];
    $array = [...$array1, ...$array2];
    //     :
    $array = array_merge($array1, $array2);
    
          
          



  • [RFC] Fibers

    , .



    Fiber API Ruby.



    ReactPHP trowski/react-fiber:



    
    $loop = new FiberLoop(Factory::create());
    
    $browser = new Browser($loop);
    
    $request = function (string $method, string $url) use ($browser, $loop): void {
        /** @var Response $response */
        $response = $loop->await($browser->requestStreaming($method, $url));
    
        /** @var ReadableStreamInterface $stream */
        $stream = $response->getBody();
    
        $body = $loop->await(Stream\buffer($stream));
    
        var_dump(\sprintf(
            '%s %s; Status: %d; Body length: %d',
            $method,
            $url,
            $response->getStatusCode(),
            \strlen($body)
        ));
    };
    
    $requests = [];
    
    $requests[] = $loop->async($request, 'GET', 'https://reactphp.org');
    $requests[] = $loop->async($request, 'GET', 'https://google.com');
    $requests[] = $loop->async($request, 'GET', 'https://www.php.net');
    
    $loop->await(Promise\all($requests));
    
          
          



  • [RFC] CachedIterable (rewindable, allows any key&repeating keys)

    Tyson Andre . .
  • Proposal: namespace the SPL

    Spl



    : Spl\FixedArray



    -> SplFixedArray



    . , CachedIterable



    ReverseIterator



    .



    azjezz/psl.

  • [RFC] mysqli bind in execute

    Kamil Tekiela mysqli



    . RFC mysqli_stmt::execute()



    . , , mysqli_stmt::bind_param()



    . , bind_param .
  • cross [RFC] PHP\iterable\any() and all() on iterables β€” any()



    all()



    .
  • cross [RFC] var_representation(): readable alternative to var_export() β€” var_export



    , brick/varexporter.
  • [Draft] Unify PHP's typing modes β€” PHP . β€” , , – strict_types=1



    – . , , .



    George Peter Banyard, RFC.



    .
  • Observer API PHP 8 β€” API . Xdebug, APM- New Relic, Tideways, ..






Symfony





Laravel





Yii





Async PHP



  • swow/swow β€” PHP, libuv, , PDO, file_get_ontents() .. ( ). , Swoole.


phpstorm PhpStorm









/





Entertaining



  • mario-deluna / php-render is a pure PHP 3D renderer, even without using FFI. Shaders, parser .obj files and more. Example



    code :
















Already a traditional stream based on PHP Digest. There will be a parsing of news and links from the issue with details and additional details.

Beginning at 20:00 Moscow, Minsk / 19:00 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 β„– 198




All Articles