craftcms / rector

Rector rules for updating plugins and modules to Craft CMS 4.
19 stars 6 forks source link

[ERROR] syntax error, unexpected '=>' (T_DOUBLE_ARROW) #16

Closed cap-akimrey closed 11 months ago

cap-akimrey commented 11 months ago

Description

Fresh install of Rector following commands in the Readme.

Steps to reproduce

  1. composer require php:^8.0.2
  2. composer config minimum-stability dev
  3. composer config prefer-stable true
  4. composer require craftcms/rector:dev-main --dev
  5. vendor/bin/rector process src --config vendor/craftcms/rector/sets/craft-cms-40.php

Return is "[ERROR] syntax error, unexpected '=>' (T_DOUBLE_ARROW)"

Additional info

cap-akimrey commented 11 months ago

Actually, I think I might be misunderstanding usage. Is this actually supposed to be run from within a given plugin's directory?

cap-akimrey commented 11 months ago

Turns out I was missing the need to ssh into my container before running Rector. Thanks, Craftquest.io!

nicolasbottari commented 11 months ago

This is from running into the error myself as well:

Note that you have to log into the plugin's directory, not do this from the root of a craftcms project. If you start drilling through a Craft 3 => 4 upgrade, the docs might give the impression this is done at root craft level, but it should be at the plugin's root to run the final vendor/bin/rector process src --config vendor/craftcms/rector/sets/craft-cms-40.php command.

As for the T_DOUBLE_ARROW error, I realized my CLI was using PHP 7.4, which is below the PHP version requirement. Make sure your CLI is running the PHP version required by Rector. :)