Php Symfony 4-带有类类型提示的参数的默认值只能为NULL
我有一个与此类似的问题:但当我启动composer命令时…:Php Symfony 4-带有类类型提示的参数的默认值只能为NULL,php,composer-php,symfony4,Php,Composer Php,Symfony4,我有一个与此类似的问题:但当我启动composer命令时…: 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
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.8PHP版本。。。我用PHP7.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';
}
给我一个主意
多谢各位 我不知道这样做是否合适。。。我在composer.json中替换了这一行:
"security-checker security:check": "script"
作者:
"security:check": "symfony-cmd"
我猜也希望命令是一样的。我不明白为什么。我遵循Symfony 4的官方文档,并拥有正确的PHP版本。:/
我一点也不知道。。。TT_uutt你能发布受影响的代码吗?没关系。受影响的行是(函数的)第一行。谢谢你的帮助。你确定你正在运行PHP7吗?Composer可能使用与Web服务器不同的PHP版本。在命令行上运行
php-v
会得到什么?我有一个别名php7。当我运行我的别名“php7-v”时,我得到以下信息:php7.1.8(cli)(构建时间:2017年8月17日11:34:56)(NTS)版权(c)1997-2017 PHP组Zend Engine v3.1.0版权(c)1998-2017 Zend Technologiesha,它也更改为7.1.8。。。但通常情况下,我希望PHP5.6带有PHP命令。我在Mamp中暂时改变了这一点,以确保CLI也有7.1.8版本。