Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TypeCombinator::union() for intersection of array and template type
- Loading branch information
1 parent
20a6b38
commit b1069e1
Showing
3 changed files
with
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug4117; | ||
|
||
use ArrayIterator; | ||
use IteratorAggregate; | ||
|
||
/** | ||
* @refactor Refactor utils into base library | ||
* @template T of mixed | ||
* @implements IteratorAggregate<int, T> | ||
*/ | ||
class GenericList implements IteratorAggregate | ||
{ | ||
/** @var array<int, T> */ | ||
protected $items = []; | ||
|
||
/** | ||
* @return ArrayIterator<int, T> | ||
*/ | ||
public function getIterator(): ArrayIterator | ||
{ | ||
return new ArrayIterator($this->items); | ||
} | ||
|
||
/** | ||
* @return ?T | ||
*/ | ||
public function broken(int $key) | ||
{ | ||
$item = $this->items[$key] ?? null; | ||
if ($item) { | ||
} | ||
|
||
return $item; | ||
} | ||
|
||
/** | ||
* @return ?T | ||
*/ | ||
public function works(int $key) | ||
{ | ||
$item = $this->items[$key] ?? null; | ||
|
||
return $item; | ||
} | ||
} |