From f3f58c7f52751beb16bc98ffee5dbfe2c19fd80f Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Mon, 15 Nov 2021 22:20:00 +0100 Subject: [PATCH] upgrade to phpstan lvl 7 --- phpstan.neon | 2 +- src/Bootstrappers/BootSubscribers.php | 2 +- src/Datasets.php | 10 +++++----- src/Factories/TestCaseFactory.php | 1 + src/Functions.php | 2 ++ src/Kernel.php | 1 + src/PendingCalls/UsesCall.php | 4 ++-- src/Plugin.php | 2 ++ src/Repositories/TestRepository.php | 2 +- src/Support/Container.php | 5 +++++ src/Support/HigherOrderMessage.php | 2 +- 11 files changed, 22 insertions(+), 11 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index eda92dbf..1b341db4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,7 +4,7 @@ includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon parameters: - level: 6 + level: 7 paths: - src parallel: diff --git a/src/Bootstrappers/BootSubscribers.php b/src/Bootstrappers/BootSubscribers.php index c23e9bf0..42bdeaba 100644 --- a/src/Bootstrappers/BootSubscribers.php +++ b/src/Bootstrappers/BootSubscribers.php @@ -29,7 +29,7 @@ final class BootSubscribers { foreach (self::$subscribers as $subscriber) { Event\Facade::registerSubscriber( - new $subscriber() + new $subscriber() //@phpstan-ignore-line ); } } diff --git a/src/Datasets.php b/src/Datasets.php index 09e0219f..96aa00dd 100644 --- a/src/Datasets.php +++ b/src/Datasets.php @@ -8,8 +8,8 @@ use Closure; use Pest\Exceptions\DatasetAlreadyExist; use Pest\Exceptions\DatasetDoesNotExist; use SebastianBergmann\Exporter\Exporter; -use Traversable; use function sprintf; +use Traversable; /** * @internal @@ -19,14 +19,14 @@ final class Datasets /** * Holds the datasets. * - * @var array> + * @var array> */ private static array $datasets = []; /** * Holds the withs. * - * @var array|string> + * @var array|string>> */ private static array $withs = []; @@ -47,9 +47,9 @@ final class Datasets /** * Sets the given. * - * @phpstan-param Closure|iterable|string $with + * @phpstan-param array|string> $with */ - public static function with(string $filename, string $description, Closure|iterable|string $with): void + public static function with(string $filename, string $description, array $with): void { self::$withs[$filename . '>>>' . $description] = $with; } diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index edb37fd3..5b077d08 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -148,6 +148,7 @@ final class TestCaseFactory $annotations = ['@test']; foreach (self::$annotations as $annotation) { + //@phpstan-ignore-next-line $annotations = (new $annotation())->add($method, $annotations); } diff --git a/src/Functions.php b/src/Functions.php index 1e306999..ddc6f3af 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -70,6 +70,8 @@ if (!function_exists('uses')) { /** * The uses function binds the given * arguments to test closures. + * + * @param class-string ...$classAndTraits */ function uses(string ...$classAndTraits): UsesCall { diff --git a/src/Kernel.php b/src/Kernel.php index af2d82e6..67c4dcf9 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -37,6 +37,7 @@ final class Kernel public static function boot(): self { foreach (self::$bootstrappers as $bootstrapper) { + //@phpstan-ignore-next-line (new $bootstrapper())->__invoke(); } diff --git a/src/PendingCalls/UsesCall.php b/src/PendingCalls/UsesCall.php index 6609e8b2..457f8699 100644 --- a/src/PendingCalls/UsesCall.php +++ b/src/PendingCalls/UsesCall.php @@ -36,14 +36,14 @@ final class UsesCall /** * Holds the groups of the uses. * - * @var array + * @var array */ private array $groups = []; /** * Creates a new Pending Call. * - * @param array $classAndTraits + * @param array $classAndTraits */ public function __construct( private string $filename, diff --git a/src/Plugin.php b/src/Plugin.php index 9de1f707..5f676be4 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -18,6 +18,8 @@ final class Plugin /** * Lazy loads an `uses` call on the context of plugins. + * + * @param class-string ...$traits */ public static function uses(string ...$traits): void { diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index 3a65c529..869d1000 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -23,7 +23,7 @@ final class TestRepository private array $testCases = []; /** - * @var array>> + * @var array, 1: array, 2: array}> */ private array $uses = []; diff --git a/src/Support/Container.php b/src/Support/Container.php index 6390484b..b87fdd65 100644 --- a/src/Support/Container.php +++ b/src/Support/Container.php @@ -35,6 +35,8 @@ final class Container /** * Gets a dependency from the container. * + * @param class-string $id + * * @return object */ public function get(string $id) @@ -60,6 +62,8 @@ final class Container /** * Tries to build the given instance. + * + * @param class-string $id */ private function build(string $id): object { @@ -83,6 +87,7 @@ final class Container } } + //@phpstan-ignore-next-line return $this->get($candidate); }, $constructor->getParameters() diff --git a/src/Support/HigherOrderMessage.php b/src/Support/HigherOrderMessage.php index f756c64d..575eaf98 100644 --- a/src/Support/HigherOrderMessage.php +++ b/src/Support/HigherOrderMessage.php @@ -77,7 +77,7 @@ final class HigherOrderMessage */ public function when(callable $condition): self { - $this->condition = $condition; + $this->condition = Closure::fromCallable($condition); return $this; }