Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 32 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-1501.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types = 1);

namespace Bug1501;

class HelloWorld
{
public function sayHello(): void
{
$so = new SomeObject();
$this->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;
}
}
Loading