Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimize README code example #353

Merged
merged 1 commit into from
Nov 21, 2024
Merged

Conversation

sasezaki
Copy link
Contributor

@sasezaki sasezaki commented Nov 21, 2024

As I said at #347 , and changed like 37d8420

It seems property $prophecy taken as mixed in phpstan. With level 10 would be error.

as example, see below analyse result

diff --git a/test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php b/test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php
index 76d7552..cce56f9 100644
--- a/test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php
+++ b/test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php
@@ -28,10 +28,7 @@ final class ProphesizeTest extends Framework\TestCase
 {
     use ProphecyTrait;

-    /**
-     * @var ObjectProphecy<Src\BaseModel>
-     */
-    private \Prophecy\Prophecy\ObjectProphecy $prophecy;
+    private $prophecy;

     protected function setUp(): void
     {
@@ -40,6 +37,7 @@ final class ProphesizeTest extends Framework\TestCase

     public function testCreateProphecyInSetUp(): void
     {
+        \PHPStan\dumpType($this->prophecy);
         $this->prophecy
             ->getFoo()
             ->willReturn('bar');
vendor/bin/phpstan analyse --configuration=phpstan-with-extension.neon --level=10 test/StaticAnalysis/Test/ObjectProphecy/ProphesizeTest.php
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ----------------------------------------------------------------------------------------------------------------------
  Line   ProphesizeTest.php
 ------ ----------------------------------------------------------------------------------------------------------------------
  31     Property JanGregor\Prophecy\Test\StaticAnalysis\Test\ObjectProphecy\ProphesizeTest::$prophecy has no type specified.
         🪪  missingType.property
  40     Dumped type: mixed
  41     Cannot call method getFoo() on mixed.
         🪪  method.nonObject

I removed it, because it is not mostly required as code example.

Follows #348
Related to #346
Fixes #348

@sasezaki sasezaki mentioned this pull request Nov 21, 2024
@alexander-schranz alexander-schranz merged commit 8937c0f into Jan0707:master Nov 21, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants