Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Suggestion and Error on JoomlaNamespaceHandlingTrait #1

Open
carcam opened this issue Aug 25, 2022 · 5 comments
Open

Suggestion and Error on JoomlaNamespaceHandlingTrait #1

carcam opened this issue Aug 25, 2022 · 5 comments

Comments

@carcam
Copy link

carcam commented Aug 25, 2022

Hi Nicholas,
thank you very much for this great contribution!!!

I am testing it and I have one suggestion for the composer.json update and one issue I found in a couple of components.

For the composer.json suggestion, after adding your settings and executing composer update --dev, composer complaint about minimum stability, so I had to add the following line to my settings:
"minimum-stability": "dev",

After that, everything was correctly installed, and I could execute the PHP command (after creating the rector.php file).

When executing, I got a couple of PHP exceptions:

PHP Fatal error: Uncaught Error: Call to undefined method Rector\Naming\Rector\FileWithoutNamespace\JoomlaLegacyMVCToJ4Rector::getFile() in ./vendor/nikosdion/joomla_com_upgrader/rules/Naming/Rector/FileWithoutNamespace/JoomlaNamespaceHandlingTrait.php:69

And also:

./vendor/nikosdion/joomla_com_upgrader/rules/Naming/Rector/FileWithoutNamespace/JoomlaNamespaceHandlingTrait.php(153): Rector\Naming\Rector\FileWithoutNamespace\JoomlaLegacyMVCToJ4Rector->getApplicationSide()

Not sure whether these have to do with my configuration or they are generic issues.

Thank you very much again!! This is a great tool that will help lots of developers to update their extensions.

@nikosdion
Copy link
Owner

Ah, I see what happens here. Run

composer update
composer dump-autoload
php ./vendor/bin/rector --clear-cache --dry-run

Well, the current code is a start. It still leaves the component in a VERY rough state but at least you have a starting point which doesn't completely suck 😄

@carcam
Copy link
Author

carcam commented Aug 25, 2022

Thanks for the hint @nikosdion !!

I have applied it but I got a different error this time:

[ERROR] Cannot autowire service "Rector\Naming\Rector\FileWithoutNamespace\JoomlaLegacyMVCToJ4Rector": argument
"$renamedClassHandlerService" of method "__construct()" references class
"Rector\Naming\Rector\FileWithoutNamespace\RenamedClassHandlerService" but no such service exists.

And it seems it does not even start executing the rector. Any further ideas?

@nikosdion
Copy link
Owner

You need to update rector.php. See the updated README on this repo. I am using a custom Symfony service to record the remapping of class names. I am planning on adding a custom Rector which will run on a second pass to replace the renamed class names in DocBlocks and stuff using that information.

@carcam
Copy link
Author

carcam commented Aug 25, 2022

It works!!

After updating rector.php with the new directions, I tested it in a pretty old component (2015) with bare minimum changes and what I can see in the structure and code refactoring looks awesome!!

This is definitely a great tool!! Thank you very much!!

@nikosdion
Copy link
Owner

Thank you! And, mind you, that's before I have even added support for HTML helpers, fields, rules and forms, or even renaming language files 😊

The goal of that tool is to ease the pain. If I can have it ready by 4.3 it will hopefully convince the last holdouts to finally migrate their components. 🤞🏼

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants