aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2017-11-07 16:15:37 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2017-11-07 16:15:37 +0100
commitc862614a1b9f6d53c13bc12d51528258ed3a0596 (patch)
tree424e78bfdd82af4ef84501f128ab2148b28054d3
parent1d804f5539ca4c7c990773ae96c881ccf6f4691c (diff)
downloadStream-c862614a1b9f6d53c13bc12d51528258ed3a0596.zip
Stream-c862614a1b9f6d53c13bc12d51528258ed3a0596.tar.gz
Stream-c862614a1b9f6d53c13bc12d51528258ed3a0596.tar.bz2
chore(php) Update to PHP 7.
-rw-r--r--Source/Context.php4
-rw-r--r--Source/Filter/Basic.php2
-rw-r--r--Source/Filter/LateComputed.php2
-rw-r--r--Test/Integration/Stream.php4
-rw-r--r--Test/Unit/Composite.php21
-rw-r--r--Test/Unit/Context.php9
-rw-r--r--Test/Unit/IStream/Touchable.php87
-rw-r--r--Test/Unit/Stream.php7
8 files changed, 26 insertions, 110 deletions
diff --git a/Source/Context.php b/Source/Context.php
index 2e9b84a..e4b6a7f 100644
--- a/Source/Context.php
+++ b/Source/Context.php
@@ -73,10 +73,6 @@ class Context
*/
public static function getInstance(string $id): self
{
- if (empty($id)) {
- throw new Exception('Context ID must not be null.', 0);
- }
-
if (false === static::contextExists($id)) {
static::$_instances[$id] = new static($id);
}
diff --git a/Source/Filter/Basic.php b/Source/Filter/Basic.php
index a3c562c..a29082c 100644
--- a/Source/Filter/Basic.php
+++ b/Source/Filter/Basic.php
@@ -87,7 +87,7 @@ abstract class Basic extends \php_user_filter implements Stream\IStream\Stream
* This method is called whenever data is read from or written to the attach
* stream.
*/
- public function filter($in, $out, int &$consumed, bool $closing): int
+ public function filter($in, $out, &$consumed, $closing)
{
$iBucket = new Stream\Bucket($in);
$oBucket = new Stream\Bucket($out);
diff --git a/Source/Filter/LateComputed.php b/Source/Filter/LateComputed.php
index c4cf8fc..439559d 100644
--- a/Source/Filter/LateComputed.php
+++ b/Source/Filter/LateComputed.php
@@ -59,7 +59,7 @@ abstract class LateComputed extends Basic
* This method is called whenever data is read from or written to the attach
* stream.
*/
- public function filter($in, $out, int &$consumed, bool $closing): int
+ public function filter($in, $out, &$consumed, $closing)
{
$return = self::FEED_ME;
$iBucket = new Stream\Bucket($in);
diff --git a/Test/Integration/Stream.php b/Test/Integration/Stream.php
index 03f7fdb..d39324f 100644
--- a/Test/Integration/Stream.php
+++ b/Test/Integration/Stream.php
@@ -46,8 +46,6 @@ use Hoa\Test;
* Class \Hoa\Stream\Test\Integration\Stream.
*
* Test suite of the stream class.
- *
- * @license New BSD License
*/
class Stream extends Test\Integration\Suite
{
@@ -154,7 +152,7 @@ class Stream extends Test\Integration\Suite
class SUT extends LUT\Stream
{
- protected function &_open(string $streamName, ?LUT\Context $context)
+ protected function &_open(string $streamName, LUT\Context $context = null)
{
if (null === $context) {
$out = fopen($streamName, 'rb');
diff --git a/Test/Unit/Composite.php b/Test/Unit/Composite.php
index 50d9c61..31e0506 100644
--- a/Test/Unit/Composite.php
+++ b/Test/Unit/Composite.php
@@ -38,6 +38,7 @@ declare(strict_types=1);
namespace Hoa\Stream\Test\Unit;
+use Hoa\Stream as LUT;
use Hoa\Test;
use Mock\Hoa\Stream\Composite as SUT;
@@ -81,7 +82,7 @@ class Composite extends Test\Unit\Suite
{
$this
->given(
- $innerStream = new \Mock\Hoa\Stream(__FILE__),
+ $innerStream = new MockedStream(),
$composite = new SUT()
)
->when($result = $this->invoke($composite)->setInnerStream($innerStream))
@@ -94,7 +95,7 @@ class Composite extends Test\Unit\Suite
{
$this
->given(
- $innerStream = new \Mock\Hoa\Stream(__FILE__),
+ $innerStream = new MockedStream(),
$composite = new SUT(),
$this->invoke($composite)->setInnerStream($innerStream)
)
@@ -104,3 +105,19 @@ class Composite extends Test\Unit\Suite
->isIdenticalTo($innerStream);
}
}
+
+class MockedStream extends LUT\Stream
+{
+ public function __construct()
+ {
+ }
+
+ public function &_open(string $fileName, LUT\Context $context = null)
+ {
+ }
+
+ public function _close(): bool
+ {
+ return false;
+ }
+}
diff --git a/Test/Unit/Context.php b/Test/Unit/Context.php
index f45d54c..f56f624 100644
--- a/Test/Unit/Context.php
+++ b/Test/Unit/Context.php
@@ -51,15 +51,6 @@ use Hoa\Test;
*/
class Context extends Test\Unit\Suite
{
- public function case_get_instance_with_empty_id(): void
- {
- $this
- ->exception(function (): void {
- SUT::getInstance(null);
- })
- ->isInstanceOf(LUT\Exception::class);
- }
-
public function case_get_new_instance(): void
{
$this
diff --git a/Test/Unit/IStream/Touchable.php b/Test/Unit/IStream/Touchable.php
deleted file mode 100644
index 5338e0e..0000000
--- a/Test/Unit/IStream/Touchable.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * Hoa
- *
- *
- * @license
- *
- * New BSD License
- *
- * Copyright © 2007-2017, Hoa community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Hoa nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace Hoa\Stream\Test\Unit\IStream;
-
-use Hoa\Stream as LUT;
-use Hoa\Stream\IStream\Touchable as SUT;
-use Hoa\Test;
-
-/**
- * Class \Hoa\Stream\Test\Unit\IStream\Touchable.
- *
- * Test suite of the touchable interface.
- *
- * @license New BSD License
- */
-class Touchable extends Test\Unit\Suite
-{
- public function case_is_a_valid_interface(): void
- {
- $this
- ->when($result = new \Mock\Hoa\Stream\IStream\Touchable())
- ->then
- ->object($result)
- ->isInstanceOf(SUT::class)
- ->isInstanceOf(LUT\IStream\Stream::class);
- }
-
- public function case_constants(): void
- {
- $this
- ->when($result = SUT::OVERWRITE)
- ->then
- ->boolean($result)
- ->isEqualTo(true)
-
- ->when($result = SUT::DO_NOT_OVERWRITE)
- ->then
- ->boolean($result)
- ->isEqualTo(false)
-
- ->when($result = SUT::MAKE_DIRECTORY)
- ->then
- ->boolean($result)
- ->isEqualTo(true)
-
- ->when($result = SUT::DO_NOT_MAKE_DIRECTORY)
- ->then
- ->boolean($result)
- ->isEqualTo(false);
- }
-}
diff --git a/Test/Unit/Stream.php b/Test/Unit/Stream.php
index 58f204b..be9e7f7 100644
--- a/Test/Unit/Stream.php
+++ b/Test/Unit/Stream.php
@@ -39,6 +39,7 @@ declare(strict_types=1);
namespace Hoa\Stream\Test\Unit;
use Hoa\Event;
+use Hoa\Protocol;
use Hoa\Stream as LUT;
use Hoa\Test;
@@ -756,7 +757,7 @@ class Stream extends Test\Unit\Suite
$name = 'hoa://Test/Vfs/Foo?type=file',
$stream = new SUT($name)
)
- ->when($result = resolve('hoa://Library/Stream#' . $name))
+ ->when($result = Protocol\Protocol::getInstance()->resolve('hoa://Library/Stream#' . $name))
->then
->object($result)
->isIdenticalTo($stream);
@@ -766,7 +767,7 @@ class Stream extends Test\Unit\Suite
{
$this
->given($name = 'hoa://Test/Vfs/Foo?type=file')
- ->when($result = resolve('hoa://Library/Stream#' . $name))
+ ->when($result = Protocol\Protocol::getInstance()->resolve('hoa://Library/Stream#' . $name))
->then
->variable($result)
->isNull();
@@ -775,7 +776,7 @@ class Stream extends Test\Unit\Suite
class SUT extends LUT\Stream
{
- protected function &_open(string $streamName, ?LUT\Context $context)
+ protected function &_open(string $streamName, LUT\Context $context = null)
{
if (null === $context) {
$out = fopen($streamName, 'rb');