Skip to content
Open
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
9 changes: 4 additions & 5 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,10 @@ public function collection(
return $this->collectionFactoryAlias[$name];
}
// Find by interface
if (\class_exists($name)) {
foreach ($this->collectionFactoryInterface as $interface => $factory) {
if (\is_subclass_of($name, $interface, true)) {
return $this->collectionFactoryAlias[$name] = $factory->withCollectionClass($name);
}
foreach ($this->collectionFactoryInterface as $interface => $factory) {
if (\is_a($name, $interface, true)) {
/** @var class-string $name */
return $this->collectionFactoryAlias[$name] = $factory->withCollectionClass($name);
}
}
return $this->collectionFactoryAlias[$name] = $this->factory->make($name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ public function collectionTypesProvider(): array
'Alias Common Illuminate collection eager' => [
'illuminate', false, \Illuminate\Support\Collection::class,
],
'Interface Doctrine collection lazy' => [
\Doctrine\Common\Collections\Collection::class, true, \Doctrine\Common\Collections\ArrayCollection::class,
],
'Interface Doctrine collection eager' => [
\Doctrine\Common\Collections\Collection::class, false, \Doctrine\Common\Collections\ArrayCollection::class,
],
'Base Illuminate collection lazy' => [
\Illuminate\Support\Collection::class, true, \Illuminate\Support\Collection::class,
],
'Base Illuminate collection eager' => [
\Illuminate\Support\Collection::class, false, \Illuminate\Support\Collection::class,
],
'Class Custom Doctrine collection lazy' => [
CustomCollection::class, true, CustomCollection::class,
],
Expand Down