Ocramius / PackageVersions

:package: Composer addon to efficiently get installed packages' version numbers
MIT License
3.22k stars 67 forks source link

scrutinizer-ci.com fails: unexpected 'string' (T_STRING) in src/PackageVersions/Installer.php on line 34 #124

Closed igormukhingmailcom closed 4 years ago

igormukhingmailcom commented 4 years ago

This is a hint for users coming from google...

As Scrutinizer can use php version less than 7.4 by default, you can have next exception:

  - Installing ocramius/package-versions (1.6.0): Loading from cache
PHP Parse error:  syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /home/scrutinizer/build/vendor/ocramius/package-versions/src/PackageVersions/Installer.php on line 34

Example: https://scrutinizer-ci.com/g/Setono/SyliusTrustpilotPlugin/inspections/e4dcd104-7acf-441a-b6b7-d7275213477b

To fix that, just add next lines to your .scrutinizer.yml:

build:
  environment:
    php:
      version: 7.4
Ocramius commented 4 years ago

Thanks @igormukhingmailcom!

Ocramius commented 4 years ago

Linking as duplicate of #105

freezy-sk commented 4 years ago

Scrutinizer by default run composer install with --ignore-platform-reqs. So if you want to run Scrutinizer with lower or multiple versions of PHP, you can do it with these lines in your .scrutinizer.yml:

build:
    dependencies:
        override:
            - composer install --no-interaction --no-scripts
    tests:
        override:
            - php-scrutinizer-run
    nodes:
        php72:
            environment:
                php:
                    version: 7.2
        php73:
            environment:
                php:
                    version: 7.3
        php74:
            environment:
                php:
                    version: 7.4