From 9eebad8ceb52ad5e8f7c5012c4b7ed8777673ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mor=C3=A1vek?= Date: Fri, 7 Jun 2024 08:46:54 +0200 Subject: [PATCH] Add stubs marking immediately invoked callables in utils and caching --- extension.neon | 4 ++++ stubs/Caching/Cache.stub | 40 ++++++++++++++++++++++++++++++++++++ stubs/Utils/Arrays.stub | 43 +++++++++++++++++++++++++++++++++++++++ stubs/Utils/Callback.stub | 24 ++++++++++++++++++++++ stubs/Utils/Helpers.stub | 15 ++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 stubs/Caching/Cache.stub create mode 100644 stubs/Utils/Arrays.stub create mode 100644 stubs/Utils/Callback.stub create mode 100644 stubs/Utils/Helpers.stub diff --git a/extension.neon b/extension.neon index c8c147f..9563acb 100644 --- a/extension.neon +++ b/extension.neon @@ -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 @@ -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 diff --git a/stubs/Caching/Cache.stub b/stubs/Caching/Cache.stub new file mode 100644 index 0000000..8e6c29f --- /dev/null +++ b/stubs/Caching/Cache.stub @@ -0,0 +1,40 @@ +|null $dependencies + * @param-immediately-invoked-callable $generator + */ + public function load(mixed $key, ?callable $generator = null, ?array $dependencies = null): mixed + { + } + + /** + * @param array $keys + * @return array + * @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|null $dependencies + * @param-immediately-invoked-callable $function + */ + public function wrap(callable $function, ?array $dependencies = null): \Closure + { + } + +} diff --git a/stubs/Utils/Arrays.stub b/stubs/Utils/Arrays.stub new file mode 100644 index 0000000..e7ab015 --- /dev/null +++ b/stubs/Utils/Arrays.stub @@ -0,0 +1,43 @@ + $array + * @param callable(V, K, array): 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 $array + * @param callable(V, K, array): 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 $array + * @param callable(V, K, array): R $callback + * @return array + * @param-immediately-invoked-callable $callback + */ + public static function map(iterable $array, callable $callback): array + { + } + +} diff --git a/stubs/Utils/Callback.stub b/stubs/Utils/Callback.stub new file mode 100644 index 0000000..c0159df --- /dev/null +++ b/stubs/Utils/Callback.stub @@ -0,0 +1,24 @@ +