Skip to content

Commit 80e832a

Browse files
committed
Regression test for #3782
1 parent e36e1cd commit 80e832a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,14 @@ public function testIntersection(): void
235235
$this->analyse([__DIR__ . '/data/nonexistent-offset-intersection.php'], []);
236236
}
237237

238+
public function testBug3782(): void
239+
{
240+
$this->analyse([__DIR__ . '/data/bug-3782.php'], [
241+
[
242+
'Cannot access offset (int|string) on Bug3782\HelloWorld.',
243+
11,
244+
],
245+
]);
246+
}
247+
238248
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Bug3782;
4+
5+
class HelloWorld
6+
{
7+
/** @param mixed[] $data */
8+
public function sayHello(array $data): void
9+
{
10+
foreach($data as $key => $value){
11+
$this[$key] = $value;
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)