Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Apr 17, 2024
1 parent 9186239 commit 5dec3fd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ parameters:
level: 8
paths:
- src
- tests/StaticAnalysis

ignoreErrors:
-
Expand Down
1 change: 1 addition & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
>
<projectFiles>
<directory name="src" />
<directory name="tests/StaticAnalysis" />
<ignoreFiles>
<directory name="vendor" />
<directory name="src/Expr"/>
Expand Down
46 changes: 46 additions & 0 deletions tests/StaticAnalysis/CustomCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\Common\Collections\StaticAnalysis;

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

/**
* @phpstan-template TKey of array-key
* @phpstan-template T of object
* @phpstan-implements Collection<TKey, T>
*/
abstract class CustomCollection implements Collection
{
/** @var ArrayCollection<TKey, T> */
private ArrayCollection $collection;

/** @param ArrayCollection<TKey, T> $arrayCollection */
public function __construct(ArrayCollection $arrayCollection)
{
$this->collection = $arrayCollection;
}

/**
* @psalm-param Closure(T, TKey):bool $p
*
* @return Collection<TKey, T>
*/
public function filter(Closure $p)
{
return $this->collection->filter($p);
}

/**
* @psalm-param Closure(TKey, T):bool $p
*
* @psalm-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
*/
public function partition(Closure $p)
{
return $this->collection->partition($p);
}
}

0 comments on commit 5dec3fd

Please sign in to comment.