aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2017-11-06 22:07:39 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2017-11-06 22:07:39 +0100
commit5c0f02f6541c808493230d8c58f6ca6d80256e55 (patch)
tree751a6e2cd1dfa20b21860bc95b0ea3c6d25afabd
parent008748d42a621e5dc74dc265c98dca77c2333405 (diff)
downloadStream-5c0f02f6541c808493230d8c58f6ca6d80256e55.zip
Stream-5c0f02f6541c808493230d8c58f6ca6d80256e55.tar.gz
Stream-5c0f02f6541c808493230d8c58f6ca6d80256e55.tar.bz2
chore(php) Update to PHP 7.
-rw-r--r--Source/Bucket.php68
-rw-r--r--Source/Composite.php23
-rw-r--r--Source/Context.php45
-rw-r--r--Source/Exception.php5
-rw-r--r--Source/Filter/Basic.php69
-rw-r--r--Source/Filter/Exception.php5
-rw-r--r--Source/Filter/Filter.php86
-rw-r--r--Source/Filter/LateComputed.php31
-rw-r--r--Source/IStream/Bufferable.php25
-rw-r--r--Source/IStream/In.php55
-rw-r--r--Source/IStream/Lockable.php13
-rw-r--r--Source/IStream/Out.php54
-rw-r--r--Source/IStream/Pathable.php13
-rw-r--r--Source/IStream/Pointable.php31
-rw-r--r--Source/IStream/Statable.php57
-rw-r--r--Source/IStream/Stream.php7
-rw-r--r--Source/IStream/Structural.php48
-rw-r--r--Source/IStream/Touchable.php76
-rw-r--r--Source/Stream.php187
-rw-r--r--Source/Wrapper/Exception.php5
-rw-r--r--Source/Wrapper/IWrapper/File.php67
-rw-r--r--Source/Wrapper/IWrapper/IWrapper.php8
-rw-r--r--Source/Wrapper/IWrapper/Stream.php136
-rw-r--r--Source/Wrapper/Wrapper.php36
-rw-r--r--Test/Integration/Filter/Filter.php17
-rw-r--r--Test/Integration/Filter/LateComputed.php9
-rw-r--r--Test/Integration/Stream.php17
-rw-r--r--Test/Unit/Bucket.php17
-rw-r--r--Test/Unit/Composite.php13
-rw-r--r--Test/Unit/Context.php29
-rw-r--r--Test/Unit/Exception.php5
-rw-r--r--Test/Unit/Filter/Basic.php21
-rw-r--r--Test/Unit/Filter/Exception.php5
-rw-r--r--Test/Unit/Filter/Filter.php39
-rw-r--r--Test/Unit/IStream/Bufferable.php5
-rw-r--r--Test/Unit/IStream/In.php5
-rw-r--r--Test/Unit/IStream/Lockable.php7
-rw-r--r--Test/Unit/IStream/Out.php5
-rw-r--r--Test/Unit/IStream/Pathable.php5
-rw-r--r--Test/Unit/IStream/Pointable.php7
-rw-r--r--Test/Unit/IStream/Statable.php7
-rw-r--r--Test/Unit/IStream/Stream.php5
-rw-r--r--Test/Unit/IStream/Structural.php5
-rw-r--r--Test/Unit/IStream/Touchable.php7
-rw-r--r--Test/Unit/Stream.php105
-rw-r--r--Test/Unit/Wrapper/Exception.php5
-rw-r--r--Test/Unit/Wrapper/IWrapper/File.php5
-rw-r--r--Test/Unit/Wrapper/IWrapper/IWrapper.php5
-rw-r--r--Test/Unit/Wrapper/IWrapper/Stream.php5
-rw-r--r--Test/Unit/Wrapper/Wrapper.php29
50 files changed, 442 insertions, 1092 deletions
diff --git a/Source/Bucket.php b/Source/Bucket.php
index c17650f..54ec1c1 100644
--- a/Source/Bucket.php
+++ b/Source/Bucket.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,44 +42,31 @@ namespace Hoa\Stream;
* Class \Hoa\Stream\Bucket.
*
* Manipulate stream buckets through brigades.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
class Bucket
{
/**
* Whether the stream is already a brigade.
- *
- * @const bool
*/
- const IS_A_BRIGADE = true;
+ public const IS_A_BRIGADE = true;
/**
* Whether the stream is not a brigade.
- *
- * @const bool
*/
- const IS_A_STREAM = false;
+ public const IS_A_STREAM = false;
/**
* Type of the bucket.
- *
- * @var bool
*/
protected $_type = null;
/**
* Brigade.
- *
- * @var resource
*/
protected $_brigade = null;
/**
* Bucket.
- *
- * @var resource
*/
protected $_bucket = null;
@@ -87,13 +76,8 @@ class Bucket
* Set a brigade.
* If a stream is given (with the constant `self::IS_A_STREAM`), it will
* create a brigade automatically.
- *
- * @param resource &$brigade A stream or a brigade.
- * @param bool $is Specify if `$brigade` is a stream or a
- * brigade, given by `self::IS_A_*` constant.
- * @param string $buffer Stream buffer.
*/
- public function __construct(&$brigade, $is = self::IS_A_BRIGADE, $buffer = '')
+ public function __construct(&$brigade, bool $is = self::IS_A_BRIGADE, string $buffer = '')
{
$this->setType($is);
@@ -111,10 +95,8 @@ class Bucket
/**
* Test the end-of-bucket.
* When testing, set the new bucket object.
- *
- * @return bool
*/
- public function eob()
+ public function eob(): bool
{
$this->_bucket = null;
@@ -123,9 +105,6 @@ class Bucket
/**
* Append bucket to the brigade.
- *
- * @param \Hoa\Stream\Bucket $bucket Bucket to add.
- * @return void
*/
public function append(Bucket $bucket)
{
@@ -136,9 +115,6 @@ class Bucket
/**
* Prepend bucket to the brigade.
- *
- * @param \Hoa\Stream\Bucket $bucket Bucket to add.
- * @return void
*/
public function prepend(Bucket $bucket)
{
@@ -149,11 +125,8 @@ class Bucket
/**
* Set type.
- *
- * @param bool $type Type. Please, see self::IS_A_* constants.
- * @return bool
*/
- protected function setType($type)
+ protected function setType(bool $type): ?bool
{
$old = $this->_type;
$this->_type = $type;
@@ -163,21 +136,16 @@ class Bucket
/**
* Get type.
- *
- * @return bool
*/
- public function getType()
+ public function getType(): ?bool
{
return $this->_type;
}
/**
* Set bucket data.
- *
- * @param string $data Data to set.
- * @return string
*/
- public function setData($data)
+ public function setData(string $data): ?string
{
$old = $this->getBucket()->data;
$this->getBucket()->data = $data;
@@ -188,10 +156,8 @@ class Bucket
/**
* Get bucket data.
- *
- * @return string
*/
- public function getData()
+ public function getData(): ?string
{
if (null === $this->getBucket()) {
return null;
@@ -202,10 +168,8 @@ class Bucket
/**
* Get bucket length.
- *
- * @return int
*/
- public function getLength()
+ public function getLength(): int
{
if (null === $this->getBucket()) {
return 0;
@@ -216,9 +180,6 @@ class Bucket
/**
* Set the brigade.
- *
- * @param resource &$brigade Brigade to add.
- * @return resource
*/
protected function setBrigade(&$brigade)
{
@@ -230,8 +191,6 @@ class Bucket
/**
* Get the brigade.
- *
- * @return resource
*/
public function getBrigade()
{
@@ -240,9 +199,6 @@ class Bucket
/**
* Set bucket.
- *
- * @param resource $bucket Bucket.
- * @return resource
*/
protected function setBucket($bucket)
{
@@ -254,8 +210,6 @@ class Bucket
/**
* Get the current bucket.
- *
- * @return mixed
*/
protected function getBucket()
{
diff --git a/Source/Composite.php b/Source/Composite.php
index e5e56e9..21a81e5 100644
--- a/Source/Composite.php
+++ b/Source/Composite.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,23 +42,16 @@ namespace Hoa\Stream;
* Class \Hoa\Stream\Composite.
*
* Declare a composite stream, i.e. a stream that uses a stream.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
abstract class Composite
{
/**
* Current stream.
- *
- * @var mixed
*/
protected $_stream = null;
/**
* Inner stream.
- *
- * @var \Hoa\Stream
*/
protected $_innerStream = null;
@@ -64,9 +59,6 @@ abstract class Composite
/**
* Set current stream.
- *
- * @param object $stream Current stream.
- * @return object
*/
protected function setStream($stream)
{
@@ -78,8 +70,6 @@ abstract class Composite
/**
* Get current stream.
- *
- * @return object
*/
public function getStream()
{
@@ -88,11 +78,8 @@ abstract class Composite
/**
* Set inner stream.
- *
- * @param \Hoa\Stream $innerStream Inner stream.
- * @return \Hoa\Stream
*/
- protected function setInnerStream(Stream $innerStream)
+ protected function setInnerStream(Stream $innerStream): ?Stream
{
$old = $this->_innerStream;
$this->_innerStream = $innerStream;
@@ -102,10 +89,8 @@ abstract class Composite
/**
* Get inner stream.
- *
- * @return \Hoa\Stream
*/
- public function getInnerStream()
+ public function getInnerStream(): ?Stream
{
return $this->_innerStream;
}
diff --git a/Source/Context.php b/Source/Context.php
index ce8ca72..2e9b84a 100644
--- a/Source/Context.php
+++ b/Source/Context.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,23 +42,16 @@ namespace Hoa\Stream;
* Class \Hoa\Stream\Context.
*
* Make a multiton of stream contexts.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
class Context
{
/**
* Context ID.
- *
- * @var string
*/
protected $_id = null;
/**
* Multiton.
- *
- * @var array
*/
protected static $_instances = [];
@@ -64,7 +59,6 @@ class Context
/**
* Construct a context.
- *
*/
protected function __construct($id)
{
@@ -76,12 +70,8 @@ class Context
/**
* Multiton.
- *
- * @param string $id ID.
- * @return \Hoa\Stream\Context
- * @throws \Hoa\Stream\Exception
*/
- public static function getInstance($id)
+ public static function getInstance(string $id): self
{
if (empty($id)) {
throw new Exception('Context ID must not be null.', 0);
@@ -96,21 +86,16 @@ class Context
/**
* Get context ID.
- *
- * @return string
*/
- public function getId()
+ public function getId(): string
{
return $this->_id;
}
/**
* Check if a context exists.
- *
- * @param string $id ID.
- * @return bool
*/
- public static function contextExists($id)
+ public static function contextExists(string $id): bool
{
return array_key_exists($id, static::$_instances);
}
@@ -118,11 +103,8 @@ class Context
/**
* Set options.
* Please, see http://php.net/context.
- *
- * @param array $options Options.
- * @return bool
*/
- public function setOptions(array $options)
+ public function setOptions(array $options): bool
{
return stream_context_set_option($this->getContext(), $options);
}
@@ -130,39 +112,30 @@ class Context
/**
* Set parameters.
* Please, see http://php.net/context.params.
- *
- * @param array $parameters Parameters.
- * @return bool
*/
- public function setParameters(array $parameters)
+ public function setParameters(array $parameters): bool
{
return stream_context_set_params($this->getContext(), $parameters);
}
/**
* Get options.
- *
- * @return array
*/
- public function getOptions()
+ public function getOptions(): array
{
return stream_context_get_options($this->getContext());
}
/**
* Get parameters.
- * .
- * @return array
*/
- public function getParameters()
+ public function getParameters(): array
{
return stream_context_get_params($this->getContext());
}
/**
* Get context as a resource.
- *
- * @return resource
*/
public function getContext()
{
diff --git a/Source/Exception.php b/Source/Exception.php
index eb0de09..a6e6072 100644
--- a/Source/Exception.php
+++ b/Source/Exception.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -42,9 +44,6 @@ use Hoa\Exception as HoaException;
* Class \Hoa\Stream\Exception.
*
* Extending the \Hoa\Exception\Exception class.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
class Exception extends HoaException
{
diff --git a/Source/Filter/Basic.php b/Source/Filter/Basic.php
index fddf70f..a3c562c 100644
--- a/Source/Filter/Basic.php
+++ b/Source/Filter/Basic.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -43,55 +45,40 @@ use Hoa\Stream;
*
* Basic filter. Force to implement some methods.
* Actually, it extends the php_user_filter class.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
abstract class Basic extends \php_user_filter implements Stream\IStream\Stream
{
/**
* Filter processed successfully with data available in the out bucket
* brigade.
- *
- * @const int
*/
- const PASS_ON = PSFS_PASS_ON;
+ public const PASS_ON = PSFS_PASS_ON;
/**
* Filter processed successfully, however no data was available to return.
* More data is required from the stream or prior filter.
- *
- * @const int
*/
- const FEED_ME = PSFS_FEED_ME;
+ public const FEED_ME = PSFS_FEED_ME;
/**
* The filter experienced and unrecoverable error and cannot continue.
- *
- * @const int
*/
- const FATAL_ERROR = PSFS_ERR_FATAL;
+ public const FATAL_ERROR = PSFS_ERR_FATAL;
/**
* Regular read/write.
- *
- * @const int
*/
- const FLAG_NORMAL = PSFS_FLAG_NORMAL;
+ public const FLAG_NORMAL = PSFS_FLAG_NORMAL;
/**
* An incremental flush.
- *
- * @const int
*/
- const FLAG_FLUSH_INC = PSFS_FLAG_FLUSH_INC;
+ public const FLAG_FLUSH_INC = PSFS_FLAG_FLUSH_INC;
/**
* Final flush prior to closing.
- *
- * @const int
*/
- const FLAG_FLUSH_CLOSE = PSFS_FLAG_FLUSH_CLOSE;
+ public const FLAG_FLUSH_CLOSE = PSFS_FLAG_FLUSH_CLOSE;
@@ -99,24 +86,8 @@ abstract class Basic extends \php_user_filter implements Stream\IStream\Stream
* Filter data.
* This method is called whenever data is read from or written to the attach
* stream.
- *
- * @param resource $in A resource pointing to a bucket brigade
- * which contains one or more bucket
- * objects containing data to be filtered.
- * @param resource $out A resource pointing to a second bucket
- * brigade into which your modified buckets
- * should be replaced.
- * @param int &$consumed Which must always be declared by
- * reference, should be incremented by the
- * length of the data which your filter
- * reads in and alters.
- * @param bool $closing If the stream is in the process of
- * closing (and therefore this is the last
- * pass through the filterchain), the
- * closing parameter will be set to true.
- * @return int
*/
- public function filter($in, $out, &$consumed, $closing)
+ public function filter($in, $out, int &$consumed, bool $closing): int
{
$iBucket = new Stream\Bucket($in);
$oBucket = new Stream\Bucket($out);
@@ -134,10 +105,8 @@ abstract class Basic extends \php_user_filter implements Stream\IStream\Stream
/**
* Called during instanciation of the filter class object.
- *
- * @return bool
*/
- public function onCreate()
+ public function onCreate(): bool
{
return true;
}
@@ -145,8 +114,6 @@ abstract class Basic extends \php_user_filter implements Stream\IStream\Stream
/**
* Called upon filter shutdown (typically, this is also during stream
* shutdown), and is executed after the flush method is called.
- *
- * @return void
*/
public function onClose()
{
@@ -155,11 +122,8 @@ abstract class Basic extends \php_user_filter implements Stream\IStream\Stream
/**
* Set the filter name.
- *
- * @param string $name Filter name.
- * @return string
*/
- public function setName($name)
+ public function setName(string $name): ?string
{
$old = $this->filtername;
$this->filtername = $name;
@@ -169,9 +133,6 @@ abstract class Basic extends \php_user_filter implements Stream\IStream\Stream
/**
* Set the filter parameters.
- *
- * @param mixed $parameters Filter parameters.
- * @return mixed
*/
public function setParameters($parameters)
{
@@ -183,18 +144,14 @@ abstract class Basic extends \php_user_filter implements Stream\IStream\Stream
/**
* Get the filter name.
- *
- * @return string
*/
- public function getName()
+ public function getName(): ?string
{
return $this->filtername;
}
/**
* Get the filter parameters.
- *
- * @return mixed
*/
public function getParameters()
{
@@ -205,8 +162,6 @@ abstract class Basic extends \php_user_filter implements Stream\IStream\Stream
* Get the stream resource being filtered.
* Maybe available only during **filter** calls when the closing parameter
* is set to false.
- *
- * @return resource
*/
public function getStream()
{
diff --git a/Source/Filter/Exception.php b/Source/Filter/Exception.php
index ef25372..bc7872f 100644
--- a/Source/Filter/Exception.php
+++ b/Source/Filter/Exception.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -42,9 +44,6 @@ use Hoa\Stream;
* Class \Hoa\Stream\Filter\Exception.
*
* Extending the \Hoa\Stream\Exception class.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
class Exception extends Stream\Exception
{
diff --git a/Source/Filter/Filter.php b/Source/Filter/Filter.php
index c36b340..50353d3 100644
--- a/Source/Filter/Filter.php
+++ b/Source/Filter/Filter.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -43,51 +45,36 @@ use Hoa\Stream;
* Class \Hoa\Stream\Filter.
*
* Proposes some methods to handle filter.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
abstract class Filter extends Stream
{
/**
* Overwrite filter if already exists.
- *
- * @const bool
*/
- const OVERWRITE = true;
+ public const OVERWRITE = true;
/**
* Do not overwrite filter if already exists.
- *
- * @const bool
*/
- const DO_NOT_OVERWRITE = false;
+ public const DO_NOT_OVERWRITE = false;
/**
* Filter should only be applied when reading.
- *
- * @const int
*/
- const READ = STREAM_FILTER_READ;
+ public const READ = STREAM_FILTER_READ;
/**
* Filter should only be applied when writing.
- *
- * @const int
*/
- const WRITE = STREAM_FILTER_WRITE;
+ public const WRITE = STREAM_FILTER_WRITE;
/**
* Filter should be applied when reading and writing.
- *
- * @const int
*/
- const READ_AND_WRITE = STREAM_FILTER_ALL;
+ public const READ_AND_WRITE = STREAM_FILTER_ALL;
/**
* All resources with at least one filter registered.
- *
- * @var array
*/
protected static $_resources = [];
@@ -95,21 +82,14 @@ abstract class Filter extends Stream
/**
* Register a stream filter.
- *
- * @param string $name Filter name.
- * @param mixed $class Class name or instance.
- * @param bool $overwrite Overwrite filter if already exists or
- * not. Given by self::*OVERWRITE constants.
- * @return bool
- * @throws \Hoa\Stream\Filter\Exception
*/
public static function register(
- $name,
+ string $name,
$class,
- $overwrite = self::DO_NOT_OVERWRITE
- ) {
+ bool $overwrite = self::DO_NOT_OVERWRITE
+ ): bool {
if ($overwrite === self::DO_NOT_OVERWRITE &&
- true === self::isRegistered($name)) {
+ true === self::isRegistered($name)) {
throw new Exception('Filter %s is already registered.', 0, $name);
}
@@ -139,20 +119,11 @@ abstract class Filter extends Stream
/**
* Append a filter to the list of filters.
- *
- * @param mixed $stream Stream which received the filter.
- * Should be resource or an object
- * of kind `Hoa\Stream`.
- * @param string $name Filter name.
- * @param int $mode `self::READ`, `self::WRITE` or
- * `self::READ_AND_WRITE`.
- * @param mixed $parameters Parameters.
- * @return resource
*/
public static function append(
$stream,
- $name,
- $mode = self::READ,
+ string $name,
+ int $mode = self::READ,
$parameters = null
) {
if ($stream instanceof Stream) {
@@ -177,20 +148,12 @@ abstract class Filter extends Stream
/**
* Prepend a filter to the list of filters.
- *
- * @param mixed $stream Stream which received the filter.
- * Should be resource or an object
- * \Hoa\Stream.
- * @param string $name Filter name.
- * @param int $mode self::READ, self::WRITE or
- * self::READ_AND_WRITE.
- * @param mixed $parameters Parameters.
- * @return resource
*/
public static function prepend(
$stream,
- $name,
- $mode = self::READ, $parameters = null
+ string $name,
+ int $mode = self::READ,
+ $parameters = null
) {
if ($stream instanceof Stream) {
$stream = $stream->getStream();
@@ -214,12 +177,8 @@ abstract class Filter extends Stream
/**
* Delete a filter.
- *
- * @param mixed $streamFilter Stream filter resource or name.
- * @return bool
- * @throws \Hoa\Stream\Filter\Exception
*/
- public static function remove($streamFilter)
+ public static function remove($streamFilter): bool
{
if (!is_resource($streamFilter)) {
if (isset(self::$_resources[$streamFilter])) {
@@ -239,21 +198,16 @@ abstract class Filter extends Stream
/**
* Check if a filter is already registered or not.
- *
- * @param string $name Filter name.
- * @return bool
*/
- public static function isRegistered($name)
+ public static function isRegistered(string $name): bool
{
return in_array($name, self::getRegistered());
}
/**
* Get all registered filer names.
- *
- * @return array
*/
- public static function getRegistered()
+ public static function getRegistered(): array
{
return stream_get_filters();
}
@@ -262,4 +216,4 @@ abstract class Filter extends Stream
/**
* Flex entity.
*/
-Consistency::flexEntity('Hoa\Stream\Filter\Filter');
+Consistency::flexEntity(Filter::class);
diff --git a/Source/Filter/LateComputed.php b/Source/Filter/LateComputed.php
index 209b5ab..c4cf8fc 100644
--- a/Source/Filter/LateComputed.php
+++ b/Source/Filter/LateComputed.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -42,16 +44,11 @@ use Hoa\Stream;
* Class \Hoa\Stream\Filter\LateComputed.
*
* A late computed filter computes the data when closing the filtering.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
abstract class LateComputed extends Basic
{
/**
* Buffer.
- *
- * @var string
*/
protected $_buffer = null;
@@ -61,31 +58,15 @@ abstract class LateComputed extends Basic
* Filter data.
* This method is called whenever data is read from or written to the attach
* stream.
- *
- * @param resource $in A resource pointing to a bucket brigade
- * which contains one or more bucket
- * objects containing data to be filtered.
- * @param resource $out A resource pointing to a second bucket
- * brigade into which your modified buckets
- * should be replaced.
- * @param int &$consumed Which must always be declared by
- * reference, should be incremented by the
- * length of the data which your filter
- * reads in and alters.
- * @param bool $closing If the stream is in the process of
- * closing (and therefore this is the last
- * pass through the filterchain), the
- * closing parameter will be set to true.
- * @return int
*/
- public function filter($in, $out, &$consumed, $closing)
+ public function filter($in, $out, int &$consumed, bool $closing): int
{
$return = self::FEED_ME;
$iBucket = new Stream\Bucket($in);
while (false === $iBucket->eob()) {
$this->_buffer .= $iBucket->getData();
- $consumed += $iBucket->getLength();
+ $consumed += $iBucket->getLength();
}
if (null !== $consumed) {
@@ -112,8 +93,6 @@ abstract class LateComputed extends Basic
/**
* Compute the whole data (stored in $this->_buffer).
- *
- * @return string
*/
- abstract protected function compute();
+ abstract protected function compute(): ?string;
}
diff --git a/Source/IStream/Bufferable.php b/Source/IStream/Bufferable.php
index 3853c0b..ab6881b 100644
--- a/Source/IStream/Bufferable.php
+++ b/Source/IStream/Bufferable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -42,47 +44,32 @@ namespace Hoa\Stream\IStream;
* Interface for bufferable streams. It's complementary to native buffer support
* of Hoa\Stream (please, see *StreamBuffer*() methods). Classes implementing
* this interface are able to create nested buffers, flush them etc.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface Bufferable extends Stream
{
/**
* Start a new buffer.
* The callable acts like a light filter.
- *
- * @param mixed $callable Callable.
- * @param int $size Size.
- * @return int
*/
- public function newBuffer($callable = null, $size = null);
+ public function newBuffer($callable = null, int $size = null): int;
/**
* Flush the buffer.
- *
- * @return void
*/
public function flush();
/**
* Delete buffer.
- *
- * @return bool
*/
- public function deleteBuffer();
+ public function deleteBuffer(): bool;
/**
* Get bufffer level.
- *
- * @return int
*/
- public function getBufferLevel();
+ public function getBufferLevel(): int;
/**
* Get buffer size.
- *
- * @return int
*/
- public function getBufferSize();
+ public function getBufferSize(): int;
}
diff --git a/Source/IStream/In.php b/Source/IStream/In.php
index d9709eb..4b498a0 100644
--- a/Source/IStream/In.php
+++ b/Source/IStream/In.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,96 +42,63 @@ namespace Hoa\Stream\IStream;
* Interface \Hoa\Stream\IStream\In.
*
* Interface for input.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface In extends Stream
{
/**
* Test for end-of-stream.
- *
- * @return bool
*/
- public function eof();
+ public function eof(): bool;
/**
* Read n characters.
- *
- * @param int $length Length.
- * @return string
*/
- public function read($length);
+ public function read(int $length): string;
/**
* Alias of $this->read().
- *
- * @param int $length Length.
- * @return string
*/
- public function readString($length);
+ public function readString(int $length): string;
/**
* Read a character.
* It could be equivalent to $this->read(1).
- *
- * @return string
*/
- public function readCharacter();
+ public function readCharacter(): string;
/**
* Read a boolean.
- *
- * @return bool
*/
- public function readBoolean();
+ public function readBoolean(): bool;
/**
* Read an integer.
- *
- * @param int $length Length.
- * @return int
*/
- public function readInteger($length = 1);
+ public function readInteger(int $length = 1): int;
/**
* Read a float.
- *
- * @param int $length Length.
- * @return float
*/
- public function readFloat($length = 1);
+ public function readFloat(int $length = 1): float;
/**
* Read an array.
* In most cases, it could be an alias to the $this->scanf() method.
- *
- * @param mixed $argument Argument (because the behavior is very
- * different according to the implementation).
- * @return array
*/
- public function readArray($argument = null);
+ public function readArray(): array;
/**
* Read a line.
- *
- * @return string
*/
public function readLine();
/**
* Read all, i.e. read as much as possible.
- *
- * @param int $offset Offset.
- * @return string
*/
- public function readAll($offset = 0);
+ public function readAll(int $offset = 0): string;
/**
* Parse input from a stream according to a format.
- *
- * @param string $format Format (see printf's formats).
- * @return array
*/
- public function scanf($format);
+ public function scanf(string $format): array;
}
diff --git a/Source/IStream/Lockable.php b/Source/IStream/Lockable.php
index 3e46666..be0639d 100644
--- a/Source/IStream/Lockable.php
+++ b/Source/IStream/Lockable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -41,7 +43,6 @@ namespace Hoa\Stream\IStream;
*
* Interface for lockable input/output.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
interface Lockable extends Stream
@@ -51,28 +52,28 @@ interface Lockable extends Stream
*
* @const int
*/
- const LOCK_SHARED = LOCK_SH;
+ public const LOCK_SHARED = LOCK_SH;
/**
* Acquire an exclusive lock (writer).
*
* @const int
*/
- const LOCK_EXCLUSIVE = LOCK_EX;
+ public const LOCK_EXCLUSIVE = LOCK_EX;
/**
* Release a lock (shared or exclusive).
*
* @const int
*/
- const LOCK_RELEASE = LOCK_UN;
+ public const LOCK_RELEASE = LOCK_UN;
/**
* If we do not want $this->lock() to block while locking.
*
* @const int
*/
- const LOCK_NO_BLOCK = LOCK_NB;
+ public const LOCK_NO_BLOCK = LOCK_NB;
@@ -83,5 +84,5 @@ interface Lockable extends Stream
* @param int $operation Operation, use the self::LOCK_* constants.
* @return bool
*/
- public function lock($operation);
+ public function lock(int $operation): bool;
}
diff --git a/Source/IStream/Out.php b/Source/IStream/Out.php
index c6fe922..405304a 100644
--- a/Source/IStream/Out.php
+++ b/Source/IStream/Out.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,90 +42,56 @@ namespace Hoa\Stream\IStream;
* Interface \Hoa\Stream\IStream\Out.
*
* Interface for output.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface Out extends Stream
{
/**
* Write n characters.
- *
- * @param string $string String.
- * @param int $length Length.
- * @return mixed
*/
- public function write($string, $length);
+ public function write(string $string, int $length);
/**
* Write a string.
- *
- * @param string $string String.
- * @return mixed
*/
- public function writeString($string);
+ public function writeString(string $string);
/**
* Write a character.
- *
- * @param string $character Character.
- * @return mixed
*/
- public function writeCharacter($character);
+ public function writeCharacter(string $character);
/**
* Write a boolean.
- *
- * @param bool $boolean Boolean.
- * @return mixed
*/
- public function writeBoolean($boolean);
+ public function writeBoolean(bool $boolean);
/**
* Write an integer.
- *
- * @param int $integer Integer.
- * @return mixed
*/
- public function writeInteger($integer);
+ public function writeInteger(int $integer);
/**
* Write a float.
- *
- * @param float $float Float.
- * @return mixed
*/
- public function writeFloat($float);
+ public function writeFloat(float $float);
/**
* Write an array.
- *
- * @param array $array Array.
- * @return mixed
*/
public function writeArray(array $array);
/**
* Write a line.
- *
- * @param string $line Line.
- * @return mixed
*/
- public function writeLine($line);
+ public function writeLine(string $line);
/**
* Write all, i.e. as much as possible.
- *
- * @param string $string String.
- * @return mixed
*/
- public function writeAll($string);
+ public function writeAll(string $string);
/**
* Truncate a stream to a given length.
- *
- * @param int $size Size.
- * @return bool
*/
- public function truncate($size);
+ public function truncate(int $size): bool;
}
diff --git a/Source/IStream/Pathable.php b/Source/IStream/Pathable.php
index bac7af7..5c45de3 100644
--- a/Source/IStream/Pathable.php
+++ b/Source/IStream/Pathable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,23 +42,16 @@ namespace Hoa\Stream\IStream;
* Interface \Hoa\Stream\IStream\Pathable.
*
* Interface for pathable input/output.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface Pathable extends Stream
{
/**
* Get filename component of path.
- *
- * @return string
*/
- public function getBasename();
+ public function getBasename(): string;
/**
* Get directory name component of path.
- *
- * @return string
*/
- public function getDirname();
+ public function getDirname(): string;
}
diff --git a/Source/IStream/Pointable.php b/Source/IStream/Pointable.php
index f421de1..b3f9e38 100644
--- a/Source/IStream/Pointable.php
+++ b/Source/IStream/Pointable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,55 +42,38 @@ namespace Hoa\Stream\IStream;
* Interface \Hoa\Stream\IStream\Pointable.
*
* Interface for pointable input/output.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface Pointable extends Stream
{
/**
* Set position equal to $offset bytes.
- *
- * @const int
*/
- const SEEK_SET = SEEK_SET;
+ public const SEEK_SET = SEEK_SET;
/**
* Set position to current location plus $offset.
- *
- * @const int
*/
- const SEEK_CURRENT = SEEK_CUR;
+ public const SEEK_CURRENT = SEEK_CUR;
/**
* Set position to end-of-file plus $offset.
- *
- * @const int
*/
- const SEEK_END = SEEK_END;
+ public const SEEK_END = SEEK_END;
/**
* Rewind the position of a stream pointer.
- *
- * @return bool
*/
- public function rewind();
+ public function rewind(): bool;
/**
* Seek on a stream pointer.
- *
- * @param int $offset Offset (negative value should be supported).
- * @param int $whence Whence, use the self::SEEK_* constants.
- * @return int
*/
- public function seek($offset, $whence = self::SEEK_SET);
+ public function seek(int $offset, int $whence = self::SEEK_SET): int;
/**
* Get the current position of the stream pointer.
- *
- * @return int
*/
- public function tell();
+ public function tell(): int;
}
diff --git a/Source/IStream/Statable.php b/Source/IStream/Statable.php
index 3eb35c1..331bc69 100644
--- a/Source/IStream/Statable.php
+++ b/Source/IStream/Statable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,107 +42,76 @@ namespace Hoa\Stream\IStream;
* Interface \Hoa\Stream\IStream\Statable.
*
* Interface for statable input/output.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface Statable extends Stream
{
/**
* Size is undefined.
- *
- * @const int
*/
- const SIZE_UNDEFINED = -1;
+ public const SIZE_UNDEFINED = -1;
/**
* Get size.
- *
- * @return int
*/
- public function getSize();
+ public function getSize(): int;
/**
* Get informations about a file.
- *
- * @return array
*/
- public function getStatistic();
+ public function getStatistic(): array;
/**
* Get last access time of file.
- *
- * @return int
*/
- public function getATime();
+ public function getATime(): int;
/**
* Get inode change time of file.
- *
- * @return int
*/
- public function getCTime();
+ public function getCTime(): int;
/**
* Get file modification time.
- *
- * @return int
*/
- public function getMTime();
+ public function getMTime(): int;
/**
* Get file group.
- *
- * @return int
*/
- public function getGroup();
+ public function getGroup(): int;
/**
* Get file owner.
- *
- * @return int
*/
- public function getOwner();
+ public function getOwner(): int;
/**
* Get file permissions.
- *
- * @return int
*/
- public function getPermissions();
+ public function getPermissions(): int;
/**
* Check if the file is readable.
- *
- * @return bool
*/
- public function isReadable();
+ public function isReadable(): bool;
/**
* Check if the file is writable.
- *
- * @return bool
*/
- public function isWritable();
+ public function isWritable(): bool;
/**
* Check if the file is executable.
- *
- * @return bool
*/
- public function isExecutable();
+ public function isExecutable(): bool;
/**
* Clear file status cache.
- *
- * @return void
*/
public function clearStatisticCache();
/**
* Clear all files status cache.
- *
- * @return void
*/
public static function clearAllStatisticCaches();
}
diff --git a/Source/IStream/Stream.php b/Source/IStream/Stream.php
index 0946ed0..64035e6 100644
--- a/Source/IStream/Stream.php
+++ b/Source/IStream/Stream.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,16 +42,11 @@ namespace Hoa\Stream\IStream;
* Interface \Hoa\Stream\IStream\Stream.
*
* Interface for all streams.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface Stream
{
/**
* Get the current stream.
- *
- * @return resource
*/
public function getStream();
}
diff --git a/Source/IStream/Structural.php b/Source/IStream/Structural.php
index 6ca09ef..fb35cd8 100644
--- a/Source/IStream/Structural.php
+++ b/Source/IStream/Structural.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,79 +42,51 @@ namespace Hoa\Stream\IStream;
* Interface \Hoa\Stream\IStream\Structural.
*
* Interface for structural input/output.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface Structural extends Stream
{
/**
* Select root of the document: :root.
- *
- * @return \Hoa\Stream\IStream\Structural
*/
- public function selectRoot();
+ public function selectRoot(): self;
/**
* Select any elements: *.
- *
- * @return array
*/
- public function selectAnyElements();
+ public function selectAnyElements(): array;
/**
* Select elements of type E: E.
- *
- * @param string $E Element E.
- * @return array
*/
- public function selectElements($E = null);
+ public function selectElements(string $E = null): array;
/**
* Select F elements descendant of an E element: E F.
- *
- * @param string $F Element F.
- * @return array
*/
- public function selectDescendantElements($F = null);
+ public function selectDescendantElements(string $F = null): array;
/**
* Select F elements children of an E element: E > F.
- *
- * @param string $F Element F.
- * @return array
*/
- public function selectChildElements($F = null);
+ public function selectChildElements(string $F = null): array;
/**
* Select an F element immediately preceded by an E element: E + F.
- *
- * @param string $F Element F.
- * @return \Hoa\Stream\IStream\Structural
*/
- public function selectAdjacentSiblingElement($F);
+ public function selectAdjacentSiblingElement(string $F): Structural;
/**
* Select F elements preceded by an E element: E ~ F.
- *
- * @param string $F Element F.
- * @return array
*/
- public function selectSiblingElements($F = null);
+ public function selectSiblingElements(string $F = null): array;
/**
* Execute a query selector and return the first result.
- *
- * @param string $query Query.
- * @return \Hoa\Stream\IStream\Structural
*/
- public function querySelector($query);
+ public function querySelector(string $query): Structural;
/**
* Execute a query selector and return one or many results.
- *
- * @param string $query Query.
- * @return array
*/
- public function querySelectorAll($query);
+ public function querySelectorAll(string $query): array;
}
diff --git a/Source/IStream/Touchable.php b/Source/IStream/Touchable.php
index fdb390f..284bc61 100644
--- a/Source/IStream/Touchable.php
+++ b/Source/IStream/Touchable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,117 +42,73 @@ namespace Hoa\Stream\IStream;
* Interface \Hoa\Stream\IStream\Touchable.
*
* Interface for touchable input/output.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface Touchable extends Stream
{
/**
* Overwrite file if already exists.
- *
- * @const bool
*/
- const OVERWRITE = true;
+ public const OVERWRITE = true;
/**
* Do not overwrite file if already exists.
- *
- * @const bool
*/
- const DO_NOT_OVERWRITE = false;
+ public const DO_NOT_OVERWRITE = false;
/**
* Make directory if does not exist.
- *
- * @const bool
*/
- const MAKE_DIRECTORY = true;
+ public const MAKE_DIRECTORY = true;
/**
* Do not make directory if does not exist.
- *
- * @const bool
*/
- const DO_NOT_MAKE_DIRECTORY = false;
+ public const DO_NOT_MAKE_DIRECTORY = false;
/**
* Set access and modification time of file.
- *
- * @param int $time Time. If equals to -1, time() should be used.
- * @param int $atime Access time. If equals to -1, $time should be
- * used.
- * @return bool
*/
- public function touch($time = -1, $atime = -1);
+ public function touch(int $time = -1, int $atime = -1): bool;
/**
* Copy file.
* Return the destination file path if succeed, false otherwise.
- *
- * @param string $to Destination path.
- * @param bool $force Force to copy if the file $to already exists.
- * Use the self::*OVERWRITE constants.
- * @return bool
*/
- public function copy($to, $force = self::DO_NOT_OVERWRITE);
+ public function copy(string $to, bool $force = self::DO_NOT_OVERWRITE): bool;
/**
* Move a file.
- *
- * @param string $name New name.
- * @param bool $force Force to move if the file $name already
- * exists.
- * Use the self::*OVERWRITE constants.
- * @param bool $mkdir Force to make directory if does not exist.
- * Use the self::*DIRECTORY constants.
- * @return bool
*/
public function move(
- $name,
- $force = self::DO_NOT_OVERWRITE,
- $mkdir = self::DO_NOT_MAKE_DIRECTORY
- );
+ string $name,
+ bool $force = self::DO_NOT_OVERWRITE,
+ bool $mkdir = self::DO_NOT_MAKE_DIRECTORY
+ ): bool;
/**
* Delete a file.
- *
- * @return bool
*/
- public function delete();
+ public function delete(): bool;
/**
* Change file group.
- *
- * @param mixed $group Group name or number.
- * @return bool
*/
- public function changeGroup($group);
+ public function changeGroup($group): bool;
/**
* Change file mode.
- *
- * @param int $mode Mode (in octal!).
- * @return bool
*/
- public function changeMode($mode);
+ public function changeMode(int $mode): bool;
/**
* Change file owner.
- *
- * @param mixed $user User.
- * @return bool
*/
- public function changeOwner($user);
+ public function changeOwner($user): bool;
/**
* Change the current umask.
- *
- * @param int $umask Umask (in octal!). If null, given the current
- * umask value.
- * @return int
*/
- public static function umask($umask = null);
+ public static function umask(int $umask = null): int;
}
diff --git a/Source/Stream.php b/Source/Stream.php
index 57388ab..6b073ce 100644
--- a/Source/Stream.php
+++ b/Source/Stream.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -44,9 +46,6 @@ use Hoa\Protocol;
* Class \Hoa\Stream.
*
* Static register for all streams (files, sockets etc.).
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
abstract class Stream implements IStream\Stream, Event\Listenable
{
@@ -54,85 +53,61 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Name index in the stream bucket.
- *
- * @const int
*/
- const NAME = 0;
+ public const NAME = 0;
/**
* Handler index in the stream bucket.
- *
- * @const int
*/
- const HANDLER = 1;
+ public const HANDLER = 1;
/**
* Resource index in the stream bucket.
- *
- * @const int
*/
- const RESOURCE = 2;
+ public const RESOURCE = 2;
/**
* Context index in the stream bucket.
- *
- * @const int
*/
- const CONTEXT = 3;
+ public const CONTEXT = 3;
/**
* Default buffer size.
- *
- * @const int
*/
- const DEFAULT_BUFFER_SIZE = 8192;
+ public const DEFAULT_BUFFER_SIZE = 8192;
/**
* Current stream bucket.
- *
- * @var array
*/
protected $_bucket = [];
/**
* Static stream register.
- *
- * @var array
*/
private static $_register = [];
/**
* Buffer size (default is 8Ko).
- *
- * @var bool
*/
protected $_bufferSize = self::DEFAULT_BUFFER_SIZE;
/**
* Original stream name, given to the stream constructor.
- *
- * @var string
*/
protected $_streamName = null;
/**
* Context name.
- *
- * @var string
*/
protected $_context = null;
/**
* Whether the opening has been deferred.
- *
- * @var bool
*/
protected $_hasBeenDeferred = false;
/**
* Whether this stream is already opened by another handler.
- *
- * @var bool
*/
protected $_borrowing = false;
@@ -142,13 +117,8 @@ abstract class Stream implements IStream\Stream, Event\Listenable
* Set the current stream.
* If not exists in the register, try to call the
* `$this->_open()` method. Please, see the `self::_getStream()` method.
- *
- * @param string $streamName Stream name (e.g. path or URL).
- * @param string $context Context ID (please, see the
- * `Hoa\Stream\Context` class).
- * @param bool $wait Differ opening or not.
*/
- public function __construct($streamName, $context = null, $wait = false)
+ public function __construct(string $streamName, string $context = null, bool $wait = false)
{
$this->_streamName = $streamName;
$this->_context = $context;
@@ -184,19 +154,12 @@ abstract class Stream implements IStream\Stream, Event\Listenable
* Get a stream in the register.
* If the stream does not exist, try to open it by calling the
* $handler->_open() method.
- *
- * @param string $streamName Stream name.
- * @param \Hoa\Stream $handler Stream handler.
- * @param string $context Context ID (please, see the
- * \Hoa\Stream\Context class).
- * @return array
- * @throws \Hoa\Stream\Exception
*/
final private static function &_getStream(
- $streamName,
+ string $streamName,
Stream $handler,
- $context = null
- ) {
+ string $context = null
+ ): array {
$name = md5($streamName);
if (null !== $context) {
@@ -244,30 +207,20 @@ abstract class Stream implements IStream\Stream, Event\Listenable
* Open the stream and return the associated resource.
* Note: This method is protected, but do not forget that it could be
* overloaded into a public context.
- *
- * @param string $streamName Stream name (e.g. path or URL).
- * @param \Hoa\Stream\Context $context Context.
- * @return resource
- * @throws \Hoa\Exception\Exception
*/
- abstract protected function &_open($streamName, Context $context = null);
+ abstract protected function &_open(string $streamName, ?Context $context);
/**
* Close the current stream.
* Note: this method is protected, but do not forget that it could be
* overloaded into a public context.
- *
- * @return bool
*/
- abstract protected function _close();
+ abstract protected function _close(): bool;
/**
* Open the stream.
- *
- * @return \Hoa\Stream
- * @throws \Hoa\Stream\Exception
*/
- final public function open()
+ final public function open(): self
{
$context = $this->_context;
@@ -302,8 +255,6 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Close the current stream.
- *
- * @return void
*/
final public function close()
{
@@ -338,10 +289,8 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Get the current stream name.
- *
- * @return string
*/
- public function getStreamName()
+ public function getStreamName(): ?string
{
if (empty($this->_bucket)) {
return null;
@@ -352,8 +301,6 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Get the current stream.
- *
- * @return resource
*/
public function getStream()
{
@@ -366,10 +313,8 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Get the current stream context.
- *
- * @return \Hoa\Stream\Context
*/
- public function getStreamContext()
+ public function getStreamContext(): ?Context
{
if (empty($this->_bucket)) {
return null;
@@ -380,11 +325,8 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Get stream handler according to its name.
- *
- * @param string $streamName Stream name.
- * @return \Hoa\Stream
*/
- public static function getStreamHandler($streamName)
+ public static function getStreamHandler(string $streamName): ?self
{
$name = md5($streamName);
@@ -400,15 +342,12 @@ abstract class Stream implements IStream\Stream, Event\Listenable
* and select). Notice that it could be unsafe to use this method without
* taking time to think about it two minutes. Resource of type “Unknown” is
* considered as valid.
- *
- * @return resource
- * @throws \Hoa\Stream\Exception
*/
public function _setStream($stream)
{
if (false === is_resource($stream) &&
('resource' !== gettype($stream) ||
- 'Unknown' !== get_resource_type($stream))) {
+ 'Unknown' !== get_resource_type($stream))) {
throw new Exception(
'Try to change the stream resource with an invalid one; ' .
'given %s.',
@@ -425,22 +364,16 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Check if the stream is opened.
- *
- * @return bool
*/
- public function isOpened()
+ public function isOpened(): bool
{
return is_resource($this->getStream());
}
/**
* Set the timeout period.
- *
- * @param int $seconds Timeout period in seconds.
- * @param int $microseconds Timeout period in microseconds.
- * @return bool
*/
- public function setStreamTimeout($seconds, $microseconds = 0)
+ public function setStreamTimeout(int $seconds, int $microseconds = 0): bool
{
return stream_set_timeout($this->getStream(), $seconds, $microseconds);
}
@@ -457,10 +390,8 @@ abstract class Stream implements IStream\Stream, Event\Listenable
* Check whether the connection has timed out or not.
* This is basically a shortcut of `getStreamMetaData` + the `timed_out`
* index, but the resulting code is more readable.
- *
- * @return bool
*/
- public function hasTimedOut()
+ public function hasTimedOut(): bool
{
$metaData = $this->getStreamMetaData();
@@ -469,11 +400,8 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Set blocking/non-blocking mode.
- *
- * @param bool $mode Blocking mode.
- * @return bool
*/
- public function setStreamBlocking($mode)
+ public function setStreamBlocking(bool $mode): bool
{
return stream_set_blocking($this->getStream(), (int) $mode);
}
@@ -484,15 +412,8 @@ abstract class Stream implements IStream\Stream, Event\Listenable
* This means that if there are two processes wanting to write to the same
* output stream, each is paused after 8 Ko of data to allow the other to
* write.
- *
- * @param int $buffer Number of bytes to buffer. If zero, write
- * operations are unbuffered. This ensures that
- * all writes are completed before other
- * processes are allowed to write to that output
- * stream.
- * @return bool
- */
- public function setStreamBuffer($buffer)
+ */
+ public function setStreamBuffer(int $buffer): bool
{
// Zero means success.
$out = 0 === stream_set_write_buffer($this->getStream(), $buffer);
@@ -507,30 +428,24 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Disable stream buffering.
* Alias of $this->setBuffer(0).
- *
- * @return bool
*/
- public function disableStreamBuffer()
+ public function disableStreamBuffer(): bool
{
return $this->setStreamBuffer(0);
}
/**
* Get stream buffer size.
- *
- * @return int
*/
- public function getStreamBufferSize()
+ public function getStreamBufferSize(): int
{
return $this->_bufferSize;
}
/**
* Get stream wrapper name.
- *
- * @return string
*/
- public function getStreamWrapperName()
+ public function getStreamWrapperName(): string
{
if (false === $pos = strpos($this->getStreamName(), '://')) {
return 'file';
@@ -541,46 +456,31 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Get stream meta data.
- *
- * @return array
*/
- public function getStreamMetaData()
+ public function getStreamMetaData(): array
{
return stream_get_meta_data($this->getStream());
}
/**
* Whether this stream is already opened by another handler.
- *
- * @return bool
*/
- public function isBorrowing()
+ public function isBorrowing(): bool
{
return $this->_borrowing;
}
/**
* Notification callback.
- *
- * @param int $ncode Notification code. Please, see
- * STREAM_NOTIFY_* constants.
- * @param int $severity Severity. Please, see
- * STREAM_NOTIFY_SEVERITY_* constants.
- * @param string $message Message.
- * @param int $code Message code.
- * @param int $transferred If applicable, the number of transferred
- * bytes.
- * @param int $max If applicable, the number of max bytes.
- * @return void
*/
public function _notify(
- $ncode,
- $severity,
- $message,
- $code,
- $transferred,
- $max
- ) {
+ int $ncode,
+ int $severity,
+ ?string $message,
+ ?int $code,
+ ?int $transferred,
+ ?int $max
+ ): void {
static $_map = [
STREAM_NOTIFY_AUTH_REQUIRED => 'authrequire',
STREAM_NOTIFY_AUTH_RESULT => 'authresult',
@@ -601,8 +501,6 @@ abstract class Stream implements IStream\Stream, Event\Listenable
'transferred' => $transferred,
'max' => $max
]));
-
- return;
}
/**
@@ -611,8 +509,6 @@ abstract class Stream implements IStream\Stream, Event\Listenable
* This method does not check the return value of $handler->close(). Thus,
* if a stream is persistent, the $handler->close() should do anything. It
* is a very generic method.
- *
- * @return void
*/
final public static function _Hoa_Stream()
{
@@ -625,18 +521,14 @@ abstract class Stream implements IStream\Stream, Event\Listenable
/**
* Transform object to string.
- *
- * @return string
*/
- public function __toString()
+ public function __toString(): string
{
return $this->getStreamName();
}
/**
* Close the stream when destructing.
- *
- * @return void
*/
public function __destruct()
{
@@ -655,7 +547,6 @@ abstract class Stream implements IStream\Stream, Event\Listenable
*
* The `hoa://Library/Stream` node.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class _Protocol extends Protocol\Node
@@ -675,7 +566,7 @@ class _Protocol extends Protocol\Node
* @param string $id ID of the component.
* @return mixed
*/
- public function reachId($id)
+ public function reachId(string $id)
{
return Stream::getStreamHandler($id);
}
@@ -684,7 +575,7 @@ class _Protocol extends Protocol\Node
/**
* Flex entity.
*/
-Consistency::flexEntity('Hoa\Stream\Stream');
+Consistency::flexEntity(Stream::class);
/**
* Shutdown method.
diff --git a/Source/Wrapper/Exception.php b/Source/Wrapper/Exception.php
index 849e5fa..952c020 100644
--- a/Source/Wrapper/Exception.php
+++ b/Source/Wrapper/Exception.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -42,9 +44,6 @@ use Hoa\Stream;
* Class \Hoa\Stream\Wrapper\Exception.
*
* Extending the \Hoa\Stream\Exception class.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
class Exception extends Stream\Exception
{
diff --git a/Source/Wrapper/IWrapper/File.php b/Source/Wrapper/IWrapper/File.php
index 1d4ab6c..41161e9 100644
--- a/Source/Wrapper/IWrapper/File.php
+++ b/Source/Wrapper/IWrapper/File.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,9 +42,6 @@ namespace Hoa\Stream\Wrapper\IWrapper;
* Interface \Hoa\Stream\Wrapper\IWrapper\File.
*
* Interface for “file stream wrapper” class.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface File
{
@@ -51,26 +50,18 @@ interface File
* This method is called in to closedir().
* Any resources which were locked, or allocated, during opening and use of
* the directory stream should be released.
- *
- * @return bool
*/
- public function dir_closedir();
+ public function dir_closedir(): bool;
/**
* Open directory handle.
* This method is called in response to opendir().
- *
- * @param string $path Specifies the URL that was passed to opendir().
- * @param int $options Whether or not to enforce safe_mode (0x04).
- * @return bool
*/
- public function dir_opendir($path, $options);
+ public function dir_opendir(string $path, int $options): bool;
/**
* Read entry from directory handle.
* This method is called in response to readdir().
- *
- * @return mixed
*/
public function dir_readdir();
@@ -80,75 +71,37 @@ interface File
* Should reset the output generated by self::dir_readdir, i.e. the next
* call to self::dir_readdir should return the first entry in the location
* returned by self::dir_opendir.
- *
- * @return bool
*/
- public function dir_rewinddir();
+ public function dir_rewinddir(): bool;
/**
* Create a directory.
* This method is called in response to mkdir().
- *
- * @param string $path Directory which should be created.
- * @param int $mode The value passed to mkdir().
- * @param int $options A bitwise mask of values.
- * @return bool
*/
- public function mkdir($path, $mode, $options);
+ public function mkdir(string $path, int $mode, int $options): bool;
/**
* Rename a file or directory.
* This method is called in response to rename().
* Should attempt to rename $from to $to.
- *
- * @param string $from The URL to current file.
- * @param string $to The URL which $from should be renamed to.
- * @return bool
*/
- public function rename($from, $to);
+ public function rename(string $from, string $to): bool;
/**
* Remove a directory.
* This method is called in response to rmdir().
- *
- * @param string $path The directory URL which should be removed.
- * @param int $options A bitwise mask of values.
- * @return bool
*/
- public function rmdir($path, $options);
+ public function rmdir(string $path, int $options): bool;
/**
* Delete a file.
* This method is called in response to unlink().
- *
- * @param string $path The file URL which should be deleted.
- * @return bool
*/
- public function unlink($path);
+ public function unlink(string $path): bool;
/**
* Retrieve information about a file.
* This method is called in response to all stat() related functions.
- *
- * @param string $path The file URL which should be retrieve
- * information about.
- * @param int $flags Holds additional flags set by the streams API.
- * It can hold one or more of the following
- * values OR'd together.
- * STREAM_URL_STAT_LINK: for resource with the
- * ability to link to other resource (such as an
- * HTTP location: forward, or a filesystem
- * symlink). This flag specified that only
- * information about the link itself should be
- * returned, not the resource pointed to by the
- * link. This flag is set in response to calls to
- * lstat(), is_link(), or filetype().
- * STREAM_URL_STAT_QUIET: if this flag is set,
- * our wrapper should not raise any errors. If
- * this flag is not set, we are responsible for
- * reporting errors using the trigger_error()
- * function during stating of the path.
- * @return array
*/
- public function url_stat($path, $flags);
+ public function url_stat(string $path, int $flags): array;
}
diff --git a/Source/Wrapper/IWrapper/IWrapper.php b/Source/Wrapper/IWrapper/IWrapper.php
index dd8d69c..c59a926 100644
--- a/Source/Wrapper/IWrapper/IWrapper.php
+++ b/Source/Wrapper/IWrapper/IWrapper.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -42,16 +44,12 @@ use Hoa\Consistency;
* Interface \Hoa\Stream\Wrapper\IWrapper.
*
* Interface for stream wrapper class.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface IWrapper extends File, Stream
{
/**
* Constructs a new stream wrapper.
* Called when opening the stream wrapper, right before self::stream_open().
- *
*/
public function __construct();
}
@@ -59,4 +57,4 @@ interface IWrapper extends File, Stream
/**
* Flex entity.
*/
-Consistency::flexEntity('Hoa\Stream\Wrapper\IWrapper\IWrapper');
+Consistency::flexEntity(IWrapper::class);
diff --git a/Source/Wrapper/IWrapper/Stream.php b/Source/Wrapper/IWrapper/Stream.php
index 3e8ab39..21e8d00 100644
--- a/Source/Wrapper/IWrapper/Stream.php
+++ b/Source/Wrapper/IWrapper/Stream.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -40,207 +42,99 @@ namespace Hoa\Stream\Wrapper\IWrapper;
* Interface \Hoa\Stream\Wrapper\IWrapper\Stream.
*
* Interface for “stream stream wrapper” class.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
interface Stream
{
/**
* Retrieve the underlaying resource.
- *
- * @param int $castAs Can be STREAM_CAST_FOR_SELECT when
- * stream_select() is calling stream_cast() or
- * STREAM_CAST_AS_STREAM when stream_cast() is
- * called for other uses.
- * @return resource
*/
- public function stream_cast($castAs);
+ public function stream_cast(int $castAs);
/**
* Close a resource.
* This method is called in response to fclose().
* All resources that were locked, or allocated, by the wrapper should be
* released.
- *
- * @return void
*/
public function stream_close();
/**
* Tests for end-of-file on a file pointer.
* This method is called in response to feof().
- *
- * @return bool
*/
- public function stream_eof();
+ public function stream_eof(): bool;
/**
* Flush the output.
* This method is called in response to fflush().
* If we have cached data in our stream but not yet stored it into the
* underlying storage, we should do so now.
- *
- * @return bool
*/
- public function stream_flush();
+ public function stream_flush(): bool;
/**
* Advisory file locking.
* This method is called in response to flock(), when file_put_contents()
* (when flags contains LOCK_EX), stream_set_blocking() and when closing the
* stream (LOCK_UN).
- *
- * @param int $operation Operation is one the following:
- * * LOCK_SH to acquire a shared lock (reader) ;
- * * LOCK_EX to acquire an exclusive lock (writer) ;
- * * LOCK_UN to release a lock (shared or exclusive) ;
- * * LOCK_NB if we don't want flock() to
- * block while locking (not supported on
- * Windows).
- * @return bool
*/
- public function stream_lock($operation);
+ public function stream_lock(int $operation): bool;
/**
* Change stream options.
* This method is called to set metadata on the stream. It is called when
* one of the following functions is called one a stream URL: touch, chmod,
* chown or chgrp.
- *
- * @param string $path The file path or URL to set metadata.
- * @param int $option One of the following:
- * * STREAM_META_TOUCH,
- * * STREAM_META_OWNER_NAME,
- * * STREAM_META_OWNER,
- * * STREAM_META_GROUP_NAME,
- * * STREAM_META_GROUP,
- * * STREAM_META_ACCESS.
- * @param mixed $value An array or a scalar depending of the option.
- * @return bool
*/
- public function stream_metadata($path, $option, $value);
+ public function stream_metadata(string $path, int $option, $value): bool;
/**
* Open file or URL.
* This method is called immediately after the wrapper is initialized (f.e.
* by fopen() and file_get_contents()).
- *
- * @param string $path Specifies the URL that was passed to the
- * original function.
- * @param string $mode The mode used to open the file, as
- * detailed for fopen().
- * @param int $options Holds additional flags set by the
- * streams API. It can hold one or more of
- * the following values OR'd together:
- * * STREAM_USE_PATH, if path is relative,
- * search for the resource using the
- * include_path;
- * * STREAM_REPORT_ERRORS, if this is
- * set, you are responsible for raising
- * errors using trigger_error during
- * opening the stream. If this is not
- * set, you should not raise any errors.
- * @param string &$openedPath If the $path is opened successfully, and
- * STREAM_USE_PATH is set in $options,
- * $openedPath should be set to the full
- * path of the file/resource that was
- * actually opened.
- * @return bool
*/
- public function stream_open($path, $mode, $options, &$openedPath);
+ public function stream_open(string $path, string $mode, int $options, &$openedPath): bool;
/**
* Read from stream.
* This method is called in response to fread() and fgets().
- *
- * @param int $count How many bytes of data from the current
- * position should be returned.
- * @return string
*/
- public function stream_read($count);
+ public function stream_read(int $count): string;
/**
* Seek to specific location in a stream.
* This method is called in response to fseek().
* The read/write position of the stream should be updated according to the
* $offset and $whence.
- *
- * @param int $offset The stream offset to seek to.
- * @param int $whence Possible values:
- * * SEEK_SET to set position equal to $offset
- * bytes ;
- * * SEEK_CUR to set position to current
- * location plus $offsete ;
- * * SEEK_END to set position to end-of-file
- * plus $offset.
- * @return bool
*/
- public function stream_seek($offset, $whence = SEEK_SET);
+ public function stream_seek(int $offset, int $whence = SEEK_SET): bool;
/**
* Change stream options.
* This method is called to set options on the stream.
- *
- * @param int $option One of:
- * * STREAM_OPTION_BLOCKING, the method was
- * called in response to
- * stream_set_blocking() ;
- * * STREAM_OPTION_READ_TIMEOUT, the method
- * was called in response to
- * stream_set_timeout() ;
- * * STREAM_OPTION_WRITE_BUFFER, the method
- * was called in response to
- * stream_set_write_buffer().
- * @param int $arg1 If $option is:
- * * STREAM_OPTION_BLOCKING: requested blocking
- * mode (1 meaning block, 0 not blocking) ;
- * * STREAM_OPTION_READ_TIMEOUT: the timeout
- * in seconds ;
- * * STREAM_OPTION_WRITE_BUFFER: buffer mode
- * (STREAM_BUFFER_NONE or
- * STREAM_BUFFER_FULL).
- * @param int $arg2 If $option is:
- * * STREAM_OPTION_BLOCKING: this option is
- * not set ;
- * * STREAM_OPTION_READ_TIMEOUT: the timeout
- * in microseconds ;
- * * STREAM_OPTION_WRITE_BUFFER: the requested
- * buffer size.
- * @return bool
*/
- public function stream_set_option($option, $arg1, $arg2);
+ public function stream_set_option(int $option, int $arg1, int $arg2): bool;
/**
* Retrieve information about a file resource.
* This method is called in response to fstat().
- *
- * @return array
*/
- public function stream_stat();
+ public function stream_stat(): array;
/**
* Retrieve the current position of a stream.
* This method is called in response to ftell().
- *
- * @return int
*/
- public function stream_tell();
+ public function stream_tell(): int;
/**
* Truncate a stream to a given length.
- *
- * @param int $size Size.
- * @return bool
*/
- public function stream_truncate($size);
+ public function stream_truncate(int $size): bool;
/**
* Write to stream.
* This method is called in response to fwrite().
- *
- * @param string $data Should be stored into the underlying stream.
- * @return int
*/
- public function stream_write($data);
+ public function stream_write(string $data): int;
}
diff --git a/Source/Wrapper/Wrapper.php b/Source/Wrapper/Wrapper.php
index 52fef91..ddfbbb8 100644
--- a/Source/Wrapper/Wrapper.php
+++ b/Source/Wrapper/Wrapper.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -42,24 +44,13 @@ use Hoa\Consistency;
* Class \Hoa\Stream\Wrapper.
*
* Manipulate wrappers.
- *
- * @copyright Copyright © 2007-2017 Hoa community
- * @license New BSD License
*/
class Wrapper
{
/**
* Register a wrapper.
- *
- * @param string $protocol The wrapper name to be registered.
- * @param string $className Class name which implements the protocol.
- * @param int $flags Should be set to `STREAM_IS_URL` if
- * `$protocol` is a URL protocol. Default is 0,
- * local stream.
- * @return bool
- * @throws \Hoa\Stream\Wrapper\Exception
*/
- public static function register($protocol, $className, $flags = 0)
+ public static function register(string $protocol, string $className, int $flags = 0): bool
{
if (true === self::isRegistered($protocol)) {
throw new Exception(
@@ -83,11 +74,8 @@ class Wrapper
/**
* Unregister a wrapper.
- *
- * @param string $protocol The wrapper name to be unregistered.
- * @return bool
*/
- public static function unregister($protocol)
+ public static function unregister(string $protocol): bool
{
// Silent errors if `$protocol` does not exist. This function already
// returns `false` in this case, which is the strict expected
@@ -97,11 +85,8 @@ class Wrapper
/**
* Restore a previously unregistered build-in wrapper.
- *
- * @param string $protocol The wrapper name to be restored.
- * @return bool
*/
- public static function restore($protocol)
+ public static function restore(string $protocol): bool
{
// Silent errors if `$protocol` does not exist. This function already
// returns `false` in this case, which is the strict expected
@@ -111,21 +96,16 @@ class Wrapper
/**
* Check if a protocol is registered or not.
- *
- * @param string $protocol Protocol name.
- * @return bool
*/
- public static function isRegistered($protocol)
+ public static function isRegistered(string $protocol): bool
{
return in_array($protocol, self::getRegistered());
}
/**
* Get all registered wrapper.
- *
- * @return array
*/
- public static function getRegistered()
+ public static function getRegistered(): array
{
return stream_get_wrappers();
}
@@ -134,4 +114,4 @@ class Wrapper
/**
* Flex entity.
*/
-Consistency::flexEntity('Hoa\Stream\Wrapper\Wrapper');
+Consistency::flexEntity(Wrapper::class);
diff --git a/Test/Integration/Filter/Filter.php b/Test/Integration/Filter/Filter.php
index db657a9..d5ab529 100644
--- a/Test/Integration/Filter/Filter.php
+++ b/Test/Integration/Filter/Filter.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -44,12 +46,11 @@ use Hoa\Test;
*
* Test suite of the filter class.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Filter extends Test\Integration\Suite
{
- public function case_append()
+ public function case_append(): void
{
$this
->given(
@@ -68,7 +69,7 @@ class Filter extends Test\Integration\Suite
->isEqualTo(strtoupper($content));
}
- public function case_prepend()
+ public function case_prepend(): void
{
$this
->given(
@@ -87,7 +88,7 @@ class Filter extends Test\Integration\Suite
->isEqualTo(strtoupper($content));
}
- public function case_append_append()
+ public function case_append_append(): void
{
$this
->given(
@@ -108,7 +109,7 @@ class Filter extends Test\Integration\Suite
->isEqualTo(strtolower($content));
}
- public function case_append_prepend()
+ public function case_append_prepend(): void
{
$this
->given(
@@ -129,7 +130,7 @@ class Filter extends Test\Integration\Suite
->isEqualTo(strtoupper($content));
}
- public function case_prepend_prepend()
+ public function case_prepend_prepend(): void
{
$this
->given(
@@ -150,7 +151,7 @@ class Filter extends Test\Integration\Suite
->isEqualTo(strtoupper($content));
}
- public function case_append_1000_filters()
+ public function case_append_1000_filters(): void
{
$this
->given(
@@ -160,7 +161,7 @@ class Filter extends Test\Integration\Suite
$stream = fopen($filename, 'r'),
$name = 'string.toupper'
)
- ->when(function () use ($stream, $name) {
+ ->when(function () use ($stream, $name): void {
for ($i = 1000; $i >= 0; --$i) {
$this->resource(SUT::prepend($stream, $name));
}
diff --git a/Test/Integration/Filter/LateComputed.php b/Test/Integration/Filter/LateComputed.php
index f58cfd7..3b710d9 100644
--- a/Test/Integration/Filter/LateComputed.php
+++ b/Test/Integration/Filter/LateComputed.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the late computed filter class.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class LateComputed extends Test\Integration\Suite
{
- public function case_custom_late_computed_filter()
+ public function case_custom_late_computed_filter(): void
{
$this
->given(
@@ -77,12 +78,12 @@ class LateComputed extends Test\Integration\Suite
class CustomFilter extends LUT\Filter\LateComputed
{
- protected function compute()
+ protected function compute(): string
{
$this->_buffer =
strtolower($this->_buffer) . ' ' .
strlen($this->_buffer); // proof that the buffer contains all the data
- return;
+ return '';
}
}
diff --git a/Test/Integration/Stream.php b/Test/Integration/Stream.php
index b770e37..03f7fdb 100644
--- a/Test/Integration/Stream.php
+++ b/Test/Integration/Stream.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the stream class.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Stream extends Test\Integration\Suite
{
- public function case_notifications()
+ public function case_notifications(): void
{
$self = $this;
@@ -70,7 +71,7 @@ class Stream extends Test\Integration\Suite
$stream->on(
'connect',
- function (Event\Bucket $bucket) use ($self, &$connectCalled) {
+ function (Event\Bucket $bucket) use ($self, &$connectCalled): void {
$connectCalled = true;
$data = $bucket->getData();
@@ -87,7 +88,7 @@ class Stream extends Test\Integration\Suite
),
$stream->on(
'mimetype',
- function (Event\Bucket $bucket) use ($self, &$mimetypeCalled) {
+ function (Event\Bucket $bucket) use ($self, &$mimetypeCalled): void {
$mimetypeCalled = true;
$data = $bucket->getData();
@@ -104,7 +105,7 @@ class Stream extends Test\Integration\Suite
),
$stream->on(
'size',
- function (Event\Bucket $bucket) use ($self, &$sizeCalled) {
+ function (Event\Bucket $bucket) use ($self, &$sizeCalled): void {
$sizeCalled = true;
$data = $bucket->getData();
@@ -121,7 +122,7 @@ class Stream extends Test\Integration\Suite
),
$stream->on(
'progress',
- function (Event\Bucket $bucket) use ($self, &$progressCalled) {
+ function (Event\Bucket $bucket) use ($self, &$progressCalled): void {
$progressCalled = true;
$data = $bucket->getData();
@@ -153,7 +154,7 @@ class Stream extends Test\Integration\Suite
class SUT extends LUT\Stream
{
- protected function &_open($streamName, LUT\Context $context = null)
+ protected function &_open(string $streamName, ?LUT\Context $context)
{
if (null === $context) {
$out = fopen($streamName, 'rb');
@@ -164,7 +165,7 @@ class SUT extends LUT\Stream
return $out;
}
- protected function _close()
+ protected function _close(): bool
{
return fclose($this->getStream());
}
diff --git a/Test/Unit/Bucket.php b/Test/Unit/Bucket.php
index 269fa68..11b7cec 100644
--- a/Test/Unit/Bucket.php
+++ b/Test/Unit/Bucket.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -44,12 +46,11 @@ use Hoa\Test;
*
* Test suite of the stream bucket.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Bucket extends Test\Unit\Suite
{
- public function case_constants()
+ public function case_constants(): void
{
$this
->boolean(SUT::IS_A_BRIGADE)
@@ -58,7 +59,7 @@ class Bucket extends Test\Unit\Suite
->isFalse();
}
- public function case_construct_a_brigade()
+ public function case_construct_a_brigade(): void
{
$this
->given($brigade = 'foo')
@@ -71,7 +72,7 @@ class Bucket extends Test\Unit\Suite
->isIdenticalTo('foo');
}
- public function case_construct_a_stream()
+ public function case_construct_a_stream(): void
{
$this
->given(
@@ -94,7 +95,7 @@ class Bucket extends Test\Unit\Suite
->isIdenticalTo($bucket);
}
- public function case_eob()
+ public function case_eob(): void
{
$this
->given(
@@ -107,7 +108,7 @@ class Bucket extends Test\Unit\Suite
->isTrue();
}
- public function case_set_data()
+ public function case_set_data(): void
{
$this
->given(
@@ -132,7 +133,7 @@ class Bucket extends Test\Unit\Suite
->isIdenticalTo($_bucket);
}
- public function case_get_data()
+ public function case_get_data(): void
{
$this
->given(
@@ -147,7 +148,7 @@ class Bucket extends Test\Unit\Suite
->isEqualTo($this->invoke($bucket)->getBucket()->data);
}
- public function case_get_length()
+ public function case_get_length(): void
{
$this
->given(
diff --git a/Test/Unit/Composite.php b/Test/Unit/Composite.php
index 73f4a44..50d9c61 100644
--- a/Test/Unit/Composite.php
+++ b/Test/Unit/Composite.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -36,20 +38,19 @@
namespace Hoa\Stream\Test\Unit;
-use Mock\Hoa\Stream\Composite as SUT;
use Hoa\Test;
+use Mock\Hoa\Stream\Composite as SUT;
/**
* Class \Hoa\Stream\Test\Unit\Composite.
*
* Test suite of the composite stream.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Composite extends Test\Unit\Suite
{
- public function case_set_stream()
+ public function case_set_stream(): void
{
$this
->given(
@@ -62,7 +63,7 @@ class Composite extends Test\Unit\Suite
->isNull();
}
- public function case_get_stream()
+ public function case_get_stream(): void
{
$this
->given(
@@ -76,7 +77,7 @@ class Composite extends Test\Unit\Suite
->isIdenticalTo($stream);
}
- public function case_set_inner_stream()
+ public function case_set_inner_stream(): void
{
$this
->given(
@@ -89,7 +90,7 @@ class Composite extends Test\Unit\Suite
->isNull();
}
- public function case_get_inner_stream()
+ public function case_get_inner_stream(): void
{
$this
->given(
diff --git a/Test/Unit/Context.php b/Test/Unit/Context.php
index 55cd836..f45d54c 100644
--- a/Test/Unit/Context.php
+++ b/Test/Unit/Context.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,21 +47,20 @@ use Hoa\Test;
*
* Test suite of the context stream class.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Context extends Test\Unit\Suite
{
- public function case_get_instance_with_empty_id()
+ public function case_get_instance_with_empty_id(): void
{
$this
- ->exception(function () {
+ ->exception(function (): void {
SUT::getInstance(null);
})
->isInstanceOf(LUT\Exception::class);
}
- public function case_get_new_instance()
+ public function case_get_new_instance(): void
{
$this
->when($result = SUT::getInstance('foo'))
@@ -68,7 +69,7 @@ class Context extends Test\Unit\Suite
->isInstanceOf(SUT::class);
}
- public function case_get_new_instances()
+ public function case_get_new_instances(): void
{
$this
->when($result = SUT::getInstance('foo'))
@@ -77,7 +78,7 @@ class Context extends Test\Unit\Suite
->isNotIdenticalTo(SUT::getInstance('bar'));
}
- public function case_get_same_instance()
+ public function case_get_same_instance(): void
{
$this
->when($result = SUT::getInstance('foo'))
@@ -86,7 +87,7 @@ class Context extends Test\Unit\Suite
->isIdenticalTo(SUT::getInstance('foo'));
}
- public function case_get_id()
+ public function case_get_id(): void
{
$this
->given(
@@ -99,7 +100,7 @@ class Context extends Test\Unit\Suite
->isEqualTo($id);
}
- public function case_context_exists()
+ public function case_context_exists(): void
{
$this
->given(
@@ -112,7 +113,7 @@ class Context extends Test\Unit\Suite
->isTrue();
}
- public function case_context_does_not_exist()
+ public function case_context_does_not_exist(): void
{
$this
->when($result = SUT::contextExists('foo'))
@@ -121,7 +122,7 @@ class Context extends Test\Unit\Suite
->isFalse();
}
- public function case_set_options()
+ public function case_set_options(): void
{
$this
->given(
@@ -134,7 +135,7 @@ class Context extends Test\Unit\Suite
->isTrue();
}
- public function case_get_options()
+ public function case_get_options(): void
{
$this
->given(
@@ -148,7 +149,7 @@ class Context extends Test\Unit\Suite
->isEqualTo($options);
}
- public function case_set_parameters()
+ public function case_set_parameters(): void
{
$this
->given(
@@ -164,7 +165,7 @@ class Context extends Test\Unit\Suite
->isTrue();
}
- public function case_get_parameters()
+ public function case_get_parameters(): void
{
$this
->given(
@@ -181,7 +182,7 @@ class Context extends Test\Unit\Suite
->isEqualTo($parameters);
}
- public function case_get_context()
+ public function case_get_context(): void
{
$this
->given($context = SUT::getInstance('foo'))
diff --git a/Test/Unit/Exception.php b/Test/Unit/Exception.php
index 2f437c9..919dac0 100644
--- a/Test/Unit/Exception.php
+++ b/Test/Unit/Exception.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the exception.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Exception extends Test\Unit\Suite
{
- public function case_hoa_exception()
+ public function case_hoa_exception(): void
{
$this
->when($result = new SUT('foo', 0))
diff --git a/Test/Unit/Filter/Basic.php b/Test/Unit/Filter/Basic.php
index 2e10328..a899f61 100644
--- a/Test/Unit/Filter/Basic.php
+++ b/Test/Unit/Filter/Basic.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -37,20 +39,19 @@
namespace Hoa\Stream\Test\Unit\Filter;
use Hoa\Stream as LUT;
-use Mock\Hoa\Stream\Filter\Basic as SUT;
use Hoa\Test;
+use Mock\Hoa\Stream\Filter\Basic as SUT;
/**
* Class \Hoa\Stream\Test\Unit\Filter\Basic.
*
* Test suite of the basic filter class.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Basic extends Test\Unit\Suite
{
- public function case_constants()
+ public function case_constants(): void
{
$this
->integer(SUT::PASS_ON)
@@ -67,7 +68,7 @@ class Basic extends Test\Unit\Suite
->isEqualTo(PSFS_FLAG_FLUSH_CLOSE);
}
- public function case_is_a_php_filter()
+ public function case_is_a_php_filter(): void
{
$this
->when($result = new SUT())
@@ -76,7 +77,7 @@ class Basic extends Test\Unit\Suite
->isInstanceOf(\php_user_filter::class);
}
- public function case_interfaces()
+ public function case_interfaces(): void
{
$this
->when($result = new SUT())
@@ -85,7 +86,7 @@ class Basic extends Test\Unit\Suite
->isInstanceOf(LUT\IStream\Stream::class);
}
- public function case_set_name()
+ public function case_set_name(): void
{
$this
->given($filter = new SUT())
@@ -95,7 +96,7 @@ class Basic extends Test\Unit\Suite
->isEqualTo('');
}
- public function case_get_name()
+ public function case_get_name(): void
{
$this
->given(
@@ -109,7 +110,7 @@ class Basic extends Test\Unit\Suite
->isEqualTo($name);
}
- public function case_set_parameters()
+ public function case_set_parameters(): void
{
$this
->given($filter = new SUT())
@@ -119,7 +120,7 @@ class Basic extends Test\Unit\Suite
->isEqualTo('');
}
- public function case_get_parameters()
+ public function case_get_parameters(): void
{
$this
->given(
@@ -133,7 +134,7 @@ class Basic extends Test\Unit\Suite
->isEqualTo($parameters);
}
- public function case_get_stream()
+ public function case_get_stream(): void
{
$this
->given($filter = new SUT())
diff --git a/Test/Unit/Filter/Exception.php b/Test/Unit/Filter/Exception.php
index e3970e0..65873b4 100644
--- a/Test/Unit/Filter/Exception.php
+++ b/Test/Unit/Filter/Exception.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the filter exception.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Exception extends Test\Unit\Suite
{
- public function case_exception()
+ public function case_exception(): void
{
$this
->when($result = new SUT('foo', 0))
diff --git a/Test/Unit/Filter/Filter.php b/Test/Unit/Filter/Filter.php
index 2404f7a..ec33113 100644
--- a/Test/Unit/Filter/Filter.php
+++ b/Test/Unit/Filter/Filter.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the filter class.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Filter extends Test\Unit\Suite
{
- public function case_constants()
+ public function case_constants(): void
{
$this
->boolean(SUT::OVERWRITE)
@@ -65,7 +66,7 @@ class Filter extends Test\Unit\Suite
->isEqualTo(STREAM_FILTER_ALL);
}
- public function case_register()
+ public function case_register(): void
{
$this
->when($result = SUT::register('foo', \StdClass::class))
@@ -74,7 +75,7 @@ class Filter extends Test\Unit\Suite
->isTrue();
}
- public function case_register_already_registered_do_not_overwrite()
+ public function case_register_already_registered_do_not_overwrite(): void
{
$this
->given(
@@ -82,14 +83,14 @@ class Filter extends Test\Unit\Suite
$class = \StdClass::class,
SUT::register($name, $class)
)
- ->exception(function () use ($name, $class) {
+ ->exception(function () use ($name, $class): void {
SUT::register($name, $class);
})
->isInstanceOf(LUT\Filter\Exception::class)
->hasMessage('Filter foo is already registered.');
}
- public function case_register_already_registered_do_overwrite()
+ public function case_register_already_registered_do_overwrite(): void
{
$this
->given(
@@ -103,10 +104,10 @@ class Filter extends Test\Unit\Suite
->isFalse();
}
- public function case_register_empty_name()
+ public function case_register_empty_name(): void
{
$this
- ->exception(function () {
+ ->exception(function (): void {
SUT::register('', \StdClass::class);
})
->isInstanceOf(LUT\Filter\Exception::class)
@@ -116,10 +117,10 @@ class Filter extends Test\Unit\Suite
);
}
- public function case_register_unknown_class()
+ public function case_register_unknown_class(): void
{
$this
- ->exception(function () {
+ ->exception(function (): void {
SUT::register('foo', '42Foo');
})
->isInstanceOf(LUT\Filter\Exception::class)
@@ -129,7 +130,7 @@ class Filter extends Test\Unit\Suite
);
}
- public function case_append()
+ public function case_append(): void
{
$this
->given(
@@ -142,7 +143,7 @@ class Filter extends Test\Unit\Suite
->isStreamFilter();
}
- public function case_prepend()
+ public function case_prepend(): void
{
$this
->given(
@@ -155,7 +156,7 @@ class Filter extends Test\Unit\Suite
->isStreamFilter();
}
- public function case_remove()
+ public function case_remove(): void
{
$this
->given(
@@ -169,7 +170,7 @@ class Filter extends Test\Unit\Suite
->isTrue();
}
- public function case_remove_by_name()
+ public function case_remove_by_name(): void
{
$this
->given(
@@ -183,10 +184,10 @@ class Filter extends Test\Unit\Suite
->isTrue();
}
- public function case_remove_unknown()
+ public function case_remove_unknown(): void
{
$this
- ->exception(function () {
+ ->exception(function (): void {
SUT::remove('foo');
})
->isInstanceOf(LUT\Filter\Exception::class)
@@ -196,7 +197,7 @@ class Filter extends Test\Unit\Suite
);
}
- public function case_is_registered()
+ public function case_is_registered(): void
{
$this
->when($result = SUT::isRegistered('string.toupper'))
@@ -205,7 +206,7 @@ class Filter extends Test\Unit\Suite
->isTrue();
}
- public function case_is_not_registered()
+ public function case_is_not_registered(): void
{
$this
->when($result = SUT::isRegistered('foo'))
@@ -214,7 +215,7 @@ class Filter extends Test\Unit\Suite
->isFalse();
}
- public function case_get_registered()
+ public function case_get_registered(): void
{
$this
->when($result = SUT::getRegistered())
diff --git a/Test/Unit/IStream/Bufferable.php b/Test/Unit/IStream/Bufferable.php
index f1d2472..bf9c090 100644
--- a/Test/Unit/IStream/Bufferable.php
+++ b/Test/Unit/IStream/Bufferable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the bufferable interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Bufferable extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\Bufferable())
diff --git a/Test/Unit/IStream/In.php b/Test/Unit/IStream/In.php
index 26aaa37..9eac7f1 100644
--- a/Test/Unit/IStream/In.php
+++ b/Test/Unit/IStream/In.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the input interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class In extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\In())
diff --git a/Test/Unit/IStream/Lockable.php b/Test/Unit/IStream/Lockable.php
index bd95a3e..c0102f5 100644
--- a/Test/Unit/IStream/Lockable.php
+++ b/Test/Unit/IStream/Lockable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the lockable interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Lockable extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\Lockable())
@@ -60,7 +61,7 @@ class Lockable extends Test\Unit\Suite
->isInstanceOf(LUT\IStream\Stream::class);
}
- public function case_constants()
+ public function case_constants(): void
{
$this
->when($result = SUT::LOCK_SHARED)
diff --git a/Test/Unit/IStream/Out.php b/Test/Unit/IStream/Out.php
index 8ba4577..4a4223c 100644
--- a/Test/Unit/IStream/Out.php
+++ b/Test/Unit/IStream/Out.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the output interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Out extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\Out())
diff --git a/Test/Unit/IStream/Pathable.php b/Test/Unit/IStream/Pathable.php
index fdc871a..f718f76 100644
--- a/Test/Unit/IStream/Pathable.php
+++ b/Test/Unit/IStream/Pathable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the pathable interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Pathable extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\Pathable())
diff --git a/Test/Unit/IStream/Pointable.php b/Test/Unit/IStream/Pointable.php
index 2275ee4..98be67f 100644
--- a/Test/Unit/IStream/Pointable.php
+++ b/Test/Unit/IStream/Pointable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the pointable interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Pointable extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\Pointable())
@@ -60,7 +61,7 @@ class Pointable extends Test\Unit\Suite
->isInstanceOf(LUT\IStream\Stream::class);
}
- public function case_constants()
+ public function case_constants(): void
{
$this
->when($result = SUT::SEEK_SET)
diff --git a/Test/Unit/IStream/Statable.php b/Test/Unit/IStream/Statable.php
index c0ae5d0..713eb84 100644
--- a/Test/Unit/IStream/Statable.php
+++ b/Test/Unit/IStream/Statable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the statable interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Statable extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\Statable())
@@ -60,7 +61,7 @@ class Statable extends Test\Unit\Suite
->isInstanceOf(LUT\IStream\Stream::class);
}
- public function case_constants()
+ public function case_constants(): void
{
$this
->when($result = SUT::SIZE_UNDEFINED)
diff --git a/Test/Unit/IStream/Stream.php b/Test/Unit/IStream/Stream.php
index c0936b2..5c95637 100644
--- a/Test/Unit/IStream/Stream.php
+++ b/Test/Unit/IStream/Stream.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -44,12 +46,11 @@ use Hoa\Test;
*
* Test suite of the parent stream interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Stream extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\Stream())
diff --git a/Test/Unit/IStream/Structural.php b/Test/Unit/IStream/Structural.php
index ae3732c..865c5d5 100644
--- a/Test/Unit/IStream/Structural.php
+++ b/Test/Unit/IStream/Structural.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the structural interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Structural extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\Structural())
diff --git a/Test/Unit/IStream/Touchable.php b/Test/Unit/IStream/Touchable.php
index 075332d..5338e0e 100644
--- a/Test/Unit/IStream/Touchable.php
+++ b/Test/Unit/IStream/Touchable.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the touchable interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Touchable extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\IStream\Touchable())
@@ -60,7 +61,7 @@ class Touchable extends Test\Unit\Suite
->isInstanceOf(LUT\IStream\Stream::class);
}
- public function case_constants()
+ public function case_constants(): void
{
$this
->when($result = SUT::OVERWRITE)
diff --git a/Test/Unit/Stream.php b/Test/Unit/Stream.php
index db75578..58f204b 100644
--- a/Test/Unit/Stream.php
+++ b/Test/Unit/Stream.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the stream class.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Stream extends Test\Unit\Suite
{
- public function case_interfaces()
+ public function case_interfaces(): void
{
$this
->when($result = new SUT(__FILE__))
@@ -60,7 +61,7 @@ class Stream extends Test\Unit\Suite
->isInstanceOf(Event\Listenable::class);
}
- public function case_constants()
+ public function case_constants(): void
{
$this
->integer(SUT::NAME)
@@ -73,7 +74,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo(3);
}
- public function case_construct()
+ public function case_construct(): void
{
$this
->given($name = __FILE__)
@@ -112,7 +113,7 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_construct_with_a_context()
+ public function case_construct_with_a_context(): void
{
$this
->given(
@@ -130,7 +131,7 @@ class Stream extends Test\Unit\Suite
->isInstanceOf(Event\Listener::class);
}
- public function case_construct_with_deferred_opening()
+ public function case_construct_with_deferred_opening(): void
{
$this
->given($name = __FILE__)
@@ -144,7 +145,7 @@ class Stream extends Test\Unit\Suite
->isNull();
}
- public function case_open()
+ public function case_open(): void
{
$this
->given(
@@ -165,7 +166,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo(SUT::DEFAULT_BUFFER_SIZE);
}
- public function case_close()
+ public function case_close(): void
{
$this
->given(
@@ -180,7 +181,7 @@ class Stream extends Test\Unit\Suite
->isNull()
->boolean($stream->isOpened())
->isFalse()
- ->variable(SUT::getStreamHandler($stream))
+ ->variable(SUT::getStreamHandler((string) $stream))
->isNull()
->variable($stream->getStreamName())
->isEqualTo($name)
@@ -194,7 +195,7 @@ class Stream extends Test\Unit\Suite
->isFalse();
}
- public function case_close_more_than_once()
+ public function case_close_more_than_once(): void
{
$this
->given(
@@ -208,7 +209,7 @@ class Stream extends Test\Unit\Suite
->isIdenticalTo($close1);
}
- public function case_open_close_open()
+ public function case_open_close_open(): void
{
$this
->given(
@@ -217,7 +218,7 @@ class Stream extends Test\Unit\Suite
$stream->open(),
$resource = $stream->getStream(),
$context = $stream->getStreamContext(),
- $handler = SUT::getStreamHandler($stream),
+ $handler = SUT::getStreamHandler((string) $stream),
$this->function->stream_set_write_buffer = 0,
@@ -242,7 +243,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo(SUT::DEFAULT_BUFFER_SIZE);
}
- public function case_close_event_close_before()
+ public function case_close_event_close_before(): void
{
$self = $this;
@@ -251,7 +252,7 @@ class Stream extends Test\Unit\Suite
$name = 'hoa://Test/Vfs/Foo?type=file',
$stream = new SUT($name),
Event::getEvent('hoa://Event/Stream/' . $name . ':close-before')->attach(
- function (Event\Bucket $bucket) use ($self, &$called) {
+ function (Event\Bucket $bucket) use ($self, &$called): void {
$called = true;
$self
@@ -268,7 +269,7 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_get_stream_name()
+ public function case_get_stream_name(): void
{
$this
->given(
@@ -281,7 +282,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo($name);
}
- public function case_get_stream()
+ public function case_get_stream(): void
{
$this
->given(
@@ -294,7 +295,7 @@ class Stream extends Test\Unit\Suite
->isStream($name);
}
- public function case_get_stream_context()
+ public function case_get_stream_context(): void
{
$this
->given(
@@ -309,7 +310,7 @@ class Stream extends Test\Unit\Suite
->isIdenticalTo($context);
}
- public function case_get_stream_context_with_no_context_given()
+ public function case_get_stream_context_with_no_context_given(): void
{
$this
->given(
@@ -322,7 +323,7 @@ class Stream extends Test\Unit\Suite
->isNull();
}
- public function case_get_stream_handler()
+ public function case_get_stream_handler(): void
{
$this
->given(
@@ -335,7 +336,7 @@ class Stream extends Test\Unit\Suite
->isIdenticalTo($result);
}
- public function case_get_stream_handler_of_unknown_stream()
+ public function case_get_stream_handler_of_unknown_stream(): void
{
$this
->when($result = SUT::getStreamHandler('foo'))
@@ -344,7 +345,7 @@ class Stream extends Test\Unit\Suite
->isNull();
}
- public function case__set_stream()
+ public function case__set_stream(): void
{
$this
->given(
@@ -362,17 +363,17 @@ class Stream extends Test\Unit\Suite
->isIdenticalTo($newStream);
}
- public function case__set_stream_invalid_resource()
+ public function case__set_stream_invalid_resource(): void
{
$this
->given($stream = new SUT(__FILE__))
- ->exception(function () use ($stream) {
+ ->exception(function () use ($stream): void {
$stream->_setStream(true);
})
->isInstanceOf(LUT\Exception::class);
}
- public function case__set_stream_unknown_resource()
+ public function case__set_stream_unknown_resource(): void
{
$this
->given(
@@ -393,7 +394,7 @@ class Stream extends Test\Unit\Suite
->isIdenticalTo($newStream);
}
- public function case_is_opened()
+ public function case_is_opened(): void
{
$this
->given($stream = new SUT(__FILE__))
@@ -403,7 +404,7 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_is_not_opened()
+ public function case_is_not_opened(): void
{
$this
->given($stream = new SUT(__FILE__, null, true))
@@ -421,7 +422,7 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_set_stream_timeout()
+ public function case_set_stream_timeout(): void
{
$self = $this;
@@ -451,7 +452,7 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_has_been_deferred()
+ public function case_has_been_deferred(): void
{
$this
->given($stream = new SUT(__FILE__, null, true))
@@ -461,7 +462,7 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_has_not_been_deferred()
+ public function case_has_not_been_deferred(): void
{
$this
->given($stream = new SUT(__FILE__))
@@ -471,7 +472,7 @@ class Stream extends Test\Unit\Suite
->isFalse();
}
- public function case_has_timed_out()
+ public function case_has_timed_out(): void
{
$this
->given(
@@ -486,7 +487,7 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_has_not_timed_out()
+ public function case_has_not_timed_out(): void
{
$this
->given(
@@ -501,7 +502,7 @@ class Stream extends Test\Unit\Suite
->isFalse();
}
- public function case_set_stream_blocking()
+ public function case_set_stream_blocking(): void
{
$self = $this;
@@ -529,7 +530,7 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_get_default_stream_buffer_size()
+ public function case_get_default_stream_buffer_size(): void
{
$self = $this;
@@ -541,7 +542,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo(8192);
}
- public function case_set_stream_buffer()
+ public function case_set_stream_buffer(): void
{
$self = $this;
@@ -571,7 +572,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo(42);
}
- public function case_set_stream_buffer_fail()
+ public function case_set_stream_buffer_fail(): void
{
$self = $this;
@@ -602,7 +603,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo($oldStreamBufferSize);
}
- public function case_disable_stream_buffer()
+ public function case_disable_stream_buffer(): void
{
$self = $this;
@@ -632,7 +633,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo(0);
}
- public function case_get_stream_wrapper_name_with_no_wrapper()
+ public function case_get_stream_wrapper_name_with_no_wrapper(): void
{
$this
->given($stream = new SUT(__FILE__))
@@ -642,7 +643,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo('file');
}
- public function case_get_stream_wrapper_name()
+ public function case_get_stream_wrapper_name(): void
{
$this
->given($stream = new SUT('hoa://Test/Vfs/Foo?type=file'))
@@ -652,7 +653,7 @@ class Stream extends Test\Unit\Suite
->isEqualTo('hoa');
}
- public function case_get_stream_meta_data()
+ public function case_get_stream_meta_data(): void
{
$this
->given($stream = new SUT(__FILE__))
@@ -672,7 +673,7 @@ class Stream extends Test\Unit\Suite
]);
}
- public function case_is_borrowing()
+ public function case_is_borrowing(): void
{
$this
->given(
@@ -687,7 +688,7 @@ class Stream extends Test\Unit\Suite
->isFalse();
}
- public function case_is_not_borrowing()
+ public function case_is_not_borrowing(): void
{
$this
->given($stream = new SUT(__FILE__))
@@ -697,13 +698,15 @@ class Stream extends Test\Unit\Suite
->isFalse();
}
- public function case_shutdown_destructor()
+ public function case_shutdown_destructor(): void
{
$this
->given(
$stream = new \Mock\Hoa\Stream\Test\Unit\SUTWithPublicClose(__FILE__),
$this->calling($stream)->_close = function () use (&$called) {
$called = true;
+
+ return true;
}
)
->when($result = SUT::_Hoa_Stream())
@@ -712,13 +715,15 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_destruct_an_opened_stream()
+ public function case_destruct_an_opened_stream(): void
{
$this
->given(
$stream = new \Mock\Hoa\Stream\Test\Unit\SUTWithPublicClose(__FILE__),
$this->calling($stream)->_close = function () use (&$called) {
$called = true;
+
+ return true;
}
)
->when($result = $stream->__destruct())
@@ -727,13 +732,15 @@ class Stream extends Test\Unit\Suite
->isTrue();
}
- public function case_destruct_a_deferred_stream()
+ public function case_destruct_a_deferred_stream(): void
{
$this
->given(
$stream = new \Mock\Hoa\Stream\Test\Unit\SUTWithPublicClose(__FILE__, null, true),
$this->calling($stream)->_close = function () use (&$called) {
$called = true;
+
+ return true;
}
)
->when($result = $stream->__destruct())
@@ -742,7 +749,7 @@ class Stream extends Test\Unit\Suite
->isNull();
}
- public function case_protocol_reach_id()
+ public function case_protocol_reach_id(): void
{
$this
->given(
@@ -755,7 +762,7 @@ class Stream extends Test\Unit\Suite
->isIdenticalTo($stream);
}
- public function case_protocol_reach_unknown_id()
+ public function case_protocol_reach_unknown_id(): void
{
$this
->given($name = 'hoa://Test/Vfs/Foo?type=file')
@@ -768,7 +775,7 @@ class Stream extends Test\Unit\Suite
class SUT extends LUT\Stream
{
- protected function &_open($streamName, LUT\Context $context = null)
+ protected function &_open(string $streamName, ?LUT\Context $context)
{
if (null === $context) {
$out = fopen($streamName, 'rb');
@@ -779,7 +786,7 @@ class SUT extends LUT\Stream
return $out;
}
- protected function _close()
+ protected function _close(): bool
{
return fclose($this->getStream());
}
@@ -787,7 +794,7 @@ class SUT extends LUT\Stream
class SUTWithPublicClose extends SUT
{
- public function _close()
+ public function _close(): bool
{
return parent::_close();
}
diff --git a/Test/Unit/Wrapper/Exception.php b/Test/Unit/Wrapper/Exception.php
index 57829bc..0ed2033 100644
--- a/Test/Unit/Wrapper/Exception.php
+++ b/Test/Unit/Wrapper/Exception.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the wrapper exception.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Exception extends Test\Unit\Suite
{
- public function case_hoa_exception()
+ public function case_hoa_exception(): void
{
$this
->when($result = new SUT('foo', 0))
diff --git a/Test/Unit/Wrapper/IWrapper/File.php b/Test/Unit/Wrapper/IWrapper/File.php
index 5ee10d1..3ed7617 100644
--- a/Test/Unit/Wrapper/IWrapper/File.php
+++ b/Test/Unit/Wrapper/IWrapper/File.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -44,12 +46,11 @@ use Hoa\Test;
*
* Test suite of the file wrapper interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class File extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\Wrapper\IWrapper\File())
diff --git a/Test/Unit/Wrapper/IWrapper/IWrapper.php b/Test/Unit/Wrapper/IWrapper/IWrapper.php
index 23cda46..c67e7ad 100644
--- a/Test/Unit/Wrapper/IWrapper/IWrapper.php
+++ b/Test/Unit/Wrapper/IWrapper/IWrapper.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the wrapper parent interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class IWrapper extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\Wrapper\IWrapper\IWrapper())
diff --git a/Test/Unit/Wrapper/IWrapper/Stream.php b/Test/Unit/Wrapper/IWrapper/Stream.php
index b2f749e..ad66b11 100644
--- a/Test/Unit/Wrapper/IWrapper/Stream.php
+++ b/Test/Unit/Wrapper/IWrapper/Stream.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -44,12 +46,11 @@ use Hoa\Test;
*
* Test suite of the stream wrapper interface.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Stream extends Test\Unit\Suite
{
- public function case_is_a_valid_interface()
+ public function case_is_a_valid_interface(): void
{
$this
->when($result = new \Mock\Hoa\Stream\Wrapper\IWrapper\Stream())
diff --git a/Test/Unit/Wrapper/Wrapper.php b/Test/Unit/Wrapper/Wrapper.php
index 27daed5..f289e62 100644
--- a/Test/Unit/Wrapper/Wrapper.php
+++ b/Test/Unit/Wrapper/Wrapper.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* Hoa
*
@@ -45,12 +47,11 @@ use Hoa\Test;
*
* Test suite of the wrapper class.
*
- * @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Wrapper extends Test\Unit\Suite
{
- public function case_register()
+ public function case_register(): void
{
$this
->given($oldIsRegistered = SUT::isRegistered('foo'))
@@ -64,20 +65,20 @@ class Wrapper extends Test\Unit\Suite
->isTrue();
}
- public function case_register_already_registered()
+ public function case_register_already_registered(): void
{
$this
- ->exception(function () {
+ ->exception(function (): void {
SUT::register('php', 'ClassName');
})
->isInstanceOf(LUT\Exception::class)
->hasMessage('The protocol php is already registered.');
}
- public function case_register_implementation_does_not_exist()
+ public function case_register_implementation_does_not_exist(): void
{
$this
- ->exception(function () {
+ ->exception(function (): void {
SUT::register('foo', 'ClassName');
})
->isInstanceOf(LUT\Exception::class)
@@ -87,7 +88,7 @@ class Wrapper extends Test\Unit\Suite
);
}
- public function case_unregister()
+ public function case_unregister(): void
{
$this
->given(
@@ -104,7 +105,7 @@ class Wrapper extends Test\Unit\Suite
->isFalse();
}
- public function case_unregister_unregistered_protocol()
+ public function case_unregister_unregistered_protocol(): void
{
$this
->when($result = SUT::unregister('foo'))
@@ -113,7 +114,7 @@ class Wrapper extends Test\Unit\Suite
->isFalse();
}
- public function case_restore_registered_protocol()
+ public function case_restore_registered_protocol(): void
{
$this
->when($result = SUT::restore('php'))
@@ -122,7 +123,7 @@ class Wrapper extends Test\Unit\Suite
->isTrue();
}
- public function case_restore_unregistered_protocol()
+ public function case_restore_unregistered_protocol(): void
{
$this
->when($result = SUT::restore('foo'))
@@ -131,7 +132,7 @@ class Wrapper extends Test\Unit\Suite
->isFalse();
}
- public function case_is_registered()
+ public function case_is_registered(): void
{
$this
->when($result = SUT::isRegistered('php'))
@@ -140,7 +141,7 @@ class Wrapper extends Test\Unit\Suite
->isTrue();
}
- public function case_is_not_registered()
+ public function case_is_not_registered(): void
{
$this
->when($result = SUT::isRegistered('foo'))
@@ -149,7 +150,7 @@ class Wrapper extends Test\Unit\Suite
->isFalse();
}
- public function case_get_registered()
+ public function case_get_registered(): void
{
$this
->when($result = SUT::getRegistered())
@@ -166,7 +167,7 @@ class Wrapper extends Test\Unit\Suite
]);
}
- public function case_get_registered_dynamically()
+ public function case_get_registered_dynamically(): void
{
$this
->given($oldCount = count(SUT::getRegistered()))