cakephp / upgrade

Upgrade tools for CakePHP meant to facilitate migrating from one version of the framework to another
MIT License
110 stars 60 forks source link

Cannot redeclare Cake\Core\h() #261

Closed abakalidis closed 9 months ago

abakalidis commented 11 months ago

Trying to upgrade from CakePHP 4.5 to 5, I installed the upgrade tool as explained in 5.0 Upgrade Guide.
When running ./bin/cake upgrade rector -v --rules cakephp50 /var/www/html/hermonax-dev/src I get this

Detecting autoload file for /var/www/html/hermonax-dev/src
-> Checking /var/www/html/hermonax-dev/src/vendor/autoload.php
-> Checking /var/www/html/hermonax-dev/vendor/autoload.php
-> Found /var/www/html/hermonax-dev/vendor/autoload.php
Running /home/batman/upgrade/vendor/bin/rector process  --autoload-file='/var/www/html/hermonax-dev/vendor/autoload.php' --config='/home/batman/upgrade/config/rector/cakephp50.php' '/var/www/html/hermonax-dev/src' --clear-cache
PHP Fatal error:  Cannot redeclare Cake\Core\h() (previously declared in /home/batman/upgrade/vendor/cakephp/core/functions.php:42) in /var/www/html/hermonax-dev/vendor/cakephp/cakephp/src/Core/functions.php on line 33
Fatal error: Cannot redeclare Cake\Core\h() (previously declared in /home/batman/upgrade/vendor/cakephp/core/functions.php:42) in /var/www/html/hermonax-dev/vendor/cakephp/cakephp/src/Core/functions.php on line 33

Rector applied successfully

I am using Ubuntu Server 22.04.3 LTS

mixable commented 10 months ago

I get the same error when trying to upgrade from CakePHP 4.5 to 5.0.

I am on macOS 14.0, PHP 8.2.8.

LordSimal commented 10 months ago

I am pretty sure my proposed PR fixes this issue.

LordSimal commented 9 months ago

I am unable to reproduce this problem with the latest Cake 4.5 version (which is 4.5.1)