From 3a57997eec9cdd64b4ccdc05cee0628162c62aa2 Mon Sep 17 00:00:00 2001 From: Daan Date: Mon, 11 May 2020 19:17:57 +0200 Subject: [PATCH] Update --- composer.json | 1 + extension.neon | 26 +++++++++---------- .../HigherOrderTapProxyExtension.php | 1 - stubs/Helpers.stub | 10 +++++++ .../ReturnTypes/Helpers/TapExtension.php | 23 +++++++++------- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index 17ba09176..7682e72d3 100644 --- a/composer.json +++ b/composer.json @@ -60,6 +60,7 @@ "test:types": "phpstan analyse --ansi", "test:unit": "phpunit --colors=always", "test": [ + "@test:types", "@test:unit" ] } diff --git a/extension.neon b/extension.neon index baf1fce29..b50c69e1d 100644 --- a/extension.neon +++ b/extension.neon @@ -63,17 +63,17 @@ services: - phpstan.broker.methodsClassReflectionExtension - - class: NunoMaduro\Larastan\Methods\StorageMethodsClassReflectionExtension + class: NunoMaduro\Larastan\Methods\HigherOrderTapProxyExtension tags: - phpstan.broker.methodsClassReflectionExtension - - class: NunoMaduro\Larastan\Methods\Extension + class: NunoMaduro\Larastan\Methods\StorageMethodsClassReflectionExtension tags: - phpstan.broker.methodsClassReflectionExtension - - class: NunoMaduro\Larastan\Methods\HigherOrderTapProxyExtension + class: NunoMaduro\Larastan\Methods\Extension tags: - phpstan.broker.methodsClassReflectionExtension @@ -102,6 +102,11 @@ services: tags: - phpstan.broker.dynamicMethodReturnTypeExtension + - + class: NunoMaduro\Larastan\ReturnTypes\HigherOrderTapProxyExtension + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension + - class: NunoMaduro\Larastan\Properties\ModelRelationsExtension tags: @@ -122,11 +127,6 @@ services: tags: - phpstan.broker.dynamicStaticMethodReturnTypeExtension - - - class: NunoMaduro\Larastan\ReturnTypes\HigherOrderTapProxyExtension - tags: - - phpstan.broker.dynamicMethodReturnTypeExtension - - class: NunoMaduro\Larastan\ReturnTypes\AuthManagerExtension tags: @@ -206,11 +206,6 @@ services: tags: - phpstan.broker.dynamicFunctionReturnTypeExtension - - - class: NunoMaduro\Larastan\ReturnTypes\Helpers\TapExtension - tags: - - phpstan.broker.dynamicFunctionReturnTypeExtension - - class: NunoMaduro\Larastan\ReturnTypes\Helpers\ViewExtension tags: @@ -263,6 +258,11 @@ services: tags: - phpstan.broker.dynamicFunctionReturnTypeExtension + - + class: NunoMaduro\Larastan\ReturnTypes\Helpers\TapExtension + tags: + - phpstan.broker.dynamicFunctionReturnTypeExtension + - class: NunoMaduro\Larastan\ReturnTypes\StorageDynamicStaticMethodReturnTypeExtension tags: diff --git a/src/ReturnTypes/HigherOrderTapProxyExtension.php b/src/ReturnTypes/HigherOrderTapProxyExtension.php index 8b72db883..f39e13f9b 100644 --- a/src/ReturnTypes/HigherOrderTapProxyExtension.php +++ b/src/ReturnTypes/HigherOrderTapProxyExtension.php @@ -32,7 +32,6 @@ public function getClass(): string */ public function isMethodSupported(MethodReflection $methodReflection): bool { - dd($methodReflection->getName(), $methodReflection->getDeclaringClass()); return true; } diff --git a/stubs/Helpers.stub b/stubs/Helpers.stub index e68251f5d..2cd9ce4b3 100644 --- a/stubs/Helpers.stub +++ b/stubs/Helpers.stub @@ -13,3 +13,13 @@ function retry($times, callable $callback, $sleep = 0, $when = null) { } + +/** + * @template TValue + * @param TValue $value + * @param null|callable(TValue): void $callback + * @return mixed + */ +function tap($value, $callback = null) +{ +} diff --git a/tests/Features/ReturnTypes/Helpers/TapExtension.php b/tests/Features/ReturnTypes/Helpers/TapExtension.php index 4782c930b..fa9075168 100644 --- a/tests/Features/ReturnTypes/Helpers/TapExtension.php +++ b/tests/Features/ReturnTypes/Helpers/TapExtension.php @@ -5,23 +5,28 @@ namespace Tests\Features\ReturnTypes\Helpers; use App\User; -use Illuminate\Auth\AuthManager; -use Illuminate\Foundation\Application; -use NunoMaduro\Larastan\ApplicationResolver; +use Illuminate\Support\HigherOrderTapProxy; class TapExtension { - /*public function testTapClosure(): User + public function testTapClosure(): User { - return tap(new User, function (User $user) { + return tap(new User, function (User $user): void { $user->name = 'Daan Raatjes'; $user->save(); }); - }*/ + } + + /** + * @return HigherOrderTapProxy + */ + public function testTapProxyReturnType(): HigherOrderTapProxy + { + return tap(new User); + } - public function testTapProxy(): int + public function testTapProxy(): User { - // User::firstOrFail()->hello(); - return tap(new User)->updatez(['name' => 'Taylor otwell']); + return tap(new User)->update(['name' => 'Taylor Otwell']); } }