Parse error: syntax error, unexpected '?', expecting variable
Hello. I found a thread on Google Groups to use this repository for this issue. In that thread it was said that the PHP library requires 5.5.9 or higher. I'm currently running on 7.0.29 and I'm still getting this error.
I'm getting this error: Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /home/........./wp-content/themes/clientTheme/adwords/symfony/serializer/Normalizer/AbstractObjectNormalizer.php on line 238
I got this error when testing out the DownloadCriteriaReportWithAwql.php file. I took a look at line 238 in the AbstractObjectNormalizer file just to see and it's a line that's been commented out.
Any help or advice?
Could you tell what is the version of Symfony serializer you have installed?
The Changelog in the Symfony directory says 4.0.0
OK. Symfony Serializer v4.0.0 needs PHP v7.1.3. This is probably the cause why you see an error because there might be some syntax that your PHP version doesn't recognize.
So what do I do? I cannot increase my php version. I am using 7.0.29
On Sun, May 13, 2018 at 7:23 PM Thanet Knack Praneenararat < [email protected]> wrote:
OK. Symfony Serializer v4.0.0 needs PHP v7.1.3. This is probably the cause why you see an error because there might be some syntax that your PHP version doesn't recognize.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/googleads/googleads-php-lib/issues/489#issuecomment-388672064, or mute the thread https://github.com/notifications/unsubscribe-auth/AIP3gOXV2xmp_exYYaStZqf6gEi_Njlxks5tyNx9gaJpZM4T78-8 .
How did you install Symfony serializer? Is it installed via other libraries by composer? I can't see your project directory structure so I can't advice more. Could you explain in detail what libraries do you use and what does your composer.json look like?
I downloaded the entire adwords api via composer. I did this two weeks ago.
composer require googleads/googleads-php-lib
On Sun, May 13, 2018 at 10:39 PM Thanet Knack Praneenararat < [email protected]> wrote:
How did you install Symfony serializer? Is it installed via other libraries by composer? I can't see your project directory structure so I can't advice more. Could you explain in detail what libraries do you use and what does your composer.json look like?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/googleads/googleads-php-lib/issues/489#issuecomment-388695144, or mute the thread https://github.com/notifications/unsubscribe-auth/AIP3gIsNDo6J7q6aUJvdS64zJrpWNxNuks5tyQqJgaJpZM4T78-8 .
Could you please answer all my previous questions in the previous reply? This will save us turn-around time and it would lead us to the solution more quickly. The more details you could provide, the faster I can understand your circumstances. Thanks. :)
How did you install Symfony serializer? and Is it installed via other libraries by composer? I installed Symfony and the the rest of the googleads-php files via Composer and then I moved them to my webhost environment via FTP. I cannot install it otherwise onto my webhost.
Could you explain in detail what libraries do you use and what does your composer.json look like? I'm not sure what libraries I use because I haven't finished the project. This project will be a custom dashboard for clients to see their own data. Right now I'm trying to use one of the reporting sample DownloadCriteriaReportWithAwql to view an XML or CSV string and it's throwing me the error above.
Attached is a screenshot of the composer.json found in the Symfony directory.

Thanks for the information. I meant your project's composer.json, not the Serializer's composer.json. Could you share that too?
Here's the project's composer.json. I have not changed anything in this file since downloading via composer.

Hmm.. Everything should be alright.
Can you try, in your local machine, removing the vendor/ directory, run composer install, and try again?
Just to let you know, these files are from my web host. So do I need to redo everything?
At least, you would need to try in the local machine first. I wonder why composer install a dependency that is not compatible with your PHP version.
If you have developed something in your project file, you can try on a clean directory first. By the way, you would need to use the same PHP version (7.0) as your web host too.
I just redownloaded the vendor files. How do I check to see if they are for PHP 7.0?
Just run what you originally ran to get the error message, probably DownloadCriteriaReportWithAwql? Also, you can check the Serializer version by yourself. You can use that to check with Serializer GitHub repo to see its composer.json
I was able to successfully run it on my local machine. I'm going to upload all the files to my webhost and test it there.
So I checked the php version on my local machine compared to the one in my webhost. Local Machine is at php version 7.1.14 and my webhost is 7.0.29. I redownloaded everything to my webhost and I'm going to safely assume it's my php version because now I'm getting a: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /home/........../wp-content/themes/clientTheme/adwords/symfony/serializer/Normalizer/AbstractObjectNormalizer.php on line 238
So, there's no other way. If you need to install via local machine and copy files over to the host, you need to find a machine that have the same PHP version as your web host. Alternatively, you could install Symfony serializer by yourself by doing the following:
- Remove only
symfony/serializerin yourvendor/ - Run
composer require symfony/serializer:3.1
Then copy newly created symfony/serializer over to the vendor/ directory in your web host.
Is that serializer version compatible to php v7.0?
You can check by yourself by checking the require part of composer.json of any projects.