Skip to content

Commit 0fa6903

Browse files
committed
Reproduce result cache bug with type aliases
1 parent 83bfbdf commit 0fa6903

File tree

7 files changed

+64
-0
lines changed

7 files changed

+64
-0
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ jobs:
114114
mv src/Baz.php.orig src/Baz.php
115115
echo -n > phpstan-baseline.neon
116116
../../bin/phpstan -vvv
117+
- script: |
118+
cd e2e/bug-9622
119+
echo -n > phpstan-baseline.neon
120+
../../bin/phpstan -vvv
121+
patch -b src/Foo.php < patch-1.patch
122+
cat baseline-1.neon > phpstan-baseline.neon
123+
../../bin/phpstan -vvv
124+
mv src/Foo.php.orig src/Foo.php
125+
echo -n > phpstan-baseline.neon
126+
../../bin/phpstan -vvv
117127
118128
steps:
119129
- name: "Checkout"

e2e/bug-9622/baseline-1.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Offset 'foo' does not exist on array\\{foo\\?\\: int\\}\\.$#"
5+
count: 1
6+
path: src/Bar.php

e2e/bug-9622/patch-1.patch

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- src/Foo.php 2023-07-13 09:01:37
2+
+++ src/Foo.php 2023-07-13 09:02:20
3+
@@ -3,7 +3,7 @@
4+
namespace Bug9622;
5+
6+
/**
7+
- * @phpstan-type AnArray array{foo: int}
8+
+ * @phpstan-type AnArray array{foo?: int}
9+
*/
10+
class Foo
11+
{

e2e/bug-9622/phpstan-baseline.neon

Whitespace-only changes.

e2e/bug-9622/phpstan.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: 8
6+
paths:
7+
- src

e2e/bug-9622/src/Bar.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Bug9622;
4+
5+
/**
6+
* @phpstan-import-type AnArray from Foo
7+
*/
8+
class Bar
9+
{
10+
11+
/**
12+
* @param AnArray $a
13+
*/
14+
public function doFoo(array $a): void
15+
{
16+
echo 1 + $a['foo'];
17+
}
18+
19+
}

e2e/bug-9622/src/Foo.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Bug9622;
4+
5+
/**
6+
* @phpstan-type AnArray array{foo: int}
7+
*/
8+
class Foo
9+
{
10+
11+
}

0 commit comments

Comments
 (0)