PHP Digest # 197 (January 11 - 25, 2021)



Fresh selection with links to news and materials. In the release: objects as array keys and other RFC proposals for PHP 8.1, running WebAssembly in PHP, about collisions in arrays, a portion of useful tools, articles, videos, PHP Live Digest .



Enjoy reading!









News and releases





PHP Internals



  • [RFC] Object keys in arrays

    .



    $obj1 = new stdClass;
    $obj2 = new stdClass;
    
    $array = [];
    $array[$obj1] = 1;
    $array[$obj2] = 2;
    
    var_dump($array[$obj1]); // int(1)
    var_dump($array[$obj2]); // int(2)
    
          
          





    SplObjectStorage



    WeakMap



    , . . , array_*



    .



    , , , .



    , RFC Enumerations . . .
  • [RFC] Object scoped RNG Implementations

    rand()



    mt_rand()



    (seed) srand()



    . - .



    API , .

    $seed = 1234;
    $rng = new RNG\MT19937($seed);
    $array = [1, 2, 3, 4, 5];
    
    shuffle($array, $rng); //   
    
          
          



    , , , : random_bytes() random_int().

  • [RFC] var_representation(): readable alternative to var_export()

    var_export()



    , , . RFC array( )



    [ ]



    .



    var_representation($value, int $flags=0) :string



    , var_export()



    .



    brick/varexporter.
  • [RFC] Change Default mysqli Error Mode

    mysqli ( PHPLive#3 ) : . : mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);







    mysqli CodeIgniter WordPress.
  • [RFC] Dump results of expressions in `php -a` β€” php -a



    .
  • PHP 8.1: What's New and Changed β€” php.watch , PHP 8.1. RFC - .




  • fabpot/local-php-security-checker β€” composer.json . FriendsOfPHP/security-advisories.



    GitHub action Docker- oxcom.

  • funivan/PhpClean β€” PhpStorm, , , , , . .
  • wasmerio/wasmer-php β€” WebAssembly PHP. wasm- PHP. Rust, wasm PHP. . .
  • temporalio/sdk-php β€” PHP-SDK temporal.io – , , , , -.



    .. - :
    #[Workflow\WorkflowInterface]
    class LoopWorkflow
    {
        private array $values = [];
        private array $result = [];
        private $simple;
    
        public function __construct()
        {
            $this->simple = Workflow::newActivityStub(
                SimpleActivity::class,
                ActivityOptions::new()->withStartToCloseTimeout(5)
            );
        }
    
        #[SignalMethod]
        public function addValue(
            string $value
        ) {
            $this->values[] = $value;
        }
    
        #[WorkflowMethod(name: 'LoopWorkflow')]
        public function run(
            int $count
        ) {
            while (true) {
                yield Workflow::await(fn() => $this->values !== []);
                $value = array_shift($this->values);
    
                $this->result[] = yield $this->simple->echo($value);
    
                if (count($this->result) === $count) {
                    break;
                }
            }
    
            return $this->result;
        }
    }
          
          





    RoadRunner, reactphp/promise, PHP 8. , .


Symfony





Laravel





Yii





Async PHP









/







  • habr -, PHP.
  • PHP 8 β€” @jrf_nl, , PHP 8 .

    , PHP 1997-2017.





    Brent Roose , , .



    . . , , PHP 8.0 TypeError



    :



    var_dump(round("foo"));
          
          



    3v4l.org/pU0LD



    , , :
    $sub = substr('abcdef', 4, -4);
    if ($sub === false) {
        echo 'fail';
    } else {
        echo 'do something with $sub';
    }
    
    // PHP 5-7 > 'fail'
    // PHP 8   > 'do something with $sub'
    
          
          



    3v4l.org/Ln9g3



    : understandlegacycode.com.
  • What PHP would look like if it depended on me - A selection of desirable features from Brent Roose: final and void by default, no mixed, parameters and properties must be typed, generics, where can we go without them, enams, objects for scalars.













Today there will be the fourth stream based on PHP Digest. Parsing of news and links from the issue with details and interesting details not included in the text edition. Guest Anton Titov with a story about a new instrument. As well as the results of the drawing and a new competition with elephants.

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 for links in all digests

← Previous issue: PHP-Digest β„– 196




All Articles