Improve PHPStan config

This commit is contained in:
Alejandro Celaya 2024-07-31 19:53:05 +02:00
parent c10f0db170
commit 133efff2cd
3 changed files with 18 additions and 3 deletions

View File

@ -114,7 +114,7 @@
],
"cs": "phpcs -s",
"cs:fix": "phpcbf",
"stan": "APP_ENV=test php vendor/bin/phpstan analyse module/*/src module/*/test* module/*/config module/*/migrations config docker/config --level=8",
"stan": "APP_ENV=test php vendor/bin/phpstan analyse",
"test": [
"@parallel test:unit test:db",
"@parallel test:api test:cli"

View File

@ -109,7 +109,7 @@ function normalizeLocale(string $locale): string
* minimum quality
*
* @param non-empty-string $acceptLanguage
* @param float<0, 1> $minQuality
* @param float $minQuality
* @return iterable<string>;
*/
function acceptLanguageToLocales(string $acceptLanguage, float $minQuality = 0): iterable
@ -142,21 +142,31 @@ function acceptLanguageToLocales(string $acceptLanguage, float $minQuality = 0):
*/
function splitLocale(string $locale): array
{
return array_pad(explode('-', $locale), length: 2, value: null);
[$lang, $countryCode] = array_pad(explode('-', $locale), length: 2, value: null);
return [$lang, $countryCode];
}
/**
* @param InputFilter<mixed> $inputFilter
*/
function getOptionalIntFromInputFilter(InputFilter $inputFilter, string $fieldName): ?int
{
$value = $inputFilter->getValue($fieldName);
return $value !== null ? (int) $value : null;
}
/**
* @param InputFilter<mixed> $inputFilter
*/
function getOptionalBoolFromInputFilter(InputFilter $inputFilter, string $fieldName): ?bool
{
$value = $inputFilter->getValue($fieldName);
return $value !== null ? (bool) $value : null;
}
/**
* @param InputFilter<mixed> $inputFilter
*/
function getNonEmptyOptionalValueFromInputFilter(InputFilter $inputFilter, string $fieldName): mixed
{
$value = $inputFilter->getValue($fieldName);

View File

@ -4,6 +4,11 @@ includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
parameters:
level: 8
paths:
- module
- config
- docker/config
symfony:
console_application_loader: 'config/cli-app.php'
doctrine: