PHP Digest No. 178 (6 - 21 April 2020)


Seleksi segar dengan tautan ke berita dan bahan. Dalam rilis: Komposer 2.0 Alpha dan rilis lainnya, 5 penawaran RFC baru dan satu diterima dari PHP Internals, serta atribut yang diperbarui pada pemungutan suara, sebagian dari alat yang bermanfaat, podcast, wawancara, dan banyak lagi.

Selamat membaca!


Berita dan Siaran



PHP Internals


  • [RFC] throw expression โ€” PHP 8 throw , . , , :

    $callable = fn() => throw new Exception();
    
    $foo = $bar['key'] ?? throw new KeyNotSetOnBarException();
    
  • [RFC] Attributes v2 โ€” () . , , , , . .

    , . : <<>> @:.

    <<ExampleAttribute>>
    class Foo
    {
        <<ExampleAttribute>>
        public const FOO = 'foo';
    
        <<ExampleAttribute>>
        public $x;
    
        <<ExampleAttribute>>
        public function foo(<<ExampleAttribute>> $bar) { }
    }
    
    $object = new <<ExampleAttribute>> class () { };
    
    <<ExampleAttribute>>
    function f1() { }
    
    $f2 = <<ExampleAttribute>> function () { };
    
    $f3 = <<ExampleAttribute>> fn () => 1;
    
  • [RFC] PHP Namespace in core, [RFC] PHP Namespace Policy โ€” RFC-, \PHP , .
  • [RFC] Mixed Type v2 โ€” , , - . mixed .

    PHP 8. mixed array|bool|callable|int|float|null|object|resource|string.
  • [RFC] non-capturing catches โ€” catch:

    try {
        changeImportantData();
    } catch (PermissionException) { // The intention is clear: exception details are irrelevant
        echo "You don't have permission to do this";
    }
    
  • [RFC] Match expression โ€” switch match, switch, . -.

    match ($condition) {
        1 => {
            foo();
            bar();
        },
        2 => baz(),
    }
    
    $expressionResult = match ($condition) {
        1, 2 => foo(),
        3, 4 => bar(),
        default => baz(),
    };
    
  • [RFC] Pipe Operator v2 โ€” |> c . Elixir / JS (Hack) $$.

    $result = "Hello World"
        |> 'htmlentities'
        |> 'explode'
        |> fn($x) => array_map(fn($v) => 'strtoupper', $x)
        |> fn($x) => array_filter(fn($v) => $v != 'O');
    
  • : [RFC] Compact Object Property Assignment



Symfony



Laravel



Laminas



Async PHP





/



!

โ€” , , .
.

Telegram- PHP Digest.



โ† : PHP- โ„– 177


All Articles