max-antipin/php-code-sniffs
最新稳定版本:0.11.2
Composer 安装命令:
composer require --dev max-antipin/php-code-sniffs
包简介
Coding Standard for PHP_CodeSniffer by Max Antipin provides sniffs with additional checks.
README 文档
README
Development & testing
Start dev container:
docker compose -f .docker/compose.yaml up -d
For the first time run:
docker exec php-code-sniffs-dev composer install
Enter dev container:
docker exec -it php-code-sniffs-dev sh
Run all tests (or view this file to get list of commands for testing):
./test.sh
Run all tests without creating one more service:
PHP_VERSION=8.3 docker compose -f .docker/compose.yaml run --rm --build --quiet-build -e XDEBUG_MODE=off php-dev ./test.sh
Run service with test coverage:
docker compose -f .docker/compose.yaml up dev-coverage
The results will be stored in var/coverage-report/.
Below PHP 8.4 there is a conflict between PHP_CodeSniffer and nikic/php-parser which causes fatal error: Token T_PUBLIC_SET has ID of type string, should be int. You may be using a library with broken token emulation. nikic/php-parser package is used by PHPUnit while calculation code coverage.
PHP_CodeSniffer file src/Util/Tokens.php, lines 183-194:
// Some PHP 8.4 tokens, replicated for lower versions. if (defined('T_PUBLIC_SET') === false) { define('T_PUBLIC_SET', 'PHPCS_T_PUBLIC_SET'); } if (defined('T_PROTECTED_SET') === false) { define('T_PROTECTED_SET', 'PHPCS_T_PROTECTED_SET'); } if (defined('T_PRIVATE_SET') === false) { define('T_PRIVATE_SET', 'PHPCS_T_PRIVATE_SET'); }
nikic/php-parser file lib/PhpParser/compatibility_tokens.php, lines 34-42:
foreach ($compatTokens as $token) { if (\defined($token)) { $tokenId = \constant($token); if (!\is_int($tokenId)) { throw new \Error(sprintf( 'Token %s has ID of type %s, should be int. ' . 'You may be using a library with broken token emulation', $token, \gettype($tokenId) )); } // ... } }
Run test containers with all PHP versions and code coverage:
docker compose -f .docker/compose-test.yaml up --quiet-build
统计信息
- 总下载量: 109
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unlicense
- 更新时间: 2024-04-11