当将项目从laravel 6迁移到7时,我遇到了这个错误,有人知道我如何解决它吗?我已经试图删除供应商文件,并重新安装从0与作曲家安装,但我仍然得到同样的错误。我真的不知道发生了什么。提前感谢。欢迎任何帮助。
Parse error: syntax error, unexpected '=' in C:projetoscursovendorsymfonystringResourcesfunctions.php on line 34
PHP Parse error: syntax error, unexpected '=' in C:projetoscursovendorsymfonystringResourcesfunctions.php on line 34
我作曲家. json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "^7.0",
"laravel/horizon": "^4.0",
"laravel/tinker": "^2.0",
"psr/log": "^1.1.4",
"stripe/stripe-php": "^8.10"
},
"require-dev": {
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"files": [
"app/helpers.php"
],
"psr-4": {
"App\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\Foundation\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r "file_exists('.env') || copy('.env.example', '.env');""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
——显然也在
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SymfonyComponentString;
if (!function_exists(u::class)) {
function u(?string $string = ''): UnicodeString
{
return new UnicodeString($string ?? '');
}
}
if (!function_exists(b::class)) {
function b(?string $string = ''): ByteString
{
return new ByteString($string ?? '');
}
}
if (!function_exists(s::class)) {
/**
* @return UnicodeString|ByteString
*/
function s(?string $string = ''): AbstractString
{
$string ??= ''; <---Line 34
return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string);
}
}
vendorsymfonystringResourcesfunctions.php
$string ??= '';
这是一个Null Coalescing Assignment Operator
- https://wiki.php.net/rfc/null_coalesce_equal_operator#:~:text=coalescing%20operator%20being%20a%20comparison,not%20null%2C%20nothing%20is%20made。
如上面的链接所述,这已经在PHP 7.4中实现了。您需要将PHP版本更新到7.4