feat: add PHPStan level 9, PHP CS Fixer, Pest; fix docker user=1000 to avoid root-owned files

This commit is contained in:
Simon Kuehn 2026-05-14 04:25:30 +00:00
parent e249c3d80f
commit f204233509
11 changed files with 4500 additions and 8 deletions

2
.gitignore vendored
View file

@ -5,3 +5,5 @@
/public/bundles/
/.php-cs-fixer.cache
/.phpunit.result.cache
/phpunit.xml
/.phpunit.cache/

19
.php-cs-fixer.php Normal file
View file

@ -0,0 +1,19 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests');
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'declare_strict_types' => true,
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
'ordered_imports' => true,
'no_unused_imports' => true,
'array_syntax' => ['syntax' => 'short'],
'phpdoc_align' => false,
])
->setRiskyAllowed(true)
->setFinder($finder);

View file

@ -28,7 +28,9 @@
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
"symfony/runtime": true,
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
},
"bump-after-update": true,
"sort-packages": true
@ -75,5 +77,14 @@
"allow-contrib": false,
"require": "8.0.*"
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"pestphp/pest": "^3",
"phpstan/extension-installer": "*",
"phpstan/phpstan": "^2",
"phpstan/phpstan-doctrine": "^2",
"phpstan/phpstan-symfony": "^2",
"phpunit/phpunit": "*"
}
}

4393
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -3,8 +3,6 @@ doctrine:
url: '%env(resolve:DATABASE_URL)%'
schema_filter: ~^(?!logs\.|logs_archive\.)~
orm:
auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:

View file

@ -1,8 +1,6 @@
framework:
router:
# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
default_uri: '%env(DEFAULT_URI)%'
default_uri: 'http://localhost'
when@prod:
framework:

View file

@ -3,6 +3,9 @@ services:
build:
context: .
dockerfile: docker/app/Dockerfile
user: "1000:1000"
environment:
HOME: /tmp
volumes:
- .:/var/www
depends_on:
@ -47,6 +50,9 @@ services:
build:
context: .
dockerfile: docker/app/Dockerfile
user: "1000:1000"
environment:
HOME: /tmp
command: php bin/console messenger:consume ai_pipeline --time-limit=3600 --memory-limit=256M
volumes:
- .:/var/www
@ -60,6 +66,9 @@ services:
build:
context: .
dockerfile: docker/app/Dockerfile
user: "1000:1000"
environment:
HOME: /tmp
command: php bin/console messenger:consume orders --time-limit=3600 --memory-limit=256M
volumes:
- .:/var/www
@ -73,6 +82,9 @@ services:
build:
context: .
dockerfile: docker/app/Dockerfile
user: "1000:1000"
environment:
HOME: /tmp
command: php bin/console messenger:consume channel_sync --time-limit=3600 --memory-limit=256M
volumes:
- .:/var/www
@ -86,6 +98,9 @@ services:
build:
context: .
dockerfile: docker/app/Dockerfile
user: "1000:1000"
environment:
HOME: /tmp
command: >
sh -c "while true; do
php bin/console app:logs:rotate;

13
phpstan.neon Normal file
View file

@ -0,0 +1,13 @@
includes:
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-doctrine/extension.neon
parameters:
level: 9
paths:
- src
- tests
symfony:
containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml
doctrine:
objectManagerLoader: tests/bootstrap.php

29
phpunit.xml.dist Normal file
View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
failOnWarning="true"
failOnRisky="true"
>
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory>tests/Integration</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="SHELL_VERBOSITY" value="-1"/>
</php>
</phpunit>

5
tests/Pest.php Normal file
View file

@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
uses(PHPUnit\Framework\TestCase::class)->in('Unit');

13
tests/bootstrap.php Normal file
View file

@ -0,0 +1,13 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
require dirname(__DIR__).'/vendor/autoload.php';
if (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}
if ($_SERVER['APP_DEBUG']) {
umask(0000);
}