From a65c2a52b71c55cc4cdc2d85aecb87bd8a02ad37 Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Sun, 17 Mar 2024 16:23:46 +0100 Subject: [PATCH 1/2] Add Application stub --- stubs/Contracts/Application.stubphp | 23 +++++++++++++++++++ .../Type/tests/Contracts/ApplicationTest.phpt | 20 ++++++++++++++++ tests/Type/tests/Support/helpers/app.phpt | 12 ---------- 3 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 stubs/Contracts/Application.stubphp create mode 100644 tests/Type/tests/Contracts/ApplicationTest.phpt delete mode 100644 tests/Type/tests/Support/helpers/app.phpt diff --git a/stubs/Contracts/Application.stubphp b/stubs/Contracts/Application.stubphp new file mode 100644 index 00000000..88572c25 --- /dev/null +++ b/stubs/Contracts/Application.stubphp @@ -0,0 +1,23 @@ + ...$environments + * @return string|bool + * @psalm-return ($environments is (string|non-empty-array) ? bool : string) + */ + public function environment(...$environments) {} + + /** + * Get the registered service provider instances if any exist. + * @param \Illuminate\Support\ServiceProvider|string $provider + * @psalm-return array{int?, \Illuminate\Support\ServiceProvider} + */ + public function getProviders($provider) {} +} diff --git a/tests/Type/tests/Contracts/ApplicationTest.phpt b/tests/Type/tests/Contracts/ApplicationTest.phpt new file mode 100644 index 00000000..f06ab1c0 --- /dev/null +++ b/tests/Type/tests/Contracts/ApplicationTest.phpt @@ -0,0 +1,20 @@ +--FILE-- +environment($env); +} + +/** @param non-empty-list $envs */ +function returns_bool_for_array_arg(array $envs): bool +{ + return app()->environment($envs); +} + +function returns_string(): string +{ + return app()->environment(); +} +?> +--EXPECTF-- diff --git a/tests/Type/tests/Support/helpers/app.phpt b/tests/Type/tests/Support/helpers/app.phpt deleted file mode 100644 index d326c658..00000000 --- a/tests/Type/tests/Support/helpers/app.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---FILE-- -environment($env); -} - -function returns_string(): string { - return app()->environment(); -} -?> ---EXPECTF-- From 5f1d4b0f7caca93fc570cff750f382aeb4de008d Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Sun, 17 Mar 2024 21:49:17 +0100 Subject: [PATCH 2/2] Fix tests --- .../Application.stubphp | 8 +++---- .../Type/tests/Contracts/ApplicationTest.phpt | 20 ----------------- .../tests/Foundation/ApplicationTest.phpt | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 25 deletions(-) rename stubs/{Contracts => Foundation}/Application.stubphp (69%) delete mode 100644 tests/Type/tests/Contracts/ApplicationTest.phpt create mode 100644 tests/Type/tests/Foundation/ApplicationTest.phpt diff --git a/stubs/Contracts/Application.stubphp b/stubs/Foundation/Application.stubphp similarity index 69% rename from stubs/Contracts/Application.stubphp rename to stubs/Foundation/Application.stubphp index 88572c25..cafb08a1 100644 --- a/stubs/Contracts/Application.stubphp +++ b/stubs/Foundation/Application.stubphp @@ -1,16 +1,14 @@ ...$environments * @return string|bool - * @psalm-return ($environments is (string|non-empty-array) ? bool : string) + * @psalm-return ($environments is null ? string : bool) */ public function environment(...$environments) {} diff --git a/tests/Type/tests/Contracts/ApplicationTest.phpt b/tests/Type/tests/Contracts/ApplicationTest.phpt deleted file mode 100644 index f06ab1c0..00000000 --- a/tests/Type/tests/Contracts/ApplicationTest.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---FILE-- -environment($env); -} - -/** @param non-empty-list $envs */ -function returns_bool_for_array_arg(array $envs): bool -{ - return app()->environment($envs); -} - -function returns_string(): string -{ - return app()->environment(); -} -?> ---EXPECTF-- diff --git a/tests/Type/tests/Foundation/ApplicationTest.phpt b/tests/Type/tests/Foundation/ApplicationTest.phpt new file mode 100644 index 00000000..9fca5cb2 --- /dev/null +++ b/tests/Type/tests/Foundation/ApplicationTest.phpt @@ -0,0 +1,22 @@ +--FILE-- +environment($env); +} + +/** @param non-empty-list $envs */ +function returns_bool_for_array_arg(Application $application, array $envs): bool +{ + return $application->environment($envs); +} + +function returns_string(Application $application): string +{ + return $application->environment(); +} +?> +--EXPECTF--