Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Illuminate/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,11 @@ function windows_os()
/**
* Return the given value, optionally passed through the given callback.
*
* @param mixed $value
* @param callable|null $callback
* @return mixed
* @template TValue
*
* @param TValue $value
* @param (callable(TValue): TValue)|null $callback
* @return TValue
*/
function with($value, callable $callback = null)
{
Expand Down
15 changes: 15 additions & 0 deletions types/Support/Helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use function PHPStan\Testing\assertType;

assertType('User', with(new User()));
assertType('bool', with(new User())->save());
assertType('User', with(new User(), function (User $user) {
return $user;
}));

assertType('int|User', with(new User(), function ($user) {
assertType('int|User', $user);

return 10;
}));