Download the PHP package magician79/coding-standard without Composer
On this page you can find all versions of the php package magician79/coding-standard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download magician79/coding-standard
More information about magician79/coding-standard
Files in magician79/coding-standard
Package coding-standard
Short Description Shared coding standards: PHPCS (PSR-12 + Slevomat) and PHPStan defaults for PHP8 projects.
License MIT
Homepage https://github.com/magician79/coding-standard
Informations about the package coding-standard
Magician79 Coding Standard
Shared coding standards for PHP projects:
- PHPCS — Doctrine Coding Standard (PSR-12 + curated Slevomat) as a baseline, with Pragmatic and Strict profiles
- PHPStan — Pragmatic and Strict configs
- Syntax linting — via php-parallel-lint (with optional var-dump check)
Packaged for easy reuse across repositories with sensible defaults and stricter opt-ins.
Table of Contents
- What this package provides
- Installation
- PHPCS ruleset profiles
- PHPStan profiles
- PHP syntax linting
- Quick usage options
- Choosing a PHPCS profile
- Excluding or tuning sniffs
- PHPStan: extend in a project
- Composer and installation behavior
- CI examples
- Pre-commit hook example
- Versioning and upgrade policy
- Troubleshooting
- License
What this package provides
-
PHPCS rulesets
- Pragmatic (default): Based on Doctrine coding standard, this profile balances strictness with low noise and high autofix coverage. It avoids overlapping or conflicting PHPCS sniffs by carefully selecting compatible rules.
- Strict (opt-in): Extends the Pragmatic profile with a stricter set of sniffs from Doctrine and Slevomat for maximum code quality and rigor, suitable for new or greenfield modules.
-
PHPStan configurations
- Pragmatic (default): Level 6 + noise reduction toggles.
- Strict (opt-in): Level max, bleedingEdge, phpstan-strict-rules included.
-
PHP syntax linting
php-parallel-lint(fast, parallel parse error detection)- Optional
var-dump-checkto block accidental debug prints.
-
Optional Composer scripts
- Predefined tasks (
cs,stan,check, etc.) for quick setup.
- Predefined tasks (
- Out-of-the-box tooling
- PHPCS, Doctrine Coding Standard, Slevomat, PHPStan, php-parallel-lint are bundled so consumers don’t need to install them separately.
Installation
Install in your project as a dev dependency:
This installs (into your project’s vendor/):
doctrine/coding-standardsquizlabs/php_codesnifferslevomat/coding-standarddealerdirect/phpcodesniffer-composer-installerphpstan/phpstan(+phpstan/phpstan-strict-rules)php-parallel-lint/php-parallel-lint- (optional)
php-parallel-lint/php-var-dump-check,php-parallel-lint/php-console-highlighter
Note: tools are installed in dev mode (composer install). They are omitted in production installs (composer install --no-dev).
PHPCS ruleset profiles
There are two PHPCS profiles in this package:
-
Pragmatic profile (recommended default)
- File:
vendor/magician79/coding-standard/ruleset/phpcs.pragmatic.xml - Intent: Low-friction adoption. Doctrine baseline + curated Slevomat. Enforces
declare(strict_types=1), type hints, imports hygiene, strict comparisons, unused code cleanup, and a pragmatic line length rule. Most findings are auto-fixable viaphpcbf.
- File:
- Strict profile (opt-in)
- File:
vendor/magician79/coding-standard/ruleset/phpcs.strict.xml - Intent: Maximum rigor by extending the Doctrine baseline and Pragmatic profile with nearly all Slevomat sniffs. Best for new projects or modules. Expect to exclude or tune some sniffs.
- File:
PHPStan profiles
This package ships two PHPStan configurations:
-
Pragmatic (default)
- File:
vendor/magician79/coding-standard/phpstan/pragmatic.neon.dist - Level 6 with noise-reducing toggles. Designed for adoption on existing code.
- File:
- Strict (opt-in)
- File:
vendor/magician79/coding-standard/phpstan/strict.neon.dist - Level max, phpstan-strict-rules included. Ideal for greenfield modules.
- File:
Run directly:
PHP syntax linting (php-parallel-lint)
php-parallel-lint runs a fast, parallel parse check of your PHP files. It catches syntax/parse errors before PHPCS or PHPStan run.
Useful flags:
-j 8or higher for concurrency--colorsfor readable output--excludeto skip vendor/cache/build directories--blameto show the author of the failing line
Run directly:
Optional: disallow debug prints using php-var-dump-check:
Quick usage options
Option A: Use shared profiles via Composer scripts
Add to your project’s composer.json:
Run:
composer lint:phpcomposer cscomposer fixcomposer stancomposer check(syntax lint → PHPCS → PHPStan)
Option B: Extend rules in your project (recommended for larger projects)
Create phpcs.xml in your project root:
Run:
vendor/bin/phpcsvendor/bin/phpcbf
Choosing a PHPCS profile
- Pragmatic: best for existing/legacy code.
- Strict: best for new projects or modernized code.
You can also mix: Pragmatic globally, Strict on certain paths:
Excluding or tuning sniffs
You can always exclude or adjust any sniff in your project’s phpcs.xml:
-
Disable globally:
-
Demote error to warning:
- Exclude by path:
PHPStan: extend in a project (recommended for larger repos)
Create a phpstan.neon.dist file in your project root and include one of the shared profiles.
Pragmatic baseline:
Or Strict mode:
Baselines:
- This package does not ship a baseline. Generate one in your project only if needed:
vendor/bin/phpstan analyse --generate-baseline=phpstan-baseline.neon
- Consider starting with Pragmatic without a baseline; use Strict for new modules or as a second CI job.
Mix-and-match:
- Use Pragmatic globally and enforce Strict on certain paths (e.g.,
src/NewModule) by running a second job or restricting analysis paths:
Performance tips:
- Parallel analysis is enabled by default; tweak
maximumNumberOfProcessesper project. - Limit paths for faster iteration during refactors.
- Ensure
var/cache/phpstanis writable in your environment.
Composer and installation behavior (FAQ)
- Add under
require-devin consumer projects. - In dev installs, all tools are present.
- In production (
--no-dev), the package is omitted and none of the tooling is present. - Rule of thumb:
- Shared package: put tools in
requireso they’re available whenever the consumer installs your package as a dev dependency. - Consumer project: add
magician79/coding-standardunderrequire-dev.
- Shared package: put tools in
CI examples (consumer project)
Run php-parallel-lint first to fail fast, then PHPCS and PHPStan. This workflow uses local config if present, otherwise falls back to vendor defaults.
Minimal pragmatic job:
Separate jobs for strict profiles:
Pre-commit hook example (consumer project)
Create .git/hooks/pre-commit:
Make it executable:
Versioning and upgrade policy
- SemVer:
- MAJOR: enabling stricter default rules or changing defaults in a way that could fail existing code.
- MINOR: new profiles, optional rules, docs, examples that don’t change defaults.
- PATCH: bug fixes and small non-breaking updates.
- Consumers can pin the package version in
composer.jsonand choose when to upgrade. - As of v2.0.0, the Pragmatic and Strict PHPCS profiles are based on the Doctrine Coding Standard with curated Slevomat rules. This reduces overlaps and conflicts. External usage (filenames, commands) remains unchanged. Consumers should re-check their codebase when upgrading to v2.x.
Troubleshooting
- PHPCS can’t find Slevomat rules: ensure
dealerdirect/phpcodesniffer-composer-installeris installed (brought by this package). Runcomposer dump-autoloadif needed. - Too many findings initially: start with Pragmatic; run
phpcbfto auto-fix; then suppress or exclude remaining sniffs that don’t fit your context. - PHPStan seems slow: enable
parallelin your project config and scope paths tosrcandtests. - php-parallel-lint finds errors your PHP version accepts: remember it validates against the PHP version it runs under. In CI, use a matrix or the production PHP version to ensure compatibility.
License
MIT. See LICENSE in this repository.
All versions of coding-standard with dependencies
dealerdirect/phpcodesniffer-composer-installer Version ^1.0
doctrine/coding-standard Version ^13.0
php-parallel-lint/php-parallel-lint Version ^1.4
php-parallel-lint/php-console-highlighter Version ^1.0
php-parallel-lint/php-var-dump-check Version ^0.5
phpstan/phpstan Version ^1.11
phpstan/phpstan-strict-rules Version ^1.6
squizlabs/php_codesniffer Version ^3.10