PLEASE READ BEFORE MARKED IT AS DUPLICATE, because I did not write the symphony code.
A syntax error was raised after I added the following library: composer require doctrine/dbal
. This only happens on production and not on local env.
Im getting the following error:
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) on symfony/translation/Translator.php79
This is my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"barryvdh/laravel-cors": "^0.11.0",
"doctrine/dbal": "2.6.3",
"fideloper/proxy": "~3.3",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
And here it is my composer.lock
:
https://gist.github.com/Jatapiaro/61eeb4136b38395224797928cf7bab04
I added it on a gist to avoid have lot of code here.
I guess it might be related to PHP version incompatibility, but I'm not sure about this.
Also, it's important to note that this syntax error was raised after a package install and it's not my code which got broken.
What could be going on?
PHP Version on local: 7.1.7. On the server is: PHP Version => 7.2.2-3+ubuntu16.04.1+deb.sury.org+1
One of the latest discovers is the following:
The line 79 of the symfony code is
/**
* @throws InvalidArgumentException If a locale contains invalid characters
*/
public function __construct(?string $locale, MessageFormatterInterface $formatter = null, string $cacheDir = null, bool $debug = false)
{
$this->setLocale($locale);
if (null === $formatter) {
$formatter = new MessageFormatter();
}
$this->formatter = $formatter;
$this->cacheDir = $cacheDir;
$this->debug = $debug;
}
So when I changed ?string $locale
to $locale
everything works on production. It's important to add that also I change dbal
to 2.6.3
because it causes conflicts with some queries.