-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add phpdoc for transformation methods into other Collection stubs (fixes
#621)
- Loading branch information
1 parent
f61f963
commit 80f3b5f
Showing
5 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Bug621; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use function PHPStan\Testing\assertType; | ||
|
||
class Foo | ||
{ | ||
|
||
/** @var Collection<int, Item> */ | ||
private $items; | ||
|
||
public function __construct() | ||
{ | ||
/** @var ArrayCollection<int, int> $numbers */ | ||
$numbers = new ArrayCollection([1, 2, 3]); | ||
|
||
$filteredNumbers = $numbers->filter(function (int $number): bool { | ||
return $number % 2 === 1; | ||
}); | ||
assertType('Doctrine\Common\Collections\ArrayCollection<int, int>', $filteredNumbers); | ||
|
||
$items = $filteredNumbers->map(static function (int $number): Item { | ||
return new Item(); | ||
}); | ||
assertType('Doctrine\Common\Collections\ArrayCollection<int, Bug621\Item>', $items); | ||
|
||
$this->items = $items; | ||
} | ||
|
||
public function removeOdd(): void | ||
{ | ||
$this->items = $this->items->filter(function (Item $item, int $idx): bool { | ||
return $idx % 2 === 1; | ||
}); | ||
assertType('Doctrine\Common\Collections\Collection<int, Bug621\Item>', $this->items); | ||
} | ||
|
||
public function __clone() | ||
{ | ||
$this->items = $this->items->map( | ||
static function (Item $item): Item { | ||
return clone $item; | ||
} | ||
); | ||
assertType('Doctrine\Common\Collections\Collection<int, Bug621\Item>', $this->items); | ||
} | ||
|
||
} | ||
|
||
class Item | ||
{ | ||
|
||
} |