亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

用于在閉包中拋出異常的 PHPDoc

用于在閉包中拋出異常的 PHPDoc

PHP
撒科打諢 2023-05-12 14:48:05
有什么聰明的方法來記錄閉包拋出異常嗎?我正在使用 PhpStorm,我想擺脫惱人的警告,即給定塊中永遠不會拋出異常。該方法createFromState()是拋出AbstractEntityRepositoryException異常,我想讓IDE知道它。    /**     * Closure used to create an object from repository.     * The default implementation is using the method {@link EntityRepositoryInterface::createFromState()}     *     * @var Closure|null     * @throws AbstractEntityRepositoryException     */    private ?Closure $create = null;    public function __construct(ControllerInteface $controller, string $id, ?Closure $create = null)    {        parent::__construct($controller, $id);        if ($create === null) {            $this->create = static function (EntityRepositoryInterface $repository, FormModelInterface $model): Entity {                return $repository->createFromState($model->toState());            };        }         else {          $this->create = $create;        }    }    /**     * @param FormModelInterface $model     * @return Entity     * @throws CreateActionException     */    public function saveModel(FormModelInterface $model): Entity    {        try {            $create = $this->create;            return $create($this->repository, $model);        } catch (AbstractEntityRepositoryException $e) {            throw new CreateActionException($e->getMessage(), $e->getErrors());        }    }
查看完整描述

1 回答

?
汪汪一只貓

TA貢獻1898條經驗 獲得超8個贊

似乎 PHP Storm 還沒有正確支持該注釋。


查看完整回答
反對 回復 2023-05-12
  • 1 回答
  • 0 關注
  • 151 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號