Compare commits

...

2 commits

Author SHA1 Message Date
57dcabc44f 29 - Add PHP-CS-Fixer 2026-06-15 01:15:21 +02:00
41a984950f 29 - Add PHPStan 2026-06-15 01:11:08 +02:00
8 changed files with 1515 additions and 16 deletions

9
.gitignore vendored
View file

@ -13,3 +13,12 @@
/phpunit.xml
/.phpunit.cache/
###< phpunit/phpunit ###
###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###
###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###

20
.php-cs-fixer.dist.php Normal file
View file

@ -0,0 +1,20 @@
<?php
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude('var')
// Auto-generated Symfony config files — not hand-written source, and the
// risky ruleset mangles prose like "@type" inside their doc comments.
->notPath('config/bundles.php')
->notPath('config/reference.php');
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
// PHP 8.4 may be newer than the fixer officially supports; allow it explicitly.
->setUnsupportedPhpVersionAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
])
->setFinder($finder)
->setCacheFile('var/.php-cs-fixer.cache');

View file

@ -33,6 +33,7 @@
"config": {
"allow-plugins": {
"php-http/discovery": true,
"phpstan/extension-installer": true,
"symfony/flex": true,
"symfony/runtime": true
},
@ -84,6 +85,11 @@
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.95",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.2",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^13.2",
"symfony/browser-kit": "8.1.*",
"symfony/css-selector": "8.1.*"

1419
composer.lock generated

File diff suppressed because it is too large Load diff

21
phpstan.dist.neon Normal file
View file

@ -0,0 +1,21 @@
parameters:
level: 6
paths:
- bin/
- config/
- public/
- src/
- tests/
# phpstan-symfony: point at the compiled dev container so it understands service wiring.
# Requires the dev cache to be warm (php bin/console cache:warmup).
symfony:
containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml
ignoreErrors:
# Framework-generated Kernel: getAllowedEnvs() is called via reflection by Symfony,
# so PHPStan can't see the usage. Scoped to this one file/message (not a global pattern).
-
message: '#Method App\\Kernel::getAllowedEnvs\(\) is unused\.#'
path: src/Kernel.php
# Recipe-generated test bootstrap — not our code to lint.
excludePaths:
- tests/bootstrap.php

View file

@ -103,6 +103,22 @@ pkgs.mkShell {
$COMPOSE exec php php bin/phpunit "$@"
}
dev-stan() {
# Warm the dev cache so phpstan-symfony can read the compiled container, then analyse.
$COMPOSE exec php php bin/console cache:warmup --quiet
$COMPOSE exec php vendor/bin/phpstan analyse --memory-limit=512M "$@"
}
dev-cs() {
# Dry-run code-style check (no changes). Use for CI / verification.
$COMPOSE exec php vendor/bin/php-cs-fixer check --diff "$@"
}
dev-cs-fix() {
# Apply code-style fixes in place.
$COMPOSE exec php vendor/bin/php-cs-fixer fix "$@"
}
# ===================
# BUILD COMMANDS
# ===================
@ -155,6 +171,9 @@ pkgs.mkShell {
echo " dev-console <cmd> Run Symfony console command"
echo " dev-composer <cmd> Run composer in the container"
echo " dev-test [args] Run PHPUnit (bin/phpunit)"
echo " dev-stan [args] Run PHPStan static analysis"
echo " dev-cs [args] Check code style (dry-run)"
echo " dev-cs-fix [args] Apply code style fixes"
echo " base-build Build and push image"
echo ""
echo "Services:"

View file

@ -49,6 +49,18 @@
"migrations/.gitignore"
]
},
"friendsofphp/php-cs-fixer": {
"version": "3.95",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "3.39",
"ref": "97aaf9026490db73b86c23d49e5774bc89d2b232"
},
"files": [
".php-cs-fixer.dist.php"
]
},
"nelmio/cors-bundle": {
"version": "2.6",
"recipe": {
@ -61,6 +73,18 @@
"config/packages/nelmio_cors.yaml"
]
},
"phpstan/phpstan": {
"version": "2.2",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "1.0",
"ref": "5e490cc197fb6bb1ae22e5abbc531ddc633b6767"
},
"files": [
"phpstan.dist.neon"
]
},
"phpunit/phpunit": {
"version": "13.2",
"recipe": {

View file

@ -1,13 +0,0 @@
<?php
namespace App\Tests;
use PHPUnit\Framework\TestCase;
final class SmokeTest extends TestCase
{
public function testPhpunitRuns(): void
{
self::assertTrue(true);
}
}