Skip to content

Commit

Permalink
Add modified stub for ReadableCollection from doctrine/collections 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk authored and ondrejmirtes committed Oct 29, 2024
1 parent 80f3b5f commit 4e9c77f
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
1 change: 0 additions & 1 deletion extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ parameters:
- stubs/Persistence/ObjectRepository.stub
- stubs/RepositoryFactory.stub
- stubs/Collections/ArrayCollection.stub
- stubs/Collections/ReadableCollection.stub
- stubs/Collections/Selectable.stub
- stubs/ORM/AbstractQuery.stub
- stubs/ORM/Exception/ORMException.stub
Expand Down
2 changes: 2 additions & 0 deletions src/Stubs/Doctrine/StubFilesExtensionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public function getFiles(): array
$collectionVersion = null;
}
if ($collectionVersion !== null && strpos($collectionVersion, '1.') === 0) {
$files[] = $stubsDir . '/Collections/ReadableCollection1.stub';
$files[] = $stubsDir . '/Collections/Collection1.stub';
} else {
$files[] = $stubsDir . '/Collections/ReadableCollection.stub';
$files[] = $stubsDir . '/Collections/Collection.stub';
}

Expand Down
86 changes: 86 additions & 0 deletions stubs/Collections/ReadableCollection1.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace Doctrine\Common\Collections;

use Closure;
use Countable;
use IteratorAggregate;

/**
* @template TKey of array-key
* @template-covariant T
* @extends IteratorAggregate<TKey, T>
*/
interface ReadableCollection extends Countable, IteratorAggregate
{

/**
* @param-immediately-invoked-callable $p
*
* @param Closure(TKey, T):bool $p
*
* @return bool
*/
public function exists(Closure $p);

/**
* @param-immediately-invoked-callable $p
*
* @param Closure(T, TKey):bool $p
*
* @return ReadableCollection<TKey, T>
*/
public function filter(Closure $p);

/**
* @param-immediately-invoked-callable $func
*
* @param Closure(T):U $func
*
* @return Collection<TKey, U>
*
* @template U
*/
public function map(Closure $func);

/**
* @param-immediately-invoked-callable $p
*
* @param Closure(TKey, T):bool $p
*
* @return array{0: ReadableCollection<TKey, T>, 1: ReadableCollection<TKey, T>}
*/
public function partition(Closure $p);

/**
* @param-immediately-invoked-callable $p
*
* @param Closure(TKey, T):bool $p
*
* @return bool TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.
*/
public function forAll(Closure $p);

/**
* @param-immediately-invoked-callable $p
*
* @param Closure(TKey, T):bool $p
*
* @return T|null
*/
public function findFirst(Closure $p);

/**
* @param-immediately-invoked-callable $func
*
* @param Closure(TReturn|TInitial, T):TReturn $func
* @param TInitial $initial
*
* @return TReturn|TInitial
*
* @template TReturn
* @template TInitial
*/
public function reduce(Closure $func, mixed $initial = null);

}

0 comments on commit 4e9c77f

Please sign in to comment.