现在与Symfony合作已经有一段时间了,我注意到我意识到自己也没有答案。在Symfony中,经常会看到:
public function build(string $json): ?IntegrationErrors
Run Code Online (Sandbox Code Playgroud)
但是同时您可以轻松看到:
public function build(string $json): IntegrationErrors
Run Code Online (Sandbox Code Playgroud)
问题是,据我所知它们执行相同的操作,两种方式都没有错误或警告,因此这使我想到了使用的程序含义是什么?与否?定义返回类型时?
正如您倾向于在实体中最常看到的那样,这是否是教义所特有的?