Skip to content

Commit f61f963

Browse files
xificurkondrejmirtes
authored andcommitted
Mark immediately invoked callback params
1 parent de811c7 commit f61f963

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

stubs/Collections/ReadableCollection.stub

+70
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Doctrine\Common\Collections;
44

5+
use Closure;
56
use Countable;
67
use IteratorAggregate;
78

@@ -13,4 +14,73 @@ use IteratorAggregate;
1314
interface ReadableCollection extends Countable, IteratorAggregate
1415
{
1516

17+
/**
18+
* @param-immediately-invoked-callable $p
19+
*
20+
* @param Closure(TKey, T):bool $p
21+
*
22+
* @return bool
23+
*/
24+
public function exists(Closure $p);
25+
26+
/**
27+
* @param-immediately-invoked-callable $p
28+
*
29+
* @param Closure(T, TKey):bool $p
30+
*
31+
* @return ReadableCollection<TKey, T>
32+
*/
33+
public function filter(Closure $p);
34+
35+
/**
36+
* @param-immediately-invoked-callable $func
37+
*
38+
* @param Closure(T):U $func
39+
*
40+
* @return ReadableCollection<TKey, U>
41+
*
42+
* @template U
43+
*/
44+
public function map(Closure $func);
45+
46+
/**
47+
* @param-immediately-invoked-callable $p
48+
*
49+
* @param Closure(TKey, T):bool $p
50+
*
51+
* @return array{0: ReadableCollection<TKey, T>, 1: ReadableCollection<TKey, T>}
52+
*/
53+
public function partition(Closure $p);
54+
55+
/**
56+
* @param-immediately-invoked-callable $p
57+
*
58+
* @param Closure(TKey, T):bool $p
59+
*
60+
* @return bool TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.
61+
*/
62+
public function forAll(Closure $p);
63+
64+
/**
65+
* @param-immediately-invoked-callable $p
66+
*
67+
* @param Closure(TKey, T):bool $p
68+
*
69+
* @return T|null
70+
*/
71+
public function findFirst(Closure $p);
72+
73+
/**
74+
* @param-immediately-invoked-callable $func
75+
*
76+
* @param Closure(TReturn|TInitial, T):TReturn $func
77+
* @param TInitial $initial
78+
*
79+
* @return TReturn|TInitial
80+
*
81+
* @template TReturn
82+
* @template TInitial
83+
*/
84+
public function reduce(Closure $func, mixed $initial = null);
85+
1686
}

stubs/DBAL/Connection.stub

+13
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Doctrine\DBAL;
44

5+
use Closure;
56
use Doctrine\DBAL\Cache\CacheException;
67
use Doctrine\DBAL\Cache\QueryCacheProfile;
78
use Doctrine\DBAL\Types\Type;
9+
use Throwable;
810

911
class Connection
1012
{
@@ -61,4 +63,15 @@ class Connection
6163
*/
6264
public function executeCacheQuery($sql, $params, $types, QueryCacheProfile $qcp): Result;
6365

66+
/**
67+
* @param-immediately-invoked-callable $func
68+
* @param Closure(self): T $func
69+
* @return T
70+
*
71+
* @template T
72+
*
73+
* @throws Throwable
74+
*/
75+
public function transactional(Closure $func);
76+
6477
}

stubs/DBAL/Connection4.stub

+13
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Doctrine\DBAL;
44

5+
use Closure;
56
use Doctrine\DBAL\Cache\CacheException;
67
use Doctrine\DBAL\Cache\QueryCacheProfile;
78
use Doctrine\DBAL\Types\Type;
9+
use Throwable;
810

911
/**
1012
* @phpstan-type WrapperParameterType = string|Type|ParameterType|ArrayParameterType
@@ -65,4 +67,15 @@ class Connection
6567
*/
6668
public function executeCacheQuery($sql, $params, $types, QueryCacheProfile $qcp): Result;
6769

70+
/**
71+
* @param-immediately-invoked-callable $func
72+
* @param Closure(self): T $func
73+
* @return T
74+
*
75+
* @template T
76+
*
77+
* @throws Throwable
78+
*/
79+
public function transactional(Closure $func);
80+
6881
}

0 commit comments

Comments
 (0)