-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed situation where ancestors appeared multiple times in the hierarchy
- Loading branch information
1 parent
b6e90d6
commit 65e578c
Showing
5 changed files
with
103 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Bug2740; | ||
|
||
use function PHPStan\Analyser\assertType; | ||
|
||
function (Member $member): void | ||
{ | ||
foreach ($member as $i) { | ||
assertType('Bug2740\Member', $i); | ||
} | ||
}; |
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,66 @@ | ||
<?php | ||
|
||
namespace Bug2740; | ||
|
||
/** | ||
* A collection that can contain members. | ||
* | ||
* @extends \IteratorAggregate<int,Member> | ||
*/ | ||
interface Collection extends \IteratorAggregate | ||
{ | ||
} | ||
|
||
/** | ||
* A member of a collection. Also a collection containing only itself. | ||
* | ||
* In the real world, this would contain additional methods. | ||
*/ | ||
interface Member extends Collection | ||
{ | ||
|
||
} | ||
|
||
class MemberImpl implements Member | ||
{ | ||
|
||
/** | ||
* @return \Iterator<int,Member> | ||
*/ | ||
public function getIterator(): \Iterator | ||
{ | ||
return new \ArrayIterator([$this]); | ||
} | ||
|
||
} | ||
|
||
class CollectionImpl implements Collection | ||
{ | ||
|
||
/** | ||
* @var array<int,Member> | ||
*/ | ||
private $members; | ||
|
||
public function __construct(Member ...$members) | ||
{ | ||
$this->members = $members; | ||
} | ||
|
||
/** | ||
* @return Member | ||
*/ | ||
public function getMember(): Member | ||
{ | ||
return new MemberImpl(); | ||
} | ||
|
||
/** | ||
* @return \Iterator<int,Member> | ||
*/ | ||
public function getIterator(): \Iterator | ||
{ | ||
return new \ArrayIterator($this->members); | ||
} | ||
|
||
} |