endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.46k stars 727 forks source link

Error of building, syntax error, unexpected 'array' #364

Closed sevaske closed 2 years ago

sevaske commented 2 years ago

I run a code from example and it works on my local server. When I run same code on the google cloud server, I see this in logs: PHP Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST) in /var/www/html/zxc/vendor/endroid/qr-code/src/Builder/Builder.php on line 53

I have the same error with just this:

<?php

use Endroid\QrCode\Builder\Builder;

class QR
{
    public function generate(string $data, int $size = 300, int $margin = 10): string
    {
        var_dump(Builder::create());exit;

    }
}

53 line: private array $options;

PHP 7.4.27 (cli) (built: Dec 20 2021 21:27:56) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies

And same PHP version on the google cloud server.

endroid commented 2 years ago

Hi @sevaske typing a property as an array is compliant with any PHP version >= 7.4.0 so you are either running an older PHP version or something else is wrong on your server. Please note that your PHP CLI version is not necessarily the same as your FPM version. Good luck debugging ;)

sevaske commented 2 years ago

Hi @sevaske typing a property as an array is compliant with any PHP version >= 7.4.0 so you are either running an older PHP version or something else is wrong on your server. Please note that your PHP CLI version is not necessarily the same as your FPM version. Good luck debugging ;)

Oh, you are right. We had the same PHP version FPM and CLI. Apparently someone changed the version. I should have checked it first, I'm sorry.