Skip to content

Commit e9ef210

Browse files
committed
Reproduce result cache bug with trait aliases for traits
1 parent 553c4b1 commit e9ef210

File tree

8 files changed

+74
-0
lines changed

8 files changed

+74
-0
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ jobs:
124124
mv src/Foo.php.orig src/Foo.php
125125
echo -n > phpstan-baseline.neon
126126
../../bin/phpstan -vvv
127+
- script: |
128+
cd e2e/bug-9622-trait
129+
echo -n > phpstan-baseline.neon
130+
../../bin/phpstan -vvv
131+
patch -b src/Foo.php < patch-1.patch
132+
cat baseline-1.neon > phpstan-baseline.neon
133+
../../bin/phpstan -vvv
134+
mv src/Foo.php.orig src/Foo.php
135+
echo -n > phpstan-baseline.neon
136+
../../bin/phpstan -vvv
127137
128138
steps:
129139
- name: "Checkout"

e2e/bug-9622-trait/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/UsesBar.php

e2e/bug-9622-trait/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 Bug9622Trait;
5+
6+
/**
7+
- * @phpstan-type AnArray array{foo: int}
8+
+ * @phpstan-type AnArray array{foo?: int}
9+
*/
10+
class Foo
11+
{

e2e/bug-9622-trait/phpstan-baseline.neon

Whitespace-only changes.

e2e/bug-9622-trait/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-trait/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 Bug9622Trait;
4+
5+
/**
6+
* @phpstan-import-type AnArray from Foo
7+
*/
8+
trait 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-trait/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 Bug9622Trait;
4+
5+
/**
6+
* @phpstan-type AnArray array{foo: int}
7+
*/
8+
class Foo
9+
{
10+
11+
}

e2e/bug-9622-trait/src/UsesBar.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Bug9622Trait;
4+
5+
class UsesBar
6+
{
7+
8+
use Bar;
9+
10+
}

0 commit comments

Comments
 (0)