Inflector.php第265行中的FatalErrorException:语法错误,意外的':',期望为';'或者 '{' [英] FatalErrorException in Inflector.php line 265: syntax error, unexpected ':', expecting ';' or '{'
问题描述
我用
composer update
更新后出现以下错误:
Inpector.php第265行中的FatalErrorException:语法错误, 意外的':',期望';'或'{'
FatalErrorException in Inflector.php line 265: syntax error, unexpected ':', expecting ';' or '{'
请协助
预先感谢
使用Laravel Framework 5.2.45版
Using Laravel Framework version 5.2.45
这是作曲家的代码
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"laravelcollective/html": "*.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Libraries/Functions.php"
]
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
请在发生错误的地方查看inflector.php的功能
Please see the function of inflector.php where error occures
public static function tableize(string $word) : string
{
return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word));
}
推荐答案
这是一个PHP版本的问题,由于doctrine/inflector 1.20及更高版本需要PHP 7,因此更新到PHP 7.0并可以正常运行doctrine/inflector.
It's a PHP version issue, update to PHP 7.0 and doctrine/inflector will work properly because doctrine/inflector 1.20 and above require PHP 7.
但是,如果您希望保持当前的PHP版本,则可以通过运行以下命令来降级学说/变形器的版本:
But if you want to stay at your current PHP version, you can downgrade the doctrine/inflector version by running the following commands:
-
删除composer.lock文件
Delete the composer.lock file
rm -f Composer.lock
删除供应商
rm -R -f vendor
composer install
根据您的php版本安装学说/翻译器
Install the doctrine/inflector according to your php version
composer require doctrine/inflector:1.1.0
主义/变形者:1.1.0支持PHP 5.6&以上.如果您使用的是其他版本的php,则可以参考此链接
doctrine/inflector:1.1.0 supports PHP 5.6 & above. If you have another version of php, you can refer to this link
这篇关于Inflector.php第265行中的FatalErrorException:语法错误,意外的':',期望为';'或者 '{'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!