Skip to content
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

Add stubs marking immediately invoked callables in utils and caching #146

Merged
merged 1 commit into from
Jun 7, 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
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
{
}

}