Swiss knife in pocket of every upgrade architect!
composer require tomasvotruba/lemonade --dev
Do you use Git? Then merge conflicts is not what you want in your code ever to see in pushed code:
<<<<<<< HEAD
Add this command to CI to spot these:
vendor/bin/swiss-knife check-conflicts .
Note: The /vendor
directory is excluded by default.
Have you ever forgot commented code in your code?
// foreach ($matches as $match) {
// $content = str_replace($match[0], $match[2], $content);
// }
No more! Add this command to CI to spot these:
vendor/bin/swiss-knife check-commented-code <directory>
vendor/bin/swiss-knife check-commented-code packages --line-limit 5
To make PSR-4 work properly, each class must be in its own file. This command makes it easy to spot multiple classes in single file:
vendor/bin/swiss-knife find-multi-classes src
Is your class in wrong namespace? Make it match your PSR-4 root:
vendor/bin/swiss-knife namespace-to-psr-4 src --namespace-root "App\\"
This will update all files in your /src
directory, to starts with App\\
and follow full PSR-4 path:
# file path: src/Repository/TalkRepository.php
-namespace Model;
+namespace App\Repository;
...
Do you want to finalize all classes that don't have children?
vendor/bin/swiss-knife finalize-classes src tests
Do you use mocks but not bypass final yet?
vendor/bin/swiss-knife finalize-classes src tests --skip-mocked
This will keep mocked classes non-final, so PHPUnit can extend them internally.
Do you want to test speed of your dependency tools? E.g. if PHPStan or Rector got slower after upgrade?
- Prepare a script in
composer.json
{
"scripts": {
"phpstan": "vendor/bin/phpstan analyse src --level 8"
}
}
- Run past X versions and measure time and memory
vendor/bin/swiss-knife speed-run-tool phpstan/phpstan --script-name phpstan --run-count 5
Happy coding!