From ffd4e6d577654d828f6d1ad586fc293417bfa634 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Mon, 15 Nov 2021 12:23:53 +0100 Subject: [PATCH] upgrade to phpstan level 6 --- phpstan.neon | 2 +- src/Datasets.php | 17 +++++++++-------- src/Factories/Annotations/Depends.php | 4 ++++ src/Factories/Annotations/Groups.php | 4 ++++ src/Factories/TestCaseFactory.php | 2 ++ src/Repositories/TestRepository.php | 2 +- src/Support/Arr.php | 4 ++++ 7 files changed, 25 insertions(+), 10 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index c1a0e56e..4594d0d2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,7 +4,7 @@ includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon parameters: - level: 5 + level: 6 paths: - src diff --git a/src/Datasets.php b/src/Datasets.php index 429de157..09e0219f 100644 --- a/src/Datasets.php +++ b/src/Datasets.php @@ -9,6 +9,7 @@ use Pest\Exceptions\DatasetAlreadyExist; use Pest\Exceptions\DatasetDoesNotExist; use SebastianBergmann\Exporter\Exporter; use Traversable; +use function sprintf; /** * @internal @@ -25,14 +26,14 @@ final class Datasets /** * Holds the withs. * - * @var array + * @var array|string> */ private static array $withs = []; /** * Sets the given. * - * @param Closure|iterable $data + * @phpstan-param Closure|iterable $data */ public static function set(string $name, Closure|iterable $data): void { @@ -46,7 +47,7 @@ final class Datasets /** * Sets the given. * - * @param Closure|iterable|string $with + * @phpstan-param Closure|iterable|string $with */ public static function with(string $filename, string $description, Closure|iterable|string $with): void { @@ -119,7 +120,7 @@ final class Datasets /** * @param array|string> $datasets * - * @return array + * @return array> */ private static function processDatasets(array $datasets): array { @@ -159,9 +160,9 @@ final class Datasets } /** - * @param array $combinations + * @param array> $combinations * - * @return array + * @return array> */ private static function getDataSetsCombinations(array $combinations): array { @@ -187,9 +188,9 @@ final class Datasets $exporter = new Exporter(); if (is_int($key)) { - return \sprintf('(%s)', $exporter->shortenedRecursiveExport($data)); + return sprintf('(%s)', $exporter->shortenedRecursiveExport($data)); } - return \sprintf('data set "%s"', $key); + return sprintf('data set "%s"', $key); } } diff --git a/src/Factories/Annotations/Depends.php b/src/Factories/Annotations/Depends.php index 15b29359..66c4838c 100644 --- a/src/Factories/Annotations/Depends.php +++ b/src/Factories/Annotations/Depends.php @@ -14,6 +14,10 @@ final class Depends { /** * Adds annotations regarding the "depends" feature. + * + * @param array $annotations + * + * @return array */ public function add(TestCaseMethodFactory $method, array $annotations): array { diff --git a/src/Factories/Annotations/Groups.php b/src/Factories/Annotations/Groups.php index 96752d6e..ab7749b7 100644 --- a/src/Factories/Annotations/Groups.php +++ b/src/Factories/Annotations/Groups.php @@ -13,6 +13,10 @@ final class Groups { /** * Adds annotations regarding the "groups" feature. + * + * @param array $annotations + * + * @return array */ public function add(TestCaseMethodFactory $method, array $annotations): array { diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index d21b5513..edb37fd3 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -98,6 +98,8 @@ final class TestCaseFactory /** * Creates a Test Case class using a runtime evaluate. + * + * @param array $methods */ public function evaluate(string $filename, array $methods): string { diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index b8e2b53e..3a65c529 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -80,7 +80,7 @@ final class TestRepository } } - public function get($filename): TestCaseFactory + public function get(string $filename): TestCaseFactory { return $this->testCases[$filename]; } diff --git a/src/Support/Arr.php b/src/Support/Arr.php index 3fbe0e61..531e0d19 100644 --- a/src/Support/Arr.php +++ b/src/Support/Arr.php @@ -11,6 +11,8 @@ final class Arr { /** * Checks if the given array has the given key. + * + * @param array $array */ public static function has(array $array, string|int $key): bool { @@ -33,6 +35,8 @@ final class Arr /** * Gets the given key value. + * + * @param array $array */ public static function get(array $array, string|int $key, mixed $default = null): mixed {