diff --git a/composer.json b/composer.json index db88963..13b03eb 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,9 @@ "php": "^8.0", "anteris-dev/faker-map": "^2.0", "fakerphp/faker": "^1.13", - "symfony/property-access": "^5.2", - "symfony/property-info": "^5.2", - "symfony/serializer": "^5.2" + "symfony/property-access": "^5.2 || ^6.0", + "symfony/property-info": "^5.2 || ^6.0", + "symfony/serializer": "^5.2 || ^6.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.17", diff --git a/src/PropertyFactory.php b/src/PropertyFactory.php index 94335f7..f97c0d3 100644 --- a/src/PropertyFactory.php +++ b/src/PropertyFactory.php @@ -90,7 +90,12 @@ protected function extractDocBlockType(ReflectionProperty $property): ?string $type = $types[array_rand($types, 1)]; if ($type->isCollection()) { - $collectionType = $type->getCollectionValueType(); + // Patch for Symfony 6 + if (method_exists($type,'getCollectionValueTypes')) { + $collectionType = $type->getCollectionValueTypes()[0]; + } else { + $collectionType = $type->getCollectionValueType(); + } $className = $collectionType->getClassName() ?? $collectionType->getBuiltinType(); return $className . '[]';