PHP摘要#187(2020年8月18日至9月7日)



带有新闻和资料链接的新鲜选择。在发行版中:PHP 8 beta 3,PHP 8中采用了新的属性语法,Zephir包括所有有用的工具,文章,视频,播客。



享受阅读!





新闻和发布





PHP Internals



  • 检查 [RFC] Shorter Attribute Syntax Change — - . #[Attribute].
    #[
      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;
    }
    


    , @@Attr PR. #[ ] , .



    //   
    #[ORM\Entity]
    #[ORM\Table("user")]
    
    //  
    #[
        ORM\Entity,
        ORM\Table("user")
    ]


    .
  • 新 [RFC] any() and all() on iterables — :

    any(iterable $input, ?callable $callback = null): bool — , , true.

    all(...)true , true .



    :



    // 
    $satisifes_predicate = false;
    foreach ($item_list as $item) {
        if (API::satisfiesCondition($item)) {
            $satisfies_predicate = true;
            break;
        }
    }
    if (!$satisfies_predicate) {
        throw new APIException("No matches found");
    }
    
    // 
    if (!any($item_list, fn($item) => API::satisfiesCondition($item))) {
        throw new APIException("No matches found");
    }






Symfony





Laravel





Yii





Async PHP









/












感谢您的关注!



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

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



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



发送

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

上一期:PHP-摘要#186




All Articles