diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index efa5d003..906f7413 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -20,6 +20,11 @@ $rules = [ ], 'concat_space' => ['spacing' => 'one'], 'not_operator_with_space' => false, + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_functions' => true, + 'import_constants' => true, + ], ]; $rules['increment_style'] = ['style' => 'post']; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c43668b6..91587518 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -90,11 +90,6 @@ parameters: count: 1 path: src/Expectation.php - - - message: "#^Parameter \\#1 \\$actualJson of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertJson\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Expectation.php - - message: "#^Parameter \\#1 \\$directory of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertDirectoryExists\\(\\) expects string, mixed given\\.$#" count: 1 @@ -250,16 +245,6 @@ parameters: count: 1 path: src/Support/ExceptionTrace.php - - - message: "#^Cannot access offset 'file' on mixed\\.$#" - count: 1 - path: src/Support/ExceptionTrace.php - - - - message: "#^Parameter \\#1 \\$haystack of function mb_strpos expects string, mixed given\\.$#" - count: 1 - path: src/Support/ExceptionTrace.php - - message: "#^Parameter \\#2 \\$array of function key_exists expects array, mixed given\\.$#" count: 1 diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index 72bf02bb..ba4c7387 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -9,6 +9,9 @@ use Pest\Support\ChainableClosure; use Pest\Support\ExceptionTrace; use Pest\TestSuite; use PHPUnit\Framework\ExecutionOrderDependency; + +use function sprintf; + use Throwable; /** @@ -257,7 +260,7 @@ trait Testable */ public function toString(): string { - return \sprintf( + return sprintf( '%s::%s', self::$__filename, $this->__description diff --git a/src/Console/Command.php b/src/Console/Command.php index a6ce762e..cf153247 100644 --- a/src/Console/Command.php +++ b/src/Console/Command.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Pest\Console; +use function is_dir; + use Pest\Actions\AddsDefaults; use Pest\Actions\AddsTests; use Pest\Actions\InteractsWithPlugins; @@ -81,7 +83,7 @@ final class Command extends BaseCommand $testSuite = $this->arguments['test']; if (is_string($testSuite)) { - if (\is_dir($testSuite)) { + if (is_dir($testSuite)) { /** @var string[] $files */ $files = (new FileIteratorFacade())->getFilesAsArray( $testSuite, diff --git a/src/PendingObjects/TestCall.php b/src/PendingObjects/TestCall.php index 62a9ac70..91ad70f7 100644 --- a/src/PendingObjects/TestCall.php +++ b/src/PendingObjects/TestCall.php @@ -102,7 +102,7 @@ final class TestCall * Runs the current test multiple times with * each item of the given `iterable`. * - * @param array<\Closure|iterable|string> $data + * @param array|string> $data */ public function with(...$data): TestCall { diff --git a/src/Support/HigherOrderMessage.php b/src/Support/HigherOrderMessage.php index 67993bc5..825079d2 100644 --- a/src/Support/HigherOrderMessage.php +++ b/src/Support/HigherOrderMessage.php @@ -5,6 +5,9 @@ declare(strict_types=1); namespace Pest\Support; use Closure; + +use const PHP_MAJOR_VERSION; + use ReflectionClass; use Throwable; @@ -132,7 +135,7 @@ final class HigherOrderMessage private static function getUndefinedMethodMessage(object $target, string $methodName): string { - if (\PHP_MAJOR_VERSION >= 8) { + if (PHP_MAJOR_VERSION >= 8) { return sprintf(sprintf(self::UNDEFINED_METHOD, sprintf('%s::%s()', get_class($target), $methodName))); }