diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index 82a0c166..a973d132 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -87,7 +87,7 @@ trait Testable */ public function __addBeforeAll(?Closure $hook): void { - if ($hook === null) { + if (! $hook instanceof \Closure) { return; } @@ -101,7 +101,7 @@ trait Testable */ public function __addAfterAll(?Closure $hook): void { - if ($hook === null) { + if (! $hook instanceof \Closure) { return; } @@ -131,7 +131,7 @@ trait Testable */ private function __addHook(string $property, ?Closure $hook): void { - if ($hook === null) { + if (! $hook instanceof \Closure) { return; } diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index 50043648..0b5b66f4 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -217,7 +217,7 @@ final class TestCaseFactory } if (! $method->receivesArguments()) { - if ($method->closure === null) { + if (! $method->closure instanceof \Closure) { throw ShouldNotHappen::fromMessage('The test closure may not be empty.'); } diff --git a/src/Functions.php b/src/Functions.php index 42d8c964..ede5141c 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -92,7 +92,7 @@ if (! function_exists('test')) { */ function test(string $description = null, Closure $closure = null): HigherOrderTapProxy|TestCall { - if ($description === null && TestSuite::getInstance()->test !== null) { + if ($description === null && TestSuite::getInstance()->test instanceof \PHPUnit\Framework\TestCase) { return new HigherOrderTapProxy(TestSuite::getInstance()->test); } diff --git a/src/Logging/TeamCity/TeamCityLogger.php b/src/Logging/TeamCity/TeamCityLogger.php index af0ef5c0..eadfada8 100644 --- a/src/Logging/TeamCity/TeamCityLogger.php +++ b/src/Logging/TeamCity/TeamCityLogger.php @@ -180,7 +180,7 @@ final class TeamCityLogger public function testFinished(Finished $event): void { - if ($this->time === null) { + if (! $this->time instanceof \PHPUnit\Event\Telemetry\HRTime) { throw ShouldNotHappen::fromMessage('Start time has not been set.'); } diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index ad95ea98..3bfcdadd 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -900,7 +900,7 @@ final class Expectation */ private function export(mixed $value): string { - if ($this->exporter === null) { + if (! $this->exporter instanceof \Pest\Support\Exporter) { $this->exporter = Exporter::default(); } diff --git a/src/Support/Container.php b/src/Support/Container.php index af15d003..b780fd72 100644 --- a/src/Support/Container.php +++ b/src/Support/Container.php @@ -25,7 +25,7 @@ final class Container */ public static function getInstance(): self { - if (self::$instance === null) { + if (! self::$instance instanceof \Pest\Support\Container) { self::$instance = new self(); } @@ -72,7 +72,7 @@ final class Container if ($reflectionClass->isInstantiable()) { $constructor = $reflectionClass->getConstructor(); - if ($constructor !== null) { + if ($constructor instanceof \ReflectionMethod) { $params = array_map( function (ReflectionParameter $param) use ($id): object|string { $candidate = Reflection::getParameterClassName($param); @@ -80,7 +80,7 @@ final class Container if ($candidate === null) { $type = $param->getType(); /* @phpstan-ignore-next-line */ - if ($type !== null && $type->isBuiltin()) { + if ($type instanceof \ReflectionType && $type->isBuiltin()) { $candidate = $param->getName(); } else { throw ShouldNotHappen::fromMessage(sprintf('The type of `$%s` in `%s` cannot be determined.', $id, $param->getName()));