Make StrictList compatible with SplDoublyLinkedList
This commit is contained in:
parent
1eb426de38
commit
f832b58a3e
|
@ -279,12 +279,11 @@ class StrictList extends SplDoublyLinkedList
|
||||||
/**
|
/**
|
||||||
* Create a type-sensitive, traversable list of items.
|
* Create a type-sensitive, traversable list of items.
|
||||||
*
|
*
|
||||||
* @param iterable<AllowedType> $items Initial set of items
|
|
||||||
* @param string[] $allowedTypes Allowed types of items (optional)
|
* @param string[] $allowedTypes Allowed types of items (optional)
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct(iterable $items = [], array $allowedTypes = [])
|
public function __construct(array $allowedTypes = [])
|
||||||
{
|
{
|
||||||
if (array_sum(array_map('is_string', $allowedTypes)) !== count($allowedTypes)) {
|
if (array_sum(array_map('is_string', $allowedTypes)) !== count($allowedTypes)) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
|
@ -292,7 +291,6 @@ class StrictList extends SplDoublyLinkedList
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->allowedTypes = $allowedTypes;
|
$this->allowedTypes = $allowedTypes;
|
||||||
$this->append(...$items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -330,9 +328,10 @@ class StrictList extends SplDoublyLinkedList
|
||||||
{
|
{
|
||||||
/** @var string[] $allowedTypes */
|
/** @var string[] $allowedTypes */
|
||||||
$allowedTypes = $data['StrictList::allowedTypes'];
|
$allowedTypes = $data['StrictList::allowedTypes'];
|
||||||
|
$this->__construct($allowedTypes);
|
||||||
/** @var iterable<AllowedType> $items */
|
/** @var iterable<AllowedType> $items */
|
||||||
$items = $data['SplDoublyLinkedList::dllist'];
|
$items = $data['SplDoublyLinkedList::dllist'];
|
||||||
$this->__construct($items, $allowedTypes);
|
$this->append(...$items);
|
||||||
/** @var int $flags */
|
/** @var int $flags */
|
||||||
$flags = $data['SplDoublyLinkedList::flags'];
|
$flags = $data['SplDoublyLinkedList::flags'];
|
||||||
$this->setIteratorMode($flags);
|
$this->setIteratorMode($flags);
|
||||||
|
|
|
@ -89,12 +89,11 @@ class StrictQueue extends StrictList
|
||||||
/**
|
/**
|
||||||
* Create a type-sensitive, traversable queue of items.
|
* Create a type-sensitive, traversable queue of items.
|
||||||
*
|
*
|
||||||
* @param iterable<AllowedType> $items Initial set of items
|
|
||||||
* @param string[] $allowedTypes Allowed types of items (optional)
|
* @param string[] $allowedTypes Allowed types of items (optional)
|
||||||
*/
|
*/
|
||||||
public function __construct(iterable $items = [], array $allowedTypes = [])
|
public function __construct(array $allowedTypes = [])
|
||||||
{
|
{
|
||||||
parent::__construct($items, $allowedTypes);
|
parent::__construct($allowedTypes);
|
||||||
$this->setIteratorMode(0);
|
$this->setIteratorMode(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,12 +87,11 @@ class StrictStack extends StrictList
|
||||||
/**
|
/**
|
||||||
* Create a type-sensitive, traversable stack of items.
|
* Create a type-sensitive, traversable stack of items.
|
||||||
*
|
*
|
||||||
* @param iterable<AllowedType> $items Initial set of items
|
|
||||||
* @param string[] $allowedTypes Allowed types of items (optional)
|
* @param string[] $allowedTypes Allowed types of items (optional)
|
||||||
*/
|
*/
|
||||||
public function __construct(iterable $items = [], array $allowedTypes = [])
|
public function __construct(array $allowedTypes = [])
|
||||||
{
|
{
|
||||||
parent::__construct($items, $allowedTypes);
|
parent::__construct($allowedTypes);
|
||||||
$this->setIteratorMode(2);
|
$this->setIteratorMode(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue