Symfony 4 - 具有类类型提示的参数的默认值只能为NULL

时间:2018-05-10 10:20:31

标签: php composer-php symfony4

我遇到的问题与此类似:Symfony 4 : Default value for parameters with a class type can only be但是当我启动作曲家命令时......:

executing script security-checker security:check [KO]
 [KO]
Script security-checker security:check returned with error code 255
!!  PHP Fatal error:  Default value for parameters with a class type hint can only be NULL in /xxx/vendor/symfony/console/Application.php on line 83
!!  
Script @auto-scripts was called via post-update-cmd
When I launched for example : php7 composer.phar update, because I had the same problem for others commands...

我不明白,因为我使用7.1.8 PHP版本...我用PHP 7.1.8安装了整个项目...:/

受影响的代码:

/**
     * @param string $name    The name of the application
     * @param string $version The version of the application
     */
    public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN') // Line affected HERE (line 83)
    {
        $this->name = $name;
        $this->version = $version; 
        $this->terminal = new Terminal();
        $this->defaultCommand = 'list';
    }

给我一​​个想法?

非常感谢!

1 个答案:

答案 0 :(得分:1)

我不知道这样做是否可行...我在composer.json中替换了这一行:

 "security-checker security:check": "script"

by:

 "security:check": "symfony-cmd"

我猜并希望命令是一样的。我不明白为什么。我遵循Symfony 4的官方文档,我有正确的PHP版本。 :/

我根本不知道...... TT__TT