Skip to content

Validator is giving RuntimeException after updating to 4.4.2 #35077

Closed
@tarlepp

Description

@tarlepp

Symfony version(s) affected: 4.4.2

Description
I noticed that after updating from 4.4.1 to 4.4.2 couple of my tests are failing with following stack trace

Failed asserting that exception of type "RuntimeException" matches expected exception "Symfony\Component\Validator\Exception\ValidatorException". Message was: "A type is missing in a collection expression" at
/app/vendor/phpdocumentor/type-resolver/src/TypeResolver.php:263
/app/vendor/phpdocumentor/type-resolver/src/TypeResolver.php:439
/app/vendor/phpdocumentor/type-resolver/src/TypeResolver.php:224
/app/vendor/phpdocumentor/type-resolver/src/TypeResolver.php:146
/app/vendor/symfony/property-info/Extractor/PhpDocExtractor.php:201
/app/vendor/symfony/property-info/Extractor/PhpDocExtractor.php:172
/app/vendor/symfony/property-info/Extractor/PhpDocExtractor.php:123
/app/vendor/symfony/property-info/PropertyInfoExtractor.php:109
/app/vendor/symfony/property-info/PropertyInfoExtractor.php:74
/app/vendor/symfony/property-info/PropertyInfoCacheExtractor.php:118
/app/vendor/symfony/property-info/PropertyInfoCacheExtractor.php:80
/app/vendor/symfony/validator/Mapping/Loader/PropertyInfoLoader.php:68
/app/vendor/symfony/validator/Mapping/Loader/LoaderChain.php:54
/app/vendor/symfony/validator/Mapping/Factory/LazyLoadingMetadataFactory.php:124
/app/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:305
/app/vendor/symfony/validator/Validator/RecursiveContextualValidator.php:135
/app/vendor/symfony/validator/Validator/RecursiveValidator.php:93
/app/vendor/symfony/validator/Validator/TraceableValidator.php:66
/app/src/Rest/Traits/RestResourceBaseMethods.php:457
/app/src/Rest/Traits/RestResourceBaseMethods.php:210
/app/tests/Integration/Resource/GenericResourceTest.php:408

That test is trying to validate one of my DTO's and after a little bit testing I tracked that error to following;

/**
 * @var UserGroupEntity[]|array<int, UserGroupEntity>
 *
 * @AppAssert\EntityReferenceExists(entityClass=UserGroupEntity::class)
 */
protected array $userGroups = [];

If I remove that @var UserGroupEntity[]|array<int, UserGroupEntity> line on my DTO, tests doesn't fail and if I run exactly same test within 4.4.1 there isn't that error.

So it seems like some bug fix has caused this side effect in certain use cases.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions