Add phpstan, set up composer scripts

This commit is contained in:
myrmidex 2026-06-02 17:52:39 +00:00
parent 98d85af67f
commit b5dd18cac9
6 changed files with 308 additions and 6 deletions

6
.gitignore vendored
View file

@ -10,7 +10,7 @@
###< symfony/framework-bundle ### ###< symfony/framework-bundle ###
###> phpunit/phpunit ### ###> phpunit/phpunit ###
/phpunit.xml /phpunit.*
/.phpunit.cache/ /.phpunit.cache/
###< phpunit/phpunit ### ###< phpunit/phpunit ###
@ -20,3 +20,7 @@
###< symfony/asset-mapper ### ###< symfony/asset-mapper ###
.php-cs-fixer.* .php-cs-fixer.*
###> phpstan/phpstan ###
phpstan.*
###< phpstan/phpstan ###

View file

@ -47,6 +47,7 @@
"config": { "config": {
"allow-plugins": { "allow-plugins": {
"php-http/discovery": true, "php-http/discovery": true,
"phpstan/extension-installer": true,
"symfony/flex": true, "symfony/flex": true,
"symfony/runtime": true "symfony/runtime": true
}, },
@ -86,7 +87,11 @@
], ],
"post-update-cmd": [ "post-update-cmd": [
"@auto-scripts" "@auto-scripts"
] ],
"stan": "phpstan analyse --memory-limit=1G",
"stan-baseline": "phpstan analyse --memory-limit=1G --generate-baseline",
"test": "phpunit",
"cs": "php-cs-fixer fix"
}, },
"conflict": { "conflict": {
"symfony/symfony": "*" "symfony/symfony": "*"
@ -98,11 +103,15 @@
} }
}, },
"require-dev": { "require-dev": {
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.2",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^13.1", "phpunit/phpunit": "^13.1",
"symfony/browser-kit": "8.1.*", "symfony/browser-kit": "8.1.*",
"symfony/css-selector": "8.1.*", "symfony/css-selector": "8.1.*",
"symfony/debug-bundle": "8.1.*", "symfony/debug-bundle": "8.1.*",
"symfony/maker-bundle": "^1.0", "symfony/maker-bundle": "^1.67",
"symfony/stopwatch": "8.1.*", "symfony/stopwatch": "8.1.*",
"symfony/web-profiler-bundle": "8.1.*" "symfony/web-profiler-bundle": "8.1.*"
} }

269
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "4638b54a66331abf4b0f5733d856064c", "content-hash": "6aa0596ff046b9df530a9c0757f8d54e",
"packages": [ "packages": [
{ {
"name": "composer/semver", "name": "composer/semver",
@ -7939,6 +7939,269 @@
}, },
"time": "2022-02-21T01:04:05+00:00" "time": "2022-02-21T01:04:05+00:00"
}, },
{
"name": "phpstan/extension-installer",
"version": "1.4.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/extension-installer.git",
"reference": "85e90b3942d06b2326fba0403ec24fe912372936"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936",
"reference": "85e90b3942d06b2326fba0403ec24fe912372936",
"shasum": ""
},
"require": {
"composer-plugin-api": "^2.0",
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.9.0 || ^2.0"
},
"require-dev": {
"composer/composer": "^2.0",
"php-parallel-lint/php-parallel-lint": "^1.2.0",
"phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0"
},
"type": "composer-plugin",
"extra": {
"class": "PHPStan\\ExtensionInstaller\\Plugin"
},
"autoload": {
"psr-4": {
"PHPStan\\ExtensionInstaller\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Composer plugin for automatic installation of PHPStan extensions",
"keywords": [
"dev",
"static analysis"
],
"support": {
"issues": "https://github.com/phpstan/extension-installer/issues",
"source": "https://github.com/phpstan/extension-installer/tree/1.4.3"
},
"time": "2024-09-04T20:21:43+00:00"
},
{
"name": "phpstan/phpstan",
"version": "2.2.1",
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/dea9c8f2d25cc849391042b71e429c1a4bf82660",
"reference": "dea9c8f2d25cc849391042b71e429c1a4bf82660",
"shasum": ""
},
"require": {
"php": "^7.4|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ondřej Mirtes"
},
{
"name": "Markus Staab"
},
{
"name": "Vincent Langlet"
}
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
}
],
"time": "2026-05-28T14:44:12+00:00"
},
{
"name": "phpstan/phpstan-doctrine",
"version": "2.0.23",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-doctrine.git",
"reference": "4821d678585be36f585273de38c06b7e4a98bb91"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/4821d678585be36f585273de38c06b7e4a98bb91",
"reference": "4821d678585be36f585273de38c06b7e4a98bb91",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.1.34"
},
"conflict": {
"doctrine/collections": "<1.0",
"doctrine/common": "<2.7",
"doctrine/mongodb-odm": "<1.2",
"doctrine/orm": "<2.5",
"doctrine/persistence": "<1.3"
},
"require-dev": {
"cache/array-adapter": "^1.1",
"composer/semver": "^3.3.2",
"cweagans/composer-patches": "^1.7.3",
"doctrine/annotations": "^2.0",
"doctrine/collections": "^1.6 || ^2.1",
"doctrine/common": "^2.7 || ^3.0",
"doctrine/dbal": "^3.3.8",
"doctrine/lexer": "^2.0 || ^3.0",
"doctrine/mongodb-odm": "^2.4.3",
"doctrine/orm": "^2.16.0",
"doctrine/persistence": "^2.2.1 || ^3.4.3",
"gedmo/doctrine-extensions": "^3.8",
"nesbot/carbon": "^2.49",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-deprecation-rules": "^2.0.2",
"phpstan/phpstan-phpunit": "^2.0.8",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6.20",
"ramsey/uuid": "^4.2",
"shipmonk/name-collision-detector": "^2.1",
"symfony/cache": "^5.4",
"symfony/uid": "^5.4 || ^6.4 || ^7.3"
},
"type": "phpstan-extension",
"extra": {
"phpstan": {
"includes": [
"extension.neon",
"rules.neon"
]
}
},
"autoload": {
"psr-4": {
"PHPStan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Doctrine extensions for PHPStan",
"keywords": [
"static analysis"
],
"support": {
"issues": "https://github.com/phpstan/phpstan-doctrine/issues",
"source": "https://github.com/phpstan/phpstan-doctrine/tree/2.0.23"
},
"time": "2026-05-25T15:58:25+00:00"
},
{
"name": "phpstan/phpstan-symfony",
"version": "2.0.19",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-symfony.git",
"reference": "546071ed7f80a89ec30909346eb7cc741800740a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/546071ed7f80a89ec30909346eb7cc741800740a",
"reference": "546071ed7f80a89ec30909346eb7cc741800740a",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.1.13"
},
"conflict": {
"symfony/framework-bundle": "<3.0"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^2.0.8",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6",
"psr/container": "1.1.2",
"symfony/config": "^5.4 || ^6.1",
"symfony/console": "^5.4 || ^6.1",
"symfony/dependency-injection": "^5.4 || ^6.1",
"symfony/form": "^5.4 || ^6.1",
"symfony/framework-bundle": "^5.4 || ^6.1",
"symfony/http-foundation": "^5.4 || ^6.1",
"symfony/messenger": "^5.4",
"symfony/polyfill-php80": "^1.24",
"symfony/serializer": "^5.4",
"symfony/service-contracts": "^2.2.0"
},
"type": "phpstan-extension",
"extra": {
"phpstan": {
"includes": [
"extension.neon",
"rules.neon"
]
}
},
"autoload": {
"psr-4": {
"PHPStan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Lukáš Unger",
"email": "looky.msc@gmail.com",
"homepage": "https://lookyman.net"
}
],
"description": "Symfony Framework extensions and rules for PHPStan",
"keywords": [
"static analysis"
],
"support": {
"issues": "https://github.com/phpstan/phpstan-symfony/issues",
"source": "https://github.com/phpstan/phpstan-symfony/tree/2.0.19"
},
"time": "2026-05-29T12:52:44+00:00"
},
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "14.1.10", "version": "14.1.10",
@ -10026,7 +10289,7 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {},
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
@ -10034,6 +10297,6 @@
"ext-ctype": "*", "ext-ctype": "*",
"ext-iconv": "*" "ext-iconv": "*"
}, },
"platform-dev": [], "platform-dev": {},
"plugin-api-version": "2.6.0" "plugin-api-version": "2.6.0"
} }

13
phpstan-baseline.neon Normal file
View file

@ -0,0 +1,13 @@
parameters:
ignoreErrors:
-
message: '#^Method App\\Kernel\:\:getAllowedEnvs\(\) is unused\.$#'
identifier: method.unused
count: 1
path: src/Kernel.php
-
message: '#^Call to function method_exists\(\) with ''Symfony\\\\Component\\\\Dotenv\\\\Dotenv'' and ''bootEnv'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: tests/bootstrap.php

View file

@ -18,6 +18,7 @@ pkgs.mkShell {
]; ];
shellHook = '' shellHook = ''
alias stan="vendor/bin/phpstan analyse --memory-limit=1G"
export SHELL=${pkgs.zsh}/bin/zsh export SHELL=${pkgs.zsh}/bin/zsh
exec ${pkgs.zsh}/bin/zsh exec ${pkgs.zsh}/bin/zsh
''; '';

View file

@ -35,6 +35,18 @@
"migrations/.gitignore" "migrations/.gitignore"
] ]
}, },
"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": { "phpunit/phpunit": {
"version": "13.1", "version": "13.1",
"recipe": { "recipe": {