PHP 8.0正式发布:支持JIT编译器,性能提升高达3倍

{"type":"doc","content":[{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"美国时间11月26日,PHP团队宣布PHP 8.0正式GA。PHP 8.0是PHP语言的最新主要版本,带来了许多新特性和优化,包括命名参数(named arguments)、联合类型(union types)、属性(attributes)、构造器属性提升(constructor property promotion)、Match表达式、nullsafe运算符、JIT,以及针对类型系统、错误处理和一致性的诸多改进。"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" "}]},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/04\/88\/04f7766238ee3cfdf003da32eb898688.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"PHP 8.0.0 下载地址:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/www.php.net\/downloads","title":"","type":null},"content":[{"type":"text","text":"https:\/\/www.php.net\/downloads"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"下文将对新版本的重要亮点做简单介绍:"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"命名参数"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/named_params","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/named_params"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"htmlspecialchars($string, double_encode: false);"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"仅指定必需参数,跳过可选参数。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"参数与顺序无关,且是自描述的。"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"属性"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"现在,开发者可以使用基于PHP原生语法的结构化元数据来代替PHPDoc注解。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/attributes_v2","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/attributes_v2"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class PostsController\n{\n \/**\n * @Route(\"\/api\/posts\/{id}\", methods={\"GET\"})\n *\/\n public function get($id) { \/* ... *\/ }\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class PostsController\n{\n #[Route(\"\/api\/posts\/{id}\", methods: [\"GET\"])]\n public function get($id) { \/* ... *\/ }\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"构造器属性提升"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"新版本定义和初始化属性所用的样板代码更少。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/constructor_promotion","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/constructor_promotion"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class Point {\n public float $x;\n public float $y;\n public float $z;\n\n\n public function __construct(\n float $x = 0.0,\n float $y = 0.0,\n float $z = 0.0,\n ) {\n $this->x = $x;\n $this->y = $y;\n $this->z = $z;\n }\n}"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class Point {\n public function __construct(\n public float $x = 0.0,\n public float $y = 0.0,\n public float $z = 0.0,\n ) {}\n}"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"联合类型"},{"type":"text","text":"(Union Types)"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Union Types 支持接收多个不同类型的值,而不是单个类型。目前PHP已经支持两种特殊的联合类型:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Type或null,使用特殊?Type语法。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"array或Traversable,使用特殊iterable类型。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"对于类型组合,可以使用在运行时经过验证的原生联合类型声明来代替PHPDoc注解。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/union_types_v2","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/union_types_v2"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"支持联合类型之后,将会允许将更多类型信息从 phpdoc 迁移至函数签名。可以说,泛型之后,联合类型是目前类型声明系统中最大的突破口。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class Number {\n \/** @var int|float *\/\n private $number;\n\n\n \/**\n * @param float|int $number\n *\/\n public function __construct($number) {\n $this->number = $number;\n }\n}\n\n\nnew Number('NaN'); \/\/ O"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"class Number {\n public function __construct(\n private int|float $number\n ) {}\n}\n\n\nnew Number('NaN'); \/\/ TypeError"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Match表达式"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"新的match很像switch,并具有以下特性:"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Match是一个表达式,表示其结果可以存储在变量中或返回。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Match分支仅支持单行表达式,不需要break; 语句。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Match执行严格比较。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/match_expression_v2","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/match_expression_v2"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"switch (8.0) {\n case '8.0':\n $result = \"Oh no!\";\n break;\n case 8.0:\n $result = \"This is what I expected\";\n break;\n}\necho $result;\n\/\/> Oh no!"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"echo match (8.0) {\n '8.0' => \"Oh no!\",\n 8.0 => \"This is what I expected\",\n};\n\/\/> This is what I expected"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Nullsafe运算符"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"现在,开发者可以使用带有新的nullsafe运算符的调用链来代替null check。当对链中一个元素的求值失败时,整个链的执行将中止,并且整个链的求值为null。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/nullsafe_operator","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/nullsafe_operator"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"$country = null;\n\n\nif ($session !== null) {\n $user = $session->user;\n\n\n if ($user !== null) {\n $address = $user->getAddress();\n\n\n if ($address !== null) {\n $country = $address->country;\n }\n }"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"$country = $session?->user?->getAddress()?->country;"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"字符串与数字的判断更合理"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用==和其他非严格比较运算符对字符串和数字之间做比较时,原本的做法是将字符串强制转换为数字,然后对整数或浮点数进行比较。这会导致许多令人惊讶的比较结果,其中最值得注意的是 "},{"type":"codeinline","content":[{"type":"text","text":"0 == \"foobar\""}]},{"type":"text","text":" 返回true。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在新版本中,仅在字符串实际为数字时才使用数字比较,否则将数字转换为字符串,并执行字符串比较。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/string_to_number_comparison","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/string_to_number_comparison"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"0 == 'foobar' \/\/ true"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"0 == 'foobar' \/\/ false"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"内部函数的类型错误一致"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在新版本中,如果参数验证失败,大多数内部函数将抛出Error异常。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/consistent_type_errors","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/consistent_type_errors"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 7"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"strlen([]); \/\/ Warning: strlen() expects parameter 1 to be string, array given\n\n\narray_chunk([], -1); \/\/ Warning: array_chunk(): Size parameter expected to be greater than 0"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"PHP 8"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"codeblock","attrs":{"lang":"php"},"content":[{"type":"text","text":"strlen([]); \/\/ TypeError: strlen(): Argument #1 ($str) must be of type string, array given\n\n\narray_chunk([], -1); \/\/ ValueError: array_chunk(): Argument #2 ($length) must be greater than 0"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"JIT编译"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"PHP 8引入了两个JIT编译引擎。Tracing JIT的表现最出色,它在综合基准测试中的性能提高到大约3倍,在某些特定的传统应用程序中提高到1.5–2倍。典型的应用程序性能与PHP 7.4相当。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"JIT对PHP 8性能的贡献"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/9b\/fd\/9b2b17435f130bb02fddf1c67603eafd.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"类型系统和错误处理方面的改进"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"对算术\/按位运算符进行更严格的类型检查("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/arithmetic_operator_type_checks","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/arithmetic_operator_type_checks"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"抽象特征方法验证("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/abstract_trait_method_validation","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/abstract_trait_method_validation"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"魔术方法的正确签名("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/magic-methods-signature","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/magic-methods-signature"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"重分类引擎警告("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/engine_warnings","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/engine_warnings"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不兼容方法签名的致命错误("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/lsp_errors","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/lsp_errors"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"@运算符不再使致命错误静默。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用私有方法继承("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/inheritance_private_methods","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/inheritance_private_methods"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"混合类型("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/mixed_type_v2","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/mixed_type_v2"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"静态返回类型("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/static_return_type","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/static_return_type"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"内部函数类型("},{"type":"link","attrs":{"href":"https:\/\/externals.io\/message\/106522","title":"","type":null},"content":[{"type":"text","text":"https:\/\/externals.io\/message\/106522"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不透明的对象代替Curl、Gd、Sockets、OpenSSL、XMLWriter和XML扩展的资源"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"其他语法调整和改进"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在参数列表("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/trailing_comma_in_parameter_list","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/trailing_comma_in_parameter_list"}]},{"type":"text","text":")和使用闭包的列表("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/trailing_comma_in_closure_use_list","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/trailing_comma_in_closure_use_list"}]},{"type":"text","text":")中允许结尾逗号"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"non-capturing捕获("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/non-capturing_catches","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/non-capturing_catches"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"变量语法调整("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/variable_syntax_tweaks","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/variable_syntax_tweaks"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"将命名空间名称视为单个令牌("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/namespaced_names_as_token","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/namespaced_names_as_token"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Throw现在是表达式("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/throw_expression","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/throw_expression"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在对象上允许::class("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/class_name_literal_on_object","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/class_name_literal_on_object"}]},{"type":"text","text":")"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"新的类、接口和函数"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Weak Map类("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/weak_maps","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/weak_maps"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Stringable接口("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/stringable","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/stringable"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"str_contains()、str_starts_with()、str_ends_with()("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/str_contains","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/str_contains"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"fdiv()("},{"type":"link","attrs":{"href":"https:\/\/github.com\/php\/php-src\/pull\/4769","title":"","type":null},"content":[{"type":"text","text":"https:\/\/github.com\/php\/php-src\/pull\/4769"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"get_debug_type()("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/get_debug_type","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/get_debug_type"}]},{"type":"text","text":")"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"get_resource_id()("},{"type":"link","attrs":{"href":"https:\/\/github.com\/php\/php-src\/pull\/5427","title":"","type":null},"content":[{"type":"text","text":"https:\/\/github.com\/php\/php-src\/pull\/5427"}]},{"type":"text","text":"0"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"token_get_all()对象实现("},{"type":"link","attrs":{"href":"https:\/\/wiki.php.net\/rfc\/token_as_object","title":"","type":null},"content":[{"type":"text","text":"https:\/\/wiki.php.net\/rfc\/token_as_object"}]},{"type":"text","text":")"}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"下载"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"要下载PHP 8的源代码,请访问下载页面("},{"type":"link","attrs":{"href":"https:\/\/www.php.net\/downloads","title":"","type":null},"content":[{"type":"text","text":"https:\/\/www.php.net\/downloads"}]},{"type":"text","text":")。Windows二进制文件位于Windows版PHP网站("},{"type":"link","attrs":{"href":"http:\/\/windows.php.net\/download","title":"","type":null},"content":[{"type":"text","text":"http:\/\/windows.php.net\/download"}]},{"type":"text","text":")。更改列表位于ChangeLog("},{"type":"link","attrs":{"href":"http:\/\/www.php.net\/ChangeLog-8.php","title":"","type":null},"content":[{"type":"text","text":"http:\/\/www.php.net\/ChangeLog-8.php"}]},{"type":"text","text":")。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"PHP手册中提供了迁移指南("},{"type":"link","attrs":{"href":"https:\/\/www.php.net\/manual\/en\/migration80.php","title":"","type":null},"content":[{"type":"text","text":"https:\/\/www.php.net\/manual\/en\/migration80.php"}]},{"type":"text","text":")。请查阅它以获取新特性细节和向后不兼容更改的详细列表。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"原文链接:"},{"type":"link","attrs":{"href":"https:\/\/www.php.net\/releases\/8.0\/en.php","title":"","type":null},"content":[{"type":"text","text":"https:\/\/www.php.net\/releases\/8.0\/en.php"}]}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章