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)

3
  • I strongly, strongly urge you and all Joomla users to use a professional IDE over a basic txt editor like Notepad. The features will absolutely blow your mind compared to notepad. You will save yourself hundreds of hours by using optimal tools. I use PHPStorm 100% of the time and would never go back to my old Notepad++ days.
    – mickmackusa
    Aug 18 at 1:20
  • PHPStorm might be better suited for PHP/Joomla development, but I think VS Code is a "professional" tool as well. I work on many projects with different languages and I prefer to not have a dedicated IDE for every language. That's why I will stick with VSC for now since it works well for most cases. The only missing feature for me regarding Joomla dev is the one in this question.
    – jost21
    Aug 18 at 10:52
  • I don't have anything against VSC. I just don't use it. I'm just happy that you are not using a basic text editor.
    – mickmackusa
    Aug 18 at 12:18
0

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

2
  • 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 '20 at 18:25
  • You could use Notepad++ to also insert the use statement.
    – James
    Nov 21 '20 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.