Skip to content

Commit

Permalink
Support Symfony 6 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgaal authored Jul 12, 2022
1 parent 7eec2ba commit e7db2f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion src/PropertyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . '[]';
Expand Down

0 comments on commit e7db2f6

Please sign in to comment.