From 841180897718d57a2b02221c2687f39ba4ec8ad1 Mon Sep 17 00:00:00 2001 From: Choraimy Kroonstuiver <3661474+axlon@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:43:04 +0200 Subject: [PATCH] Add generic return type to `Container::instance()` --- src/Illuminate/Container/Container.php | 6 ++++-- src/Illuminate/Contracts/Container/Container.php | 6 ++++-- types/Container/Container.php | 10 ++++++++++ types/Contracts/Container/Container.php | 10 ++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 types/Container/Container.php create mode 100644 types/Contracts/Container/Container.php diff --git a/src/Illuminate/Container/Container.php b/src/Illuminate/Container/Container.php index 58f5b89e064e..d756758d7815 100755 --- a/src/Illuminate/Container/Container.php +++ b/src/Illuminate/Container/Container.php @@ -488,9 +488,11 @@ public function extend($abstract, Closure $closure) /** * Register an existing instance as shared in the container. * + * @template TInstance + * * @param string $abstract - * @param mixed $instance - * @return mixed + * @param TInstance $instance + * @return TInstance */ public function instance($abstract, $instance) { diff --git a/src/Illuminate/Contracts/Container/Container.php b/src/Illuminate/Contracts/Container/Container.php index 47c5f8b55278..3273750e6a1e 100644 --- a/src/Illuminate/Contracts/Container/Container.php +++ b/src/Illuminate/Contracts/Container/Container.php @@ -122,9 +122,11 @@ public function extend($abstract, Closure $closure); /** * Register an existing instance as shared in the container. * + * @template TInstance + * * @param string $abstract - * @param mixed $instance - * @return mixed + * @param TInstance $instance + * @return TInstance */ public function instance($abstract, $instance); diff --git a/types/Container/Container.php b/types/Container/Container.php new file mode 100644 index 000000000000..dae598e6c3bb --- /dev/null +++ b/types/Container/Container.php @@ -0,0 +1,10 @@ +instance('request', Request::capture())); diff --git a/types/Contracts/Container/Container.php b/types/Contracts/Container/Container.php new file mode 100644 index 000000000000..3d413a586c7c --- /dev/null +++ b/types/Contracts/Container/Container.php @@ -0,0 +1,10 @@ +instance('request', Request::capture()));