Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/phpcsfixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ["8.3"]
php-versions: ["8.2"]

name: PHP ${{ matrix.php-versions }} CS-Fixer ${{ matrix.operating-system }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ["8.2", "8.3"]
php-versions: ["8.2", "8.3", "8.4"]

name: PHP ${{ matrix.php-versions }} Static Analysis on ${{ matrix.operating-system }}

Expand Down
5 changes: 4 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in([
__DIR__.'/src',
__DIR__.'/config',
])
->append([__FILE__])
)
;
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"symfony/validator": "^7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.65",
"friendsofphp/php-cs-fixer": "^3.89",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-symfony": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-symfony": "^2.0",
"symfony/doctrine-bridge": "^7.0"
},
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion config/definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Symfony\Component\Config\Definition\Configurator;

return function (DefinitionConfigurator $definitionConfigurator): void {
$definitionConfigurator
$definitionConfigurator // @phpstan-ignore method.notFound
->rootNode()
->children()
->arrayNode('cause_resolver')
Expand Down
10 changes: 10 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
level: 9

paths:
- src/
- config/

ignoreErrors:
- message: '#generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types: TData#'
- message: '#extends generic class Symfony\\Component\\Form\\AbstractType but does not specify its types: TData#'
8 changes: 0 additions & 8 deletions phpstan.neon

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
*/
class BooleanTypeToBooleanDataTransformer implements DataTransformerInterface
{
/**
* @param array<int|string|bool> $trueValues
* @param array<int|string|bool> $falseValues
*/
public function __construct(
private readonly array $trueValues,
private readonly array $falseValues,
Expand All @@ -27,7 +31,7 @@ public function transform(mixed $value): string
return $this->default ? 'true' : 'false';
}

if (!\is_bool($value)) {
if (!\is_bool($value)) { // @phpstan-ignore function.alreadyNarrowedType
throw new TransformationFailedException(\sprintf('Expected type bool, found "%s".', \get_debug_type($value)));
}

Expand All @@ -40,7 +44,7 @@ public function reverseTransform(mixed $value): ?bool
return $this->default;
}

if (\is_string($value)) {
if (\is_string($value)) { // @phpstan-ignore function.alreadyNarrowedType
$value = \strtolower($value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function reverseTransform(mixed $value): ?string
return $value;
}

if (!\is_string($value)) {
if (!\is_string($value)) { // @phpstan-ignore function.alreadyNarrowedType
throw new TransformationFailedException('Expected type string.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Form/DataTransformer/StringToUuidDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function reverseTransform(mixed $value): ?string
return $value;
}

if (!$value instanceof Uuid) {
if (!$value instanceof Uuid) { // @phpstan-ignore instanceof.alwaysTrue
throw new TransformationFailedException('Expected type Uuid, found '.\get_debug_type($value));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Form/DataTransformer/UuidToStringDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function transform(mixed $value): ?string
return null;
}

if (!$value instanceof Uuid) {
if (!$value instanceof Uuid) { // @phpstan-ignore instanceof.alwaysTrue
throw new TransformationFailedException('Expected a Uuid.');
}

Expand All @@ -44,7 +44,7 @@ public function reverseTransform(mixed $value): ?Uuid
return null;
}

if (!\is_string($value)) {
if (!\is_string($value)) { // @phpstan-ignore function.alreadyNarrowedType
throw new TransformationFailedException('Expected a string.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Form/Extension/UuidTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
}

$builder
->addViewTransformer(new UuidToStringDataTransformer($options['nil_to_null'])) // @phpstan-ignore-line
->addViewTransformer(new UuidToStringDataTransformer($options['nil_to_null'])) // @phpstan-ignore argument.type
;
}

Expand Down
1 change: 1 addition & 0 deletions src/Form/FormProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function processForm(FormInterface $form, object &$object, array $ignored
$key = $propertyPath->getElement(0);

if ($childForm->isSubmitted() && $childForm->isValid()) {
// @phpstan-ignore-next-line parameterByRef.type
$this->propertyAccessor->setValue($object, $key, $childForm->getData());
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/Form/Type/BooleanType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->addModelTransformer(new BooleanTypeToBooleanDataTransformer(
$options['true_values'], // @phpstan-ignore-line
$options['false_values'], // @phpstan-ignore-line
$options['default_value'] // @phpstan-ignore-line
$options['true_values'], // @phpstan-ignore argument.type
$options['false_values'], // @phpstan-ignore argument.type
$options['default_value'] // @phpstan-ignore argument.type
))
;
}
Expand All @@ -37,5 +37,7 @@ public function configureOptions(OptionsResolver $resolver): void
]);

$resolver->setAllowedTypes('default_value', ['bool', 'null']);
$resolver->setAllowedTypes('true_values', 'array');
$resolver->setAllowedTypes('false_values', 'array');
}
}
3 changes: 1 addition & 2 deletions src/ParamResolver/DotEncodingParamResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public function resolveParam(FormError $formError): ?string

$key = \implode('.', $keys);

// @phpstan-ignore-next-line
if ('' === $key) {
if ('' === $key) { // @phpstan-ignore identical.alwaysFalse
return null;
}

Expand Down
3 changes: 3 additions & 0 deletions src/SBSEDVFormBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

class SBSEDVFormBundle extends AbstractBundle
{
/**
* @param array<array-key, array<array-key, mixed>> $config
*/
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
{
$container->import('../config/services/cause_resolver.php');
Expand Down
1 change: 1 addition & 0 deletions src/Serializer/Normalizer/FormErrorNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
}

$error = [
// @phpstan-ignore-next-line array.invalidKey
$messageKey => $this->messageResolver->resolveMessage($formError) ?? $formError->getMessage(),
$typeKey => $errorType,
];
Expand Down
1 change: 1 addition & 0 deletions src/Serializer/Normalizer/UnsubmittedFormNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __construct(
public function normalize(mixed $object, ?string $format = null, array $context = []): array
{
return [[
// @phpstan-ignore-next-line array.invalidKey
$context[self::CONTEXT_MESSAGE_KEY] ?? 'message' => $this->translator->trans('request_body_is_empty', domain: 'sbsedv_form'),
'type' => $context[self::CONTEXT_ERROR_TYPE] ?? 'invalid_request_error',
]];
Expand Down