【问题标题】:symfony/console method not compatible with the interface it implementssymfony/console 方法与它实现的接口不兼容
【发布时间】:2020-04-06 21:07:30
【问题描述】:

我在尝试使用 symfony/console 时遇到以下错误:

Declaration of Symfony\Component\Console\Style\SymfonyStyle::ask(string $question, ?string $default = NULL, $validator = NULL) must be compatible with Symfony\Component\Console\Style\StyleInterface::ask(string $question, ?string $default = NULL, ?callable $validator = NULL)

方法声明为:
public function ask(string $question, ?string $default = null, $validator = null)

接口声明为:
public function ask(string $question, ?string $default = null, callable $validator = null);

这是原来的类:
https://github.com/symfony/console/blob/619054da7627df1c2169c7aabe0df78f9320847c/Style/SymfonyStyle.php#L257

这是界面: https://github.com/symfony/console/blob/619054da7627df1c2169c7aabe0df78f9320847c/Style/StyleInterface.php#L88

我不明白为什么声明不同。很难相信这是 Symfony 的实际错误,我可能在这里做错了什么。但是什么?

【问题讨论】:

    标签: php symfony


    【解决方案1】:

    我使用了错误的 PHP 版本:7.1 这个包至少需要 PHP v7.2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-06
      • 2017-04-16
      • 2015-06-02
      • 2015-11-11
      • 1970-01-01
      • 2020-02-09
      • 2017-08-09
      相关资源
      最近更新 更多