Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
911 views
in Technique[技术] by (71.8m points)

laravel - FatalErrorException in Inflector.php line 265: syntax error, unexpected ':', expecting ';' or '{'

I went to update composer using

composer update

after update having the following error:

FatalErrorException in Inflector.php line 265: syntax error, unexpected ':', expecting ';' or '{'

Please assist

Thanks in advance

Using Laravel Framework version 5.2.45

here is the composer code

{
    "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"
    }
}

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));
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

But if you want to stay at your current PHP version, you can downgrade the doctrine/inflector version by running the following commands:

  1. Delete the composer.lock file

    rm -f Composer.lock

  2. Delete the vendor

    rm -R -f vendor

  3. composer install

  4. Install the doctrine/inflector according to your php version

    composer require doctrine/inflector:1.1.0

doctrine/inflector:1.1.0 supports PHP 5.6 & above. If you have another version of php, you can refer to this link


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...