From f61f963a80e823462146d76b57b73788c367cc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mor=C3=A1vek?= Date: Sun, 27 Oct 2024 12:52:54 +0100 Subject: [PATCH] Mark immediately invoked callback params --- stubs/Collections/ReadableCollection.stub | 70 +++++++++++++++++++++++ stubs/DBAL/Connection.stub | 13 +++++ stubs/DBAL/Connection4.stub | 13 +++++ 3 files changed, 96 insertions(+) diff --git a/stubs/Collections/ReadableCollection.stub b/stubs/Collections/ReadableCollection.stub index df07c526..d9fba5ae 100644 --- a/stubs/Collections/ReadableCollection.stub +++ b/stubs/Collections/ReadableCollection.stub @@ -2,6 +2,7 @@ namespace Doctrine\Common\Collections; +use Closure; use Countable; use IteratorAggregate; @@ -13,4 +14,73 @@ use IteratorAggregate; 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 + */ + public function filter(Closure $p); + + /** + * @param-immediately-invoked-callable $func + * + * @param Closure(T):U $func + * + * @return ReadableCollection + * + * @template U + */ + public function map(Closure $func); + + /** + * @param-immediately-invoked-callable $p + * + * @param Closure(TKey, T):bool $p + * + * @return array{0: ReadableCollection, 1: ReadableCollection} + */ + 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); + } diff --git a/stubs/DBAL/Connection.stub b/stubs/DBAL/Connection.stub index d11b040f..15c8e6e1 100644 --- a/stubs/DBAL/Connection.stub +++ b/stubs/DBAL/Connection.stub @@ -2,9 +2,11 @@ namespace Doctrine\DBAL; +use Closure; use Doctrine\DBAL\Cache\CacheException; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Types\Type; +use Throwable; class Connection { @@ -61,4 +63,15 @@ class Connection */ public function executeCacheQuery($sql, $params, $types, QueryCacheProfile $qcp): Result; + /** + * @param-immediately-invoked-callable $func + * @param Closure(self): T $func + * @return T + * + * @template T + * + * @throws Throwable + */ + public function transactional(Closure $func); + } diff --git a/stubs/DBAL/Connection4.stub b/stubs/DBAL/Connection4.stub index 2e80b001..77b13d78 100644 --- a/stubs/DBAL/Connection4.stub +++ b/stubs/DBAL/Connection4.stub @@ -2,9 +2,11 @@ namespace Doctrine\DBAL; +use Closure; use Doctrine\DBAL\Cache\CacheException; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Types\Type; +use Throwable; /** * @phpstan-type WrapperParameterType = string|Type|ParameterType|ArrayParameterType @@ -65,4 +67,15 @@ class Connection */ public function executeCacheQuery($sql, $params, $types, QueryCacheProfile $qcp): Result; + /** + * @param-immediately-invoked-callable $func + * @param Closure(self): T $func + * @return T + * + * @template T + * + * @throws Throwable + */ + public function transactional(Closure $func); + }