Github repository is the best documentation, if the code is written mindfully.
E.g. you use Rector and you're curious about its guts. The main bin command is "vendor/bin/rector process", so you're interested in
ProcessCommand. What's inside?
You go to the Github repository:
Great documentation is useless without the even better search.
Good news! Github is closer to PHPStorm than you think:
Just press t on your keyboard and "TypeYourClass".
All Phing scripts I've seen look like someone programmed their own Arduino to open glass with water. So I migrate them to composer scripts, so people can actually use them without having an MIT degree.
Martin already wrote about it in Have you tried Composer Scripts? You may not need Phing
Let's say you already use composer scripts:
"fix-cs": "vendor/bin/ecs check bin src tests --fix"
Great job! Now all you need to do is run it:
The scripts are running... Now imagine I'll come to you and slap you in the face for failing build
master branch (that's just hypothetical case, we all know
master can never fail, right?).
Your head turns around and you grab a part of the script output. Now...
"Was it red or green?"
The output is hard to read quickly without color patterns.
How to fix this? Just add
- "fix-cs": "vendor/bin/ecs check bin src tests --fix"
+ "fix-cs": "vendor/bin/ecs check bin src tests --fix --ansi"
Thanks for this tip to Jan Mikes ❤️️.
For more composer tips, check 24 Tips for Using Composer Efficiently.
You might know PHPMD as PHP Mess Detector. But not many people know, the package is dead:
Dead packages are ok if there is no alternative that is continuously evolving. If there is, by staying at the same place, you're shooting your business and development speed to the leg.
That's this case. PHPMD features are 99 % compatible with PHP Code Sniffer and PHP CS Fixer rules:
I've migrated over 5 of these recently and you can see its a relief in developers eyes - they either have less code to maintain or (more often) they've finally got rid of that "black hole" code that no-one knew what it does.
How to migrate?
Just look at PHPMD migration to PHP_CodeSniffer in Shopsys repository.
I've learned this principle in 5th grade, it has fascinated me ever since. It fascinates me even more, how they are used to create effective code - easy to write, read, maintain and doing what it should do.
What is the least common denominator?
These 2 pictures explain it:
Now, both pictures explain it. Which one do you prefer?
Use the left approach to explain issues and problems. They're easier to understand, focused on the problem you really have and will get to the effective solution faster.
The right path is how the legacy code is manufactured in companies every day.
Occam's razor - People that use Wikipedia or studied university renamed least common denominator to Occam's razor and added more academic words. The logic is the same, but you might prefer it.
SOLID - Again the same family, just different letters and vocabulary.
That's the beauty example of pattern thinking. Instead of remembering 3 different terms, you pick one and use it.
Do you want to go balls deep and learn more about this? Book it:
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!