max-antipin/php-code-sniffs
Composer 安装命令:
composer require --dev max-antipin/php-code-sniffs
包简介
Coding Standard for PHP_CodeSniffer by Max Antipin provides sniffs with additional checks.
README 文档
README
composer require --dev max-antipin/php-code-sniffs
Development & testing
Start a dev container and install dependencies:
make up
Enter the dev container:
make shell
Run all tests:
make test-all
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 make test-all
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
Two errors with property hooks:
- There must not be more than one property declared per statement
- Missing type declaration for property "$this"
cat AntipinCS/Tests/Functions/ReturnTypeDeclarationUnitTest.2.inc | ./vendor/bin/phpcs --stdin-path=/php-code-sniffs/AntipinCS/Tests/Functions/ReturnTypeDeclarationUnitTest.2.php -v -s -
max-antipin/php-code-sniffs 适用场景与选型建议
max-antipin/php-code-sniffs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 126 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「static analysis」 「standards」 「phpcs」 「dev」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 max-antipin/php-code-sniffs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 max-antipin/php-code-sniffs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 max-antipin/php-code-sniffs 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP_CodeSniffer custom Sniff for Laravel coding standard
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
A set of abstractions that define core services provided by the DVSA
This is the ZooRoyal coding standard.
TwigStan is a static analyzer for Twig templates powered by PHPStan
Vanio Coding Standard Ruleset for PHP_CodeSniffer.
统计信息
- 总下载量: 126
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unlicense
- 更新时间: 2024-04-11