max-antipin / php-code-sniffs
Coding Standard for PHP_CodeSniffer by Max Antipin provides sniffs with additional checks.
Package info
github.com/max-antipin/php-code-sniffs
Type:phpcodesniffer-standard
pkg:composer/max-antipin/php-code-sniffs
Requires
- php: >=8.3
- dealerdirect/phpcodesniffer-composer-installer: ^1.2
- squizlabs/php_codesniffer: ^3.13
Requires (Dev)
This package is auto-updated.
Last update: 2026-04-05 11:55:40 UTC
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