{"id":415971,"date":"2024-06-30T00:40:19","date_gmt":"2024-06-30T00:40:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=415971"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-30T00:40:19","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=415971","title":{"rendered":"<span>PHP 8.1: \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/wiki.php.net\/todo\/php81\" rel=\"noopener noreferrer nofollow\">PHP 8.1<\/a> \u0432\u044b\u0439\u0434\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0438 \u044f \u0432 \u0432\u043e\u0441\u0442\u043e\u0440\u0433\u0435 \u043e\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439! \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u043b\u0438\u044f\u043d\u0438\u0435\u043c PHP 8.1 \u043d\u0430 \u043c\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<h3>\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0414\u043e\u043b\u0433\u043e\u0436\u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b!<\/p>\n<p>\u041e \u043d\u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u0441 \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043d\u0438\u0435\u043c \u0436\u0434\u0443, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/spatie\/enum\" rel=\"noopener noreferrer nofollow\">spatie\/enum<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/github.com\/myclabs\/php-enum\" rel=\"noopener noreferrer nofollow\">myclabs\/php-enum<\/a>. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u0441\u0435 \u0433\u043e\u0434\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u044d\u0442\u0438\u0445 enum-\u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0432\u044b\u043c\u0438, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043e\u0442\u043a\u0430\u0436\u0443\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f PHP 8.1 \u0438 \u043a\u043e\u0433\u0434\u0430 \u044f \u0438\u0437\u043c\u0435\u043d\u044e \u044d\u0442\u043e:<\/p>\n<pre><code class=\"php\">\/**  * @method static self draft()  * @method static self published()  * @method static self archived()  *\/ class StatusEnum extends Enum { }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e:<\/p>\n<pre><code class=\"php\">enum Status {     case draft;     case published;     case archived; }<\/code><\/pre>\n<h3>\u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438<\/h3>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043d\u043e \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u043d\u0435 \u0440\u0430\u0437 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u043b\u043e: \u0434\u043e PHP 8.1 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\">$a = [1, 2, 3]; $b = [4, 5, 6];  \/\/ \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 PHP 7.4 $new = [...$a, ...$b];<\/code><\/pre>\n<p>\u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0431\u044b\u043b\u043e \u043d\u0435\u043b\u044c\u0437\u044f:<\/p>\n<pre><code class=\"php\">$a = ['a' => 1, 'b' => 2, 'c' => 3]; $b = ['d' => 4, 'e' => 5, 'f' => 6];  $new = [...$a, ...$b];   \/\/ \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c array_merge $new = array_merge($a, $b);<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u043e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 PHP 8.1, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u043c\u043d\u0435 \u0436\u0438\u0437\u043d\u044c, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438!<\/p>\n<pre><code class=\"php\">$a = ['a' => 1, 'b' => 2, 'c' => 3]; $b = ['d' => 4, 'e' => 5, 'f' => 6];  \/\/ :) $new = [...$a, ...$b];<\/code><\/pre>\n<h3>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0438 readonly<\/h3>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u0436\u0434\u0430\u043b \u0433\u043e\u0434\u0430\u043c\u0438: \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>BlogData<\/code>. \u0414\u043e PHP 8.1 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>null<\/code> \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435:<\/p>\n<pre><code class=\"php\">class BlogData {     public function __construct(         public string $title,         public ?BlogState $state = null,     ) {         $this->state ??= new Draft();     } }<\/code><\/pre>\n<p>PHP 8.1 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 <code>new<\/code> \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0435:<\/p>\n<pre><code class=\"php\">class BlogData {     public function __construct(         public string $title,         public BlogState $state = new Draft(),     ) {     } }<\/code><\/pre>\n<p>\u0413\u043e\u0432\u043e\u0440\u044f \u043e \u0433\u0440\u0430\u043d\u0434\u0438\u043e\u0437\u043d\u044b\u0445 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f\u0445, \u044f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b, \u0447\u0442\u043e readonly-\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043b\u0438 \u044f\u0432\u044c\u044e?!?<\/p>\n<pre><code class=\"php\">class BlogData {     public function __construct(         public readonly string $title,         public readonly BlogState $state = new Draft(),     ) {     } }<\/code><\/pre>\n<p>\u0414\u0430, \u043a\u0441\u0442\u0430\u0442\u0438, \u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0439\u0442\u0435\u0441\u044c \u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, <a href=\"https:\/\/stitcher.io\/blog\/cloning-readonly-properties-in-php-81\" rel=\"noopener noreferrer nofollow\">\u044f \u043e \u0432\u0430\u0441 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u043b\u0441\u044f<\/a>.<\/p>\n<h3>First-class callable<\/h3>\n<p>\u041a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 First-class callable, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0439 \u0438\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code class=\"php\">$strlen = Closure::fromCallable('strlen'); $callback = Closure::fromCallable([$object, 'method']);<\/code><\/pre>\n<p>\u0412 PHP 8.1 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u2026 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">$strlen = strlen(...); $callback = $object->method(...);<\/code><\/pre>\n<p>\u0412 PHP 8.1 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/567710\/\" rel=\"noopener noreferrer nofollow\">\u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e<\/a>, \u043d\u043e \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u0432\u043e\u043b\u043d\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/569652\/\"> https:\/\/habr.com\/ru\/articles\/569652\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/wiki.php.net\/todo\/php81\" rel=\"noopener noreferrer nofollow\">PHP 8.1<\/a> \u0432\u044b\u0439\u0434\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0438 \u044f \u0432 \u0432\u043e\u0441\u0442\u043e\u0440\u0433\u0435 \u043e\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439! \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u043b\u0438\u044f\u043d\u0438\u0435\u043c PHP 8.1 \u043d\u0430 \u043c\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<h3>\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0414\u043e\u043b\u0433\u043e\u0436\u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b!<\/p>\n<p>\u041e \u043d\u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u0441 \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043d\u0438\u0435\u043c \u0436\u0434\u0443, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/spatie\/enum\" rel=\"noopener noreferrer nofollow\">spatie\/enum<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/github.com\/myclabs\/php-enum\" rel=\"noopener noreferrer nofollow\">myclabs\/php-enum<\/a>. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u0441\u0435 \u0433\u043e\u0434\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u044d\u0442\u0438\u0445 enum-\u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0432\u044b\u043c\u0438, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u043e\u0442\u043a\u0430\u0436\u0443\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f PHP 8.1 \u0438 \u043a\u043e\u0433\u0434\u0430 \u044f \u0438\u0437\u043c\u0435\u043d\u044e \u044d\u0442\u043e:<\/p>\n<pre><code class=\"php\">\/**  * @method static self draft()  * @method static self published()  * @method static self archived()  *\/ class StatusEnum extends Enum { }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e:<\/p>\n<pre><code class=\"php\">enum Status {     case draft;     case published;     case archived; }<\/code><\/pre>\n<h3>\u0420\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438<\/h3>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043d\u043e \u043c\u0435\u043d\u044f \u044d\u0442\u043e \u043d\u0435 \u0440\u0430\u0437 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u043b\u043e: \u0434\u043e PHP 8.1 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\">$a = [1, 2, 3]; $b = [4, 5, 6];  \/\/ \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 PHP 7.4 $new = [...$a, ...$b];<\/code><\/pre>\n<p>\u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0431\u044b\u043b\u043e \u043d\u0435\u043b\u044c\u0437\u044f:<\/p>\n<pre><code class=\"php\">$a = ['a' => 1, 'b' => 2, 'c' => 3]; $b = ['d' => 4, 'e' => 5, 'f' => 6];  $new = [...$a, ...$b];   \/\/ \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c array_merge $new = array_merge($a, $b);<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u043e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 PHP 8.1, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442 \u043c\u043d\u0435 \u0436\u0438\u0437\u043d\u044c, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438!<\/p>\n<pre><code class=\"php\">$a = ['a' => 1, 'b' => 2, 'c' => 3]; $b = ['d' => 4, 'e' => 5, 'f' => 6];  \/\/ :) $new = [...$a, ...$b];<\/code><\/pre>\n<h3>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0438 readonly<\/h3>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u0436\u0434\u0430\u043b \u0433\u043e\u0434\u0430\u043c\u0438: \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>BlogData<\/code>. \u0414\u043e PHP 8.1 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>null<\/code> \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435:<\/p>\n<pre><code class=\"php\">class BlogData {     public function __construct(         public string $title,         public ?BlogState $state = null,     ) {         $this->state ??= new Draft();     } }<\/code><\/pre>\n<p>PHP 8.1 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 <code>new<\/code> \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0435:<\/p>\n<pre><code class=\"php\">class BlogData {     public function __construct(         public string $title,         public BlogState $state = new Draft(),     ) {     } }<\/code><\/pre>\n<p>\u0413\u043e\u0432\u043e\u0440\u044f \u043e \u0433\u0440\u0430\u043d\u0434\u0438\u043e\u0437\u043d\u044b\u0445 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f\u0445, \u044f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b, \u0447\u0442\u043e readonly-\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043b\u0438 \u044f\u0432\u044c\u044e?!?<\/p>\n<pre><code class=\"php\">class BlogData {     public function __construct(         public readonly string $title,         public readonly BlogState $state = new Draft(),     ) {     } }<\/code><\/pre>\n<p>\u0414\u0430, \u043a\u0441\u0442\u0430\u0442\u0438, \u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0439\u0442\u0435\u0441\u044c \u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, <a href=\"https:\/\/stitcher.io\/blog\/cloning-readonly-properties-in-php-81\" rel=\"noopener noreferrer nofollow\">\u044f \u043e \u0432\u0430\u0441 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u043b\u0441\u044f<\/a>.<\/p>\n<h3>First-class callable<\/h3>\n<p>\u041a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 First-class callable, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0439 \u0438\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code class=\"php\">$strlen = Closure::fromCallable('strlen'); $callback = Closure::fromCallable([$object, 'method']);<\/code><\/pre>\n<p>\u0412 PHP 8.1 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u2026 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">$strlen = strlen(...); $callback = $object->method(...);<\/code><\/pre>\n<p>\u0412 PHP 8.1 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/567710\/\" rel=\"noopener noreferrer nofollow\">\u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e<\/a>, \u043d\u043e \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u0432\u043e\u043b\u043d\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/569652\/\"> https:\/\/habr.com\/ru\/articles\/569652\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-415971","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=415971"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415971\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=415971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=415971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=415971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}