-
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.
Showing
2 changed files
with
73 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,66 @@ | ||
<?php | ||
|
||
namespace Bug4854; | ||
|
||
/** | ||
* @extends \IteratorAggregate<int> | ||
* @extends \ArrayAccess<int,int> | ||
*/ | ||
interface DomainsAvailabilityInterface extends \IteratorAggregate, \ArrayAccess | ||
{ | ||
public const AVAILABLE = 1; | ||
public const UNAVAILABLE = 2; | ||
public const UNKNOWN = 3; | ||
} | ||
|
||
abstract class AbstractDomainsAvailability implements DomainsAvailabilityInterface | ||
{ | ||
/** | ||
* @var int[] | ||
*/ | ||
protected array $domains; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getIterator() | ||
{ | ||
return new \ArrayIterator($this->domains); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function offsetSet($offset, $value): void | ||
{ | ||
if ($offset === null) { | ||
$this->domains[] = $value; | ||
} else { | ||
$this->domains[$offset] = $value; | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function offsetExists($offset) | ||
{ | ||
return isset($this->domains[$offset]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function offsetUnset($offset): void | ||
{ | ||
unset($this->domains[$offset]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function offsetGet($offset): int | ||
{ | ||
return $this->domains[$offset]; | ||
} | ||
} |