Warm tip: This article is reproduced from stackoverflow.com, please click
laravel laravel-5 laravel-5.8 php

Laravel 5.8: beberlei/assert/lib/Assert/functions.php return type produces error

发布于 2020-04-08 23:36:34

I installed Laravel 5.8 on local server it works fine, but on remote server it reports the error

Parse error: syntax error, unexpected ':', expecting '{' in /***/vendor/beberlei/assert/lib/Assert/functions.php on line 37

This is the line producing the error

function that($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
{
    return Assert::that($value, $defaultMessage, $defaultPropertyPath);
}

I think the PHP version can't understand the return type or Scalar type string. The PHP version of the server is 7.3.13 and return type and scalar type sting are valid statement in this version but it still reports the error. Do any of you guys know why does this happen?

Thanks in advance

Questioner
M a m a D
Viewed
46
ceejayoz 2020-02-01 05:18

Your app works when accessed via http://mheidari.me/tour.mheidari.me/public/.

Your app doesn't work when accessed via http://tour.mheidari.me/public/.

This implies your virtualhosts have different PHP versions assigned to them, and the error you're receiving would only be present in PHP versions earlier than PHP 7.