PHP摘要133号(2018年6月10日至24日)


带有新闻和资料链接的新鲜选择。 在发行版中:PHP 7.3.0 Alpha 2,针对PHP 8.0的计划,来自PHP Internals的Typed Properties和其他RFC,有用的工具的一部分以及更多内容。
祝您阅读愉快!


新闻与发布



PHP内部


  • [RFC]:Typed Properties 2.0 -Nikita Popov和Bob Weinand提出的关于实现类型化属性的大型且非常详细的建议。 早先曾尝试实现这一机会,但该提案未超过2/3投票的门槛。 本文档解决了先前实现中的两个关键问题:支持静态属性的类型,以及对类型化属性的引用。 因此,这次有投票的机会。 相应的池请求已准备就绪。
    版本问题仍然悬而未决:目前正在考虑使用PHP 7.3,但是如果出现困难,则可以将其推迟到7.4(8)。
    隐藏文字
    class Example { // All types with the exception of "void" and "callable" are supported public int $scalarType; protected Type $type; private ?Type $nullableType; // Types are also legal on static properties public static iterable $staticProp; // Types can also be used with the "var" notation var bool $flag; // Typed properties may have default values (more below) public string $str = "foo"; public ?string $nullableStr = null; // The type applies to all properties in one declaration public float $x, $y; // equivalent to: public float $x; public float $y; } 
  • [RFC]弃用和删除不区分大小写的常量 -使用define()可以定义不区分大小写的常量。 建议删除此功能。
  • [RFC]弃用并删除继续定位开关 -在switch内部continue switch就像一个break ,尽管在其他语言中不是这种情况。 建议纠正该行为。
  • 严格转换 -萨拉·高蒙(Sara Golemon)提出实施严格switch建议:
    隐藏文字
     switch ($a) { case FOO: // Works exactly as current behavior. break; case == FOO: // Nearly identical, though we don't use the ZEND_CASE optimization. // Can probably make this equivalent to `case FOO`, but it felt like an interesting direction. break; case === FOO: // Only triggers if `$a === FOO`, no type juggling break; } 

工具




学习资料




音视频



感谢您的关注!

如果您发现错误或不准确,请在PM中通知我。
问题和建议写在邮件推特上

发送链接
搜索所有摘要的链接
先前版本:PHP文摘132

Source: https://habr.com/ru/post/zh-CN415057/


All Articles