diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f9b72b5..ee68ede 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -54,8 +54,8 @@ $ make static-code-analysis-baseline to regenerate the baselines in -- [`../phpstan-with-extension-baseline.neon`](../phpstan-with-extension-baseline.neon) -- [`../phpstan-without-extension-baseline.neon`](../phpstan-without-extension-baseline.neon) +- [`../phpstan-baseline-with-extension.neon`](../phpstan-baseline-with-extension.neon) +- [`../phpstan-baseline-without-extension.neon`](../phpstan-baseline-without-extension.neon) :exclamation: Ideally, the baselines should shrink over time. diff --git a/Makefile b/Makefile index b9dc535..198462f 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,8 @@ static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan .PHONY: static-code-analysis-baseline static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with phpstan/phpstan and vimeo/psalm mkdir -p .build/phpstan - vendor/bin/phpstan analyze --configuration=phpstan-with-extension.neon --generate-baseline=phpstan-with-extension-baseline.neon --memory-limit=-1 - vendor/bin/phpstan analyze --configuration=phpstan-without-extension.neon --generate-baseline=phpstan-without-extension-baseline.neon --memory-limit=-1 + vendor/bin/phpstan analyze --configuration=phpstan-with-extension.neon --generate-baseline=phpstan-baseline-with-extension.neon --memory-limit=-1 + vendor/bin/phpstan analyze --configuration=phpstan-without-extension.neon --generate-baseline=phpstan-baseline-without-extension.neon --memory-limit=-1 .PHONY: tests tests: vendor ## Runs tests with phpunit/phpunit diff --git a/phpstan-baseline-with-extension.neon b/phpstan-baseline-with-extension.neon new file mode 100644 index 0000000..4eabd9a --- /dev/null +++ b/phpstan-baseline-with-extension.neon @@ -0,0 +1,32 @@ +parameters: + ignoreErrors: + - + message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:createProphecy\\(\\) has no return type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php + + - + message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:\\$prophecy has no type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php + + - + message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:createProphecy\\(\\) has no return type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php + + - + message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:\\$prophecy has no type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php + + - + message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:createProphecy\\(\\) has no return type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php + + - + message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:\\$prophecy has no type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php + diff --git a/phpstan-without-extension-baseline.neon b/phpstan-baseline-without-extension.neon similarity index 52% rename from phpstan-without-extension-baseline.neon rename to phpstan-baseline-without-extension.neon index 5393963..9466479 100644 --- a/phpstan-without-extension-baseline.neon +++ b/phpstan-baseline-without-extension.neon @@ -30,33 +30,23 @@ parameters: count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php - - - message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\\\:\\:doubleTheNumber\\(\\)\\.$#" - count: 2 - path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php - - - - message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\\\:\\:getFoo\\(\\)\\.$#" - count: 2 - path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php - - message: "#^Call to an undefined method object\\:\\:doubleTheNumber\\(\\)\\.$#" - count: 3 + count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php - message: "#^Call to an undefined method object\\:\\:getFoo\\(\\)\\.$#" - count: 3 + count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php - - message: "#^PHPDoc tag @return contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\ but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#" + message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:createProphecy\\(\\) has no return type specified\\.$#" count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php - - message: "#^PHPDoc tag @var for property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:\\$prophecy contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\ but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#" + message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:\\$prophecy has no type specified\\.$#" count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php @@ -66,23 +56,18 @@ parameters: path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php - - message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\\\:\\:baz\\(\\)\\.$#" - count: 2 - path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php - - - - message: "#^PHPDoc tag @return contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\ but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#" + message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:createProphecy\\(\\) has no return type specified\\.$#" count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php - - message: "#^PHPDoc tag @var for property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:\\$prophecy contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\ but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#" + message: "#^Parameter \\#1 \\$baz of method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\BaseModel\\:\\:baz\\(\\) expects JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Baz, object given\\.$#" count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php - - message: "#^Parameter \\#1 \\$baz of method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\BaseModel\\:\\:baz\\(\\) expects JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Baz, object given\\.$#" - count: 3 + message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:\\$prophecy has no type specified\\.$#" + count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php - @@ -91,23 +76,18 @@ parameters: path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php - - message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\\\:\\:bar\\(\\)\\.$#" - count: 2 - path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php - - - - message: "#^PHPDoc tag @return contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\ but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#" + message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:createProphecy\\(\\) has no return type specified\\.$#" count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php - - message: "#^PHPDoc tag @var for property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:\\$prophecy contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\ but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#" + message: "#^Parameter \\#1 \\$bar of method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\BaseModel\\:\\:bar\\(\\) expects JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Bar, object given\\.$#" count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php - - message: "#^Parameter \\#1 \\$bar of method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\BaseModel\\:\\:bar\\(\\) expects JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Bar, object given\\.$#" - count: 3 + message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:\\$prophecy has no type specified\\.$#" + count: 1 path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php - diff --git a/phpstan-with-extension-baseline.neon b/phpstan-with-extension-baseline.neon index aab4991..4eabd9a 100644 --- a/phpstan-with-extension-baseline.neon +++ b/phpstan-with-extension-baseline.neon @@ -1,2 +1,32 @@ parameters: - ignoreErrors: [] + ignoreErrors: + - + message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:createProphecy\\(\\) has no return type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php + + - + message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:\\$prophecy has no type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php + + - + message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:createProphecy\\(\\) has no return type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php + + - + message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:\\$prophecy has no type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php + + - + message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:createProphecy\\(\\) has no return type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php + + - + message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:\\$prophecy has no type specified\\.$#" + count: 1 + path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php + diff --git a/phpstan-with-extension.neon b/phpstan-with-extension.neon index c9b0951..f56cb87 100644 --- a/phpstan-with-extension.neon +++ b/phpstan-with-extension.neon @@ -1,6 +1,6 @@ includes: - extension.neon - - phpstan-with-extension-baseline.neon + - phpstan-baseline-with-extension.neon parameters: inferPrivatePropertyTypeFromConstructor: true diff --git a/phpstan-without-extension.neon b/phpstan-without-extension.neon index 3822b79..6a91ddc 100644 --- a/phpstan-without-extension.neon +++ b/phpstan-without-extension.neon @@ -1,5 +1,5 @@ includes: - - phpstan-without-extension-baseline.neon + - phpstan-baseline-without-extension.neon parameters: inferPrivatePropertyTypeFromConstructor: true diff --git a/test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php b/test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php index a1a3250..edcc659 100644 --- a/test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php +++ b/test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php @@ -24,9 +24,6 @@ */ final class ProphesizeTest extends Framework\TestCase { - /** - * @var \Prophecy\Prophecy\ObjectProphecy - */ private $prophecy; protected function setUp(): void @@ -86,9 +83,6 @@ public function testCreateProphecyInHelperMethod(): void self::assertEquals(5, $testDouble->doubleTheNumber(2)); } - /** - * @return \Prophecy\Prophecy\ObjectProphecy - */ private function createProphecy() { return $this->prophesize(Src\BaseModel::class); diff --git a/test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php b/test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php index e9234f2..a08c984 100644 --- a/test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php +++ b/test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php @@ -23,9 +23,6 @@ */ final class WillExtendTest extends Framework\TestCase { - /** - * @var \Prophecy\Prophecy\ObjectProphecy - */ private $prophecy; protected function setUp(): void @@ -73,9 +70,6 @@ public function testCreateProphecyInHelperMethod(): void self::assertSame('Hmm', $subject->baz($prophecy->reveal())); } - /** - * @return \Prophecy\Prophecy\ObjectProphecy - */ private function createProphecy() { return $this->prophesize()->willExtend(Src\Baz::class); diff --git a/test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php b/test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php index af023df..9f56550 100644 --- a/test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php +++ b/test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php @@ -23,9 +23,6 @@ */ final class WillImplementTest extends Framework\TestCase { - /** - * @var \Prophecy\Prophecy\ObjectProphecy - */ private $prophecy; protected function setUp(): void @@ -73,9 +70,6 @@ public function testCreateProphecyInHelperMethod(): void self::assertSame('Oh', $subject->bar($prophecy->reveal())); } - /** - * @return \Prophecy\Prophecy\ObjectProphecy - */ private function createProphecy() { return $this->prophesize(Src\Foo::class)->willImplement(Src\Bar::class);