assoconnect/php-quality-config
Shared quality tooling config for PHP projects: standardized settings for static analysis, coding style, and CI checks. Helps teams apply consistent code quality rules across repositories with minimal setup.
Installation
composer require assoconnect/php-quality-config
Add the package to your project’s composer.json under require-dev if using it for testing/quality checks.
First Use Case Integrate with PHPStan or Psalm by extending their config files:
// phpstan.neon
extends = php://vendor/assoconnect/php-quality-config/phpstan.neon
For PHP-CS-Fixer, use the included ruleset:
# .php-cs-fixer.dist.php
return PhpCsFixer\Config::create()
->setRulesetFile(__DIR__.'/vendor/assoconnect/php-quality-config/php-cs-fixer.ruleset.php');
Key Files to Explore
phpstan.neon: Strict type-checking rules (e.g., Laravel-specific checks).psalm.xml: Static analysis configurations (e.g., docblock parsing).php-cs-fixer.ruleset.php: Coding standard presets (e.g., PSR-12 + AssoConnect tweaks).Laravel-Specific Integrations
Laravel extension is pre-configured to enforce:
auth, guest).mixed return types for Eloquent queries are restricted to array|Collection.Team Onboarding
.phpstan.override.neon:
includes = php://vendor/assoconnect/php-quality-config/phpstan.neon
[phpstan.rules.laravel]
checkRouteModelBinding = true
CI/CD Pipelines
- name: PHPStan
run: vendor/bin/phpstan analyse --level=max src
- name: Psalm
run: vendor/bin/psalm --init
services.neon to add project-specific rules:
services:
- Assoconnect\QualityConfig\Rules\CustomRule
// phpstan.neon
level = %env{STRICT_MODE}?max:5
Overly Strict Defaults
max level in PHPStan by default. Start with level=5 and incrementally raise it.--error-format=github to see actionable feedback.Psalm Compatibility
mixed type may conflict with Laravel’s dynamic return types (e.g., Model::all()).@var array<int, Model> to docblocks or use @psalm-suppress MixedReturnStatement.PHP-CS-Fixer Conflicts
.php-cs-fixer.dist.php:
->setLineEnding("\n")
->setRules(['line_ending' => false])
PHPStan Errors:
--generate-mock-files to auto-generate mocks for unresolved dependencies.phpstan.neon for excludePaths to ignore tests/vendors temporarily.Psalm Plugins:
laravel plugin in psalm.xml:
<pluginClass>Vimeo\PsalmPlugin\Plugin</pluginClass>
Custom Rules
Create a PHPStan rule by extending PhpStan\Rule\Rule and reference it in services.neon:
namespace App\Rules;
class NoHardcodedUrlsRule implements Rule
{
public function getNodeType(): string { return Url::class; }
// ...
}
Dynamic Analysis
Use PHPStan’s parameters to conditionally enable rules:
[phpstan.rules.functions]
callableParametersCanBeTypeChecked = %env{DEBUG}?true:false
CI Feedback
Generate a quality gate script (bin/quality-check.sh):
#!/bin/bash
set -e
vendor/bin/phpstan analyse --level=max src || exit 1
vendor/bin/psalm --no-cache --init || exit 1
How can I help you explore Laravel packages today?