Skip to content

Commit

Permalink
Add stubs marking immediately invoked callables in utils and caching
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk committed Jun 7, 2024
1 parent 8af9474 commit 75a34dc
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 0 deletions.
4 changes: 4 additions & 0 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ parameters:
- stubs/Application/Routers/RouteList.stub
- stubs/Application/UI/Component.stub
- stubs/Application/UI/Multiplier.stub
- stubs/Caching/Cache.stub
- stubs/ComponentModel/Component.stub
- stubs/ComponentModel/Container.stub
- stubs/ComponentModel/IComponent.stub
Expand All @@ -21,6 +22,9 @@ parameters:
- stubs/Http/SessionSection.stub
- stubs/Routing/Router.stub
- stubs/Utils/ArrayHash.stub
- stubs/Utils/Arrays.stub
- stubs/Utils/Callback.stub
- stubs/Utils/Helpers.stub
- stubs/Utils/Html.stub
- stubs/Utils/Paginator.stub
- stubs/Utils/Random.stub
Expand Down
40 changes: 40 additions & 0 deletions stubs/Caching/Cache.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Nette\Caching;

class Cache
{

/**
* @param array<mixed>|null $dependencies
* @param-immediately-invoked-callable $generator
*/
public function load(mixed $key, ?callable $generator = null, ?array $dependencies = null): mixed
{
}

/**
* @param array<scalar> $keys
* @return array<mixed>
* @param-immediately-invoked-callable $generator
*/
public function bulkLoad(array $keys, ?callable $generator = null): array
{
}

/**
* @param-immediately-invoked-callable $function
*/
public function call(callable $function): mixed
{
}

/**
* @param array<mixed>|null $dependencies
* @param-immediately-invoked-callable $function
*/
public function wrap(callable $function, ?array $dependencies = null): \Closure
{
}

}
43 changes: 43 additions & 0 deletions stubs/Utils/Arrays.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Nette\Utils;

class Arrays
{

/**
* @template K of array-key
* @template V
* @param array<K, V> $array
* @param callable(V, K, array<K, V>): bool $callback
* @param-immediately-invoked-callable $callback
*/
public static function some(iterable $array, callable $callback): bool
{
}

/**
* @template K of array-key
* @template V
* @param array<K, V> $array
* @param callable(V, K, array<K, V>): bool $callback
* @param-immediately-invoked-callable $callback
*/
public static function every(iterable $array, callable $callback): bool
{
}

/**
* @template K of array-key
* @template V
* @template R
* @param array<K, V> $array
* @param callable(V, K, array<K, V>): R $callback
* @return array<K, R>
* @param-immediately-invoked-callable $callback
*/
public static function map(iterable $array, callable $callback): array
{
}

}
24 changes: 24 additions & 0 deletions stubs/Utils/Callback.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Nette\Utils;

class Callback
{

/**
* @param-immediately-invoked-callable $callable
* @param mixed[] ...$args
*/
public static function invoke(callable $callable, ...$args): mixed
{
}

/**
* @param-immediately-invoked-callable $callable
* @param mixed[] $args
*/
public static function invokeArgs(callable $callable, array $args = []): mixed
{
}

}
15 changes: 15 additions & 0 deletions stubs/Utils/Helpers.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Nette\Utils;

class Helpers
{

/**
* @param-immediately-invoked-callable $func
*/
public static function capture(callable $func): string
{
}

}

0 comments on commit 75a34dc

Please sign in to comment.