Skip to content

Commit ea52b59

Browse files
authored
Fix stale result cache with imported type aliases
1 parent 142dc2f commit ea52b59

28 files changed

Lines changed: 494 additions & 18 deletions

.github/workflows/e2e-tests.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,20 @@ jobs:
134134
mv src/Bar.php.orig src/Bar.php
135135
echo -n > phpstan-baseline.neon
136136
../../bin/phpstan -vvv
137+
- script: |
138+
cd e2e/bug10449
139+
../../bin/phpstan analyze
140+
git apply patch.diff
141+
rm phpstan-baseline.neon
142+
mv after-phpstan-baseline.neon phpstan-baseline.neon
143+
../../bin/phpstan analyze -vvv
144+
- script: |
145+
cd e2e/bug10449b
146+
../../bin/phpstan analyze
147+
git apply patch.diff
148+
rm phpstan-baseline.neon
149+
mv after-phpstan-baseline.neon phpstan-baseline.neon
150+
../../bin/phpstan analyze -vvv
137151
- script: |
138152
cd e2e/bug-9622
139153
echo -n > phpstan-baseline.neon

e2e/bug10449/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Method App\\\\Example\\:\\:__invoke\\(\\) should return string but returns int\\.$#"
5+
count: 1
6+
path: src/Example.php
7+
8+
-
9+
message: "#^Parameter \\#1 \\$s of method App\\\\Example\\:\\:needsString\\(\\) expects string, int given\\.$#"
10+
count: 1
11+
path: src/Example.php

e2e/bug10449/composer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "devnix/phpstan-reproducer-10449",
3+
"type": "project",
4+
"license": "MIT",
5+
"autoload": {
6+
"psr-4": {
7+
"App\\": "src/"
8+
}
9+
},
10+
"authors": [
11+
{
12+
"name": "Pablo Largo Mohedano",
13+
"email": "devnix.code@gmail.com"
14+
}
15+
]
16+
}

e2e/bug10449/composer.lock

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/bug10449/patch.diff

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/e2e/bug10449/src/Query/ExampleQueryHandler.php b/e2e/bug10449/src/Query/ExampleQueryHandler.php
2+
index e9bc1d59f..f5d1c07bf 100644
3+
--- a/e2e/bug10449/src/Query/ExampleQueryHandler.php
4+
+++ b/e2e/bug10449/src/Query/ExampleQueryHandler.php
5+
@@ -7,13 +7,13 @@ namespace App\Query;
6+
use App\Bus\QueryHandlerInterface;
7+
8+
/**
9+
- * @phpstan-type Return string
10+
+ * @phpstan-type Return int
11+
*/
12+
final class ExampleQueryHandler implements QueryHandlerInterface
13+
{
14+
/** @return Return */
15+
public function __invoke(ExampleQuery $exampleQuery)
16+
{
17+
- return '1';
18+
+ return 1;
19+
}
20+
}
21+
\ No newline at end of file

e2e/bug10449/phpstan-baseline.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
parameters:
2+
ignoreErrors: []

e2e/bug10449/phpstan.dist.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 9
6+
paths:
7+
- src
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Bus;
6+
7+
interface QueryBusInterface
8+
{
9+
/**
10+
* @template T
11+
*
12+
* @param QueryInterface<T> $query
13+
*
14+
* @return T
15+
*/
16+
public function handle(QueryInterface $query);
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Bus;
6+
7+
interface QueryHandlerInterface
8+
{
9+
}

0 commit comments

Comments
 (0)