Skip to content

Commit 9eebad8

Browse files
xificurkondrejmirtes
authored andcommitted
Add stubs marking immediately invoked callables in utils and caching
1 parent 8af9474 commit 9eebad8

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed

extension.neon

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ parameters:
88
- stubs/Application/Routers/RouteList.stub
99
- stubs/Application/UI/Component.stub
1010
- stubs/Application/UI/Multiplier.stub
11+
- stubs/Caching/Cache.stub
1112
- stubs/ComponentModel/Component.stub
1213
- stubs/ComponentModel/Container.stub
1314
- stubs/ComponentModel/IComponent.stub
@@ -21,6 +22,9 @@ parameters:
2122
- stubs/Http/SessionSection.stub
2223
- stubs/Routing/Router.stub
2324
- stubs/Utils/ArrayHash.stub
25+
- stubs/Utils/Arrays.stub
26+
- stubs/Utils/Callback.stub
27+
- stubs/Utils/Helpers.stub
2428
- stubs/Utils/Html.stub
2529
- stubs/Utils/Paginator.stub
2630
- stubs/Utils/Random.stub

stubs/Caching/Cache.stub

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace Nette\Caching;
4+
5+
class Cache
6+
{
7+
8+
/**
9+
* @param array<mixed>|null $dependencies
10+
* @param-immediately-invoked-callable $generator
11+
*/
12+
public function load(mixed $key, ?callable $generator = null, ?array $dependencies = null): mixed
13+
{
14+
}
15+
16+
/**
17+
* @param array<scalar> $keys
18+
* @return array<mixed>
19+
* @param-immediately-invoked-callable $generator
20+
*/
21+
public function bulkLoad(array $keys, ?callable $generator = null): array
22+
{
23+
}
24+
25+
/**
26+
* @param-immediately-invoked-callable $function
27+
*/
28+
public function call(callable $function): mixed
29+
{
30+
}
31+
32+
/**
33+
* @param array<mixed>|null $dependencies
34+
* @param-immediately-invoked-callable $function
35+
*/
36+
public function wrap(callable $function, ?array $dependencies = null): \Closure
37+
{
38+
}
39+
40+
}

stubs/Utils/Arrays.stub

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Nette\Utils;
4+
5+
class Arrays
6+
{
7+
8+
/**
9+
* @template K of array-key
10+
* @template V
11+
* @param array<K, V> $array
12+
* @param callable(V, K, array<K, V>): bool $callback
13+
* @param-immediately-invoked-callable $callback
14+
*/
15+
public static function some(iterable $array, callable $callback): bool
16+
{
17+
}
18+
19+
/**
20+
* @template K of array-key
21+
* @template V
22+
* @param array<K, V> $array
23+
* @param callable(V, K, array<K, V>): bool $callback
24+
* @param-immediately-invoked-callable $callback
25+
*/
26+
public static function every(iterable $array, callable $callback): bool
27+
{
28+
}
29+
30+
/**
31+
* @template K of array-key
32+
* @template V
33+
* @template R
34+
* @param array<K, V> $array
35+
* @param callable(V, K, array<K, V>): R $callback
36+
* @return array<K, R>
37+
* @param-immediately-invoked-callable $callback
38+
*/
39+
public static function map(iterable $array, callable $callback): array
40+
{
41+
}
42+
43+
}

stubs/Utils/Callback.stub

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Nette\Utils;
4+
5+
class Callback
6+
{
7+
8+
/**
9+
* @param-immediately-invoked-callable $callable
10+
* @param mixed[] ...$args
11+
*/
12+
public static function invoke(callable $callable, ...$args): mixed
13+
{
14+
}
15+
16+
/**
17+
* @param-immediately-invoked-callable $callable
18+
* @param mixed[] $args
19+
*/
20+
public static function invokeArgs(callable $callable, array $args = []): mixed
21+
{
22+
}
23+
24+
}

stubs/Utils/Helpers.stub

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Nette\Utils;
4+
5+
class Helpers
6+
{
7+
8+
/**
9+
* @param-immediately-invoked-callable $func
10+
*/
11+
public static function capture(callable $func): string
12+
{
13+
}
14+
15+
}

0 commit comments

Comments
 (0)