ashwoodslightfoot/lightfoot-coding-standards
最新稳定版本:v1.0.3
Composer 安装命令:
composer require ashwoodslightfoot/lightfoot-coding-standards
包简介
Custom PHPCS standard based on PSR-12
README 文档
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
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-13