Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daanra committed May 11, 2020
1 parent 221a0dd commit 3a57997
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 23 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"test:types": "phpstan analyse --ansi",
"test:unit": "phpunit --colors=always",
"test": [
"@test:types",
"@test:unit"
]
}
Expand Down
26 changes: 13 additions & 13 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -102,6 +102,11 @@ services:
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

-
class: NunoMaduro\Larastan\ReturnTypes\HigherOrderTapProxyExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

-
class: NunoMaduro\Larastan\Properties\ModelRelationsExtension
tags:
Expand All @@ -122,11 +127,6 @@ services:
tags:
- phpstan.broker.dynamicStaticMethodReturnTypeExtension

-
class: NunoMaduro\Larastan\ReturnTypes\HigherOrderTapProxyExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension

-
class: NunoMaduro\Larastan\ReturnTypes\AuthManagerExtension
tags:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion src/ReturnTypes/HigherOrderTapProxyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function getClass(): string
*/
public function isMethodSupported(MethodReflection $methodReflection): bool
{
dd($methodReflection->getName(), $methodReflection->getDeclaringClass());
return true;
}

Expand Down
10 changes: 10 additions & 0 deletions stubs/Helpers.stub
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
23 changes: 14 additions & 9 deletions tests/Features/ReturnTypes/Helpers/TapExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<User>
*/
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']);
}
}

0 comments on commit 3a57997

Please sign in to comment.