TTT
TTT

Reputation: 1885

Symfony's console PHP 7 parsing error

(Using WampServer on Windows 10.)

In some of my PHP class, I used return type declaration as explained in http://php.net/manual/en/migration70.new-features.php

Most console commands using [my-symfony-project] ... bin\console return

Parse error: syntax error, undexpected ':', expecting ';' or '{' in [file] on line [x]

Am I doing something wrong ? Or is there a solution for combining Symfony console with new PHP 7 features.


Example of function not being parsed by Symfony's console:

public function getFamilyName() : string {
    return $this->familyName;
}

Upvotes: 1

Views: 460

Answers (1)

Joe
Joe

Reputation: 2436

This error:

Parse error: syntax error, undexpected ':', expecting ';' or '{' in [file] on line [x]

means normally, that the php version is not correct. In your case the Windows command line still runs with an old 5.* Version by default.

This can be fixed by changing the PATH variable pointing to the old php version to the new installed one.

Upvotes: 3

Related Questions