ashwoodslightfoot / lightfoot-coding-standards
Custom PHPCS standard based on PSR-12
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:phpcodesniffer-standard
Requires
- php: >=8.2
- squizlabs/php_codesniffer: ^3.7
Requires (Dev)
README
Custom PHP CodeSniffer (PHPCS) standard based on PSR-12.
Installation
composer require ashwoods-lightfoot/lightfoot-coding-standard --dev
Usage
Command Line
vendor/bin/phpcs --standard=LightfootCodingStandard /path/to/your/code
PhpStorm Integration
- 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
Included Sniffs
ControlStructures
LogicalOperatorLinePositionSniff
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 }
Formatting
ChainedMethodSemicolonPositionSniff
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();
Running Tests
To run the tests for this coding standard:
composer install
composer test
Testing your fixes
composer cs composer fix
Those 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.
Contributing
- Fork the repository
- Create a feature branch
- Add or modify sniffs
- Add or update tests
- Submit a pull request