mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 16:27:23 +01:00
upgrade to phpstan lvl 8
This commit is contained in:
@ -22,8 +22,8 @@ final class ChainableClosure
|
||||
throw ShouldNotHappen::fromMessage('$this not bound to chainable closure.');
|
||||
}
|
||||
|
||||
call_user_func_array(Closure::bind($closure, $this, $this::class), func_get_args());
|
||||
call_user_func_array(Closure::bind($next, $this, $this::class), func_get_args());
|
||||
\Pest\Support\Closure::safeBind($closure, $this, $this::class)(...func_get_args());
|
||||
\Pest\Support\Closure::safeBind($next, $this, $this::class)(...func_get_args());
|
||||
};
|
||||
}
|
||||
|
||||
@ -33,8 +33,8 @@ final class ChainableClosure
|
||||
public static function fromStatic(Closure $closure, Closure $next): Closure
|
||||
{
|
||||
return static function () use ($closure, $next): void {
|
||||
call_user_func_array(Closure::bind($closure, null, self::class), func_get_args());
|
||||
call_user_func_array(Closure::bind($next, null, self::class), func_get_args());
|
||||
\Pest\Support\Closure::safeBind($closure, null, self::class)(...func_get_args());
|
||||
\Pest\Support\Closure::safeBind($next, null, self::class)(...func_get_args());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
28
src/Support/Closure.php
Normal file
28
src/Support/Closure.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Support;
|
||||
|
||||
use Pest\Exceptions\ShouldNotHappen;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class Closure
|
||||
{
|
||||
public static function safeBind(\Closure|null $closure, ?object $newThis, object|string|null $newScope = 'static'): \Closure
|
||||
{
|
||||
if ($closure == null) {
|
||||
throw ShouldNotHappen::fromMessage('Could not bind null closure.');
|
||||
}
|
||||
|
||||
$closure = \Closure::bind($closure, $newThis, $newScope);
|
||||
|
||||
if ($closure == false) {
|
||||
throw ShouldNotHappen::fromMessage('Could not bind closure.');
|
||||
}
|
||||
|
||||
return $closure;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user