Canary provides linting and static analysis for stickee Laravel projects.
It includes:
- the stickee PHP CS Fixer config to adhere to our code styles
- the stickee Larastan config to analyse your code
- the stickee Rector config to refactor your code
composer require --dev stickee/canary
# Add scripts to composer.json
composer config --json scripts.analyse "vendor/bin/phpstan analyse -c phpstan.dist.neon"
composer config --json scripts.analyze "composer analyse"
composer config --json scripts.fix "vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php"
composer config --json scripts.improve "vendor/bin/rector"
composer config --json scripts.suggest "vendor/bin/rector --dry-run"
cp vendor/stickee/php-cs-fixer-config/dist/.php-cs-fixer.php .
cp vendor/stickee/larastan-config/dist/phpstan.dist.neon .
cp vendor/stickee/larastan-config/dist/phpstan.ci.neon .
cp vendor/stickee/rector-config/dist/rector.php .
You should commit these config files.
if grep -q '.php-cs-fixer.cache' .gitignore;
then
echo ".gitignore contains .php-cs-fixer.cache";
else
echo "Adding .php-cs-fixer.cache to .gitignore";
echo ".php-cs-fixer.cache" >> .gitignore;
echo "Done";
fi
Canary provides a unified package that brings together powerful linting and static analysis tools that we make heavy use of at stickee.
composer analyse
# or vendor/bin/phpstan analyse -c phpstan.dist.neon
This command will perform static-analysis of your whole project.
It could be run as part of a pre-commit
hook.
See stickee/larastan-config for more details.
composer fix
# or vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php
This command will attempt to fix minor code style issues.
It can be run against a single file.
It could be run against staged files as part of a pre-commit
hook.
See stickee/php-cs-fixer-config for more details.
composer improve
# or vendor/bin/rector
This command will refactor your code in an attempt to improve it.
Any improve
d code must be checked before committing.
It can be run against a single file.
It should not be run as part of a pre-commit
hook.
See stickee/rector-config for more details.
Rector in --dry-run
mode
composer suggest
# or vendor/bin/rector --dry-run
This command will suggest improvements as diffs in the terminal.
See stickee/rector-config for more details.
Contributions are welcome!
Improvements to any of the amalgamated open source tools should be directed towards their respective repositories.
Canary is open source software licensed under the MIT license.