From 11eb1903c2ecf83149e7c65b8160bc44a823ac39 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 17 Nov 2021 10:54:00 +0000 Subject: [PATCH] release: v1.21.0 --- phpstan-baseline.neon | 292 ++++++++++++++++++++++++++++++++ phpstan.neon | 4 +- src/Expectation.php | 1 - src/Logging/JUnit.php | 1 - src/OppositeExpectation.php | 8 +- src/PendingObjects/TestCall.php | 2 +- src/Pest.php | 2 +- tests/Visual/junit.html | 0 8 files changed, 301 insertions(+), 9 deletions(-) create mode 100644 phpstan-baseline.neon create mode 100644 tests/Visual/junit.html diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..d6e57bf2 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,292 @@ +parameters: + ignoreErrors: + - + message: "#^Cannot access an offset on mixed\\.$#" + count: 1 + path: src/Actions/AddsDefaults.php + + - + message: "#^Parameter \\#1 \\$out of class Pest\\\\Logging\\\\JUnit constructor expects string, mixed given\\.$#" + count: 1 + path: src/Actions/AddsDefaults.php + + - + message: "#^Parameter \\#2 \\$verbose of class NunoMaduro\\\\Collision\\\\Adapters\\\\Phpunit\\\\Printer constructor expects bool, mixed given\\.$#" + count: 1 + path: src/Actions/AddsDefaults.php + + - + message: "#^Parameter \\#2 \\$verbose of class Pest\\\\Logging\\\\TeamCity constructor expects bool, mixed given\\.$#" + count: 1 + path: src/Actions/AddsDefaults.php + + - + message: "#^Parameter \\#3 \\$colors of class NunoMaduro\\\\Collision\\\\Adapters\\\\Phpunit\\\\Printer constructor expects string, mixed given\\.$#" + count: 1 + path: src/Actions/AddsDefaults.php + + - + message: "#^Parameter \\#3 \\$colors of class Pest\\\\Logging\\\\TeamCity constructor expects string, mixed given\\.$#" + count: 1 + path: src/Actions/AddsDefaults.php + + - + message: "#^Parameter \\#1 \\$filename of function file_exists expects string, mixed given\\.$#" + count: 1 + path: src/Actions/ValidatesConfiguration.php + + - + message: "#^Parameter \\#1 \\$filename of method PHPUnit\\\\TextUI\\\\XmlConfiguration\\\\Loader\\:\\:load\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Actions/ValidatesConfiguration.php + + - + message: "#^Parameter \\#1 \\$loader of class PHPUnit\\\\TextUI\\\\TestRunner constructor expects PHPUnit\\\\Runner\\\\TestSuiteLoader\\|null, mixed given\\.$#" + count: 1 + path: src/Console/Command.php + + - + message: "#^Parameter \\#1 \\$testSuite of static method Pest\\\\Actions\\\\AddsTests\\:\\:to\\(\\) expects iterable\\&PHPUnit\\\\Framework\\\\TestSuite, mixed given\\.$#" + count: 1 + path: src/Console/Command.php + + - + message: "#^Parameter \\#2 \\$suffixes of method SebastianBergmann\\\\FileIterator\\\\Facade\\:\\:getFilesAsArray\\(\\) expects array\\|string, mixed given\\.$#" + count: 1 + path: src/Console/Command.php + + - + message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: src/Datasets.php + + - + message: "#^Method Pest\\\\Datasets\\:\\:getDataSetsCombinations\\(\\) has parameter \\$combinations with no value type specified in iterable type array\\.$#" + count: 1 + path: src/Datasets.php + + - + message: "#^Method Pest\\\\Datasets\\:\\:getDataSetsCombinations\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Datasets.php + + - + message: "#^Method Pest\\\\Datasets\\:\\:processDatasets\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: src/Datasets.php + + - + message: "#^Parameter \\#1 \\$key of static method Pest\\\\Datasets\\:\\:getDataSetDescription\\(\\) expects int\\|string, mixed given\\.$#" + count: 1 + path: src/Datasets.php + + - + message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: src/Each.php + + - + message: "#^Parameter \\#1 \\$ of callable callable\\(Pest\\\\Expectation\\\\)\\: mixed expects Pest\\\\Expectation\\, Pest\\\\Expectation\\ given\\.$#" + 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 + path: src/Expectation.php + + - + message: "#^Parameter \\#1 \\$directory of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertDirectoryIsReadable\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#1 \\$directory of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertDirectoryIsWritable\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#1 \\$file of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFileIsReadable\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#1 \\$file of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFileIsWritable\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#1 \\$filename of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFileExists\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#1 \\$json of function json_decode expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#1 \\$needle of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#1 \\$object_or_class of function property_exists expects object\\|string, mixed given\\.$#" + count: 2 + path: src/Expectation.php + + - + message: "#^Parameter \\#1 \\$value of method Pest\\\\Expectation\\\\:\\:and\\(\\) expects TValue, mixed given\\.$#" + count: 2 + path: src/Expectation.php + + - + message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertContains\\(\\) expects iterable, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertCount\\(\\) expects Countable\\|iterable, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#2 \\$string of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertMatchesRegularExpression\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#2 \\$string of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringEndsWith\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#2 \\$string of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringStartsWith\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Parameter \\#2 \\$value of method Pest\\\\Expectation\\\\:\\:retrieve\\(\\) expects array\\\\|object, mixed given\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Trying to invoke mixed but it's not a callable\\.$#" + count: 1 + path: src/Expectation.php + + - + message: "#^Method Pest\\\\Factories\\\\TestCaseFactory\\:\\:build\\(\\) should return array\\ but returns array\\\\.$#" + count: 1 + path: src/Factories/TestCaseFactory.php + + - + message: "#^Function it\\(\\) should return Pest\\\\PendingObjects\\\\TestCall but returns mixed\\.$#" + count: 1 + path: src/Functions.php + + - + message: "#^Parameter \\#2 \\$classAndTraits of class Pest\\\\PendingObjects\\\\UsesCall constructor expects array\\, array\\ given\\.$#" + count: 1 + path: src/Functions.php + + - + message: "#^Parameter \\#2 \\$value of method Pest\\\\HigherOrderExpectation\\:\\:retrieve\\(\\) expects array\\\\|object, mixed given\\.$#" + count: 1 + path: src/HigherOrderExpectation.php + + - + message: "#^Dead catch \\- ReflectionException is never thrown in the try block\\.$#" + count: 1 + path: src/Logging/JUnit.php + + - + message: "#^Parameter \\#2 \\$value of method DOMElement\\:\\:setAttribute\\(\\) expects string, mixed given\\.$#" + count: 1 + path: src/Logging/JUnit.php + + - + message: "#^Parameter \\$test of method Pest\\\\Logging\\\\JUnit\\:\\:startTest\\(\\) has invalid type Pest\\\\Concerns\\\\Testable\\.$#" + count: 1 + path: src/Logging/JUnit.php + + - + message: "#^Parameter \\$test of method Pest\\\\Logging\\\\TeamCity\\:\\:endTest\\(\\) has invalid type Pest\\\\Concerns\\\\Testable\\.$#" + count: 1 + path: src/Logging/TeamCity.php + + - + message: "#^Parameter \\$test of method Pest\\\\Logging\\\\TeamCity\\:\\:startTest\\(\\) has invalid type Pest\\\\Concerns\\\\Testable\\.$#" + count: 1 + path: src/Logging/TeamCity.php + + - + message: "#^Dead catch \\- PHPUnit\\\\Framework\\\\ExpectationFailedException is never thrown in the try block\\.$#" + count: 1 + path: src/OppositeExpectation.php + + - + message: "#^Property Pest\\\\PendingObjects\\\\UsesCall\\:\\:\\$groups \\(array\\\\) does not accept array\\\\.$#" + count: 1 + path: src/PendingObjects/UsesCall.php + + - + message: "#^Cannot cast mixed to float\\.$#" + count: 1 + path: src/Plugins/Coverage.php + + - + message: "#^Static property Pest\\\\Plugins\\\\Environment\\:\\:\\$instance is unused\\.$#" + count: 1 + path: src/Plugins/Environment.php + + - + message: "#^Method Pest\\\\Support\\\\Container\\:\\:get\\(\\) should return object but returns mixed\\.$#" + count: 1 + path: src/Support/Container.php + + - + message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" + 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 + path: src/Support/ExceptionTrace.php + + - + message: "#^Method Pest\\\\Support\\\\HigherOrderCallables\\:\\:expect\\(\\) should return Pest\\\\Expectation\\ but returns Pest\\\\Expectation\\\\.$#" + count: 1 + path: src/Support/HigherOrderCallables.php + + - + message: "#^Parameter \\#1 \\$target of method Pest\\\\Support\\\\HigherOrderMessage\\:\\:call\\(\\) expects object, mixed given\\.$#" + count: 1 + path: src/Support/HigherOrderMessageCollection.php + + - + message: "#^Constant Pest\\\\Support\\\\HigherOrderTapProxy\\:\\:UNDEFINED_PROPERTY is unused\\.$#" + count: 1 + path: src/Support/HigherOrderTapProxy.php + + - + message: "#^Dead catch \\- Throwable is never thrown in the try block\\.$#" + count: 1 + path: src/Support/HigherOrderTapProxy.php + diff --git a/phpstan.neon b/phpstan.neon index a32cf76a..7817d0d8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,7 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/ergebnis/phpstan-rules/rules.neon - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon + - phpstan-baseline.neon parameters: level: max @@ -23,9 +24,6 @@ parameters: - message: '#Call to an undefined method PHPUnit\\Framework\\Test::getName\(\)#' path: src/Logging - - - message: '#invalid typehint type Pest\\Concerns\\Testable#' - path: src/Logging - message: '#is not subtype of native type PHPUnit\\Framework\\Test#' path: src/Logging diff --git a/src/Expectation.php b/src/Expectation.php index a973c760..130be9e3 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -108,7 +108,6 @@ final class Expectation public function ray(...$arguments): self { if (function_exists('ray')) { - // @phpstan-ignore-next-line ray($this->value, ...$arguments); } diff --git a/src/Logging/JUnit.php b/src/Logging/JUnit.php index da15a9b9..211996da 100644 --- a/src/Logging/JUnit.php +++ b/src/Logging/JUnit.php @@ -283,7 +283,6 @@ final class JUnit extends Printer implements TestListener $class = new ReflectionClass($test); // @codeCoverageIgnoreStart } catch (ReflectionException $e) { - // @phpstan-ignore-next-line throw new Exception($e->getMessage(), (int) $e->getCode(), $e); } // @codeCoverageIgnoreEnd diff --git a/src/OppositeExpectation.php b/src/OppositeExpectation.php index 0473e2b6..d5f7aa32 100644 --- a/src/OppositeExpectation.php +++ b/src/OppositeExpectation.php @@ -51,6 +51,8 @@ final class OppositeExpectation * Handle dynamic method calls into the original expectation. * * @param array $arguments + * + * @return Expectation|never */ public function __call(string $name, array $arguments): Expectation { @@ -61,12 +63,13 @@ final class OppositeExpectation return $this->original; } - // @phpstan-ignore-next-line $this->throwExpectationFailedException($name, $arguments); } /** * Handle dynamic properties gets into the original expectation. + * + * @return Expectation|never */ public function __get(string $name): Expectation { @@ -77,7 +80,6 @@ final class OppositeExpectation return $this->original; } - // @phpstan-ignore-next-line $this->throwExpectationFailedException($name); } @@ -85,6 +87,8 @@ final class OppositeExpectation * Creates a new expectation failed exception with a nice readable message. * * @param array $arguments + * + * @return never */ private function throwExpectationFailedException(string $name, array $arguments = []): void { diff --git a/src/PendingObjects/TestCall.php b/src/PendingObjects/TestCall.php index 88928876..3f0d1045 100644 --- a/src/PendingObjects/TestCall.php +++ b/src/PendingObjects/TestCall.php @@ -160,7 +160,7 @@ final class TestCall $condition = is_callable($condition) ? $condition - : function () use ($condition) { /* @phpstan-ignore-line */ + : function () use ($condition) { return $condition; }; diff --git a/src/Pest.php b/src/Pest.php index 56a43e84..28195076 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '1.20.0'; + return '1.21.0'; } function testDirectory(string $file = ''): string diff --git a/tests/Visual/junit.html b/tests/Visual/junit.html new file mode 100644 index 00000000..e69de29b