-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes phpstan/phpstan#3034 Closes phpstan/phpstan#3117
- Loading branch information
1 parent
19e3cde
commit e494c81
Showing
3 changed files
with
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Bug3034; | ||
|
||
/** | ||
* @implements \IteratorAggregate<int, array{name: string, value: string}> | ||
*/ | ||
class HelloWorld implements \IteratorAggregate | ||
{ | ||
/** | ||
* @var array<int, array{name: string, value: string}> | ||
*/ | ||
private $list; | ||
|
||
/** | ||
* @return \ArrayIterator<int, array{name: string, value: string}> | ||
*/ | ||
public function getIterator() | ||
{ | ||
return new \ArrayIterator($this->list); | ||
} | ||
} |
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,49 @@ | ||
<?php | ||
|
||
namespace Bug3117; | ||
|
||
interface Temporal | ||
{ | ||
|
||
/** | ||
* @return static | ||
*/ | ||
public function adjustedWith(TemporalAdjuster $adjuster): Temporal; | ||
|
||
} | ||
|
||
interface TemporalAdjuster | ||
{ | ||
|
||
/** | ||
* @template T of Temporal | ||
* | ||
* @param T $temporal | ||
* | ||
* @return T | ||
*/ | ||
public function adjustInto(Temporal $temporal) : Temporal; | ||
|
||
} | ||
|
||
final class SimpleTemporal implements Temporal, TemporalAdjuster | ||
{ | ||
|
||
public function adjustInto(Temporal $temporal): Temporal | ||
{ | ||
if ($temporal instanceof self) { | ||
return $this; | ||
} | ||
|
||
return $temporal->adjustedWith($this); | ||
} | ||
|
||
/** | ||
* @return static | ||
*/ | ||
public function adjustedWith(TemporalAdjuster $adjuster): Temporal | ||
{ | ||
return $this; | ||
} | ||
|
||
} |