m6web/symfony2-coding-standard
Symfony2 coding standard ruleset for PHP_CodeSniffer from M6Web, providing a ready-to-use standard aligned with Symfony2 conventions to help keep code style consistent across teams and projects.
Symfony or Symfony54).composer require --dev friendsofphp/php-cs-fixer
.php-cs-fixer.dist.php with Symfony rules:
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'risky_nullable_type_declaration' => false, // Adjust as needed
]);
./vendor/bin/php-cs-fixer fix
CI/CD Pipeline:
- name: Fix Coding Standards
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
--dry-run for previews).Pre-Commit Hooks:
composer require --dev digitalbazaar/husky-php-cs-fixer
package.json:
"husky": {
"hooks": {
"pre-commit": "husky-php-cs-fixer"
}
}
Team Onboarding:
CONTRIBUTING.md:
## Coding Standards
Run `composer cs-fix` to auto-fix issues. Use `@Symfony` rules unless overridden.
.blade.php files from PHP-CS-Fixer (add to .php-cs-fixer.dist.php):
->exclude(['storage/*', 'vendor/*', 'resources/views/*']);
use App\Models\{}):
->withCustomFixers([new CustomLaravelFixer()]);
Deprecation Warning:
Your requirements could not be resolved to an installable set of packages.
Problem 1: m6web/symfony2-coding-standard v1.0.0 requires symfony/coding-standard ~2.0 -> found symfony/coding-standard[5.4.0] but it does not match your requirement.
Rule Conflicts:
.php-cs-fixer.dist.php:
->setRules([
'@Symfony' => true,
'namespace_separation' => ['custom_rule' => 'one'],
'class_attributes_separation' => false, // Disable if using Laravel’s traits
]);
Performance:
./vendor/bin/php-cs-fixer fix --cache-file=.php-cs-fixer.cache
./vendor/bin/php-cs-fixer fix --dry-run --diff
./vendor/bin/php-cs-fixer fix --rules=@Symfony --path=app/Models/User.php
composer require --dev friendsofphp/php-cs-fixer-config
vendor/bin/php-cs-fixer-config-generator
--parallel (PHP 7.4+):
./vendor/bin/php-cs-fixer fix --parallel
composer require --dev phpstan/phpstan
./vendor/bin/phpstan analyse --level=5
use App\Facades\Cache; as incorrect. Whitelist in config:
->setRules([
'fully_qualified_strict_types' => true,
'no_unused_imports' => false, // Allow Laravel facades
]);
app/Console/Kernel.php if it violates Symfony’s PSR-4 expectations:
->exclude(['app/Console/Kernel.php']);
How can I help you explore Laravel packages today?