Skip to content

Mark immediately invoked callback params #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

}