refactor: PHP 8 features

This commit is contained in:
Nuno Maduro
2021-10-24 18:29:59 +01:00
parent e8c2fe6e35
commit 2b687a7269
43 changed files with 283 additions and 635 deletions

View File

@ -6,8 +6,6 @@ namespace Pest\Support;
use Closure;
use Pest\Expectation;
use Pest\PendingObjects\TestCall;
use PHPUnit\Framework\TestCase;
/**
* @internal
@ -15,13 +13,11 @@ use PHPUnit\Framework\TestCase;
final class HigherOrderCallables
{
/**
* @var object
* Creates a new Higher Order Callables instances.
*/
private $target;
public function __construct(object $target)
public function __construct(private object $target)
{
$this->target = $target;
// ..
}
/**
@ -33,7 +29,7 @@ final class HigherOrderCallables
*
* @return Expectation<TValue>
*/
public function expect($value)
public function expect(mixed $value): Expectation
{
return new Expectation($value instanceof Closure ? Reflection::bindCallableWithData($value) : $value);
}
@ -47,17 +43,15 @@ final class HigherOrderCallables
*
* @return Expectation<TValue>
*/
public function and($value)
public function and(mixed $value)
{
return $this->expect($value);
}
/**
* Tap into the test case to perform an action and return the test case.
*
* @return TestCall|TestCase|object
*/
public function tap(callable $callable)
public function tap(callable $callable): object
{
Reflection::bindCallableWithData($callable);