- PVSM.RU - https://www.pvsm.ru -
Свежая подборка со ссылками на новости и материалы. В выпуске: расписание релиза PHP 8, анализ эргономики объектов в PHP и 5 свежих RFC из PHP Internals, немного полезных инструментов, видео, подкасты и многое другое.
Приятного чтения!
{public get, private set}
). class Point {
public float $x;
public float $y;
public float $z;
public function __construct(
float $x = 0.0,
float $y = 0.0,
float $z = 0.0
) {
$this->x = $x;
$this->y = $y;
$this->z = $z;
}
}
Можно будет писать:
class Point {
public function __construct(
public float $x = 0.0,
public float $y = 0.0,
public float $z = 0.0
) {}
}
class Uri {
private function __construct(
?string $scheme,
?string $user,
?string $pass,
?string $host,
?int $port,
string $path,
?string $query,
?string $fragment // <-- ARGH!
) {
...
}
}
var_dump([] % [42]);
// int(0)
// WTF?
switch
в качестве выражения, а не только как управляющую конструкцию:
$expressionResult = switch ($condition) {
1 => foo(),
2 => bar(),
3, 4, 5 => baz(),
};
Также RFC предлагает разрешить перечисление возможных значений в секциях case
: case 3, 4, 5: break;
вместо case 3: case 4: case 5: break;
.
[(int) $now, (int) $future] = ["2020", "2021"];
// По сути то же, что и
[$now, $future] = ["2020", "2021"];
$now = (int) $now;
$future = (int) $future;
Николас Грекас в Твиттере приводит примеры [9] возможного использования такой функциональности, а именно имитации именованных параметров:
...[int $i] = ['a' => '123'];
function foo(...[int $i]) {
}
foo(['a' => '234']);
и быстрого объявления типизированных вложенных структур:
$var = (Foo) [
'a' => 123,
'b' => (Bar) [
'c' => // ...
],
];
Спасибо за внимание!
Если вы заметили ошибку или неточность — сообщите, пожалуйста, в личку [49].
Вопросы и предложения пишите на почту [50] или в твиттер [51].
Больше новостей и комментариев в Telegram-канале PHP Digest [52].
Прислать ссылку [53]
Поиск ссылок по всем дайджестам [54]
← Предыдущий выпуск: PHP-Дайджест № 176 [55]
Автор: Роман Пронский
Источник [56]
Сайт-источник PVSM.RU: https://www.pvsm.ru
Путь до страницы источника: https://www.pvsm.ru/php-2/351888
Ссылки в тексте:
[1] Расписание релиза PHP 8: https://wiki.php.net/todo/php80
[2] Подробнее: https://thephp.website/en/issue/php8-release-schedule/
[3] [RFC] Constructor Property Promotion: https://wiki.php.net/rfc/constructor_promotion
[4] анализ эргономики объектов в PHP: https://hive.blog/php/@crell/improving-php-s-object-ergonomics
[5] [RFC] Allow trailing comma in parameter list: https://wiki.php.net/rfc/trailing_comma_in_parameter_list
[6] [RFC] Stricter type checks for arithmetic/bitwise operators: https://wiki.php.net/rfc/arithmetic_operator_type_checks
[7] [RFC] Switch expression: https://wiki.php.net/rfc/switch_expression
[8] [RFC] Type casting in array destructuring expressions: https://wiki.php.net/rfc/typecast_array_desctructuring
[9] в Твиттере приводит примеры: https://twitter.com/nicolasgrekas/status/1244969585138446336
[10] Server-Side Request and Response Objects: https://wiki.php.net/rfc/request_response
[11] Userspace operator overloading: https://wiki.php.net/rfc/userspace_operator_overloading
[12] Write-Once (readonly) Properties: https://wiki.php.net/rfc/write_once_properties
[13] TitasGailius/terminal: https://github.com/TitasGailius/terminal
[14] symfony/process: https://github.com/symfony/process
[15] rlanvin/php-ip: https://github.com/rlanvin/php-ip
[16] ramsey/collection: https://github.com/ramsey/collection
[17] clue/graph-composer: https://github.com/clue/graph-composer
[18] Неделя Symfony #692 (30 марта — 5 апреля 2020): https://symfony.com/blog/a-week-of-symfony-692-30-march-5-april-2020
[19] Обзор компонента symfony/messenger: https://stfalcon.com/ru/blog/post/messenger-component
[20] Временная локализация на Symfony 4 + Twig: https://habr.com/ru/post/495604/
[21] 6 секретов Laravel Eloquent для улучшения кода: https://laravel-news.com/6-eloquent-secrets
[22] Сложные формы с помощью Laravel Livewire: https://freek.dev/1609-building-complex-forms-with-laravel-livewire-in-oh-dear
[23] Всё о валидации в Laravel: https://laravel.demiart.ru/laravel-validation-controllers-form-requests-and-rules/
[24] Blade компоненты в Laravel 7: https://laravel.demiart.ru/blade-komponenty-v-laravel-7/
[25] Используем трейты для полиморфных связей в Laravel: https://habr.com/ru/post/494658/
[26] Небольшие хитрости для тестирования веб-приложений на Laravel с использованием Model Factories: https://habr.com/ru/post/493926/
[27] Новости Yii 2020, выпуск 3: https://yiiframework.ru/news/259/novosti-yii-2020-vypusk-3
[28] О тестировании без мок-фреймворков.: https://blog.frankdejonge.nl/testing-without-mocking-frameworks/
[29] О паттерне Circuit Breaker: https://sarvendev.com/en/2020/03/circuit-breaker/
[30] ackintosh/ganesha: https://github.com/ackintosh/ganesha
[31] Функциональные тесты и ускорение создания схемы БД.: https://matthiasnoback.nl/2020/03/functional-tests-speeding-up-schema-creation/
[32] О проблемах паблик свойств и методов: https://www.tomasvotruba.com/blog/2020/03/30/dont-show-your-privates-to-public/
[33] rectorphp/rector: https://github.com/rectorphp/rector
[34] О разработке с использованием флагов фич: https://www.boxuk.com/insight/coding-with-feature-flags/
[35] Разбор уязвимости в ImpressCMS: https://blog.ripstech.com/2020/sql-injection-impresscms/
[36] SerafimArts/opengl-demo: https://github.com/SerafimArts/opengl-demo
[37] Капча для CodeIgniter 4: https://habr.com/ru/post/493752/
[38] Проблемы использования Doctrine ODM в процессах-демонах: https://habr.com/ru/post/495118/
[39] Spiral: высокопроизводительный PHP/Go фреймворк: https://habr.com/ru/post/495224/
[40] большого онлайн-митапа по PHP: https://www.youtube.com/watch?v=Bxe8FQyaCBs
[41] PHP Internals News: Episode 47: Attributes v2: https://phpinternals.news/47
[42] Benjamin Eberlei: https://twitter.com/beberlei
[43] RFC Attributes v2: https://wiki.php.net/rfc/attributes_v2
[44] активная работа: https://github.com/beberlei/php-src/pull/2
[45] PHP Internals News: Episode 46: str_contains(): https://phpinternals.news/46
[46] добавленной str_contains(): https://t.me/phpdigest/127
[47] Пятиминутка PHP № 76:: https://5minphp.ru/episode76/
[48] Между скобок №2:: https://soundcloud.com/between-braces/2-anton-morev-o-graphql
[49] личку: https://habrahabr.ru/conversations/pronskiy/
[50] почту: mailto:roman@pronskiy.com
[51] твиттер: https://twitter.com/pronskiy
[52] PHP Digest: https://t.me/phpdigest
[53] Прислать ссылку: https://bit.ly/php-digest-add-link
[54] Поиск ссылок по всем дайджестам: https://pronskiy.com/php-digest/
[55] Предыдущий выпуск: PHP-Дайджест № 176: https://habr.com/ru/post/493594/
[56] Источник: https://habr.com/ru/post/495838/?utm_source=habrahabr&utm_medium=rss&utm_campaign=495838
Нажмите здесь для печати.