ParseError: syntax error, unexpected 'protected' (T_PROTECTED), expecting variable (T_VARIABLE)

Created on 5 July 2023, 12 months ago
Updated 27 October 2023, 8 months ago

I am currently using 2.33 version of Drupal Commerce. As soon as I try to update it to any version above, even the latest 2.36 version, I get this error:

ParseError: syntax error, unexpected 'protected' (T_PROTECTED), expecting variable (T_VARIABLE) in /commerce/modules/checkout/src/EventSubscriber/GuestCheckoutCompletionSubscriber.php on line 26

I checked the issue queue and I think I am the only one experiencing this issue. Any ideas?

🐛 Bug report
Status

Closed: works as designed

Version

2.36

Component

Checkout

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Samk11
  • Status changed to Closed: works as designed 12 months ago
  • 🇮🇱Israel jsacksick

    I'm pretty sure you somehow managed to update to Commerce 2.36 on PHP7 but PHP8 is required now. Judging by the line number, that's my best guess.

  • Hi... Yes I am using PHP 7... So, This issue will be fixed if I upgrade to PHP 8?

  • 🇫🇷France Toki Caen, Normandy

    Actually I got the same error here after trying to update database through Drush cr and I am working on PHP 8.1.20 and Commerce 2.36.

    ParseError: syntax error, unexpected 'protected' (T_PROTECTED), expecting variable (T_VARIABLE) in Composer\Autoload\{closure}() (line 26 of /home/my_website/public_html/modules/contrib/commerce/modules/checkout/src/EventSubscriber/GuestCheckoutCompletionSubscriber.php)
    #0 /home/my_website/public_html/vendor/composer/ClassLoader.php(433): Composer\Autoload\{closure}()
    #1 [internal function]: Composer\Autoload\ClassLoader->loadClass()
    #2 [internal function]: spl_autoload_call()
    #3 /home/my_website/public_html/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php(30): ReflectionClass->__construct()
    #4 /home/my_website/public_html/vendor/symfony/dependency-injection/Compiler/Compiler.php(94): Drupal\Core\DependencyInjection\Compiler\RegisterEventSubscribersPass->process()
    #5 /home/my_website/public_html/vendor/symfony/dependency-injection/ContainerBuilder.php(762): Symfony\Component\DependencyInjection\Compiler\Compiler->compile()
    #6 /home/my_website/public_html/core/lib/Drupal/Core/DrupalKernel.php(1351): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
    #7 /home/my_website/public_html/core/lib/Drupal/Core/DrupalKernel.php(948): Drupal\Core\DrupalKernel->compileContainer()
    #8 /home/my_website/public_html/core/lib/Drupal/Core/Update/UpdateKernel.php(42): Drupal\Core\DrupalKernel->initializeContainer()
    #9 /home/my_website/public_html/vendor/drush/drush/src/Drupal/DrupalKernelTrait.php(69): Drupal\Core\Update\UpdateKernel->initializeContainer()
    #10 /home/my_website/public_html/core/lib/Drupal/Core/DrupalKernel.php(487): Drush\Drupal\UpdateKernel->initializeContainer()
    #11 /home/my_website/public_html/vendor/drush/drush/src/Boot/DrupalBoot8.php(241): Drupal\Core\DrupalKernel->boot()
    #12 /home/my_website/public_html/vendor/drush/drush/src/Boot/BootstrapManager.php(293): Drush\Boot\DrupalBoot8->bootstrapDrupalFull()
    #13 /home/my_website/public_html/vendor/drush/drush/src/Boot/BootstrapManager.php(447): Drush\Boot\BootstrapManager->doBootstrap()
    #14 /home/my_website/public_html/vendor/drush/drush/src/Boot/BootstrapManager.php(396): Drush\Boot\BootstrapManager->bootstrapToPhaseIndex()
    #15 /home/my_website/public_html/vendor/drush/drush/src/Boot/BootstrapHook.php(28): Drush\Boot\BootstrapManager->bootstrapToPhase()
    #16 /home/my_website/public_html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(44): Drush\Boot\BootstrapHook->initialize()
    #17 /home/my_website/public_html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(36): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->doInitializeHook()
    #18 /home/my_website/public_html/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(29): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook()
    #19 /home/my_website/public_html/vendor/consolidation/annotated-command/src/CommandProcessor.php(145): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize()
    #20 /home/my_website/public_html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(376): Consolidation\AnnotatedCommand\CommandProcessor->initializeHook()
    #21 /home/my_website/public_html/vendor/symfony/console/Command/Command.php(221): Consolidation\AnnotatedCommand\AnnotatedCommand->initialize()
    #22 /home/my_website/public_html/vendor/symfony/console/Application.php(1039): Symfony\Component\Console\Command\Command->run()
    #23 /home/my_website/public_html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
    #24 /home/my_website/public_html/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
    #25 /home/my_website/public_html/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run()
    #26 /home/my_website/public_html/vendor/drush/drush/src/Runtime/Runtime.php(48): Drush\Runtime\Runtime->doRun()
    #27 /home/my_website/public_html/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run()
    #28 /home/my_website/public_html/vendor/drush/drush/drush(3): require('/home/my_website/pu...')
    #29 /home/my_website/public_html/vendor/bin/drush(115): include('/home/my_website/pu...')
    #30 {main}
  • 🇵🇱Poland Patryk Padus

    Issue is by using CLI php on version 7.4 and not 8.1
    My FPM is different and use 8.1 and CLI was configured on 7.4

    This error will be constantly. Better way is to signal that CLI version mismatch
    I think is critic as this block Drush fully from operating ;/

  • 🇮🇱Israel jsacksick

    How should we signal that? Commerce required PHP version is 8, so not much more we can do here.

  • 🇵🇱Poland Patryk Padus

    @jsacksick

    How should we signal that?

    It should break on start of script - version of PHP CLI isn't proper one and nothing inform about that. That will do less harm and is DX better that looking there.
    Somewhere like "doInitializeHook" should contain simple "if PHP_VERSION" for CLI that is minimal to have proper boot or fail before anything is init. I only provide proper testing case for this issue that can be easily replicated and people sometime will find this issue in future (when you need PHP 10 and you get PHP CLI 8 same issue will emerge.

Production build 0.69.0 2024