Download the PHP package rector/swiss-knife without Composer
On this page you can find all versions of the php package rector/swiss-knife. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rector/swiss-knife
More information about rector/swiss-knife
Files in rector/swiss-knife
Package swiss-knife
Short Description Swiss knife in pocket of every upgrade architect
License MIT
Informations about the package swiss-knife
Swiss Knife for Upgrades
Swiss knife in pocket of every upgrade architect!
Install
Usage
1. Check your Code for Git Merge Conflicts
Do you use Git? Then merge conflicts is not what you want in your code ever to see in pushed code:
`
Add this command to CI to spot these:
Note: The /vendor
directory is excluded by default.
2. Detect Commented Code
Have you ever forgot commented code in your code?
No more! Add this command to CI to spot these:
3. Reach full PSR-4
Find multiple classes in single file
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:
Update Namespace to match PSR-4 Root
Is your class in wrong namespace? Make it match your PSR-4 root:
This will update all files in your /src
directory, to starts with App\\
and follow full PSR-4 path:
4. Finalize classes without children
Do you want to finalize all classes that don't have children?
Do you use mocks but not bypass final yet?
This will keep mocked classes non-final, so PHPUnit can extend them internally.
Do you want to skip file or two?
5. Privatize local class constants
PHPStan can report unused private class constants, but it skips all the public ones. Do you have lots of class constants, all of them public but want to narrow scope to privates?
This command will:
- find all class constant usages
- scans classes and constants
- makes those constant used locally
private
That way all the constants not used outside will be made private
safely.
6. Mock only constructor param you need with MockWire
Imagine there is a service that has 6 dependencies in __construct()
:
But we want to mock only one of them:
Or pass direct instance:
The rest of argument will be mocked automatically.
This way we:
- can easily change the class constructor, without having burden of changing all the tests.
- see what is really being used in the constructor
- avoid any mock-mess clutter properties all over our test
7. Find unused Behat definitions with static analysis - Behastan
Behat uses @When()
, @Then()
and @Given()
annotations and their PHP 8 attribute alternatives to define method to be called in *.feature
files. Sometimes test change and lines from *.feature
files are deleted. But what about definitions?
This command helps you to spot definitions that are no longer needed. Just provide test directory (1 or more) and let it statically compare defined and used masks:
↓
You can also add this command to CI, to get instant feedback about unused definitions.
8. Quick search PHP files with regex
Data beats guess. Do you need a quick idea how many files contain $this->get('...')
calls? Or another anti-pattern you want to remove?
PhpStorm helps with similar search, but stops counting at 100+. To get exact data about your codebase, use this command:
↓
Happy coding!