You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
On production with PHP Version => 7.2.2-3+ubuntu16.04.1+deb.sury.org+1 I got the following error:
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)
How to reproduce
Just try to access any route on laravel. You need to include doctrine/dbal.
Possible Solution
The error throws the line 79 of the code.
/**
* @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;
}
That line corresponds to the method declaration, why does it have a ?string, I just removed that ? and everything works fine.
This error message happens when your PHP version is below PHP 7.1 which introduced nullable type hints (see http://php.net/manual/en/migration71.new-features.php). When checking the PHP version, keep in mind that the version used on CLI can be different from the one used by the web server.
Symfony version(s) affected: Latest
Description
On production with PHP Version => 7.2.2-3+ubuntu16.04.1+deb.sury.org+1 I got the following error:
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)
How to reproduce
Just try to access any route on laravel. You need to include
doctrine/dbal
.Possible Solution
The error throws the line 79 of the code.
That line corresponds to the method declaration, why does it have a
?string
, I just removed that?
and everything works fine.Also I have this stackoverflow issue if you need more information: https://stackoverflow.com/questions/51698746/how-to-fix-a-syntax-error-on-symfony-component-raised-after-composer-require-doc?noredirect=1#comment90359711_51698746
The text was updated successfully, but these errors were encountered: