Skip to content

Commit

Permalink
Improve static analysis of Timebox (#45548)
Browse files Browse the repository at this point in the history
  • Loading branch information
JurianArie authored Jan 6, 2023
1 parent 8c9ae32 commit a13b10f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Illuminate/Support/Timebox.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ class Timebox
/**
* Invoke the given callback within the specified timebox minimum.
*
* @param callable $callback
* @template TCallReturnType
*
* @param (callable($this): TCallReturnType) $callback
* @param int $microseconds
* @return mixed
* @return TCallReturnType
*/
public function call(callable $callback, int $microseconds)
{
Expand Down
10 changes: 10 additions & 0 deletions types/Support/Timebox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

use Illuminate\Support\Timebox;
use function PHPStan\Testing\assertType;

assertType('int', (new Timebox)->call(function ($timebox) {
assertType('Illuminate\Support\Timebox', $timebox);

return 1;
}, 1));

0 comments on commit a13b10f

Please sign in to comment.