During these two weeks of the core, the PHP team actively discussed the proposal for a Partial function Application and, as an alternative, Nikita Popov suggested a simpler syntax for getting a link to any function. It is also proposed to add static properties to the enums already adopted in PHP 8.1.
Symfony 6 will require PHP 8.0, and the released Doctrine 2.9 supports specifying metadata in attributes instead of PHPDoc.
Also in the release is a cool article about regexps and instructions for using Deployer, as well as other useful articles, a pack of tools, some videos and podcasts.
Enjoy reading!
PHP Internals
[RFC] First-class callable syntax
[RFC] Partial Function Application .
// $fn = Closure::fromCallable('strlen'); $fn = Closure::fromCallable([$this, 'method']); $fn = Closure::fromCallable([Foo::class, 'method']); // $fn = strlen(...); $fn = $this->method(...); $fn = Foo::method(...);
, ,callable
. , :
array_map(Something::toString(...), [1, 2, 3]); array_map(strval(...), [1, 2, 3]); // array_map([Something::class, 'toString'], [1, 2, 3]) array_map('strval', [1, 2, 3]);
[RFC] Disable autovivification on false
PHPnull
false
.false
-Fatal error
:
3v4l.org/UucOC$a = true; $a[] = 'value'; // Fatal error: Uncaught Error: Cannot use a scalar value as an array $a = null; $a[] = 'value'; // Ok $a = false; $a[] = 'value'; // ,
[RFC] Allow static properties in enums
PHP 8.1 . PHP- php.watch.
, .
enum Environment { case DEV; case STAGE; case PROD; private static Environment $currentEnvironment; /** * Read the current environment from a file on disk, once. * This will affect various parts of the application. */ public static function current(): Environment { if (!isset(self::$currentEnvironment)) { $info = json_decode(file_get_contents(__DIR__ . '/../../config.json'), true); self::$currentEnvironment = match($info['env']) { 'dev' => self::DEV, 'stage' => self::STAGE, 'prod' => self::PROD, }; } return self::$currentEnvironment; } // Other methods can also access self::$currentEnvironment } printf("Current environment is %s\n", Environment::current()->name);
. , .
, PhpStorm 2021.2enum
, 2021.2 EAP.
[PR] HTTP Early Hint support
, PHP .HTTP 1xx
. ,103
, Link, , ,200 OK
.
, :103
, ,header()
, βecho
.
, . - API Symfony HTTP.
[RFC] Add IntlDatePatternGenerator
. PHP 8.1IntlDatePatternGenerator
. PHP Internals News #85 RFC.
[RFC] Final class constants
.
Internals bugs.php.net
issues GitHub. , . , . PHP, issue php/doc-en php/doc-ru. .
- Doctrine ORM 2.9 β ORM. PHP 8, , .
- Flarum 1.0.0 β PHP.
- moneyphp/money 4.0 β .
- phpast.com β PHP. nikic/PHP-Parser. : ryangjchandler/phpast.com.
- JBZoo/CI-Report-Converter β CI. β CI (TeamCity, GitHub Actions, etc). smetdenis.
- veewee/xml β XML .
Symfony
- Symfony.
- Symfony 5.3.
- Symfony 6 PHP 8.0 β , .
Laravel
- Tinker.
- Laravel Jetstream.
- Β«One of ManyΒ».
- Laravel Octane with Swoole β Beyond the Basics β Laravel core .
- PHP.Watch: PHP.
- Deployer GitHub Actions β deployphp/deployer .
- PHP β .
- copy-on-write PHP.
- Dependency Injection Software Engineering.
- ( ).
- PHP 35 ?
- DTO yzen-dev/plain-to-class.
https://github.com/alexpts/php-data-transformer2 dto dto . .
/
- Mutation testing: how it will help and how to use it better - Interview with Max Rafalko on the eve of PHP Russia .
Subscribe to the PHP Digest Telegram channel .
If you liked the digest, please give it a plus - this is very motivating to keep doing it.
Did you spot a mistake or typo? Inform in a personal habr or telegram .
You can send the link through the form or simply by writing to me in a telegram .
Search for links in all digests
β Previous issue: PHP-Digest # 203