Skip to content

Commit

Permalink
Filter out null from callback in when method (#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvansteen authored Jul 16, 2023
1 parent b39dbed commit 8b35c10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stubs/Conditionable.stub
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait Conditionable
* @template TWhenParameter
* @template TWhenReturnType
*
* @param (\Closure($this): TWhenParameter)|TWhenParameter $value
* @param (\Closure($this): TWhenParameter)|TWhenParameter|null $value
* @param (callable($this, TWhenParameter): TWhenReturnType)|null $callback
* @param (callable($this, TWhenParameter): TWhenReturnType)|null $default
* @return (TWhenReturnType is void|null ? $this : TWhenReturnType)
Expand Down
5 changes: 5 additions & 0 deletions tests/Type/data/conditionable.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class Foo
return rand();
}));

// Test to make sure the callback has a non-null value.
(new Foo())->when(User::first(), function (Foo $foo, $user): void {
assertType(User::class, $user);
});

assertType('ConditionableStubs\Foo', (new Foo())->unless(true, function (Foo $foo) {
// do nothing
}));
Expand Down

0 comments on commit 8b35c10

Please sign in to comment.