3

Is there a way to conveniently replace deprecated Joomla classes with VS Code. I do have the PHP CodeSniffer (with Joomla Coding standards) and Intelephense extensions, although I am not sure if everything is set up 100% as it should be. Maybe I missed something. So far the deprecated classes are highlighted and the tool tips show which class to use instead.

But is it also possible to automate the replacement? Replacing the class name and also inserting the use statement at the beginning of the file?

e.g.

class HelloWorldViewHelloWorlds extends JViewLegacy

to

use Joomla\CMS\MVC\View\HtmlView

...

class HelloWorldViewHelloWorlds extends HtmlView

Updating an old extension gets quite tedious, when doing all of them manually.

Update

PHPStorm seems to have something like this:

click on indicated deprecated class, Alt + Enter, then Import Class, choose class and name spacing is placed at top of file (haven't tried it myself since I don't use PHPStorm)

0

Notepad++ has a great find/replace function that works across directories. Any automated changes to code should be handled very carefully.

| improve this answer | |
  • VS Code also has a find/replace function across directories. But that would only replace the class name but wouldn't insert the use .... – jost21 Nov 20 at 18:25
  • You could use Notepad++ to also insert the use statement. – James Shaver Nov 21 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.