mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 10:47:25 +01:00
chore: refacto
This commit is contained in:
@ -87,7 +87,7 @@ trait Testable
|
|||||||
*/
|
*/
|
||||||
public function __addBeforeAll(?Closure $hook): void
|
public function __addBeforeAll(?Closure $hook): void
|
||||||
{
|
{
|
||||||
if ($hook === null) {
|
if (! $hook instanceof \Closure) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ trait Testable
|
|||||||
*/
|
*/
|
||||||
public function __addAfterAll(?Closure $hook): void
|
public function __addAfterAll(?Closure $hook): void
|
||||||
{
|
{
|
||||||
if ($hook === null) {
|
if (! $hook instanceof \Closure) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ trait Testable
|
|||||||
*/
|
*/
|
||||||
private function __addHook(string $property, ?Closure $hook): void
|
private function __addHook(string $property, ?Closure $hook): void
|
||||||
{
|
{
|
||||||
if ($hook === null) {
|
if (! $hook instanceof \Closure) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -217,7 +217,7 @@ final class TestCaseFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! $method->receivesArguments()) {
|
if (! $method->receivesArguments()) {
|
||||||
if ($method->closure === null) {
|
if (! $method->closure instanceof \Closure) {
|
||||||
throw ShouldNotHappen::fromMessage('The test closure may not be empty.');
|
throw ShouldNotHappen::fromMessage('The test closure may not be empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,7 @@ if (! function_exists('test')) {
|
|||||||
*/
|
*/
|
||||||
function test(string $description = null, Closure $closure = null): HigherOrderTapProxy|TestCall
|
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);
|
return new HigherOrderTapProxy(TestSuite::getInstance()->test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -180,7 +180,7 @@ final class TeamCityLogger
|
|||||||
|
|
||||||
public function testFinished(Finished $event): void
|
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.');
|
throw ShouldNotHappen::fromMessage('Start time has not been set.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -900,7 +900,7 @@ final class Expectation
|
|||||||
*/
|
*/
|
||||||
private function export(mixed $value): string
|
private function export(mixed $value): string
|
||||||
{
|
{
|
||||||
if ($this->exporter === null) {
|
if (! $this->exporter instanceof \Pest\Support\Exporter) {
|
||||||
$this->exporter = Exporter::default();
|
$this->exporter = Exporter::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ final class Container
|
|||||||
*/
|
*/
|
||||||
public static function getInstance(): self
|
public static function getInstance(): self
|
||||||
{
|
{
|
||||||
if (self::$instance === null) {
|
if (! self::$instance instanceof \Pest\Support\Container) {
|
||||||
self::$instance = new self();
|
self::$instance = new self();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ final class Container
|
|||||||
if ($reflectionClass->isInstantiable()) {
|
if ($reflectionClass->isInstantiable()) {
|
||||||
$constructor = $reflectionClass->getConstructor();
|
$constructor = $reflectionClass->getConstructor();
|
||||||
|
|
||||||
if ($constructor !== null) {
|
if ($constructor instanceof \ReflectionMethod) {
|
||||||
$params = array_map(
|
$params = array_map(
|
||||||
function (ReflectionParameter $param) use ($id): object|string {
|
function (ReflectionParameter $param) use ($id): object|string {
|
||||||
$candidate = Reflection::getParameterClassName($param);
|
$candidate = Reflection::getParameterClassName($param);
|
||||||
@ -80,7 +80,7 @@ final class Container
|
|||||||
if ($candidate === null) {
|
if ($candidate === null) {
|
||||||
$type = $param->getType();
|
$type = $param->getType();
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
if ($type !== null && $type->isBuiltin()) {
|
if ($type instanceof \ReflectionType && $type->isBuiltin()) {
|
||||||
$candidate = $param->getName();
|
$candidate = $param->getName();
|
||||||
} else {
|
} else {
|
||||||
throw ShouldNotHappen::fromMessage(sprintf('The type of `$%s` in `%s` cannot be determined.', $id, $param->getName()));
|
throw ShouldNotHappen::fromMessage(sprintf('The type of `$%s` in `%s` cannot be determined.', $id, $param->getName()));
|
||||||
|
|||||||
Reference in New Issue
Block a user