mnapoli/hard-mode
Hard Mode is a small PHP library by Matthieu Napoli that encourages writing more explicit, robust code by making certain “bad practices” harder or impossible at runtime. Useful for catching hidden assumptions and improving code quality in existing projects.
composer require --dev mnapoli/hard-mode
Then write a .phpcs.xml.dist file:
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<file>src</file>
<file>tests</file>
<rule ref="HardMode"/>
</ruleset>
Then run the analysis:
vendor/bin/phpcs
Or using pretty:
vendor/bin/pretty
Run:
vendor/bin/phpcbf
Or using pretty:
vendor/bin/pretty fix
Check out the PHP CodeSniffer documentation for all the options. You will find below documentation for common scenarios.
To exclude some files from the analysis:
<exclude-pattern>tests/Fixtures</exclude-pattern>
On large projects you may want to use PHP CodeSniffer's cache:
<arg name="cache" value=".phpcs-cache"/>
Remember to add .phpcs-cache to .gitignore.
How can I help you explore Laravel packages today?