aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2017-11-08 11:36:14 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2017-11-08 11:36:14 +0100
commit4f4a49fb96b38c46c0f6ee3b13473bfcee3b6376 (patch)
tree62faf7f4696803353ce01f286eea67426961fa9f
parent4a08e30f2fce376bf63d646cb83b559a9c838cc0 (diff)
downloadIterator-4f4a49fb96b38c46c0f6ee3b13473bfcee3b6376.zip
Iterator-4f4a49fb96b38c46c0f6ee3b13473bfcee3b6376.tar.gz
Iterator-4f4a49fb96b38c46c0f6ee3b13473bfcee3b6376.tar.bz2
chore(php) Update to PHP 7.
-rw-r--r--Source/Aggregate.php2
-rw-r--r--Source/Append.php2
-rw-r--r--Source/Buffer.php45
-rw-r--r--Source/CallbackFilter.php2
-rw-r--r--Source/CallbackGenerator.php24
-rw-r--r--Source/Counter.php31
-rw-r--r--Source/Demultiplexer.php33
-rw-r--r--Source/Directory.php20
-rw-r--r--Source/Exception.php2
-rw-r--r--Source/FileSystem.php10
-rw-r--r--Source/Filter.php2
-rw-r--r--Source/Glob.php2
-rw-r--r--Source/Infinite.php2
-rw-r--r--Source/Iterator.php4
-rw-r--r--Source/IteratorIterator.php2
-rw-r--r--Source/Limit.php2
-rw-r--r--Source/Lookahead.php44
-rw-r--r--Source/Lookbehind.php40
-rw-r--r--Source/Map.php2
-rw-r--r--Source/Mock.php2
-rw-r--r--Source/Multiple.php11
-rw-r--r--Source/NoRewind.php2
-rw-r--r--Source/Outer.php2
-rw-r--r--Source/Recursive/CallbackFilter.php2
-rw-r--r--Source/Recursive/Directory.php49
-rw-r--r--Source/Recursive/Filter.php2
-rw-r--r--Source/Recursive/Iterator.php2
-rw-r--r--Source/Recursive/Map.php2
-rw-r--r--Source/Recursive/Mock.php28
-rw-r--r--Source/Recursive/Recursive.php4
-rw-r--r--Source/Recursive/RegularExpression.php22
-rw-r--r--Source/RegularExpression.php75
-rw-r--r--Source/Repeater.php35
-rw-r--r--Source/Seekable.php2
-rw-r--r--Source/SplFileInfo.php24
-rw-r--r--Test/Unit/Buffer.php165
-rw-r--r--Test/Unit/Directory.php82
-rw-r--r--Test/Unit/FileSystem.php30
38 files changed, 141 insertions, 671 deletions
diff --git a/Source/Aggregate.php b/Source/Aggregate.php
index a08f0df..eb0c955 100644
--- a/Source/Aggregate.php
+++ b/Source/Aggregate.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Interface \Hoa\Iterator\Aggregate.
*
* Extending the SPL IteratorAggregate interface.
- *
- * @license New BSD License
*/
interface Aggregate extends \IteratorAggregate
{
diff --git a/Source/Append.php b/Source/Append.php
index d3beb82..44ac27a 100644
--- a/Source/Append.php
+++ b/Source/Append.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Append.
*
* Extending the SPL AppendIterator class.
- *
- * @license New BSD License
*/
class Append extends \AppendIterator
{
diff --git a/Source/Buffer.php b/Source/Buffer.php
index c4c395b..2630e28 100644
--- a/Source/Buffer.php
+++ b/Source/Buffer.php
@@ -42,43 +42,31 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Buffer.
*
* Buffer iterator: Can go backward up to a certain limit, and forward.
- *
- * @license New BSD License
*/
class Buffer extends IteratorIterator implements Outer
{
/**
* Buffer key index.
- *
- * @const int
*/
- public const BUFFER_KEY = 0;
+ protected const BUFFER_KEY = 0;
/**
* Buffer value index.
- *
- * @const int
*/
- public const BUFFER_VALUE = 1;
+ protected const BUFFER_VALUE = 1;
/**
* Current iterator.
- *
- * @var \Iterator
*/
protected $_iterator = null;
/**
* Buffer.
- *
- * @var \SplDoublyLinkedList
*/
protected $_buffer = null;
/**
* Maximum buffer size.
- *
- * @var int
*/
protected $_bufferSize = 1;
@@ -86,11 +74,8 @@ class Buffer extends IteratorIterator implements Outer
/**
* Construct.
- *
- * @param \Iterator $iterator Iterator.
- * @param int $bufferSize Buffer size.
*/
- public function __construct(\Iterator $iterator, int $bufferSize)
+ public function __construct(iterable $iterator, int $bufferSize)
{
$this->_iterator = $iterator;
$this->_bufferSize = max($bufferSize, 1);
@@ -101,18 +86,14 @@ class Buffer extends IteratorIterator implements Outer
/**
* Get inner iterator.
- *
- * @return \Iterator
*/
- public function getInnerIterator(): \Iterator
+ public function getInnerIterator(): iterable
{
return $this->_iterator;
}
/**
* Get buffer.
- *
- * @return \SplDoublyLinkedList
*/
protected function getBuffer(): \SplDoublyLinkedList
{
@@ -121,8 +102,6 @@ class Buffer extends IteratorIterator implements Outer
/**
* Get buffer size.
- *
- * @return int
*/
public function getBufferSize(): int
{
@@ -131,8 +110,6 @@ class Buffer extends IteratorIterator implements Outer
/**
* Return the current element.
- *
- * @return mixed
*/
public function current()
{
@@ -141,8 +118,6 @@ class Buffer extends IteratorIterator implements Outer
/**
* Return the key of the current element.
- *
- * @return mixed
*/
public function key()
{
@@ -151,8 +126,6 @@ class Buffer extends IteratorIterator implements Outer
/**
* Move forward to next element.
- *
- * @return void
*/
public function next(): void
{
@@ -184,26 +157,18 @@ class Buffer extends IteratorIterator implements Outer
$buffer->rewind();
$buffer->setIteratorMode($buffer::IT_MODE_FIFO | $buffer::IT_MODE_KEEP);
}
-
- return;
}
/**
* Move backward to previous element.
- *
- * @return void
*/
public function previous(): void
{
$this->getBuffer()->prev();
-
- return;
}
/**
* Rewind the iterator to the first element.
- *
- * @return void
*/
public function rewind(): void
{
@@ -226,8 +191,6 @@ class Buffer extends IteratorIterator implements Outer
/**
* Check if current position is valid.
- *
- * @return bool
*/
public function valid(): bool
{
diff --git a/Source/CallbackFilter.php b/Source/CallbackFilter.php
index b619f33..ac344f9 100644
--- a/Source/CallbackFilter.php
+++ b/Source/CallbackFilter.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\CallbackFilter.
*
* Extending the SPL CallbackFilterIterator class.
- *
- * @license New BSD License
*/
class CallbackFilter extends \CallbackFilterIterator
{
diff --git a/Source/CallbackGenerator.php b/Source/CallbackGenerator.php
index f096f42..27d5524 100644
--- a/Source/CallbackGenerator.php
+++ b/Source/CallbackGenerator.php
@@ -42,29 +42,21 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\CallbackGenerator.
*
* Yield a value based on a callback.
- *
- * @license New BSD License
*/
class CallbackGenerator implements Iterator
{
/**
* Callback.
- *
- * @var callable
*/
protected $_callback = null;
/**
* Current key.
- *
- * @var mixed
*/
protected $_key = 0;
/**
* Current computed value.
- *
- * @var mixed
*/
protected $_current = null;
@@ -72,8 +64,6 @@ class CallbackGenerator implements Iterator
/**
* Constructor.
- *
- * @param callable $callback Callback.
*/
public function __construct(callable $callback)
{
@@ -84,8 +74,6 @@ class CallbackGenerator implements Iterator
/**
* Return the current element.
- *
- * @return mixed
*/
public function current()
{
@@ -96,8 +84,6 @@ class CallbackGenerator implements Iterator
/**
* Return the key of the current element.
- *
- * @return mixed
*/
public function key()
{
@@ -106,33 +92,23 @@ class CallbackGenerator implements Iterator
/**
* Move forward to next element.
- *
- * @return void
*/
public function next(): void
{
++$this->_key;
-
- return;
}
/**
* Rewind the iterator to the first element.
- *
- * @return void
*/
public function rewind(): void
{
$this->_key = 0;
$this->_current = null;
-
- return;
}
/**
* Check if current position is valid.
- *
- * @return bool
*/
public function valid(): bool
{
diff --git a/Source/Counter.php b/Source/Counter.php
index 17c41a3..defac6f 100644
--- a/Source/Counter.php
+++ b/Source/Counter.php
@@ -42,43 +42,31 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Counter.
*
* A counter.
- *
- * @license New BSD License
*/
class Counter implements Iterator
{
/**
* From (lower bound).
- *
- * @var int
*/
protected $_from = 0;
/**
* Current key.
- *
- * @var int
*/
protected $_key = 0;
/**
* Current index.
- *
- * @var int
*/
protected $_i = 0;
/**
* To (upper bound).
- *
- * @var int
*/
protected $_to = 0;
/**
* Step.
- *
- * @var int
*/
protected $_step = 0;
@@ -88,11 +76,6 @@ class Counter implements Iterator
* Constructor.
* Equivalent to:
* for($i = $from; $i < $to; $i += $step)
- *
- * @param int $from Start value.
- * @param int $to Maximum value.
- * @param int $step Step.
- * @throws \Hoa\Iterator\Exception
*/
public function __construct(int $from, int $to, int $step)
{
@@ -113,8 +96,6 @@ class Counter implements Iterator
/**
* Return the current element.
- *
- * @return int
*/
public function current(): int
{
@@ -123,8 +104,6 @@ class Counter implements Iterator
/**
* Return the key of the current element.
- *
- * @return int
*/
public function key(): int
{
@@ -133,34 +112,24 @@ class Counter implements Iterator
/**
* Move forward to next element.
- *
- * @return void
*/
public function next(): void
{
++$this->_key;
$this->_i += $this->_step;
-
- return;
}
/**
* Rewind the iterator to the first element.
- *
- * @return void
*/
public function rewind(): void
{
$this->_key = 0;
$this->_i = $this->_from;
-
- return;
}
/**
* Check if current position is valid.
- *
- * @return bool
*/
public function valid(): bool
{
diff --git a/Source/Demultiplexer.php b/Source/Demultiplexer.php
index 1531e19..6243dae 100644
--- a/Source/Demultiplexer.php
+++ b/Source/Demultiplexer.php
@@ -43,29 +43,21 @@ namespace Hoa\Iterator;
*
* Demux result from another iterator.
* This iterator is somehow the opposite of the Hoa\Iterator\Multiple iterator.
- *
- * @license New BSD License
*/
class Demultiplexer implements Iterator
{
/**
* Current iterator.
- *
- * @var \Traversable
*/
protected $_iterator = null;
/**
* Current computed value.
- *
- * @var mixed
*/
protected $_current = null;
/**
* Demuxer (callable to execute each time).
- *
- * @var callable
*/
protected $_demuxer = null;
@@ -73,12 +65,8 @@ class Demultiplexer implements Iterator
/**
* Constructor.
- *
- * @param \Traversable $iterator Iterator.
- * @param callable $demuxer Demuxer.
- * @throws \Hoa\Iterator\Exception
*/
- public function __construct(\Traversable $iterator, callable $demuxer)
+ public function __construct(iterable $iterator, callable $demuxer)
{
if ($iterator instanceof \IteratorAggregate) {
$iterator = $iterator->getIterator();
@@ -92,8 +80,6 @@ class Demultiplexer implements Iterator
/**
* Return the current element.
- *
- * @return mixed
*/
public function current()
{
@@ -108,8 +94,6 @@ class Demultiplexer implements Iterator
/**
* Return the key of the current element.
- *
- * @return mixed
*/
public function key()
{
@@ -118,30 +102,23 @@ class Demultiplexer implements Iterator
/**
* Move forward to next element.
- *
- * @return void
*/
- public function next()
+ public function next(): void
{
$this->_current = null;
-
- return $this->_iterator->next();
+ $this->_iterator->next();
}
/**
* Rewind the iterator to the first element.
- *
- * @return void
*/
- public function rewind()
+ public function rewind(): void
{
- return $this->_iterator->rewind();
+ $this->_iterator->rewind();
}
/**
* Check if current position is valid.
- *
- * @return bool
*/
public function valid(): bool
{
diff --git a/Source/Directory.php b/Source/Directory.php
index 09cf673..7fa5ab4 100644
--- a/Source/Directory.php
+++ b/Source/Directory.php
@@ -42,22 +42,16 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Directory.
*
* Extending the SPL DirectoryIterator class.
- *
- * @license New BSD License
*/
class Directory extends \DirectoryIterator
{
/**
* SplFileInfo classname.
- *
- * @var string
*/
protected $_splFileInfoClass = null;
/**
* Relative path.
- *
- * @var string
*/
protected $_relativePath = null;
@@ -67,9 +61,6 @@ class Directory extends \DirectoryIterator
* Constructor.
* Please, see \DirectoryIterator::__construct() method.
* We add the $splFileInfoClass parameter.
- *
- * @param string $path Path.
- * @param string $splFileInfoClass SplFileInfo classname.
*/
public function __construct(string $path, string $splFileInfoClass = null)
{
@@ -83,8 +74,6 @@ class Directory extends \DirectoryIterator
/**
* Current.
* Please, see \DirectoryIterator::current() method.
- *
- * @return mixed
*/
public function current()
{
@@ -95,7 +84,7 @@ class Directory extends \DirectoryIterator
$out->setInfoClass($this->_splFileInfoClass);
$out = $out->getFileInfo();
- if ($out instanceof \Hoa\Iterator\SplFileInfo) {
+ if ($out instanceof SplFileInfo) {
$out->setRelativePath($this->getRelativePath());
}
}
@@ -105,11 +94,8 @@ class Directory extends \DirectoryIterator
/**
* Set relative path.
- *
- * @param string $relativePath Relative path.
- * @return string
*/
- protected function setRelativePath($path): string
+ protected function setRelativePath($path): ?string
{
$old = $this->_relativePath;
$this->_relativePath = $path;
@@ -119,8 +105,6 @@ class Directory extends \DirectoryIterator
/**
* Get relative path (if given).
- *
- * @return string
*/
public function getRelativePath(): string
{
diff --git a/Source/Exception.php b/Source/Exception.php
index 6a992d8..23669b2 100644
--- a/Source/Exception.php
+++ b/Source/Exception.php
@@ -44,8 +44,6 @@ use Hoa\Exception as HoaException;
* Class \Hoa\Iterator\Exception.
*
* Extending the \Hoa\Exception\Exception class.
- *
- * @license New BSD License
*/
class Exception extends HoaException
{
diff --git a/Source/FileSystem.php b/Source/FileSystem.php
index f0e9a62..a5e4f75 100644
--- a/Source/FileSystem.php
+++ b/Source/FileSystem.php
@@ -42,15 +42,11 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\FileSystem.
*
* Extending the SPL FileSystemIterator class.
- *
- * @license New BSD License
*/
class FileSystem extends \FilesystemIterator
{
/**
* SplFileInfo classname.
- *
- * @var string
*/
protected $_splFileInfoClass = null;
@@ -60,10 +56,6 @@ class FileSystem extends \FilesystemIterator
* Constructor.
* Please, see \FileSystemIterator::__construct() method.
* We add the $splFileInfoClass parameter.
- *
- * @param string $path Path.
- * @param int $flags Flags.
- * @param string $splFileInfoClass SplFileInfo classname.
*/
public function __construct(string $path, int $flags = null, string $splFileInfoClass = null)
{
@@ -81,8 +73,6 @@ class FileSystem extends \FilesystemIterator
/**
* Current.
* Please, see \FileSystemIterator::current() method.
- *
- * @return mixed
*/
public function current()
{
diff --git a/Source/Filter.php b/Source/Filter.php
index 6dcd92b..e487299 100644
--- a/Source/Filter.php
+++ b/Source/Filter.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Filter.
*
* Extending the SPL FilterIterator class.
- *
- * @license New BSD License
*/
abstract class Filter extends \FilterIterator
{
diff --git a/Source/Glob.php b/Source/Glob.php
index 115a5a4..a724c77 100644
--- a/Source/Glob.php
+++ b/Source/Glob.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Glob.
*
* Extending the SPL GlobIterator class.
- *
- * @license New BSD License
*/
class Glob extends \GlobIterator
{
diff --git a/Source/Infinite.php b/Source/Infinite.php
index 182b1bf..e3ff56e 100644
--- a/Source/Infinite.php
+++ b/Source/Infinite.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Infinite.
*
* Extending the SPL InfiniteIterator class.
- *
- * @license New BSD License
*/
class Infinite extends \InfiniteIterator
{
diff --git a/Source/Iterator.php b/Source/Iterator.php
index 6a46192..5472918 100644
--- a/Source/Iterator.php
+++ b/Source/Iterator.php
@@ -44,8 +44,6 @@ use Hoa\Consistency;
* Interface \Hoa\Iterator.
*
* Extending the SPL Iterator interface.
- *
- * @license New BSD License
*/
interface Iterator extends \Iterator
{
@@ -54,4 +52,4 @@ interface Iterator extends \Iterator
/**
* Flex entity.
*/
-Consistency::flexEntity('Hoa\Iterator\Iterator');
+Consistency::flexEntity(Iterator::class);
diff --git a/Source/IteratorIterator.php b/Source/IteratorIterator.php
index 89ef8b8..c4f29fc 100644
--- a/Source/IteratorIterator.php
+++ b/Source/IteratorIterator.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\IteratorIterator.
*
* Extending the SPL IteratorIterator class.
- *
- * @license New BSD License
*/
class IteratorIterator extends \IteratorIterator
{
diff --git a/Source/Limit.php b/Source/Limit.php
index 2c63680..c18779f 100644
--- a/Source/Limit.php
+++ b/Source/Limit.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Limit.
*
* Extending the SPL LimitIterator class.
- *
- * @license New BSD License
*/
class Limit extends \LimitIterator
{
diff --git a/Source/Lookahead.php b/Source/Lookahead.php
index 5ccec47..7b77c71 100644
--- a/Source/Lookahead.php
+++ b/Source/Lookahead.php
@@ -42,36 +42,26 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Lookahead.
*
* Look ahead iterator.
- *
- * @license New BSD License
*/
class Lookahead extends IteratorIterator implements Outer
{
/**
* Current iterator.
- *
- * @var \Iterator
*/
protected $_iterator = null;
/**
* Current key.
- *
- * @var mixed
*/
protected $_key = 0;
/**
* Current value.
- *
- * @var mixed
*/
protected $_current = null;
/**
* Whether the current element is valid or not.
- *
- * @var bool
*/
protected $_valid = false;
@@ -79,10 +69,8 @@ class Lookahead extends IteratorIterator implements Outer
/**
* Construct.
- *
- * @param \Iterator $iterator Iterator.
*/
- public function __construct(\Iterator $iterator)
+ public function __construct(iterable $iterator)
{
$this->_iterator = $iterator;
@@ -91,18 +79,14 @@ class Lookahead extends IteratorIterator implements Outer
/**
* Get inner iterator.
- *
- * @return \Iterator
*/
- public function getInnerIterator(): \Iterator
+ public function getInnerIterator(): iterable
{
return $this->_iterator;
}
/**
* Return the current element.
- *
- * @return mixed
*/
public function current()
{
@@ -111,8 +95,6 @@ class Lookahead extends IteratorIterator implements Outer
/**
* Return the key of the current element.
- *
- * @return mixed
*/
public function key()
{
@@ -121,10 +103,8 @@ class Lookahead extends IteratorIterator implements Outer
/**
* Move forward to next element.
- *
- * @return void
*/
- public function next()
+ public function next(): void
{
$innerIterator = $this->getInnerIterator();
$this->_valid = $innerIterator->valid();
@@ -136,26 +116,20 @@ class Lookahead extends IteratorIterator implements Outer
$this->_key = $innerIterator->key();
$this->_current = $innerIterator->current();
- return $innerIterator->next();
+ $innerIterator->next();
}
/**
* Rewind the iterator to the first element.
- *
- * @return void
*/
- public function rewind()
+ public function rewind(): void
{
- $out = $this->getInnerIterator()->rewind();
+ $this->getInnerIterator()->rewind();
$this->next();
-
- return $out;
}
/**
* Check if current position is valid.
- *
- * @return bool
*/
public function valid(): bool
{
@@ -164,8 +138,6 @@ class Lookahead extends IteratorIterator implements Outer
/**
* Check whether there is a next element.
- *
- * @return bool
*/
public function hasNext(): bool
{
@@ -174,8 +146,6 @@ class Lookahead extends IteratorIterator implements Outer
/**
* Get next value.
- *
- * @return mixed
*/
public function getNext()
{
@@ -184,8 +154,6 @@ class Lookahead extends IteratorIterator implements Outer
/**
* Get next key.
- *
- * @return mixed
*/
public function getNextKey()
{
diff --git a/Source/Lookbehind.php b/Source/Lookbehind.php
index f700a65..66d484b 100644
--- a/Source/Lookbehind.php
+++ b/Source/Lookbehind.php
@@ -42,29 +42,21 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Lookbehind.
*
* Look behind iterator.
- *
- * @license New BSD License
*/
class Lookbehind extends IteratorIterator implements Outer
{
/**
* Current iterator.
- *
- * @var \Iterator
*/
protected $_iterator = null;
/**
* Previous key.
- *
- * @var mixed
*/
protected $_previousKey = -1;
/**
* Previous value.
- *
- * @var mixed
*/
protected $_previousCurrent = null;
@@ -72,10 +64,8 @@ class Lookbehind extends IteratorIterator implements Outer
/**
* Construct.
- *
- * @param \Iterator $iterator Iterator.
*/
- public function __construct(\Iterator $iterator)
+ public function __construct(iterable $iterator)
{
$this->_iterator = $iterator;
@@ -84,18 +74,14 @@ class Lookbehind extends IteratorIterator implements Outer
/**
* Get inner iterator.
- *
- * @return \Iterator
*/
- public function getInnerIterator(): \Iterator
+ public function getInnerIterator(): iterable
{
return $this->_iterator;
}
/**
* Return the current element.
- *
- * @return mixed
*/
public function current()
{
@@ -104,8 +90,6 @@ class Lookbehind extends IteratorIterator implements Outer
/**
* Return the key of the current element.
- *
- * @return mixed
*/
public function key()
{
@@ -114,34 +98,28 @@ class Lookbehind extends IteratorIterator implements Outer
/**
* Move forward to next element.
- *
- * @return void
*/
- public function next()
+ public function next(): void
{
$this->_previousKey = $this->key();
$this->_previousCurrent = $this->current();
- return $this->getInnerIterator()->next();
+ $this->getInnerIterator()->next();
}
/**
* Rewind the iterator to the first element.
- *
- * @return void
*/
- public function rewind()
+ public function rewind(): void
{
$this->_previousKey = -1;
$this->_previousCurrent = null;
- return $this->getInnerIterator()->rewind();
+ $this->getInnerIterator()->rewind();
}
/**
* Check if current position is valid.
- *
- * @return bool
*/
public function valid(): bool
{
@@ -150,8 +128,6 @@ class Lookbehind extends IteratorIterator implements Outer
/**
* Check whether there is a previous element.
- *
- * @return bool
*/
public function hasPrevious(): bool
{
@@ -160,8 +136,6 @@ class Lookbehind extends IteratorIterator implements Outer
/**
* Get previous value.
- *
- * @return mixed
*/
public function getPrevious()
{
@@ -170,8 +144,6 @@ class Lookbehind extends IteratorIterator implements Outer
/**
* Get previous key.
- *
- * @return mixed
*/
public function getPreviousKey()
{
diff --git a/Source/Map.php b/Source/Map.php
index 4fb6371..7b1995a 100644
--- a/Source/Map.php
+++ b/Source/Map.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Map.
*
* Extending the SPL ArrayIterator class.
- *
- * @license New BSD License
*/
class Map extends \ArrayIterator
{
diff --git a/Source/Mock.php b/Source/Mock.php
index eda96ac..0cab651 100644
--- a/Source/Mock.php
+++ b/Source/Mock.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Mock.
*
* Extending the SPL EmptyIterator class.
- *
- * @license New BSD License
*/
class Mock extends \EmptyIterator
{
diff --git a/Source/Multiple.php b/Source/Multiple.php
index 0004a64..b291666 100644
--- a/Source/Multiple.php
+++ b/Source/Multiple.php
@@ -42,15 +42,11 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Multiple.
*
* Extending the SPL MultipleIterator class.
- *
- * @license New BSD License
*/
class Multiple extends \MultipleIterator
{
/**
* Default value for each $infos.
- *
- * @var array
*/
protected $_infos = [];
@@ -60,11 +56,6 @@ class Multiple extends \MultipleIterator
* Attach iterator informations.
* Add the $default argument that will be use when the iterator has reached
* its end.
- *
- * @param \Iterator $iterator Iterator.
- * @param string $infos Informations to attach.
- * @param mixed $default Default value.
- * @return void
*/
public function attachIterator(
\Iterator $iterator,
@@ -84,8 +75,6 @@ class Multiple extends \MultipleIterator
/**
* Get the registered iterator instances.
- *
- * @return array
*/
public function current(): array
{
diff --git a/Source/NoRewind.php b/Source/NoRewind.php
index 5c3b050..16e176d 100644
--- a/Source/NoRewind.php
+++ b/Source/NoRewind.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\NoRewind.
*
* Extending the SPL NoRewindIterator class.
- *
- * @license New BSD License
*/
class NoRewind extends \NoRewindIterator
{
diff --git a/Source/Outer.php b/Source/Outer.php
index 8b8b555..4b725fa 100644
--- a/Source/Outer.php
+++ b/Source/Outer.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Interface \Hoa\Iterator\Outer.
*
* Extending the SPL OuterIterator interface.
- *
- * @license New BSD License
*/
interface Outer extends \OuterIterator
{
diff --git a/Source/Recursive/CallbackFilter.php b/Source/Recursive/CallbackFilter.php
index 06af2e3..133b8b1 100644
--- a/Source/Recursive/CallbackFilter.php
+++ b/Source/Recursive/CallbackFilter.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator\Recursive;
* Class \Hoa\Iterator\Recursive\CallbackFilter.
*
* Extending the SPL RecursiveCallbackFilterIterator class.
- *
- * @license New BSD License
*/
class CallbackFilter extends \RecursiveCallbackFilterIterator
{
diff --git a/Source/Recursive/Directory.php b/Source/Recursive/Directory.php
index 1a3bca7..faf4682 100644
--- a/Source/Recursive/Directory.php
+++ b/Source/Recursive/Directory.php
@@ -42,31 +42,18 @@ namespace Hoa\Iterator\Recursive;
* Class \Hoa\Iterator\Recursive\Directory.
*
* Extending the SPL RecursiveDirectoryIterator class.
- *
- * @license New BSD License
*/
class Directory extends \RecursiveDirectoryIterator
{
/**
* SplFileInfo classname.
- *
- * @var string
*/
protected $_splFileInfoClass = null;
/**
* Relative path.
- *
- * @var string
- */
- protected $_relativePath = 0;
-
- /**
- * Workaround for the bug #65136.
- *
- * @var string
*/
- private static $_handlePath = null;
+ protected $_relativePath = null;
@@ -74,10 +61,6 @@ class Directory extends \RecursiveDirectoryIterator
* Constructor.
* Please, see \RecursiveDirectoryIterator::__construct() method.
* We add the $splFileInfoClass parameter.
- *
- * @param string $path Path.
- * @param int $flags Flags.
- * @param string $splFileInfoClass SplFileInfo classname.
*/
public function __construct(string $path, int $flags = null, string $splFileInfoClass = null)
{
@@ -87,13 +70,7 @@ class Directory extends \RecursiveDirectoryIterator
parent::__construct($path, $flags);
}
- if (null !== self::$_handlePath) {
- $this->_relativePath = self::$_handlePath;
- self::$_handlePath = null;
- } else {
- $this->_relativePath = $path;
- }
-
+ $this->_relativePath = $path;
$this->setSplFileInfoClass($splFileInfoClass);
return;
@@ -102,8 +79,6 @@ class Directory extends \RecursiveDirectoryIterator
/**
* Current.
* Please, see \RecursiveDirectoryIterator::current() method.
- *
- * @return mixed
*/
public function current()
{
@@ -125,38 +100,26 @@ class Directory extends \RecursiveDirectoryIterator
/**
* Get children.
* Please, see \RecursiveDirectoryIterator::getChildren() method.
- *
- * @return mixed
*/
public function getChildren()
{
- self::$_handlePath = $this->getRelativePath();
- $out = parent::getChildren();
-
- if ($out instanceof \RecursiveDirectoryIterator) {
- $out->setSplFileInfoClass($this->_splFileInfoClass);
- }
+ $out = parent::getChildren();
+ $out->_relativePath = $this->getRelativePath();
+ $out->setSplFileInfoClass($this->_splFileInfoClass);
return $out;
}
/**
* Set SplFileInfo classname.
- *
- * @param string $splFileInfoClass SplFileInfo classname.
- * @return void
*/
- public function setSplFileInfoClass(string $splFileInfoClass): void
+ public function setSplFileInfoClass(?string $splFileInfoClass): void
{
$this->_splFileInfoClass = $splFileInfoClass;
-
- return;
}
/**
* Get relative path (if given).
- *
- * @return string
*/
public function getRelativePath(): string
{
diff --git a/Source/Recursive/Filter.php b/Source/Recursive/Filter.php
index ff32e75..8dd128f 100644
--- a/Source/Recursive/Filter.php
+++ b/Source/Recursive/Filter.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator\Recursive;
* Class \Hoa\Iterator\Recursive\Filter.
*
* Extending the SPL RecursiveFilterIterator class.
- *
- * @license New BSD License
*/
abstract class Filter extends \RecursiveFilterIterator
{
diff --git a/Source/Recursive/Iterator.php b/Source/Recursive/Iterator.php
index 1651be5..55cf320 100644
--- a/Source/Recursive/Iterator.php
+++ b/Source/Recursive/Iterator.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator\Recursive;
* Class \Hoa\Iterator\Recursive\Iterator.
*
* Extending the SPL RecursiveIteratorIterator class.
- *
- * @license New BSD License
*/
class Iterator extends \RecursiveIteratorIterator
{
diff --git a/Source/Recursive/Map.php b/Source/Recursive/Map.php
index b0717a5..11e14dd 100644
--- a/Source/Recursive/Map.php
+++ b/Source/Recursive/Map.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator\Recursive;
* Class \Hoa\Iterator\Recursive\Map.
*
* Extending the SPL RecursiveArrayIterator class.
- *
- * @license New BSD License
*/
class Map extends \RecursiveArrayIterator
{
diff --git a/Source/Recursive/Mock.php b/Source/Recursive/Mock.php
index 8d029ad..be79fd2 100644
--- a/Source/Recursive/Mock.php
+++ b/Source/Recursive/Mock.php
@@ -43,15 +43,11 @@ namespace Hoa\Iterator\Recursive;
*
* Mock a recursive iterator with no children.
* It allows to use regular iterators with a recursive iterator iterator.
- *
- * @license New BSD License
*/
class Mock implements Recursive
{
/**
* Current iterator.
- *
- * @var \Traversable
*/
protected $_iterator = null;
@@ -59,10 +55,8 @@ class Mock implements Recursive
/**
* Constructor.
- *
- * @param \Traversable $iterator Iterator.
*/
- public function __construct(\Traversable $iterator)
+ public function __construct(iterable $iterator)
{
if ($iterator instanceof \IteratorAggregate) {
$iterator = $iterator->getIterator();
@@ -75,8 +69,6 @@ class Mock implements Recursive
/**
* Return the current element.
- *
- * @return mixed
*/
public function current()
{
@@ -85,8 +77,6 @@ class Mock implements Recursive
/**
* Return the key of the current element.
- *
- * @return mixed
*/
public function key()
{
@@ -95,22 +85,18 @@ class Mock implements Recursive
/**
* Move forward to next element.
- *
- * @return void
*/
- public function next()
+ public function next(): void
{
- return $this->_iterator->next();
+ $this->_iterator->next();
}
/**
* Rewind the iterator to the first element.
- *
- * @return void
*/
- public function rewind()
+ public function rewind(): void
{
- return $this->_iterator->rewind();
+ $this->_iterator->rewind();
}
/**
@@ -126,8 +112,6 @@ class Mock implements Recursive
/**
* Return an iterator for the current entry.
* It's a fake, we return null.
- *
- * @return void
*/
public function getChildren()
{
@@ -137,8 +121,6 @@ class Mock implements Recursive
/**
* Return if an iterator can be created for the current entry.
* It's a fake, we return false.
- *
- * @return bool
*/
public function hasChildren(): bool
{
diff --git a/Source/Recursive/Recursive.php b/Source/Recursive/Recursive.php
index c102444..5c5f816 100644
--- a/Source/Recursive/Recursive.php
+++ b/Source/Recursive/Recursive.php
@@ -44,8 +44,6 @@ use Hoa\Consistency;
* Class \Hoa\Iterator\Recursive.
*
* Extending the SPL RecursiveIterator interface.
- *
- * @license New BSD License
*/
interface Recursive extends \RecursiveIterator
{
@@ -54,4 +52,4 @@ interface Recursive extends \RecursiveIterator
/**
* Flex entity.
*/
-Consistency::flexEntity('Hoa\Iterator\Recursive\Recursive');
+Consistency::flexEntity(Recursive::class);
diff --git a/Source/Recursive/RegularExpression.php b/Source/Recursive/RegularExpression.php
index 75defc0..e91bbe0 100644
--- a/Source/Recursive/RegularExpression.php
+++ b/Source/Recursive/RegularExpression.php
@@ -48,25 +48,11 @@ use Hoa\Iterator;
* scratch without extending the existing class.
*
* Inspired by hhvm://hphp/system/php/spl/iterators/RecursiveRegexIterator.php
- *
- * @license New BSD License
*/
class RegularExpression extends Iterator\RegularExpression implements Recursive
{
/**
* Constructor.
- *
- * @param \RecursiveIterator $iterator The recursive iterator to
- * apply this regex filter to.
- * @param string $regex The regular expression to
- * match.
- * @param int $mode Operation mode, please see the
- * \RegexIterator::setMode method.
- * @param int $flags Special flags, please see the
- * \RegexIterator::setFlags method.
- * @param int $pregFlags Regular expression flags,
- * please see
- * \RegexIterator constants.
*/
public function __construct(
\RecursiveIterator $iterator,
@@ -82,8 +68,6 @@ class RegularExpression extends Iterator\RegularExpression implements Recursive
/**
* Get accept status.
- *
- * @return bool
*/
public function accept(): bool
{
@@ -94,10 +78,8 @@ class RegularExpression extends Iterator\RegularExpression implements Recursive
/**
* Get an iterator for the current entry.
- *
- * @return \Hoa\Iterator\Recursive\RegularExpression
*/
- public function getChildren(): RegularExpression
+ public function getChildren(): self
{
return new static(
true === $this->hasChildren()
@@ -112,8 +94,6 @@ class RegularExpression extends Iterator\RegularExpression implements Recursive
/**
* Check whether an iterator can be obtained for the current entry.
- *
- * @return bool
*/
public function hasChildren(): bool
{
diff --git a/Source/RegularExpression.php b/Source/RegularExpression.php
index 5e96445..28b1362 100644
--- a/Source/RegularExpression.php
+++ b/Source/RegularExpression.php
@@ -46,108 +46,78 @@ namespace Hoa\Iterator;
* scratch without extending the existing class.
*
* Inspired by hhvm://hphp/system/php/spl/iterators/RegexIterator.php
- *
- * @license New BSD License
*/
class RegularExpression extends Filter
{
/**
* Flag: match the entry key instead of the entry value.
- *
- * @const int
*/
public const USE_KEY = 1;
/**
* Flag: invert match.
- *
- * @const int
*/
public const INVERT_MATCH = 2;
/**
* Mode and preg flag: only execute match (filter) for the current entry.
- *
- * @const int
*/
public const MATCH = 0;
/**
* Mode and preg flag: first match for the current entry.
- *
- * @const int
*/
public const GET_MATCH = 1;
/**
* Mode and preg flag: all matches for the current entry.
- *
- * @const int
*/
public const ALL_MATCHES = 2;
/**
* Mode and preg flag: split values for the current entry.
- *
- * @const int
*/
public const SPLIT = 3;
/**
* Mode and preg flag: replace the current entry.
- *
- * @const int
*/
public const REPLACE = 4;
/**
* The regular expression to match.
- *
- * @var string
*/
protected $_regex = null;
/**
* Operation mode, see the \RegexIterator::setMode method for a list of
* modes.
- *
- * @var int
*/
protected $_mode = 0;
/**
* Special flags, see the \RegexIterator::setFlag method for a list of
* available flags.
- *
- * @var int
*/
protected $_flags = 0;
/**
* The regular expression flags. See constants.
- *
- * @var int
*/
protected $_pregFlags = 0;
/**
* Current key.
- *
- * @var int
*/
protected $_key = 0;
/**
* Current value.
- *
- * @var string
*/
protected $_current = null;
/**
* Replacement.
- *
- * @var string
*/
public $replacement = null;
@@ -155,21 +125,9 @@ class RegularExpression extends Filter
/**
* Constructor.
- *
- * @param \RecursiveIterator $iterator The recursive iterator to
- * apply this regex filter to.
- * @param string $regex The regular expression to
- * match.
- * @param int $mode Operation mode, please see the
- * \RegexIterator::setMode method.
- * @param int $flags Special flags, please see the
- * \RegexIterator::setFlags method.
- * @param int $pregFlags Regular expression flags,
- * please see
- * \RegexIterator constants.
*/
public function __construct(
- \Iterator $iterator,
+ iterable $iterator,
string $regex,
int $mode = self::MATCH,
int $flags = 0,
@@ -188,8 +146,6 @@ class RegularExpression extends Filter
/**
* Get accept status.
- *
- * @return bool
*/
public function accept(): bool
{
@@ -296,8 +252,6 @@ class RegularExpression extends Filter
/**
* Get current key.
- *
- * @return int
*/
public function key(): int
{
@@ -306,8 +260,6 @@ class RegularExpression extends Filter
/**
* Get current value.
- *
- * @return string
*/
public function current(): string
{
@@ -316,9 +268,6 @@ class RegularExpression extends Filter
/**
* Set mode.
- *
- * @param int $mode Mode.
- * @return void
*/
public function setMode(int $mode): void
{
@@ -329,50 +278,34 @@ class RegularExpression extends Filter
}
$this->_mode = $mode;
-
- return;
}
/**
* Set flags.
- *
- * @param int $flags Flags.
- * @return void
*/
public function setFlags(int $flags): void
{
$this->_flags = $flags;
-
- return;
}
/**
* Set preg flags.
- *
- * @param int $pregFlags Preg flags.
- * @return void
*/
public function setPregFlags(int $pregFlags): void
{
$this->_pregFlags = $pregFlags;
-
- return;
}
/**
* Get regular expression.
- *
- * @return string
*/
- public function getRegex(): string
+ public function getRegex(): ?string
{
return $this->_regex;
}
/**
* Get mode.
- *
- * @return int
*/
public function getMode(): int
{
@@ -381,8 +314,6 @@ class RegularExpression extends Filter
/**
* Get flags.
- *
- * @return int
*/
public function getFlags(): int
{
@@ -391,8 +322,6 @@ class RegularExpression extends Filter
/**
* Get preg flags.
- *
- * @return int
*/
public function getPregFlags(): int
{
diff --git a/Source/Repeater.php b/Source/Repeater.php
index efbb898..ed17ce4 100644
--- a/Source/Repeater.php
+++ b/Source/Repeater.php
@@ -42,36 +42,26 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\Repeater.
*
* Repeat an iterator n-times.
- *
- * @license New BSD License
*/
class Repeater implements Iterator
{
/**
* Current iterator.
- *
- * @var \Traversable
*/
protected $_iterator = null;
/**
* Maximum repetition.
- *
- * @var int
*/
protected $_n = 1;
/**
* Current repetition.
- *
- * @var int
*/
protected $_i = 1;
/**
* Body (callable to execute each time).
- *
- * @var callable
*/
protected $_body = null;
@@ -79,13 +69,8 @@ class Repeater implements Iterator
/**
* Constructor.
- *
- * @param \Traversable $iterator Iterator.
- * @param int $n Repeat $n-times.
- * @param callable $body Body.
- * @throws \Hoa\Iterator\Exception
*/
- public function __construct(\Traversable $iterator, int $n, callable $body = null)
+ public function __construct(iterable $iterator, int $n, callable $body = null)
{
if (0 >= $n) {
throw new Exception(
@@ -108,8 +93,6 @@ class Repeater implements Iterator
/**
* Return the current element.
- *
- * @return mixed
*/
public function current()
{
@@ -118,8 +101,6 @@ class Repeater implements Iterator
/**
* Return the key of the current element.
- *
- * @return mixed
*/
public function key()
{
@@ -128,28 +109,22 @@ class Repeater implements Iterator
/**
* Move forward to next element.
- *
- * @return void
*/
- public function next()
+ public function next(): void
{
- return $this->_iterator->next();
+ $this->_iterator->next();
}
/**
* Rewind the iterator to the first element.
- *
- * @return void
*/
- public function rewind()
+ public function rewind(): void
{
- return $this->_iterator->rewind();
+ $this->_iterator->rewind();
}
/**
* Check if current position is valid.
- *
- * @return bool
*/
public function valid(): bool
{
diff --git a/Source/Seekable.php b/Source/Seekable.php
index dcfb303..7150c53 100644
--- a/Source/Seekable.php
+++ b/Source/Seekable.php
@@ -42,8 +42,6 @@ namespace Hoa\Iterator;
* Interface \Hoa\IteratorSeekable.
*
* Extending the SPL SeekableIterator interface.
- *
- * @license New BSD License
*/
interface Seekable extends \SeekableIterator
{
diff --git a/Source/SplFileInfo.php b/Source/SplFileInfo.php
index 0a2353b..aee861e 100644
--- a/Source/SplFileInfo.php
+++ b/Source/SplFileInfo.php
@@ -42,22 +42,16 @@ namespace Hoa\Iterator;
* Class \Hoa\Iterator\SplFileInfo.
*
* Enhance SplFileInfo implementation.
- *
- * @license New BSD License
*/
class SplFileInfo extends \SplFileInfo
{
/**
* Hash.
- *
- * @var string
*/
protected $_hash = null;
/**
* Relative path.
- *
- * @var string
*/
protected $_relativePath = null;
@@ -65,9 +59,6 @@ class SplFileInfo extends \SplFileInfo
/**
* Construct.
- *
- * @param string $filename Filename.
- * @param string $relativePath Relative path.
*/
public function __construct(string $filename, string $relativePath = null)
{
@@ -84,8 +75,6 @@ class SplFileInfo extends \SplFileInfo
/**
* Get the hash.
- *
- * @return string
*/
public function getHash(): string
{
@@ -94,8 +83,6 @@ class SplFileInfo extends \SplFileInfo
/**
* Get the MTime.
- *
- * @return int
*/
public function getMTime(): int
{
@@ -108,11 +95,8 @@ class SplFileInfo extends \SplFileInfo
/**
* Set relative path.
- *
- * @param string $relativePath Relative path.
- * @return string
*/
- public function setRelativePath(string $relativePath): string
+ public function setRelativePath(string $relativePath): ?string
{
$old = $this->_relativePath;
$this->_relativePath = $relativePath;
@@ -122,18 +106,14 @@ class SplFileInfo extends \SplFileInfo
/**
* Get relative path (if given).
- *
- * @return string
*/
- public function getRelativePath(): string
+ public function getRelativePath(): ?string
{
return $this->_relativePath;
}
/**
* Get relative pathname (if possible).
- *
- * @return string
*/
public function getRelativePathname(): string
{
diff --git a/Test/Unit/Buffer.php b/Test/Unit/Buffer.php
index e7a7a75..a2a4909 100644
--- a/Test/Unit/Buffer.php
+++ b/Test/Unit/Buffer.php
@@ -107,18 +107,9 @@ class Buffer extends Test\Unit\Suite
->isEqualTo(['a', 'b', 'c', 'd', 'e'])
->array(iterator_to_array($this->invoke($iterator)->getBuffer()))
->isEqualTo([
- 0 => [
- $iterator::BUFFER_KEY => 3,
- $iterator::BUFFER_VALUE => 'd'
- ],
- 1 => [
- $iterator::BUFFER_KEY => 4,
- $iterator::BUFFER_VALUE => 'e'
- ],
- 2 => [
- $iterator::BUFFER_KEY => null,
- $iterator::BUFFER_VALUE => null
- ]
+ 0 => [3, 'd'],
+ 1 => [4, 'e'],
+ 2 => [null, null]
]);
}
@@ -132,30 +123,12 @@ class Buffer extends Test\Unit\Suite
->isEqualTo(['a', 'b', 'c', 'd', 'e'])
->array(iterator_to_array($this->invoke($iterator)->getBuffer()))
->isEqualTo([
- 0 => [
- $iterator::BUFFER_KEY => 0,
- $iterator::BUFFER_VALUE => 'a'
- ],
- 1 => [
- $iterator::BUFFER_KEY => 1,
- $iterator::BUFFER_VALUE => 'b'
- ],
- 2 => [
- $iterator::BUFFER_KEY => 2,
- $iterator::BUFFER_VALUE => 'c'
- ],
- 3 => [
- $iterator::BUFFER_KEY => 3,
- $iterator::BUFFER_VALUE => 'd'
- ],
- 4 => [
- $iterator::BUFFER_KEY => 4,
- $iterator::BUFFER_VALUE => 'e'
- ],
- 5 => [
- $iterator::BUFFER_KEY => null,
- $iterator::BUFFER_VALUE => null
- ]
+ 0 => [0, 'a'],
+ 1 => [1, 'b'],
+ 2 => [2, 'c'],
+ 3 => [3, 'd'],
+ 4 => [4, 'e'],
+ 5 => [null, null]
]);
}
@@ -169,10 +142,7 @@ class Buffer extends Test\Unit\Suite
->isEqualTo(['a', 'b', 'c', 'd', 'e'])
->array(iterator_to_array($this->invoke($iterator)->getBuffer()))
->isEqualTo([
- 0 => [
- $iterator::BUFFER_KEY => null,
- $iterator::BUFFER_VALUE => null
- ]
+ 0 => [null, null]
]);
}
@@ -227,10 +197,7 @@ class Buffer extends Test\Unit\Suite
->isNull()
->array(iterator_to_array($this->invoke($result)->getBuffer()))
->isEqualTo([
- 0 => [
- $result::BUFFER_KEY => 0,
- $result::BUFFER_VALUE => 'a'
- ]
+ 0 => [0, 'a']
])
->boolean($result->valid())
@@ -243,14 +210,8 @@ class Buffer extends Test\Unit\Suite
->isNull()
->array(iterator_to_array($this->invoke($result)->getBuffer()))
->isEqualTo([
- 0 => [
- $result::BUFFER_KEY => 0,
- $result::BUFFER_VALUE => 'a'
- ],
- 1 => [
- $result::BUFFER_KEY => 1,
- $result::BUFFER_VALUE => 'b'
- ]
+ 0 => [0, 'a'],
+ 1 => [1, 'b']
])
->boolean($result->valid())
@@ -263,18 +224,9 @@ class Buffer extends Test\Unit\Suite
->isNull()
->array(iterator_to_array($this->invoke($result)->getBuffer()))
->isEqualTo([
- 0 => [
- $result::BUFFER_KEY => 0,
- $result::BUFFER_VALUE => 'a'
- ],
- 1 => [
- $result::BUFFER_KEY => 1,
- $result::BUFFER_VALUE => 'b'
- ],
- 2 => [
- $result::BUFFER_KEY => 2,
- $result::BUFFER_VALUE => 'c'
- ]
+ 0 => [0, 'a'],
+ 1 => [1, 'b'],
+ 2 => [2, 'c']
])
->boolean($result->valid())
@@ -287,18 +239,9 @@ class Buffer extends Test\Unit\Suite
->isNull()
->array(iterator_to_array($this->invoke($result)->getBuffer()))
->isEqualTo([
- 0 => [
- $result::BUFFER_KEY => 0,
- $result::BUFFER_VALUE => 'a'
- ],
- 1 => [
- $result::BUFFER_KEY => 1,
- $result::BUFFER_VALUE => 'b'
- ],
- 2 => [
- $result::BUFFER_KEY => 2,
- $result::BUFFER_VALUE => 'c'
- ]
+ 0 => [0, 'a'],
+ 1 => [1, 'b'],
+ 2 => [2, 'c']
])
->boolean($result->valid())
@@ -311,18 +254,9 @@ class Buffer extends Test\Unit\Suite
->isNull()
->array(iterator_to_array($this->invoke($result)->getBuffer()))
->isEqualTo([
- 0 => [
- $result::BUFFER_KEY => 0,
- $result::BUFFER_VALUE => 'a'
- ],
- 1 => [
- $result::BUFFER_KEY => 1,
- $result::BUFFER_VALUE => 'b'
- ],
- 2 => [
- $result::BUFFER_KEY => 2,
- $result::BUFFER_VALUE => 'c'
- ]
+ 0 => [0, 'a'],
+ 1 => [1, 'b'],
+ 2 => [2, 'c']
])
->boolean($result->valid())
@@ -335,18 +269,9 @@ class Buffer extends Test\Unit\Suite
->isNull()
->array(iterator_to_array($this->invoke($result)->getBuffer()))
->isEqualTo([
- 0 => [
- $result::BUFFER_KEY => 0,
- $result::BUFFER_VALUE => 'a'
- ],
- 1 => [
- $result::BUFFER_KEY => 1,
- $result::BUFFER_VALUE => 'b'
- ],
- 2 => [
- $result::BUFFER_KEY => 2,
- $result::BUFFER_VALUE => 'c'
- ]
+ 0 => [0, 'a'],
+ 1 => [1, 'b'],
+ 2 => [2, 'c']
])
->boolean($result->valid())
@@ -359,18 +284,9 @@ class Buffer extends Test\Unit\Suite
->isNull()
->array(iterator_to_array($this->invoke($result)->getBuffer()))
->isEqualTo([
- 0 => [
- $result::BUFFER_KEY => 0,
- $result::BUFFER_VALUE => 'a'
- ],
- 1 => [
- $result::BUFFER_KEY => 1,
- $result::BUFFER_VALUE => 'b'
- ],
- 2 => [
- $result::BUFFER_KEY => 2,
- $result::BUFFER_VALUE => 'c'
- ]
+ 0 => [0, 'a'],
+ 1 => [1, 'b'],
+ 2 => [2, 'c']
])
->boolean($result->valid())
@@ -383,18 +299,9 @@ class Buffer extends Test\Unit\Suite
->isNull()
->array(iterator_to_array($this->invoke($result)->getBuffer()))
->isEqualTo([
- 0 => [
- $result::BUFFER_KEY => 1,
- $result::BUFFER_VALUE => 'b'
- ],
- 1 => [
- $result::BUFFER_KEY => 2,
- $result::BUFFER_VALUE => 'c'
- ],
- 2 => [
- $result::BUFFER_KEY => null,
- $result::BUFFER_VALUE => null
- ]
+ 0 => [1, 'b'],
+ 1 => [2, 'c'],
+ 2 => [null, null]
])
->boolean($result->valid())
@@ -463,14 +370,8 @@ class Buffer extends Test\Unit\Suite
->array(iterator_to_array($this->invoke($result)->getBuffer()))
->isEqualTo([
- 0 => [
- $result::BUFFER_KEY => 0,
- $result::BUFFER_VALUE => 'a'
- ],
- 1 => [
- $result::BUFFER_KEY => 1,
- $result::BUFFER_VALUE => 'b'
- ]
+ 0 => [0, 'a'],
+ 1 => [1, 'b']
]);
}
diff --git a/Test/Unit/Directory.php b/Test/Unit/Directory.php
index 2b28392..fab29cb 100644
--- a/Test/Unit/Directory.php
+++ b/Test/Unit/Directory.php
@@ -39,6 +39,7 @@ declare(strict_types=1);
namespace Hoa\Iterator\Test\Unit;
use Hoa\Iterator as LUT;
+use Hoa\Protocol;
use Hoa\Test;
/**
@@ -54,10 +55,10 @@ class Directory extends Test\Unit\Suite
{
$this
->given(
- $root = resolve('hoa://Test/Vfs/Root?type=directory'),
- resolve('hoa://Test/Vfs/Root/A?type=file'),
- resolve('hoa://Test/Vfs/Root/Aa?type=file'),
- resolve('hoa://Test/Vfs/Root/Aaa?type=file'),
+ $root = $this->resolve('hoa://Test/Vfs/Root?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/A?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Aa?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Aaa?type=file'),
$iterator = new LUT\Directory($root),
$result = []
)
@@ -83,11 +84,11 @@ class Directory extends Test\Unit\Suite
{
$this
->given(
- $root = resolve('hoa://Test/Vfs/Root?type=directory'),
- resolve('hoa://Test/Vfs/Root/.?type=directory'),
- resolve('hoa://Test/Vfs/Root/..?type=directory'),
- resolve('hoa://Test/Vfs/Root/Skip?type=file'),
- resolve('hoa://Test/Vfs/Root/Gotcha?type=file'),
+ $root = $this->resolve('hoa://Test/Vfs/Root?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/.?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/..?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/Skip?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Gotcha?type=file'),
$iterator = new LUT\Directory($root)
)
->when($result = $iterator->current())
@@ -124,18 +125,18 @@ class Directory extends Test\Unit\Suite
{
$this
->given(
- $root = resolve('hoa://Test/Vfs/Root?type=directory'),
- resolve('hoa://Test/Vfs/Root/A?type=file'),
- resolve('hoa://Test/Vfs/Root/Aa?type=file'),
- resolve('hoa://Test/Vfs/Root/Aaa?type=file'),
- resolve('hoa://Test/Vfs/Root/Foo?type=directory'),
- resolve('hoa://Test/Vfs/Root/Foo/Bar?type=directory'),
- resolve('hoa://Test/Vfs/Root/Foo/Bar/B?type=file'),
- resolve('hoa://Test/Vfs/Root/Foo/Bar/Bb?type=file'),
- resolve('hoa://Test/Vfs/Root/Foo/Bar/Bbb?type=file'),
- resolve('hoa://Test/Vfs/Root/Foo/C?type=file'),
- resolve('hoa://Test/Vfs/Root/Foo/Cc?type=file'),
- resolve('hoa://Test/Vfs/Root/Foo/Ccc?type=file'),
+ $root = $this->resolve('hoa://Test/Vfs/Root?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/A?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Aa?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Aaa?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Foo?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/Foo/Bar?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/Foo/Bar/B?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Foo/Bar/Bb?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Foo/Bar/Bbb?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Foo/C?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Foo/Cc?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/Foo/Ccc?type=file'),
$directory = new LUT\Recursive\Directory($root),
$iterator = new LUT\Recursive\Iterator($directory),
$result = []
@@ -165,13 +166,13 @@ class Directory extends Test\Unit\Suite
$this
->given(
$splFileInfo = 'Hoa\Iterator\SplFileInfo',
- $root = resolve('hoa://Test/Vfs/Root?type=directory'),
- resolve('hoa://Test/Vfs/Root/a?type=file'),
- resolve('hoa://Test/Vfs/Root/b?type=file'),
- resolve('hoa://Test/Vfs/Root/c?type=file'),
- resolve('hoa://Test/Vfs/Root/d?type=file'),
- resolve('hoa://Test/Vfs/Root/e?type=file'),
- resolve('hoa://Test/Vfs/Root/f?type=file'),
+ $root = $this->resolve('hoa://Test/Vfs/Root?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/a?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/b?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/c?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/d?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/e?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/f?type=file'),
$iterator = new LUT\Directory(
$root,
$splFileInfo
@@ -204,16 +205,16 @@ class Directory extends Test\Unit\Suite
$this
->given(
$splFileInfo = 'Hoa\Iterator\SplFileInfo',
- $root = resolve('hoa://Test/Vfs/Root?type=directory'),
- resolve('hoa://Test/Vfs/Root/A?type=directory'),
- resolve('hoa://Test/Vfs/Root/A/a?type=file'),
- resolve('hoa://Test/Vfs/Root/A/b?type=file'),
- resolve('hoa://Test/Vfs/Root/A/c?type=file'),
- resolve('hoa://Test/Vfs/Root/B?type=directory'),
- resolve('hoa://Test/Vfs/Root/B/d?type=file'),
- resolve('hoa://Test/Vfs/Root/B/e?type=file'),
- resolve('hoa://Test/Vfs/Root/B/c?type=directory'),
- resolve('hoa://Test/Vfs/Root/B/c/f?type=file'),
+ $root = $this->resolve('hoa://Test/Vfs/Root?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/A?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/A/a?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/A/b?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/A/c?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/B?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/B/d?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/B/e?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/B/c?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/B/c/f?type=file'),
$directory = new LUT\Recursive\Directory(
$root,
LUT\FileSystem::CURRENT_AS_FILEINFO,
@@ -242,4 +243,9 @@ class Directory extends Test\Unit\Suite
'f'
]);
}
+
+ private function resolve(string $path)
+ {
+ return Protocol\Protocol::getInstance()->resolve($path);
+ }
}
diff --git a/Test/Unit/FileSystem.php b/Test/Unit/FileSystem.php
index 388f3c9..4c909fa 100644
--- a/Test/Unit/FileSystem.php
+++ b/Test/Unit/FileSystem.php
@@ -39,6 +39,7 @@ declare(strict_types=1);
namespace Hoa\Iterator\Test\Unit;
use Hoa\Iterator as LUT;
+use Hoa\Protocol;
use Hoa\Test;
/**
@@ -54,11 +55,11 @@ class FileSystem extends Test\Unit\Suite
{
$this
->given(
- $root = resolve('hoa://Test/Vfs/Root?type=directory'),
- resolve('hoa://Test/Vfs/Root/.?type=directory'),
- resolve('hoa://Test/Vfs/Root/..?type=directory'),
- resolve('hoa://Test/Vfs/Root/A?type=file'),
- resolve('hoa://Test/Vfs/Root/B?type=file'),
+ $root = $this->resolve('hoa://Test/Vfs/Root?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/.?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/..?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/A?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/B?type=file'),
$iterator = new LUT\FileSystem($root),
$result = []
)
@@ -83,13 +84,13 @@ class FileSystem extends Test\Unit\Suite
$this
->given(
$splFileInfo = 'Hoa\Iterator\SplFileInfo',
- $root = resolve('hoa://Test/Vfs/Root?type=directory'),
- resolve('hoa://Test/Vfs/Root/a?type=file'),
- resolve('hoa://Test/Vfs/Root/b?type=file'),
- resolve('hoa://Test/Vfs/Root/c?type=file'),
- resolve('hoa://Test/Vfs/Root/d?type=file'),
- resolve('hoa://Test/Vfs/Root/e?type=file'),
- resolve('hoa://Test/Vfs/Root/f?type=file'),
+ $root = $this->resolve('hoa://Test/Vfs/Root?type=directory'),
+ $this->resolve('hoa://Test/Vfs/Root/a?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/b?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/c?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/d?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/e?type=file'),
+ $this->resolve('hoa://Test/Vfs/Root/f?type=file'),
$iterator = new LUT\FileSystem(
$root,
LUT\FileSystem::CURRENT_AS_FILEINFO,
@@ -117,4 +118,9 @@ class FileSystem extends Test\Unit\Suite
'f'
]);
}
+
+ private function resolve(string $path)
+ {
+ return Protocol\Protocol::getInstance()->resolve($path);
+ }
}