diff --git a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php index 2f5ce4e226..3460563a48 100644 --- a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php @@ -3900,6 +3900,14 @@ public function testBug6120(): void $this->analyse([__DIR__ . '/data/bug-6120.php'], []); } + public function testBug1501(): void + { + $this->checkThisOnly = false; + $this->checkNullables = true; + $this->checkUnionTypes = true; + $this->analyse([__DIR__ . '/data/bug-1501.php'], []); + } + public function testBug11463(): void { $this->checkThisOnly = false; diff --git a/tests/PHPStan/Rules/Methods/data/bug-1501.php b/tests/PHPStan/Rules/Methods/data/bug-1501.php new file mode 100644 index 0000000000..b5c4fd826d --- /dev/null +++ b/tests/PHPStan/Rules/Methods/data/bug-1501.php @@ -0,0 +1,32 @@ +modify($so->getForModify()); + } + + private function modify(array &$data): void + { + $data[] = 'abc'; + } +} + +class SomeObject +{ + private $someVar; + + public function __construct() + { + $this->someVar = []; + } + + public function &getForModify(): array + { + return $this->someVar; + } +}