From 9cbfbfc218aa8856395f2b733cfa372a9a39200d Mon Sep 17 00:00:00 2001 From: David ALLIX <517753+webda2l@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:51:42 +0000 Subject: [PATCH] Update / Improvement --- .php-cs-fixer.dist.php | 1 - composer.json | 12 ++++++------ src/Form/Attribute/AutoTypeCustom.php | 6 +++--- src/Form/Builder/AutoTypeBuilder.php | 4 ++-- tests/Fixtures/Dto/Product1.php | 8 +++----- tests/Fixtures/Entity/Product1.php | 2 +- tests/Form/TestScenario.php | 2 +- tests/Form/Type/AutoTypeTest.php | 5 ++--- 8 files changed, 18 insertions(+), 22 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f8a719e..5b80b3c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -51,7 +51,6 @@ 'phpdoc_var_without_name' => true, 'phpdoc_to_comment' => false, 'single_line_throw' => true, - 'string_implicit_backslashes' => false, // Temporary? 'statement_indentation' => true, 'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays', 'parameters']], 'use_arrow_functions' => true, diff --git a/composer.json b/composer.json index fe488a8..8d7700f 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/http-kernel": "^7.4|^8.0", "symfony/property-info": "^7.4|^8.0", "symfony/type-info": "^7.4|^8.0", - "phpdocumentor/reflection-docblock": "^5.6" + "phpdocumentor/reflection-docblock": "^5.6|^6.0" }, "require-dev": { "doctrine/orm": "^3.5.8", @@ -34,12 +34,12 @@ "phpstan/phpstan-phpunit": "^2.0.10", "phpstan/phpstan-strict-rules": "^2.0.7", "phpstan/phpstan-symfony": "^2.0.9", - "phpunit/phpunit": "^12.5.2", + "phpunit/phpunit": "^13.0.5", "rector/rector": "^2.2.14", - "symfony/cache": "^7.4.1", - "symfony/doctrine-bridge": "^7.4.1", - "symfony/validator": "^7.4.2", - "symfony/var-dumper": "^7.4" + "symfony/cache": "^7.4|^8.0", + "symfony/doctrine-bridge": "^7.4|^8.0", + "symfony/validator": "^7.4|^8.0", + "symfony/var-dumper": "^7.4|^8.0" }, "suggest": { "a2lix/translation-form-bundle": "For translation form" diff --git a/src/Form/Attribute/AutoTypeCustom.php b/src/Form/Attribute/AutoTypeCustom.php index 9104895..46ff553 100644 --- a/src/Form/Attribute/AutoTypeCustom.php +++ b/src/Form/Attribute/AutoTypeCustom.php @@ -20,9 +20,9 @@ final readonly class AutoTypeCustom { /** - * @param array $options - * @param class-string|null $type - * @param list|null $groups + * @param array $options + * @param class-string<\Symfony\Component\Form\FormTypeInterface>|null $type + * @param list|null $groups */ public function __construct( private array $options = [], diff --git a/src/Form/Builder/AutoTypeBuilder.php b/src/Form/Builder/AutoTypeBuilder.php index 6e56d07..0a0693a 100644 --- a/src/Form/Builder/AutoTypeBuilder.php +++ b/src/Form/Builder/AutoTypeBuilder.php @@ -23,7 +23,7 @@ /** * @phpstan-type ChildOptions array{ - * child_type?: class-string, + * child_type?: class-string<\Symfony\Component\Form\FormTypeInterface>, * child_name?: string, * child_excluded?: bool, * child_embedded?: bool, @@ -287,7 +287,7 @@ private function updateEmbeddedChildOptions( $innerType = $propTypeInfo instanceof TypeInfo\NullableType ? $propTypeInfo->getWrappedType() : $propTypeInfo; if (Collection::class === $innerType->getClassName()) { - throw new \RuntimeException(\sprintf('Unprecise PhpDoc Collection detected for "%s:%s". Fix it. For example: "@param Collection $%s"', $refProperty->class, $refProperty->name, $refProperty->name)); + throw new \RuntimeException(\sprintf('Unprecise PhpDoc Collection detected for "%s:%s". Fix it. For example: "@var Collection"', $refProperty->class, $refProperty->name)); } return [ diff --git a/tests/Fixtures/Dto/Product1.php b/tests/Fixtures/Dto/Product1.php index 6e6df83..6fde35c 100644 --- a/tests/Fixtures/Dto/Product1.php +++ b/tests/Fixtures/Dto/Product1.php @@ -19,11 +19,6 @@ class Product1 { - /** - * @param list $tags - * @param Collection $mediaColl - * @param list $statusList - */ public function __construct( #[AutoTypeCustom(excluded: true)] public readonly ?string $id = null, @@ -31,10 +26,13 @@ public function __construct( #[AutoTypeCustom(type: CoreType\TextareaType::class, name: 'desc', options: ['attr' => ['rows' => 2]])] private ?string $description = null, public readonly ?int $code = null, + /** @var list */ public readonly array $tags = [], public readonly ?Media1 $mediaMain = null, + /** @var Collection */ public ?Collection $mediaColl = null, public readonly ?ProductStatus $status = null, + /** @var list */ public readonly ?array $statusList = null, #[AutoTypeCustom(groups: ['Default', 'validity'])] public readonly ?\DateTimeImmutable $validityStartAt = null, diff --git a/tests/Fixtures/Entity/Product1.php b/tests/Fixtures/Entity/Product1.php index 354c106..dd8c77f 100644 --- a/tests/Fixtures/Entity/Product1.php +++ b/tests/Fixtures/Entity/Product1.php @@ -45,7 +45,7 @@ class Product1 #[ORM\ManyToOne(targetEntity: Media1::class)] public ?Media1 $mediaMain = null; - /** @var Collection */ + /** @var Collection */ #[ORM\OneToMany(targetEntity: Media1::class, mappedBy: 'product', cascade: ['all'], orphanRemoval: true)] public Collection $mediaColl; diff --git a/tests/Form/TestScenario.php b/tests/Form/TestScenario.php index 8c700e6..f4825aa 100644 --- a/tests/Form/TestScenario.php +++ b/tests/Form/TestScenario.php @@ -13,7 +13,7 @@ /** * @phpstan-type ExpectedChildren = array>, * expected_children?: mixed, * ... * }> diff --git a/tests/Form/Type/AutoTypeTest.php b/tests/Form/Type/AutoTypeTest.php index de4f82b..d0410d5 100755 --- a/tests/Form/Type/AutoTypeTest.php +++ b/tests/Form/Type/AutoTypeTest.php @@ -22,7 +22,6 @@ use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProviderExternal; -use Symfony\Component\Form\FormInterface; /** * @internal @@ -49,8 +48,8 @@ public function testScenario(TestScenario $testScenario): void } /** - * @param ExpectedChildren $expectedForm - * @param array> $formChildren + * @param ExpectedChildren $expectedForm + * @param array> $formChildren */ private static function assertFormChildren(array $expectedForm, array $formChildren, string $parentPath = ''): void {