upgrade to phpstan lvl 7

This commit is contained in:
Fabio Ivona
2021-11-15 22:20:00 +01:00
parent f2a9b73b83
commit f3f58c7f52
11 changed files with 22 additions and 11 deletions

View File

@ -4,7 +4,7 @@ includes:
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
parameters: parameters:
level: 6 level: 7
paths: paths:
- src - src
parallel: parallel:

View File

@ -29,7 +29,7 @@ final class BootSubscribers
{ {
foreach (self::$subscribers as $subscriber) { foreach (self::$subscribers as $subscriber) {
Event\Facade::registerSubscriber( Event\Facade::registerSubscriber(
new $subscriber() new $subscriber() //@phpstan-ignore-line
); );
} }
} }

View File

@ -8,8 +8,8 @@ use Closure;
use Pest\Exceptions\DatasetAlreadyExist; use Pest\Exceptions\DatasetAlreadyExist;
use Pest\Exceptions\DatasetDoesNotExist; use Pest\Exceptions\DatasetDoesNotExist;
use SebastianBergmann\Exporter\Exporter; use SebastianBergmann\Exporter\Exporter;
use Traversable;
use function sprintf; use function sprintf;
use Traversable;
/** /**
* @internal * @internal
@ -19,14 +19,14 @@ final class Datasets
/** /**
* Holds the datasets. * Holds the datasets.
* *
* @var array<int|string, Closure|iterable<int|string, mixed>> * @var array<string, Closure|iterable<int|string, mixed>>
*/ */
private static array $datasets = []; private static array $datasets = [];
/** /**
* Holds the withs. * Holds the withs.
* *
* @var array<string, Closure|iterable<mixed>|string> * @var array<array<string, Closure|iterable<int|string, mixed>|string>>
*/ */
private static array $withs = []; private static array $withs = [];
@ -47,9 +47,9 @@ final class Datasets
/** /**
* Sets the given. * Sets the given.
* *
* @phpstan-param Closure|iterable<int|string, mixed>|string $with * @phpstan-param array<Closure|iterable<int|string, mixed>|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; self::$withs[$filename . '>>>' . $description] = $with;
} }

View File

@ -148,6 +148,7 @@ final class TestCaseFactory
$annotations = ['@test']; $annotations = ['@test'];
foreach (self::$annotations as $annotation) { foreach (self::$annotations as $annotation) {
//@phpstan-ignore-next-line
$annotations = (new $annotation())->add($method, $annotations); $annotations = (new $annotation())->add($method, $annotations);
} }

View File

@ -70,6 +70,8 @@ if (!function_exists('uses')) {
/** /**
* The uses function binds the given * The uses function binds the given
* arguments to test closures. * arguments to test closures.
*
* @param class-string ...$classAndTraits
*/ */
function uses(string ...$classAndTraits): UsesCall function uses(string ...$classAndTraits): UsesCall
{ {

View File

@ -37,6 +37,7 @@ final class Kernel
public static function boot(): self public static function boot(): self
{ {
foreach (self::$bootstrappers as $bootstrapper) { foreach (self::$bootstrappers as $bootstrapper) {
//@phpstan-ignore-next-line
(new $bootstrapper())->__invoke(); (new $bootstrapper())->__invoke();
} }

View File

@ -36,14 +36,14 @@ final class UsesCall
/** /**
* Holds the groups of the uses. * Holds the groups of the uses.
* *
* @var array<int, string> * @var array<string>
*/ */
private array $groups = []; private array $groups = [];
/** /**
* Creates a new Pending Call. * Creates a new Pending Call.
* *
* @param array<int, string> $classAndTraits * @param array<string> $classAndTraits
*/ */
public function __construct( public function __construct(
private string $filename, private string $filename,

View File

@ -18,6 +18,8 @@ final class Plugin
/** /**
* Lazy loads an `uses` call on the context of plugins. * Lazy loads an `uses` call on the context of plugins.
*
* @param class-string ...$traits
*/ */
public static function uses(string ...$traits): void public static function uses(string ...$traits): void
{ {

View File

@ -23,7 +23,7 @@ final class TestRepository
private array $testCases = []; private array $testCases = [];
/** /**
* @var array<string, array<int, array<int, string|Closure>>> * @var array<string, array{0: array<int, string>, 1: array<int, string>, 2: array<int, string|Closure>}>
*/ */
private array $uses = []; private array $uses = [];

View File

@ -35,6 +35,8 @@ final class Container
/** /**
* Gets a dependency from the container. * Gets a dependency from the container.
* *
* @param class-string $id
*
* @return object * @return object
*/ */
public function get(string $id) public function get(string $id)
@ -60,6 +62,8 @@ final class Container
/** /**
* Tries to build the given instance. * Tries to build the given instance.
*
* @param class-string $id
*/ */
private function build(string $id): object private function build(string $id): object
{ {
@ -83,6 +87,7 @@ final class Container
} }
} }
//@phpstan-ignore-next-line
return $this->get($candidate); return $this->get($candidate);
}, },
$constructor->getParameters() $constructor->getParameters()

View File

@ -77,7 +77,7 @@ final class HigherOrderMessage
*/ */
public function when(callable $condition): self public function when(callable $condition): self
{ {
$this->condition = $condition; $this->condition = Closure::fromCallable($condition);
return $this; return $this;
} }