File: CustomCollection.php

package info (click to toggle)
php-doctrine-collections 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 468 kB
  • sloc: php: 2,531; makefile: 18
file content (46 lines) | stat: -rw-r--r-- 1,103 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;
    }

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

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