Skip to content

Commit

Permalink
Handle intersection types
Browse files Browse the repository at this point in the history
  • Loading branch information
malarzm committed Dec 21, 2021
1 parent 96d0d8b commit 3868c4d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);

namespace Doctrine\ODM\MongoDB\Tests\PersistentCollection;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

/**
* @template TKey of array-key
* @template TElement
* @template-extends ArrayCollection<TKey, TElement>
*/
class CollWithPHP81Types extends ArrayCollection
{
/**
* @param Collection<TKey, TElement>&ArrayCollection<TKey, TElement> $param
* @return Collection<TKey, TElement>&ArrayCollection<TKey, TElement>
*/
public function intersection(Collection&ArrayCollection $param) : Collection&ArrayCollection
{
return $param;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,14 @@ public function testPHP80Types(): void
$coll = new $class(new CollWithPHP80Types(), $this->dm, $this->uow);
$this->assertInstanceOf(CollWithPHP80Types::class, $coll);
}

/**
* @requires PHP 8.1
*/
public function testPHP81Types(): void
{
$class = $this->generator->loadClass(CollWithPHP81Types::class, Configuration::AUTOGENERATE_EVAL);
$coll = new $class(new CollWithPHP81Types(), $this->dm, $this->uow);
$this->assertInstanceOf(CollWithPHP81Types::class, $coll);
}
}

0 comments on commit 3868c4d

Please sign in to comment.