
Fresh selection with links to news and materials. In the release: updates to PHP, Codeception 3.0 and other releases, short lambdas in PHP 7.4 and an overview of recent RFC proposals from PHP Internals, a portion of useful tools, and much more.
Enjoy reading!
fn() => and automatic capture of variables from an external scop by value: $y = 1; $fn = fn($x) => $x + $y; andOperator = ($x) => ($y = 10) && $x + $y; console.log(andOperator(5)); // 15 $andOperator = fn($x) => ($y = 10) && $x + $y; var_dump($andOperator(5)); // bool(true) end() : <?php function last(...$args) { return end($args); } $multipleLines = fn($x) => last( $y = $x * 10, // 10 $z = $y + 15, // 25 $x + $y + $z // 1 + 10 + 25 last() ); var_dump($multipleLines(1)); // int(36) array_slice() , thanks to Grikdotnet for the tip : $multipleLines = fn($x) => array_slice([ $y = $x * 10, $z = $y + 15, $x + $y + $z ], -1)[0]; var_dump($multipleLines(1)); // int(36) <? however, it was greeted by a storm of indignation and dispute. Therefore, a much milder way was proposed, in which in the next versions the possibility remains available as is and deprecation warning will be thrown.... will now be available in arrays. $parts = ['apple', 'pear']; $fruits = ['banana', 'orange', ...$parts, 'watermelon']; // ['banana', 'orange', 'apple', 'pear', 'watermelon']; iterator_to_array : $array = [...$iter]; __toString() . Another nice and not at all trivial improvement for PHP 7.4, which eliminates the need to use any workarounds 1 , 2 .
How Eloquent Works - Laravel Core Adventures
We start working with event sourcing in Laravel - using spatie / laravel-event-projector .
Yii is joined by Mehdi Achour
Review Yii3
Asynchronous PHP. What for?
5 ways to deploy PHP code in terms of hayload
Statistics and monitoring of PHP scripts in real time. ClickHouse and Grafana go to Pinba for help.
Breaking a Singleton design pattern in PHP
Stream to update spatie / period - to pry into someone else's monitor is quite informative.Thanks for attention!
If you notice an error or inaccuracy - please inform the PM .
Write questions and suggestions by mail or twitter .
')
More news and comments on the PHP Digest Telegram channel.
Send link
Search links for all digests
← Previous release: PHP Digest number 154
Source: https://habr.com/ru/post/450642/
All Articles