Skip to content

Commit

Permalink
Mark immediately invoked callback params
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk authored and ondrejmirtes committed Oct 28, 2024
1 parent de811c7 commit f61f963
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
70 changes: 70 additions & 0 deletions stubs/Collections/ReadableCollection.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Doctrine\Common\Collections;

use Closure;
use Countable;
use IteratorAggregate;

Expand All @@ -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<TKey, T>
*/
public function filter(Closure $p);

/**
* @param-immediately-invoked-callable $func
*
* @param Closure(T):U $func
*
* @return ReadableCollection<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);

}
13 changes: 13 additions & 0 deletions stubs/DBAL/Connection.stub
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);

}
13 changes: 13 additions & 0 deletions stubs/DBAL/Connection4.stub
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

}

0 comments on commit f61f963

Please sign in to comment.