Skip to content

Commit 3788aa0

Browse files
Add non regression test (#5035)
1 parent 826449b commit 3788aa0

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,6 +3900,14 @@ public function testBug6120(): void
39003900
$this->analyse([__DIR__ . '/data/bug-6120.php'], []);
39013901
}
39023902

3903+
public function testBug1501(): void
3904+
{
3905+
$this->checkThisOnly = false;
3906+
$this->checkNullables = true;
3907+
$this->checkUnionTypes = true;
3908+
$this->analyse([__DIR__ . '/data/bug-1501.php'], []);
3909+
}
3910+
39033911
public function testBug11463(): void
39043912
{
39053913
$this->checkThisOnly = false;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug1501;
4+
5+
class HelloWorld
6+
{
7+
public function sayHello(): void
8+
{
9+
$so = new SomeObject();
10+
$this->modify($so->getForModify());
11+
}
12+
13+
private function modify(array &$data): void
14+
{
15+
$data[] = 'abc';
16+
}
17+
}
18+
19+
class SomeObject
20+
{
21+
private $someVar;
22+
23+
public function __construct()
24+
{
25+
$this->someVar = [];
26+
}
27+
28+
public function &getForModify(): array
29+
{
30+
return $this->someVar;
31+
}
32+
}

0 commit comments

Comments
 (0)