Custom PHP CodeSniffer (PHPCS) standard based on PSR-12.
composer require ashwoods-lightfoot/lightfoot-coding-standard --devvendor/bin/phpcs --standard=LightfootCodingStandard /path/to/your/code- Go to Settings > Editor > Inspections
- Find "PHP_CodeSniffer validation" under "PHP"
- Check the box to enable it
- Click on the "..." button next to "Coding standard"
- Select "Custom" and provide the path to the ruleset.xml file in this package
Enforces logical operators (&&, ||) to appear at the start of a new line in multi-line conditions.
Valid:
if ($condition1
&& $condition2) {
// Code
}Invalid:
if ($condition1 &&
$condition2) {
// Code
}Enforces that in multi-line chained method calls, the terminating semicolon must be on its own line, aligned with the start of the statement. This sniff is auto-fixable using phpcbf (for example: composer fix in this repo).
Valid:
$installationId = $this->deviceAssignment
->getInstallation()
?->getId()
;
$this->deviceAssignment
->getInstallation()
->getId()
;Invalid:
$installationId = $this->deviceAssignment
->getInstallation()
?->getId();
$this->deviceAssignment
->getInstallation()
->getId();To run the tests for this coding standard:
composer install
composer testcomposer cs
composer fixThose commands will run the tests and fix any issues found on the sniff-fixture.php file. Please ensure you do not commit any fixes to the file.
- Fork the repository
- Create a feature branch
- Add or modify sniffs
- Add or update tests
- Submit a pull request