Skip to content

Commit

Permalink
Update phpstan baseline files and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Nov 1, 2021
1 parent fe58cee commit 2e0fe96
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 55 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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-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
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

.PHONY: tests
tests: vendor ## Runs tests with phpunit/phpunit
Expand Down
32 changes: 1 addition & 31 deletions phpstan-with-extension-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@
parameters:
ignoreErrors:
-
message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:\\$prophecy has no typehint specified\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

-
message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:createProphecy\\(\\) has no return typehint specified\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

-
message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:\\$prophecy has no typehint specified\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php

-
message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:createProphecy\\(\\) has no return typehint specified\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php

-
message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:\\$prophecy has no typehint specified\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php

-
message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:createProphecy\\(\\) has no return typehint specified\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php

ignoreErrors: []
56 changes: 38 additions & 18 deletions phpstan-without-extension-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ parameters:
path: test/StaticAnalysis/Test/BaseModelTest.php

-
message: "#^Parameter \\#1 \\$bar of method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\BaseModel\\:\\:bar\\(\\) expects JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Bar, object given\\.$#"
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\:\\:baz\\(\\)\\.$#"
count: 1
path: test/StaticAnalysis/Test/BaseModelTest.php

-
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\:\\:baz\\(\\)\\.$#"
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/BaseModelTest.php

Expand All @@ -21,7 +21,7 @@ parameters:
path: test/StaticAnalysis/Test/BaseModelTest.php

-
message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:\\$prophecy has no typehint specified\\.$#"
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\:\\:doubleTheNumber\\(\\)\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

Expand All @@ -31,65 +31,85 @@ parameters:
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

-
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\:\\:doubleTheNumber\\(\\)\\.$#"
count: 1
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\BaseModel\\>\\:\\:doubleTheNumber\\(\\)\\.$#"
count: 2
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

-
message: "#^Call to an undefined method object\\:\\:getFoo\\(\\)\\.$#"
count: 1
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\BaseModel\\>\\:\\:getFoo\\(\\)\\.$#"
count: 2
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

-
message: "#^Call to an undefined method object\\:\\:doubleTheNumber\\(\\)\\.$#"
count: 1
count: 3
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

-
message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:createProphecy\\(\\) has no return typehint specified\\.$#"
message: "#^Call to an undefined method object\\:\\:getFoo\\(\\)\\.$#"
count: 3
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

-
message: "#^PHPDoc tag @return contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\BaseModel\\> but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

-
message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:\\$prophecy has no typehint specified\\.$#"
message: "#^PHPDoc tag @var for property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\ProphesizeTest\\:\\:\\$prophecy contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\BaseModel\\> but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php
path: test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

-
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\:\\:baz\\(\\)\\.$#"
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: 1
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Baz\\>\\:\\:baz\\(\\)\\.$#"
count: 2
path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php

-
message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:createProphecy\\(\\) has no return typehint specified\\.$#"
message: "#^PHPDoc tag @return contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Baz\\> but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php

-
message: "#^Property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:\\$prophecy has no typehint specified\\.$#"
message: "#^PHPDoc tag @var for property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillExtendTest\\:\\:\\$prophecy contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Baz\\> but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php
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
path: test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php

-
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\:\\:bar\\(\\)\\.$#"
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\\.$#"
message: "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Bar&JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Foo\\>\\:\\:bar\\(\\)\\.$#"
count: 2
path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php

-
message: "#^PHPDoc tag @return contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Bar&JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Foo\\> but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#"
count: 1
path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php

-
message: "#^Method JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:createProphecy\\(\\) has no return typehint specified\\.$#"
message: "#^PHPDoc tag @var for property JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Test\\\\ObjectProphecy\\\\WillImplementTest\\:\\:\\$prophecy contains generic type Prophecy\\\\Prophecy\\\\ObjectProphecy\\<JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Bar&JanGregor\\\\Prophecy\\\\Test\\\\StaticAnalysis\\\\Src\\\\Foo\\> but class Prophecy\\\\Prophecy\\\\ObjectProphecy is not generic\\.$#"
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
path: test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php

-
message: "#^Parameter \\#1 \\$declaringClass of class JanGregor\\\\Prophecy\\\\Reflection\\\\ObjectProphecy\\\\MethodReflection constructor expects PHPStan\\\\Reflection\\\\ClassReflection, object given\\.$#"
count: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public function getTypeFromMethodCall(
return $returnType;
}

if (0 === \count($methodCall->args)) {
if (0 === \count($methodCall->getArgs())) {
return $returnType;
}

$argumentType = $scope->getType($methodCall->args[0]->value);
$argumentType = $scope->getType($methodCall->getArgs()[0]->value);

if (!$argumentType instanceof Type\Constant\ConstantStringType) {
return $returnType;
Expand Down
4 changes: 2 additions & 2 deletions src/Type/Prophet/ProphesizeDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public function getTypeFromMethodCall(

$returnType = $parametersAcceptor->getReturnType();

if (0 === \count($methodCall->args)) {
if (0 === \count($methodCall->getArgs())) {
return new Type\Generic\GenericObjectType(
Prophecy\ObjectProphecy::class,
[]
);
}

$argumentType = $scope->getType($methodCall->args[0]->value);
$argumentType = $scope->getType($methodCall->getArgs()[0]->value);

if (!$argumentType instanceof Type\Constant\ConstantStringType) {
return $returnType;
Expand Down
6 changes: 6 additions & 0 deletions test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
*/
final class ProphesizeTest extends Framework\TestCase
{
/**
* @var \Prophecy\Prophecy\ObjectProphecy<Src\BaseModel>
*/
private $prophecy;

protected function setUp(): void
Expand Down Expand Up @@ -83,6 +86,9 @@ public function testCreateProphecyInHelperMethod(): void
self::assertEquals(5, $testDouble->doubleTheNumber(2));
}

/**
* @return \Prophecy\Prophecy\ObjectProphecy<Src\BaseModel>
*/
private function createProphecy()
{
return $this->prophesize(Src\BaseModel::class);
Expand Down
6 changes: 6 additions & 0 deletions test/StaticAnalysis/Test/ObjectProphecy/WillExtendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*/
final class WillExtendTest extends Framework\TestCase
{
/**
* @var \Prophecy\Prophecy\ObjectProphecy<Src\Baz>
*/
private $prophecy;

protected function setUp(): void
Expand Down Expand Up @@ -70,6 +73,9 @@ public function testCreateProphecyInHelperMethod(): void
self::assertSame('Hmm', $subject->baz($prophecy->reveal()));
}

/**
* @return \Prophecy\Prophecy\ObjectProphecy<Src\Baz>
*/
private function createProphecy()
{
return $this->prophesize()->willExtend(Src\Baz::class);
Expand Down
6 changes: 6 additions & 0 deletions test/StaticAnalysis/Test/ObjectProphecy/WillImplementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*/
final class WillImplementTest extends Framework\TestCase
{
/**
* @var \Prophecy\Prophecy\ObjectProphecy<Src\Foo&Src\Bar>
*/
private $prophecy;

protected function setUp(): void
Expand Down Expand Up @@ -70,6 +73,9 @@ public function testCreateProphecyInHelperMethod(): void
self::assertSame('Oh', $subject->bar($prophecy->reveal()));
}

/**
* @return \Prophecy\Prophecy\ObjectProphecy<Src\Foo&Src\Bar>
*/
private function createProphecy()
{
return $this->prophesize(Src\Foo::class)->willImplement(Src\Bar::class);
Expand Down

0 comments on commit 2e0fe96

Please sign in to comment.