Skip to content

Commit

Permalink
Merge pull request #316 from imofix/fix-internal-phpstan-error
Browse files Browse the repository at this point in the history
Fix internal phpstan error
  • Loading branch information
localheinz committed Mar 4, 2024
2 parents 37238ea + 0f145e1 commit d750af9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 4 additions & 4 deletions phpstan-without-extension-baseline.neon
Expand Up @@ -22,22 +22,22 @@ parameters:

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

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

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

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

-
Expand Down
4 changes: 0 additions & 4 deletions src/Type/Prophet/ProphesizeDynamicReturnTypeExtension.php
Expand Up @@ -66,10 +66,6 @@ public function getTypeFromMethodCall(

$className = $argumentType->getValue();

if (!$returnType instanceof Type\TypeWithClassName) {
throw new ShouldNotHappenException();
}

if ('static' === $className) {
return $returnType;
}
Expand Down
19 changes: 19 additions & 0 deletions test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php
Expand Up @@ -16,6 +16,7 @@
use JanGregor\Prophecy\Test\StaticAnalysis\Src;
use PHPUnit\Framework;
use Prophecy\Argument;
use Prophecy\Prophet;

/**
* @internal
Expand Down Expand Up @@ -83,6 +84,24 @@ public function testCreateProphecyInHelperMethod(): void
self::assertEquals(5, $testDouble->doubleTheNumber(2));
}

public function testCreateProphecyInline(): void
{
$prophecy = (new Prophet())->prophesize(Src\BaseModel::class);

$prophecy

Check failure on line 91 in test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (7.4, 7.0.0, highest)

Call to an undefined method Prophecy\Prophecy\ObjectProphecy<JanGregor\Prophecy\Test\StaticAnalysis\Src\BaseModel>::getFoo().

Check failure on line 91 in test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (7.4, 8.0.0, highest)

Call to an undefined method Prophecy\Prophecy\ObjectProphecy<JanGregor\Prophecy\Test\StaticAnalysis\Src\BaseModel>::getFoo().

Check failure on line 91 in test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (7.4, 9.0.0, highest)

Call to an undefined method Prophecy\Prophecy\ObjectProphecy<JanGregor\Prophecy\Test\StaticAnalysis\Src\BaseModel>::getFoo().
->getFoo()
->willReturn('bar');

$prophecy

Check failure on line 95 in test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (7.4, 7.0.0, highest)

Call to an undefined method Prophecy\Prophecy\ObjectProphecy<JanGregor\Prophecy\Test\StaticAnalysis\Src\BaseModel>::doubleTheNumber().

Check failure on line 95 in test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (7.4, 8.0.0, highest)

Call to an undefined method Prophecy\Prophecy\ObjectProphecy<JanGregor\Prophecy\Test\StaticAnalysis\Src\BaseModel>::doubleTheNumber().

Check failure on line 95 in test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (7.4, 9.0.0, highest)

Call to an undefined method Prophecy\Prophecy\ObjectProphecy<JanGregor\Prophecy\Test\StaticAnalysis\Src\BaseModel>::doubleTheNumber().
->doubleTheNumber(Argument::is(2))
->willReturn(5);

$testDouble = $prophecy->reveal();

self::assertEquals('bar', $testDouble->getFoo());
self::assertEquals(5, $testDouble->doubleTheNumber(2));
}

private function createProphecy()
{
return $this->prophesize(Src\BaseModel::class);
Expand Down

0 comments on commit d750af9

Please sign in to comment.