Skip to content

Commit

Permalink
Fix stale result cache with imported type aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jan 30, 2024
1 parent 142dc2f commit ea52b59
Show file tree
Hide file tree
Showing 28 changed files with 494 additions and 18 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ jobs:
mv src/Bar.php.orig src/Bar.php
echo -n > phpstan-baseline.neon
../../bin/phpstan -vvv
- script: |
cd e2e/bug10449
../../bin/phpstan analyze
git apply patch.diff
rm phpstan-baseline.neon
mv after-phpstan-baseline.neon phpstan-baseline.neon
../../bin/phpstan analyze -vvv
- script: |
cd e2e/bug10449b
../../bin/phpstan analyze
git apply patch.diff
rm phpstan-baseline.neon
mv after-phpstan-baseline.neon phpstan-baseline.neon
../../bin/phpstan analyze -vvv
- script: |
cd e2e/bug-9622
echo -n > phpstan-baseline.neon
Expand Down
1 change: 1 addition & 0 deletions e2e/bug10449/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
11 changes: 11 additions & 0 deletions e2e/bug10449/after-phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
ignoreErrors:
-
message: "#^Method App\\\\Example\\:\\:__invoke\\(\\) should return string but returns int\\.$#"
count: 1
path: src/Example.php

-
message: "#^Parameter \\#1 \\$s of method App\\\\Example\\:\\:needsString\\(\\) expects string, int given\\.$#"
count: 1
path: src/Example.php
16 changes: 16 additions & 0 deletions e2e/bug10449/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "devnix/phpstan-reproducer-10449",
"type": "project",
"license": "MIT",
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"authors": [
{
"name": "Pablo Largo Mohedano",
"email": "devnix.code@gmail.com"
}
]
}
83 changes: 83 additions & 0 deletions e2e/bug10449/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions e2e/bug10449/patch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/e2e/bug10449/src/Query/ExampleQueryHandler.php b/e2e/bug10449/src/Query/ExampleQueryHandler.php
index e9bc1d59f..f5d1c07bf 100644
--- a/e2e/bug10449/src/Query/ExampleQueryHandler.php
+++ b/e2e/bug10449/src/Query/ExampleQueryHandler.php
@@ -7,13 +7,13 @@ namespace App\Query;
use App\Bus\QueryHandlerInterface;

/**
- * @phpstan-type Return string
+ * @phpstan-type Return int
*/
final class ExampleQueryHandler implements QueryHandlerInterface
{
/** @return Return */
public function __invoke(ExampleQuery $exampleQuery)
{
- return '1';
+ return 1;
}
}
\ No newline at end of file
2 changes: 2 additions & 0 deletions e2e/bug10449/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
ignoreErrors: []
7 changes: 7 additions & 0 deletions e2e/bug10449/phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- phpstan-baseline.neon

parameters:
level: 9
paths:
- src
17 changes: 17 additions & 0 deletions e2e/bug10449/src/Bus/QueryBusInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace App\Bus;

interface QueryBusInterface
{
/**
* @template T
*
* @param QueryInterface<T> $query
*
* @return T
*/
public function handle(QueryInterface $query);
}
9 changes: 9 additions & 0 deletions e2e/bug10449/src/Bus/QueryHandlerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace App\Bus;

interface QueryHandlerInterface
{
}
10 changes: 10 additions & 0 deletions e2e/bug10449/src/Bus/QueryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace App\Bus;

/** @template T */
interface QueryInterface
{
}
23 changes: 23 additions & 0 deletions e2e/bug10449/src/Example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace App;

use App\Bus\QueryBusInterface;

final class Example
{
public function __construct(private QueryBusInterface $queryBus)
{
}

public function __invoke(): string
{
$value = $this->queryBus->handle(new Query\ExampleQuery());
$this->needsString($value);
return $value;
}

private function needsString(string $s):void {}
}
15 changes: 15 additions & 0 deletions e2e/bug10449/src/Query/ExampleQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace App\Query;

use App\Bus\QueryInterface;

/**
* @phpstan-import-type Return from ExampleQueryHandler
* @implements QueryInterface<Return>
*/
final class ExampleQuery implements QueryInterface
{
}
19 changes: 19 additions & 0 deletions e2e/bug10449/src/Query/ExampleQueryHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Query;

use App\Bus\QueryHandlerInterface;

/**
* @phpstan-type Return string
*/
final class ExampleQueryHandler implements QueryHandlerInterface
{
/** @return Return */
public function __invoke(ExampleQuery $exampleQuery)
{
return '1';
}
}
1 change: 1 addition & 0 deletions e2e/bug10449b/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
11 changes: 11 additions & 0 deletions e2e/bug10449b/after-phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
ignoreErrors:
-
message: "#^Method App\\\\Example\\:\\:__invoke\\(\\) should return string but returns int\\.$#"
count: 1
path: src/Example.php

-
message: "#^Parameter \\#1 \\$s of method App\\\\Example\\:\\:needsString\\(\\) expects string, int given\\.$#"
count: 1
path: src/Example.php
16 changes: 16 additions & 0 deletions e2e/bug10449b/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "devnix/phpstan-reproducer-10449",
"type": "project",
"license": "MIT",
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"authors": [
{
"name": "Pablo Largo Mohedano",
"email": "devnix.code@gmail.com"
}
]
}
83 changes: 83 additions & 0 deletions e2e/bug10449b/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea52b59

Please sign in to comment.