People keep asking me about IDE plugins for Rector and Easy Coding Standard. Do you want it too? Do you use one for PHP_CodeSniffer of PHP CS Fixer? Have you ever thought about the benefits and costs of them?
When you a PHPStorm plugin that tells you what to do, you have this extra information that you can follow:
That's pretty cool, right? It will:
vendor/bin/ecs check src
The last benefit is wired to our brains.
"Everybody is addicted to dopamine."
Slack notification, Instagram likes, underline of typoes and suggestions in your IDE.
This all makes us happy by brain design.
Coding standard tools are in your IDE already, next are static analyzers and instant upgraders:
Everyone writes about the benefits of these plugins, but how much do you pay for it?
"It's free!"
Well, it's not. If you've never heard about dopamine - notification effect, read Are You Using Social Media or Being Used By It? by Cal Newport. This amazing guy helped me to quit Twitter and go deeper in topics I really care about in my life.
Basically, notifications turn your beautiful and dynamic brain capable of high abstract thinking to the brain of a heroin addict with instant feedback overloop.
Let's get back to our code again.
If we're lucky, it's gone under 15 seconds. If not, we get back to "we try to understand it" step. In time, we get better, faster and we create a small database of "message → solution" in our brains. In a few weeks, we learn how to write perfect code without any underscores.
Then our team extends rule set with PSR-12 and we have to upgrade our brain database. So we start to hate extending of coding standards and prefer less.
Now the important question: do you know how expensive this is? If you have a boss who doesn't care about productivity and you can whatever you need without critical business thinking, stop reading, because you're primed to waste money by your work design.
But if you're freelancer, or you pay your programmers or you desire to be effective by lazy, I have a comparison for you:
Without PHPStorm plugins, you have to run the tool manually in your command line once per git push:
open command line (2 s)
run coding standard command (2 s)
4 seconds per push vs 15 seconds per 1 error + persisted database in your brain
What is cheaper in money and brain damage?
Pro-lazy tip: I'm too lazy to type more than 2-3 chars manually, so I use composer scripts and 2-3 chars long bash script shortcuts:
cs
# aliased to vendor/bin/ecs check app packages tests
fs
# aliased to: vendor/bin/ecs check app packages tests --fix
Rule of the Thumb: If something requires your attention multiple times with same A → B operation, automate the change and delegate it.
PHP_CodeSniffer can actually report what should be changed, without any clear suggestion of how to change it (read-only). But PHP CS Fixer fixes the code by default, so you don't even have to think about the change. So using PHP CS Fixer manually is a pure waste of life and money.
And this just a very limited example of 1 programmer and 1 project. Most companies have multiple programmers and projects. *The waste of time for 10-programmer teams having 20 projects escalates quickly:
In simple words: exponential costs vs constant costs
Now imagine all the PHP projects in the world. Which of those is faster?
Does it ring a bell? Now think about the same way about instant upgrades or refactoring?
If there will be Rector plugin for PHPStorm (I honestly hope it won't), you'd have to find every new pattern there is in your project, again manually and randomly in your PHP files and hit the "refactor" button.
If you're effective, lazy and don't want to produce waste, you'll run:
vendor/bin/rector process src
And save millions of your brain cells :)
Happy coding!
Do you learn from my contents or use open-souce packages like Rector every day?
Consider supporting it on GitHub Sponsors.
I'd really appreciate it!