From f68d11ccae4e2be0f26a0ffe7c47fabec7d4602f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sat, 29 Mar 2025 17:44:06 +0000 Subject: [PATCH] chore: bumps dependencies --- composer.json | 12 +- phpstan-baseline.neon | 199 +++++++++++++++++++ phpstan.neon | 8 +- src/Factories/TestCaseMethodFactory.php | 2 +- src/Mixins/Expectation.php | 1 - src/Panic.php | 2 +- src/PendingCalls/DescribeCall.php | 2 +- src/PendingCalls/TestCall.php | 2 +- src/Repositories/DatasetsRepository.php | 4 +- src/Support/Closure.php | 2 +- src/Support/Exporter.php | 1 + src/Support/HigherOrderMessage.php | 10 +- src/Support/HigherOrderMessageCollection.php | 1 - src/Support/HigherOrderTapProxy.php | 4 +- 14 files changed, 219 insertions(+), 31 deletions(-) create mode 100644 phpstan-baseline.neon diff --git a/composer.json b/composer.json index bd8c21e3..778d391d 100644 --- a/composer.json +++ b/composer.json @@ -19,16 +19,16 @@ "require": { "php": "^8.2.0", "brianium/paratest": "^7.7.0", - "nunomaduro/collision": "^8.6.1", + "nunomaduro/collision": "^8.7.0", "nunomaduro/termwind": "^2.3.0", "pestphp/pest-plugin": "^3.0.0", "pestphp/pest-plugin-arch": "^3.0.0", "pestphp/pest-plugin-mutate": "^3.0.5", - "phpunit/phpunit": "^11.5.6" + "phpunit/phpunit": "^11.5.15" }, "conflict": { "filp/whoops": "<2.16.0", - "phpunit/phpunit": ">11.5.6", + "phpunit/phpunit": ">11.5.15", "sebastian/exporter": "<6.0.0", "webmozart/assert": "<1.11.0" }, @@ -53,9 +53,9 @@ ] }, "require-dev": { - "pestphp/pest-dev-tools": "^3.3.0", - "pestphp/pest-plugin-type-coverage": "^3.2.3", - "symfony/process": "^7.2.0" + "pestphp/pest-dev-tools": "^3.4.0", + "pestphp/pest-plugin-type-coverage": "^3.5.0", + "symfony/process": "^7.2.5" }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..99bbdec9 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,199 @@ +parameters: + ignoreErrors: + - + message: '#^Parameter \#1 of callable callable\(Pest\\Expectation\\)\: Pest\\Arch\\Contracts\\ArchExpectation expects Pest\\Expectation\, Pest\\Expectation\ given\.$#' + identifier: argument.type + count: 1 + path: src/ArchPresets/AbstractPreset.php + + - + message: '#^Trait Pest\\Concerns\\Expectable is used zero times and is not analysed\.$#' + identifier: trait.unused + count: 1 + path: src/Concerns/Expectable.php + + - + message: '#^Trait Pest\\Concerns\\Logging\\WritesToConsole is used zero times and is not analysed\.$#' + identifier: trait.unused + count: 1 + path: src/Concerns/Logging/WritesToConsole.php + + - + message: '#^Trait Pest\\Concerns\\Testable is used zero times and is not analysed\.$#' + identifier: trait.unused + count: 1 + path: src/Concerns/Testable.php + + - + message: '#^Loose comparison using \!\= between \(Closure\|null\) and false will always evaluate to false\.$#' + identifier: notEqual.alwaysFalse + count: 1 + path: src/Expectation.php + + - + message: '#^Method Pest\\Expectation\:\:and\(\) should return Pest\\Expectation\ but returns \(Pest\\Expectation&TAndValue\)\|Pest\\Expectation\\.$#' + identifier: return.type + count: 1 + path: src/Expectation.php + + - + message: '#^PHPDoc tag @property for property Pest\\Expectation\:\:\$each contains generic class Pest\\Expectations\\EachExpectation but does not specify its types\: TValue$#' + identifier: missingType.generics + count: 1 + path: src/Expectation.php + + - + message: '#^PHPDoc tag @property for property Pest\\Expectation\:\:\$not contains generic class Pest\\Expectations\\OppositeExpectation but does not specify its types\: TValue$#' + identifier: missingType.generics + count: 1 + path: src/Expectation.php + + - + message: '#^Parameter \#2 \$newScope of method Closure\:\:bindTo\(\) expects ''static''\|class\-string\|object\|null, string given\.$#' + identifier: argument.type + count: 1 + path: src/Expectation.php + + - + message: '#^Function expect\(\) should return Pest\\Expectation\ but returns Pest\\Expectation\\.$#' + identifier: return.type + count: 1 + path: src/Functions.php + + - + message: '#^Parameter \#1 \$argv of method PHPUnit\\TextUI\\Application\:\:run\(\) expects list\, array\ given\.$#' + identifier: argument.type + count: 1 + path: src/Kernel.php + + - + message: '#^Call to an undefined method object&TValue of mixed\:\:__toString\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Mixins/Expectation.php + + - + message: '#^Call to an undefined method object&TValue of mixed\:\:toArray\(\)\.$#' + identifier: method.notFound + count: 4 + path: src/Mixins/Expectation.php + + - + message: '#^Call to an undefined method object&TValue of mixed\:\:toSnapshot\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Mixins/Expectation.php + + - + message: '#^Call to an undefined method object&TValue of mixed\:\:toString\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Mixins/Expectation.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 2 + path: src/Mixins/Expectation.php + + - + message: '#^PHPDoc tag @var with type callable\(\)\: bool is not subtype of native type Closure\|null\.$#' + identifier: varTag.nativeType + count: 1 + path: src/PendingCalls/TestCall.php + + - + message: '#^Parameter \#1 \$argv of class Symfony\\Component\\Console\\Input\\ArgvInput constructor expects list\\|null, array\ given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel.php + + - + message: '#^Parameter \#13 \$testRunnerTriggeredDeprecationEvents of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#14 \$testRunnerTriggeredWarningEvents of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#15 \$errors of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#16 \$deprecations of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#17 \$notices of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#18 \$warnings of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#19 \$phpDeprecations of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#20 \$phpNotices of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#21 \$phpWarnings of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#4 \$testErroredEvents of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#5 \$testFailedEvents of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#7 \$testSuiteSkippedEvents of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#8 \$testSkippedEvents of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Parameter \#9 \$testMarkedIncompleteEvents of class PHPUnit\\TestRunner\\TestResult\\TestResult constructor expects list\, array given\.$#' + identifier: argument.type + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php + + - + message: '#^Property Pest\\Plugins\\Parallel\\Paratest\\WrapperRunner\:\:\$pending \(list\\) does not accept array\\.$#' + identifier: assign.propertyType + count: 1 + path: src/Plugins/Parallel/Paratest/WrapperRunner.php diff --git a/phpstan.neon b/phpstan.neon index 9ed48871..391daf0b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,14 +1,12 @@ includes: - - vendor/phpstan/phpstan-strict-rules/rules.neon - - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon + - phpstan-baseline.neon parameters: - level: max + level: 7 paths: - src - checkMissingIterableValueType: true - reportUnmatchedIgnoredErrors: true + reportUnmatchedIgnoredErrors: false ignoreErrors: - "#type mixed is not subtype of native#" diff --git a/src/Factories/TestCaseMethodFactory.php b/src/Factories/TestCaseMethodFactory.php index fb763c75..bac50071 100644 --- a/src/Factories/TestCaseMethodFactory.php +++ b/src/Factories/TestCaseMethodFactory.php @@ -155,7 +155,7 @@ final class TestCaseMethodFactory assert($testCase instanceof TestCaseFactory); $method = $this; - return function (...$arguments) use ($testCase, $method, $closure): mixed { // @phpstan-ignore-line + return function (...$arguments) use ($testCase, $method, $closure): mixed { /* @var TestCase $this */ $testCase->proxies->proxy($this); $method->proxies->proxy($this); diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index f802bc11..1566b59c 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -183,7 +183,6 @@ final class Expectation { foreach ($needles as $needle) { if (is_string($this->value)) { - // @phpstan-ignore-next-line Assert::assertStringContainsString((string) $needle, $this->value); } else { if (! is_iterable($this->value)) { diff --git a/src/Panic.php b/src/Panic.php index aca23b5e..a204472c 100644 --- a/src/Panic.php +++ b/src/Panic.php @@ -46,7 +46,7 @@ final readonly class Panic { try { $output = Container::getInstance()->get(OutputInterface::class); - } catch (Throwable) { // @phpstan-ignore-line + } catch (Throwable) { $output = new ConsoleOutput; } diff --git a/src/PendingCalls/DescribeCall.php b/src/PendingCalls/DescribeCall.php index b015595c..de472960 100644 --- a/src/PendingCalls/DescribeCall.php +++ b/src/PendingCalls/DescribeCall.php @@ -78,7 +78,7 @@ final class DescribeCall $this->currentBeforeEachCall->describing[] = $this->description; } - $this->currentBeforeEachCall->{$name}(...$arguments); // @phpstan-ignore-line + $this->currentBeforeEachCall->{$name}(...$arguments); return $this; } diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index a22ff11d..50fef3b6 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -224,7 +224,7 @@ final class TestCall // @phpstan-ignore-line */ public function only(): self { - Only::enable($this, ...func_get_args()); // @phpstan-ignore-line + Only::enable($this, ...func_get_args()); return $this; } diff --git a/src/Repositories/DatasetsRepository.php b/src/Repositories/DatasetsRepository.php index 1c296fc9..7d318a2d 100644 --- a/src/Repositories/DatasetsRepository.php +++ b/src/Repositories/DatasetsRepository.php @@ -71,7 +71,7 @@ final class DatasetsRepository * * @throws ShouldNotHappen */ - public static function get(string $filename, string $description): Closure|array + public static function get(string $filename, string $description): Closure|array // @phpstan-ignore-line { $dataset = self::$withs[$filename.self::SEPARATOR.$description]; @@ -110,7 +110,6 @@ final class DatasetsRepository foreach ($datasetCombination as $datasetCombinationElement) { $partialDescriptions[] = $datasetCombinationElement['label']; - // @phpstan-ignore-next-line $values = array_merge($values, $datasetCombinationElement['values']); } @@ -221,7 +220,6 @@ final class DatasetsRepository $result = $tmp; } - // @phpstan-ignore-next-line return $result; } diff --git a/src/Support/Closure.php b/src/Support/Closure.php index e96ec29e..e447903f 100644 --- a/src/Support/Closure.php +++ b/src/Support/Closure.php @@ -15,7 +15,6 @@ final class Closure /** * Binds the given closure to the given "this". * - * * @throws ShouldNotHappen */ public static function bind(?BaseClosure $closure, ?object $newThis, object|string|null $newScope = 'static'): BaseClosure @@ -24,6 +23,7 @@ final class Closure throw ShouldNotHappen::fromMessage('Could not bind null closure.'); } + // @phpstan-ignore-next-line $closure = BaseClosure::bind($closure, $newThis, $newScope); if (! $closure instanceof \Closure) { diff --git a/src/Support/Exporter.php b/src/Support/Exporter.php index a486445f..169f4891 100644 --- a/src/Support/Exporter.php +++ b/src/Support/Exporter.php @@ -66,6 +66,7 @@ final readonly class Exporter $result[] = $context->contains($data[$key]) !== false ? '*RECURSION*' + // @phpstan-ignore-next-line : sprintf('[%s]', $this->shortenedRecursiveExport($data[$key], $context)); } diff --git a/src/Support/HigherOrderMessage.php b/src/Support/HigherOrderMessage.php index aefc356e..89c3e1f1 100644 --- a/src/Support/HigherOrderMessage.php +++ b/src/Support/HigherOrderMessage.php @@ -50,14 +50,13 @@ final class HigherOrderMessage } if ($this->hasHigherOrderCallable()) { - /* @phpstan-ignore-next-line */ return (new HigherOrderCallables($target))->{$this->name}(...$this->arguments); } try { return is_array($this->arguments) ? Reflection::call($target, $this->name, $this->arguments) - : $target->{$this->name}; /* @phpstan-ignore-line */ + : $target->{$this->name}; } catch (Throwable $throwable) { Reflection::setPropertyValue($throwable, 'file', $this->filename); Reflection::setPropertyValue($throwable, 'line', $this->line); @@ -65,7 +64,6 @@ final class HigherOrderMessage if ($throwable->getMessage() === $this->getUndefinedMethodMessage($target, $this->name)) { /** @var ReflectionClass $reflection */ $reflection = new ReflectionClass($target); - /* @phpstan-ignore-next-line */ $reflection = $reflection->getParentClass() ?: $reflection; Reflection::setPropertyValue($throwable, 'message', sprintf('Call to undefined method %s::%s()', $reflection->getName(), $this->name)); } @@ -96,10 +94,6 @@ final class HigherOrderMessage private function getUndefinedMethodMessage(object $target, string $methodName): string { - if (\PHP_MAJOR_VERSION >= 8) { - return sprintf(self::UNDEFINED_METHOD, sprintf('%s::%s()', $target::class, $methodName)); - } - - return sprintf(self::UNDEFINED_METHOD, $methodName); + return sprintf(self::UNDEFINED_METHOD, sprintf('%s::%s()', $target::class, $methodName)); } } diff --git a/src/Support/HigherOrderMessageCollection.php b/src/Support/HigherOrderMessageCollection.php index da13a16c..41245108 100644 --- a/src/Support/HigherOrderMessageCollection.php +++ b/src/Support/HigherOrderMessageCollection.php @@ -40,7 +40,6 @@ final class HigherOrderMessageCollection public function chain(object $target): void { foreach ($this->messages as $message) { - // @phpstan-ignore-next-line $target = $message->call($target) ?? $target; } } diff --git a/src/Support/HigherOrderTapProxy.php b/src/Support/HigherOrderTapProxy.php index 151b2b80..08eb5ea7 100644 --- a/src/Support/HigherOrderTapProxy.php +++ b/src/Support/HigherOrderTapProxy.php @@ -26,7 +26,7 @@ final class HigherOrderTapProxy */ public function __set(string $property, mixed $value): void { - $this->target->{$property} = $value; // @phpstan-ignore-line + $this->target->{$property} = $value; } /** @@ -37,7 +37,7 @@ final class HigherOrderTapProxy public function __get(string $property) { if (property_exists($this->target, $property)) { - return $this->target->{$property}; // @phpstan-ignore-line + return $this->target->{$property}; } $className = (new ReflectionClass($this->target))->getName();