upgrade to phpstan lvl 8

This commit is contained in:
Fabio Ivona
2021-11-18 00:12:39 +01:00
parent f3f58c7f52
commit d4a8a3ec37
6 changed files with 54 additions and 7 deletions

28
src/Support/Closure.php Normal file
View 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;
}
}