带有新闻和资料链接的新鲜选择。在发行中:Composer 2.0 Alpha和其他发行版,PHP Internals提供了5个新的和一个被接受的RFC报价,以及有关投票的更新属性,一部分有用的工具,播客,访谈等等。享受阅读!
throw
$callable = fn() => throw new Exception(); $foo = $bar['key'] ?? throw new KeyNotSetOnBarException();
<<>>
@:
<<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;
\PHP
mixed
array|bool|callable|int|float|null|object|resource|string
catch
try { changeImportantData(); } catch (PermissionException) { // The intention is clear: exception details are irrelevant echo "You don't have permission to do this"; }
match
switch
match ($condition) { 1 => { foo(); bar(); }, 2 => baz(), } $expressionResult = match ($condition) { 1, 2 => foo(), 3, 4 => bar(), default => baz(), };
|>
$$
$result = "Hello World" |> 'htmlentities' |> 'explode' |> fn($x) => array_map(fn($v) => 'strtoupper', $x) |> fn($x) => array_filter(fn($v) => $v != 'O');
!— , , ..Telegram- PHP Digest.← : PHP- № 177