Syntax error unexpected expecting variable t_variable loggerinterface php

PHP Parse error: syntax error, unexpected ‘|', expecting variable (T_VARIABLE) in vendor/psr/log/src/LoggerInterface.php on line 30

Diff from v. 2.3.2 to 2.3.4 in LoggerInterface.php

30c30
<     public function emergency($message, array $context = array());
---
>     public function emergency(string|\Stringable $message, array $context = []): void;

Diff from psr/log v. 1.0.1 and v. 2.0 in composer.json

14c14
<         “php”: “>=5.3.0"
---
>         “php”: “>=8.0.0"
18c18
<             “Psr\\Log\\“: “Psr/Log/”
---
>             “Psr\\Log\\“: “src”
23c23
<             “dev-master”: “1.1.x-dev”
---
>             “dev-master”: “2.0.x-dev”

I'm working with php version 7.4.9, so it appears that the update to using psr/log version 2.0/3.0 which requires php 8.0 is breaking things. Is there a way around this without updating my version of php?

Hi,

I am using Symfony 5.3.10, api-platform 2.6, and php 8.0.3, when run the server and go to the home page, i got this type of syntax error , i tried to solve this problem by changing the version of psr/log(1.1.4 => 2.0.0) but, it doesn't work and its change the symfony error to PHP error, is there any other solutions for this?

I have some syntax errors from symfony vendor when i'm trying to composer install my project.

Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) vendor\psr\log\src\LoggerInterface.php on line 30

With several search, I saw the problem is from PHP version (have to be > 7.1), but actually my version is 7.4.9, this is a local machine, i'm working with WAMP on Windows. Symfony 4.4 version. Already tried to delete vendor, .lock...

Here the php version from phpinfo()

Syntax error unexpected expecting variable t_variable loggerinterface php

Here php version from wamp

Syntax error unexpected expecting variable t_variable loggerinterface php

Here php version from CLI php-v

Syntax error unexpected expecting variable t_variable loggerinterface php

Here my composer.json

{
"type": "project",
"license": "proprietary",    
"require": {
    "php": ">=7.1.3",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "doctrine/annotations": "^1.13",
    "mongodb/mongodb": "^1.10@dev",
    "ramsey/uuid": "^4.2",
    "symfony/console": "4.4.*",
    "symfony/dotenv": "4.4.*",
    "symfony/flex": "^1.3.1",
    "symfony/form": "4.4.*",
    "symfony/framework-bundle": "4.4.*",
    "symfony/messenger": "4.4.*",
    "symfony/yaml": "4.4.*"
},
"require-dev": {
},
"minimum-stability": "dev",
"config": {
    "preferred-install": {
        "*": "dist"
    },
    "sort-packages": true,
    "platform": {
        "php": "7.4.9"
    }
},
"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Tests\\": "tests/"
    }
},
"replace": {
    "paragonie/random_compat": "2.*",
    "symfony/polyfill-ctype": "*",
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php71": "*",
    "symfony/polyfill-php70": "*",
    "symfony/polyfill-php56": "*"
},
"scripts": {
    "auto-scripts": {
        "cache:clear": "symfony-cmd",
        "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },
    "post-install-cmd": [
        "@auto-scripts"
    ],
    "post-update-cmd": [
        "@auto-scripts"
    ]
},
"conflict": {
    "symfony/symfony": "*"
},
"extra": {
    "symfony": {
        "allow-contrib": false,
        "require": "4.4.*"
    }
}
}

Have some idea ?

unread,

Dec 17, 2021, 12:05:42 AM12/17/21

to AdWords API and Google Ads API Forum

Hello

we are migrating from Google Ads API V7 to V9

We have installed php client librairy V12

When we launch the app (php7.3) we  get PHP Parse error:  syntax error, unexpected '|', expecting variable (T_VARIABLE) in /home/metaio-dev-di/google-ads-php/V12/vendor/psr/log/src/LoggerInterface.php on line 30

Line 30 of  LoggerInterface.php  :

public function emergency(string|\Stringable $message, array $context = []): void;

we don't find what is wrong

thank you for your help

Google Ads API Forum Advisor

unread,

Dec 17, 2021, 1:15:44 PM12/17/21

to ,

Hi Didier,

Thank you for raising your concern.

I completely understand your concern. However, since the issue is more on client library configuration, then I would suggest to reach out to the author of the client library as they are more equipped here. You can reach out to the author of the PHP client library via this link.

Let me know if you have further questions.

Regards,

Syntax error unexpected expecting variable t_variable loggerinterface php
Ernie John Blanca Tacata
Google Ads API Team
 

Syntax error unexpected expecting variable t_variable loggerinterface php

ref:_00D1U1174p._5004Q2TLnTe:ref