PHP文摘#186(2020年8月3日至17日)



带有新闻和资料链接的新鲜选择。在:PHP 8 Beta 1中,再次讨论了PHP 8中的属性语法:#[Attr]vs @[Attr],BigInt的语法建议,PHP 8评论以及更多视频,工具,流,播客。



享受阅读!





新闻和发布





PHP内部



  • [RFC] Shorter Attribute Syntax Change — PHP 8 . , - , 2- .



    Tycon Andre , #[Attr] PHP 7. C , , ?



    @@Attr, #[Attr], <<Attr>> @[Attr]:
    @@ORM\Entity
    @@ORM\Table("user")
    class User
    {
        @@ORM\Id @@ORM\Column("integer") @@ORM\GeneratedValue
        private $id;
    
        @@ORM\Column("string", ORM\Column::UNIQUE)
        @@Assert\Email(["message" => "The email '{{ value }}' is not a valid email."])
        private $email;
    }
    
    #[
      ORM\Entity,
      ORM\Table("user")
    ]
    class User
    {
        #[ORM\Id, ORM\Column("integer"), ORM\GeneratedValue]
        private $id;
    
        #[ORM\Column("string", ORM\Column::UNIQUE)]
        #[Assert\Email(["message" => "The email '{{ value }}' is not a valid email."])]
        private $email;
    }
    
    @[
      ORM\Entity,
      ORM\Table("user")
    ]
    class User
    {
        @[ORM\Id, ORM\Column("integer"), ORM\GeneratedValue]
        private $id;
    
        @[ORM\Column("string", ORM\Column::UNIQUE)]
        @[Assert\Email(["message" => "The email '{{ value }}' is not a valid email."])]
        private $email;
    }
    
    <<
      ORM\Entity,
      ORM\Table("user")
    >>
    class User
    {
        <<ORM\Id, ORM\Column("integer"), ORM\GeneratedValue>>
        private $id;
    
        <<ORM\Column("string", ORM\Column::UNIQUE)>>
        <<Assert\Email(["message" => "The email '{{ value }}' is not a valid email."])>>
        private $email;
    }
    
    @:ORM\Entity
    @:ORM\Table("user")
    class User
    {
        @:ORM\Id @:ORM\Column("integer") @:ORM\GeneratedValue
        private $id;
    
        @:ORM\Column("string", ORM\Column::UNIQUE)
        @:Assert\Email(["message" => "The email '{{ value }}' is not a valid email."])
        private $email;
    }
    
  • [RFC] Named Parameters explicit opt in — , .
    //    
    function callBar(Foo $:parameterName) {
        $internalName->bar();
    }
    
    $x = new Foo();
    callBar(parameterName: $x);
    
    //   
    function callBar($externalName) {
        $externalName->bar();
    }
    
    $x = new Foo();
    callBar(externalName: $x); // Error: cannot call function callBar() using parameter $externalName by name.
    
    PHP 8 , 8.1, .
  • [Proposal] Bigint shorthand (123n) for GMP objects RFC.



    PHP JavaScript «n»:
    $theBiggestInt = 9007199254740991n


    GMP. GMP , , .
  • PHP (php -a), PR, . bobthecow/psysh.
  • 交叉 [RFC] PHP Namespace Policy — .






Symfony





Laravel









/












感谢您的关注!



如果您发现错误或不准确,请亲自告诉我们

问题和建议写在邮件推特上



有关PHP Digest Telegram频道的更多新闻和评论



发送

链接在所有摘要中搜索链接

上一期:PHP-摘要№185




All Articles