diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f73dc..9d207f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,15 @@ # Recoil Changelog +### 0.2.1 (2014-10-16) + +* **[IMPROVED]** Added support for cancellable promises + ### 0.2.0 (2014-09-23) To faciliate several performance improvements the following backwards compatibility breaking changes have been introduced: -* **[BC]** `CoroutineInterface` no longer implements `EventEmitterInterface` - several unused events were fired every time a co-routine was called -* **[BC]** `Recoil::finalize()` now only works with generated based co-routines - this was previously implemented using the aforementioned events +* **[BC]** `CoroutineInterface` no longer implements `EventEmitterInterface` - several unused events were fired every time a coroutine was called +* **[BC]** `Recoil::finalize()` now only works with generated based coroutines - this was previously implemented using the aforementioned events ### 0.1.0 (2014-02-04) diff --git a/README.md b/README.md index fa6dc28..069299f 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Recoil::run( yield $redisClient->connect(); - // Yielding an array of co-routines executes them concurrently. + // Yielding an array of coroutines executes them concurrently. yield [ resolveAndStore($redisClient, $dnsResolver, 'recoil.io'), resolveAndStore($redisClient, $dnsResolver, 'reactphp.org'), @@ -176,7 +176,7 @@ Recoil::run( ### Returning a value from a coroutine Because PHP's `return` keyword can not be used to return a value inside a generator, the kernel API provides -`Recoil::return_()` to send a value to the calling coroutine. Just like `return` execution of the coroutine stops when a +`Recoil::return_()` to send a value to the calling coroutine. Just like `return`, execution of the coroutine stops when a value is returned. ```php @@ -246,11 +246,8 @@ adapted into a [PromiseCoroutine](src/Coroutine/PromiseCoroutine.php) instance a the promise has been fulfilled. If the promise is resolved, the resulting value is returned from the yield statement. If it is rejected, the yield -statement throws an exception describing the error. **Recoil** does not yet support progress events. - -React promises are based on the [Promise/A+](https://github.com/promises-aplus/promises-spec) specification, which does -not yet define a mechanism for cancellation of pending promises. As such, terminating a coroutine that is waiting on a -promise simply causes the promise resolution to be ignored. +statement throws an exception describing the error. If a strand is waiting on the resolution of a cancellable promise, +and execution of that strand is terminated the promise is cancelled. **Recoil** does not yet support progress events. The [promise-dns example](examples/promise-dns) demonstrates using the [React DNS component](https://github.com/reactphp/dns), a promised-based API, to resolve several domain names concurrently. [This example](examples/promise-dns-react) shows the @@ -298,7 +295,14 @@ $kernel->execute($coroutine()); $eventLoop->run(); ``` + +## Contact us + +* Follow [@IcecaveStudios](https://twitter.com/IcecaveStudios) on Twitter +* Visit the [Icecave Studios website](http://icecave.com.au) +* Join `#icecave` on [irc.freenode.net](http://webchat.freenode.net?channels=icecave) + [Build Status]: http://img.shields.io/travis/recoilphp/recoil/develop.svg?style=flat-square [Test Coverage]: http://img.shields.io/coveralls/recoilphp/recoil/develop.svg?style=flat-square -[SemVer]: http://img.shields.io/:semver-0.2.0-yellow.svg?style=flat-square +[SemVer]: http://img.shields.io/:semver-0.2.1-yellow.svg?style=flat-square diff --git a/composer.json b/composer.json index ca8930c..26e35b4 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "php": ">=5.5", "evenement/evenement": "~2", "icecave/repr": "~1", - "react/react": "0.4.0|~0.4.2" + "react/react": "0.4.0|~0.4.2", + "react/promise": "~2" }, "require-dev": { "icecave/archer": "~1", diff --git a/composer.lock b/composer.lock index 009698d..a189264 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "be62920bf3acecfdb59bdaffa1fcb367", + "hash": "6c46870c8c4b6ec529f2e4a3c08df6aa", "packages": [ { "name": "evenement/evenement", @@ -197,16 +197,16 @@ }, { "name": "react/promise", - "version": "v2.0.0", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/reactphp/promise.git", - "reference": "58129a9cb9da88f2055309a805e2696b06928bb0" + "reference": "937b04f1b0ee8f6d180e75a0830aac778ca4bcd6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/58129a9cb9da88f2055309a805e2696b06928bb0", - "reference": "58129a9cb9da88f2055309a805e2696b06928bb0", + "url": "https://api.github.com/repos/reactphp/promise/zipball/937b04f1b0ee8f6d180e75a0830aac778ca4bcd6", + "reference": "937b04f1b0ee8f6d180e75a0830aac778ca4bcd6", "shasum": "" }, "require": { @@ -219,11 +219,11 @@ } }, "autoload": { - "psr-0": { - "React\\Promise": "src/" + "psr-4": { + "React\\Promise\\": "src/" }, "files": [ - "src/React/Promise/functions.php" + "src/functions.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -233,13 +233,11 @@ "authors": [ { "name": "Jan Sorgalla", - "email": "jsorgalla@googlemail.com", - "homepage": "http://sorgalla.com", - "role": "maintainer" + "email": "jsorgalla@googlemail.com" } ], "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "time": "2013-12-10 15:40:36" + "time": "2014-10-15 20:05:57" }, { "name": "react/react", @@ -303,17 +301,17 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b" + "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/8faf5cc7e80fde74a650a36e60d32ce3c3e0457b", - "reference": "8faf5cc7e80fde74a650a36e60d32ce3c3e0457b", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/f6281337bf5f985f585d1db6a83adb05ce531f46", + "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46", "shasum": "" }, "require": { @@ -322,7 +320,7 @@ "require-dev": { "psr/log": "~1.0", "symfony/config": "~2.0", - "symfony/dependency-injection": "~2.0", + "symfony/dependency-injection": "~2.0,<2.6.0", "symfony/stopwatch": "~2.2" }, "suggest": { @@ -356,7 +354,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2014-07-28 13:20:46" + "time": "2014-09-28 15:56:11" } ], "packages-dev": [ @@ -813,17 +811,17 @@ }, { "name": "symfony/config", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "080eabdc256c1d7a3a7cf6296271edb68eb1ab2b" + "reference": "0316364bfebc8b080077c731a99f189341476bd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/080eabdc256c1d7a3a7cf6296271edb68eb1ab2b", - "reference": "080eabdc256c1d7a3a7cf6296271edb68eb1ab2b", + "url": "https://api.github.com/repos/symfony/Config/zipball/0316364bfebc8b080077c731a99f189341476bd7", + "reference": "0316364bfebc8b080077c731a99f189341476bd7", "shasum": "" }, "require": { @@ -857,21 +855,21 @@ ], "description": "Symfony Config Component", "homepage": "http://symfony.com", - "time": "2014-08-31 03:22:04" + "time": "2014-09-23 05:25:11" }, { "name": "symfony/console", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "748beed2a1e73179c3f5154d33fe6ae100c1aeb1" + "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/748beed2a1e73179c3f5154d33fe6ae100c1aeb1", - "reference": "748beed2a1e73179c3f5154d33fe6ae100c1aeb1", + "url": "https://api.github.com/repos/symfony/Console/zipball/ca053eaa031c93afb68a71e4eb1f4168dfd4a661", + "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661", "shasum": "" }, "require": { @@ -912,21 +910,21 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-08-14 16:10:54" + "time": "2014-09-25 09:53:56" }, { "name": "symfony/filesystem", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "a765efd199e02ff4001c115c318e219030be9364" + "reference": "4e62fab0060a826561c78b665925b37c870c45f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/a765efd199e02ff4001c115c318e219030be9364", - "reference": "a765efd199e02ff4001c115c318e219030be9364", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/4e62fab0060a826561c78b665925b37c870c45f5", + "reference": "4e62fab0060a826561c78b665925b37c870c45f5", "shasum": "" }, "require": { @@ -959,21 +957,21 @@ ], "description": "Symfony Filesystem Component", "homepage": "http://symfony.com", - "time": "2014-09-03 09:00:14" + "time": "2014-09-22 09:14:18" }, { "name": "symfony/finder", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "f40854d1a19c339c7f969f8f6d6d6e9153311c4c" + "reference": "d5033742b9a6206ef6d06e813870bca18e9205df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/f40854d1a19c339c7f969f8f6d6d6e9153311c4c", - "reference": "f40854d1a19c339c7f969f8f6d6d6e9153311c4c", + "url": "https://api.github.com/repos/symfony/Finder/zipball/d5033742b9a6206ef6d06e813870bca18e9205df", + "reference": "d5033742b9a6206ef6d06e813870bca18e9205df", "shasum": "" }, "require": { @@ -1006,21 +1004,21 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-09-03 09:00:14" + "time": "2014-09-27 08:35:39" }, { "name": "symfony/process", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "136cf0bdaacea81f779583376d47dd8aef4fc6ba" + "reference": "8a1ec96c4e519cee0fb971ea48a1eb7369dda54b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/136cf0bdaacea81f779583376d47dd8aef4fc6ba", - "reference": "136cf0bdaacea81f779583376d47dd8aef4fc6ba", + "url": "https://api.github.com/repos/symfony/Process/zipball/8a1ec96c4e519cee0fb971ea48a1eb7369dda54b", + "reference": "8a1ec96c4e519cee0fb971ea48a1eb7369dda54b", "shasum": "" }, "require": { @@ -1053,21 +1051,21 @@ ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2014-08-31 03:22:04" + "time": "2014-09-23 05:25:11" }, { "name": "symfony/stopwatch", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Stopwatch", "source": { "type": "git", "url": "https://github.com/symfony/Stopwatch.git", - "reference": "22ab4f76cdeefd38b00022a6be5709190a2fd046" + "reference": "9f8a33a24f2378c0ec5f372a8d50b2d43069c050" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/22ab4f76cdeefd38b00022a6be5709190a2fd046", - "reference": "22ab4f76cdeefd38b00022a6be5709190a2fd046", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/9f8a33a24f2378c0ec5f372a8d50b2d43069c050", + "reference": "9f8a33a24f2378c0ec5f372a8d50b2d43069c050", "shasum": "" }, "require": { @@ -1100,21 +1098,21 @@ ], "description": "Symfony Stopwatch Component", "homepage": "http://symfony.com", - "time": "2014-08-14 16:10:54" + "time": "2014-09-22 09:14:18" }, { "name": "symfony/yaml", - "version": "v2.5.4", + "version": "v2.5.5", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "01a7695bcfb013d0a15c6757e15aae120342986f" + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/01a7695bcfb013d0a15c6757e15aae120342986f", - "reference": "01a7695bcfb013d0a15c6757e15aae120342986f", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/b1dbc53593b98c2d694ebf383660ac9134d30b96", + "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96", "shasum": "" }, "require": { @@ -1147,20 +1145,20 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-08-31 03:22:04" + "time": "2014-09-22 09:14:18" }, { "name": "twig/twig", - "version": "v1.16.0", + "version": "v1.16.1", "source": { "type": "git", "url": "https://github.com/fabpot/Twig.git", - "reference": "8ce37115802e257a984a82d38254884085060024" + "reference": "7c4c01dcf578523cfcddf383641a4f12790270ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/8ce37115802e257a984a82d38254884085060024", - "reference": "8ce37115802e257a984a82d38254884085060024", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/7c4c01dcf578523cfcddf383641a4f12790270ec", + "reference": "7c4c01dcf578523cfcddf383641a4f12790270ec", "shasum": "" }, "require": { @@ -1204,7 +1202,7 @@ "keywords": [ "templating" ], - "time": "2014-07-05 12:19:05" + "time": "2014-10-10 14:09:53" } ], "aliases": [ diff --git a/src/Channel/Channel.php b/src/Channel/Channel.php index aaba47f..4ed9a16 100644 --- a/src/Channel/Channel.php +++ b/src/Channel/Channel.php @@ -14,8 +14,8 @@ class Channel implements ReadableChannelInterface, WritableChannelInterface public function __construct() { $this->closed = false; - $this->readStrands = new SplQueue; - $this->writeStrands = new SplQueue; + $this->readStrands = new SplQueue(); + $this->writeStrands = new SplQueue(); } /** @@ -32,7 +32,7 @@ public function __construct() public function read() { if ($this->isClosed()) { - throw new ChannelClosedException; + throw new ChannelClosedException(); } $value = (yield Recoil::suspend( @@ -67,7 +67,7 @@ function ($strand) { public function write($value) { if ($this->isClosed()) { - throw new ChannelClosedException; + throw new ChannelClosedException(); } if ($this->readStrands->isEmpty()) { @@ -94,14 +94,14 @@ public function close() $this ->writeStrands ->pop() - ->resumeWithException(new ChannelClosedException); + ->resumeWithException(new ChannelClosedException()); } while (!$this->readStrands->isEmpty()) { $this ->readStrands ->pop() - ->resumeWithException(new ChannelClosedException); + ->resumeWithException(new ChannelClosedException()); } yield Recoil::noop(); diff --git a/src/Channel/ReadableStreamChannel.php b/src/Channel/ReadableStreamChannel.php index fe2761a..a9e9aba 100644 --- a/src/Channel/ReadableStreamChannel.php +++ b/src/Channel/ReadableStreamChannel.php @@ -27,7 +27,7 @@ public function __construct( $bufferSize = 8192 ) { if (null === $unserializer) { - $unserializer = new PhpUnserializer; + $unserializer = new PhpUnserializer(); } $this->stream = $stream; diff --git a/src/Channel/Serialization/PhpUnserializer.php b/src/Channel/Serialization/PhpUnserializer.php index 08c8c2f..a3b5571 100644 --- a/src/Channel/Serialization/PhpUnserializer.php +++ b/src/Channel/Serialization/PhpUnserializer.php @@ -13,7 +13,7 @@ class PhpUnserializer implements UnserializerInterface public function __construct() { $this->buffer = ''; - $this->packets = new SplQueue; + $this->packets = new SplQueue(); $this->falsePacket = serialize(false); } diff --git a/src/Channel/WritableStreamChannel.php b/src/Channel/WritableStreamChannel.php index 9b99f6e..ef49d25 100644 --- a/src/Channel/WritableStreamChannel.php +++ b/src/Channel/WritableStreamChannel.php @@ -25,7 +25,7 @@ public function __construct( SerializerInterface $serializer = null ) { if (null === $serializer) { - $serializer = new PhpSerializer; + $serializer = new PhpSerializer(); } $this->stream = $stream; diff --git a/src/Coroutine/GeneratorCoroutine.php b/src/Coroutine/GeneratorCoroutine.php index 79f99d2..02ee7bd 100644 --- a/src/Coroutine/GeneratorCoroutine.php +++ b/src/Coroutine/GeneratorCoroutine.php @@ -116,7 +116,7 @@ public function finalize(StrandInterface $strand) } /** - * Register a callback to be invoked when the co-routine is finalized. + * Register a callback to be invoked when the coroutine is finalized. * * @internal * diff --git a/src/Coroutine/PromiseCoroutine.php b/src/Coroutine/PromiseCoroutine.php index d1e8b8f..c7924f6 100644 --- a/src/Coroutine/PromiseCoroutine.php +++ b/src/Coroutine/PromiseCoroutine.php @@ -2,9 +2,10 @@ namespace Recoil\Coroutine; use Exception; +use React\Promise\CancellablePromiseInterface; +use React\Promise\PromiseInterface; use Recoil\Coroutine\Exception\PromiseRejectedException; use Recoil\Kernel\Strand\StrandInterface; -use React\Promise\PromiseInterface; /** * A coroutine that resumes when a promise is fulfilled or rejected. @@ -47,19 +48,15 @@ function ($reason) use ($strand) { } /** - * Adapt a promise rejection reason into an exception. + * Inform the coroutine that the executing strand is being terminated. * - * @param mixed $reason - * - * @return Exception + * @param StrandInterface $strand The strand that is executing the coroutine. */ - protected function adaptReasonToException($reason) + public function terminate(StrandInterface $strand) { - if ($reason instanceof Exception) { - return $reason; + if ($this->promise instanceof CancellablePromiseInterface) { + $this->promise->cancel(); } - - return new PromiseRejectedException($reason); } /** @@ -74,5 +71,21 @@ public function finalize(StrandInterface $strand) $this->promise = null; } + /** + * Adapt a promise rejection reason into an exception. + * + * @param mixed $reason + * + * @return Exception + */ + protected function adaptReasonToException($reason) + { + if ($reason instanceof Exception) { + return $reason; + } + + return new PromiseRejectedException($reason); + } + private $promise; } diff --git a/src/Kernel/Api/Select.php b/src/Kernel/Api/Select.php index 3b5c79f..9adc7b6 100644 --- a/src/Kernel/Api/Select.php +++ b/src/Kernel/Api/Select.php @@ -17,7 +17,7 @@ class Select implements CoroutineInterface public function __construct(array $strands) { - $this->substrands = new SplObjectStorage; + $this->substrands = new SplObjectStorage(); $this->exited = []; foreach ($strands as $index => $strand) { diff --git a/src/Kernel/Api/Timeout.php b/src/Kernel/Api/Timeout.php index 58679be..fa0921a 100644 --- a/src/Kernel/Api/Timeout.php +++ b/src/Kernel/Api/Timeout.php @@ -52,7 +52,7 @@ public function terminate(StrandInterface $strand) { if (!$this->timer) { // Stop termination of the strand and instead propagate a timeout exception. - $strand->throwException(new TimeoutException); + $strand->throwException(new TimeoutException()); } } /** diff --git a/src/Kernel/Api/WaitAll.php b/src/Kernel/Api/WaitAll.php index e785dac..3aed9f7 100644 --- a/src/Kernel/Api/WaitAll.php +++ b/src/Kernel/Api/WaitAll.php @@ -58,7 +58,7 @@ function ($strand, $exception, $preventDefault) { $substrand->on( 'terminate', function () { - $this->exception = new StrandTerminatedException; + $this->exception = new StrandTerminatedException(); } ); diff --git a/src/Kernel/Kernel.php b/src/Kernel/Kernel.php index ee77761..7344adb 100644 --- a/src/Kernel/Kernel.php +++ b/src/Kernel/Kernel.php @@ -33,15 +33,15 @@ public function __construct( } if (null === $api) { - $api = new KernelApi; + $api = new KernelApi(); } if (null === $coroutineAdaptor) { - $coroutineAdaptor = new CoroutineAdaptor; + $coroutineAdaptor = new CoroutineAdaptor(); } if (null === $strandFactory) { - $strandFactory = new StrandFactory; + $strandFactory = new StrandFactory(); } $this->eventLoop = $eventLoop; diff --git a/src/Kernel/Strand/Strand.php b/src/Kernel/Strand/Strand.php index ab38355..6bdd6a7 100644 --- a/src/Kernel/Strand/Strand.php +++ b/src/Kernel/Strand/Strand.php @@ -28,7 +28,7 @@ public function __construct(KernelInterface $kernel) $this->suspended = false; $this->stack = []; - $this->stack[] = $this->current = new StackBase; + $this->stack[] = $this->current = new StackBase(); $kernel->attachStrand($this); } @@ -230,11 +230,10 @@ public function tick() } elseif (self::STATE_TERMINATE === $this->state) { $this->current->terminate($this); - // Check if the tick logic has been changed, if not continue - // with termination of the strand. + // Check if the state has been changed, if not continue with + // termination of the strand. if ($this->state === self::STATE_TERMINATE) { $this->pop(); - // Note that tickLogic is not reset to null. } } else { throw new LogicException('No action has been requested.'); diff --git a/src/PackageInfo.php b/src/PackageInfo.php index 0bdcfba..8c8a2a1 100644 --- a/src/PackageInfo.php +++ b/src/PackageInfo.php @@ -4,5 +4,5 @@ class PackageInfo { const NAME = 'Recoil'; - const VERSION = '0.2.0'; + const VERSION = '0.2.1'; } diff --git a/src/Stream/ReadableReactStream.php b/src/Stream/ReadableReactStream.php index 5f87b68..dd82c8a 100644 --- a/src/Stream/ReadableReactStream.php +++ b/src/Stream/ReadableReactStream.php @@ -48,9 +48,9 @@ public function __construct(ReadableReactStreamInterface $stream) public function read($length) { if ($this->strand) { - throw new StreamLockedException; + throw new StreamLockedException(); } elseif ($this->isClosed()) { - throw new StreamClosedException; + throw new StreamClosedException(); } if (!$this->buffer) { @@ -86,7 +86,7 @@ function ($strand) { public function close() { if ($this->strand) { - $this->strand->resumeWithException(new StreamClosedException); + $this->strand->resumeWithException(new StreamClosedException()); $this->strand = null; } @@ -149,7 +149,7 @@ public function onStreamClose() $this->stream->removeListener('close', [$this, 'onStreamClose']); if ($this->strand) { - $this->strand->resumeWithException(new StreamClosedException); + $this->strand->resumeWithException(new StreamClosedException()); $this->strand = null; } } diff --git a/src/Stream/ReadableStream.php b/src/Stream/ReadableStream.php index ad576eb..e964adc 100644 --- a/src/Stream/ReadableStream.php +++ b/src/Stream/ReadableStream.php @@ -39,9 +39,9 @@ public function __construct($stream) public function read($length) { if ($this->strand) { - throw new StreamLockedException; + throw new StreamLockedException(); } elseif ($this->isClosed()) { - throw new StreamClosedException; + throw new StreamClosedException(); } yield Recoil::suspend( @@ -103,7 +103,7 @@ public function close() ->eventLoop() ->removeReadStream($this->stream); - $this->strand->resumeWithException(new StreamClosedException); + $this->strand->resumeWithException(new StreamClosedException()); $this->strand = null; } diff --git a/src/Stream/WritableReactStream.php b/src/Stream/WritableReactStream.php index 97453af..7fd62a3 100644 --- a/src/Stream/WritableReactStream.php +++ b/src/Stream/WritableReactStream.php @@ -44,9 +44,9 @@ public function __construct(WritableReactStreamInterface $stream) public function write($buffer, $length = null) { if ($this->strand) { - throw new StreamLockedException; + throw new StreamLockedException(); } elseif ($this->isClosed()) { - throw new StreamClosedException; + throw new StreamClosedException(); } if (null === $length) { @@ -100,7 +100,7 @@ public function writeAll($buffer) public function close() { if ($this->strand) { - $this->strand->resumeWithException(new StreamClosedException); + $this->strand->resumeWithException(new StreamClosedException()); $this->strand = null; $this->stream->close(); } else { diff --git a/src/Stream/WritableStream.php b/src/Stream/WritableStream.php index 2029859..1c18c97 100644 --- a/src/Stream/WritableStream.php +++ b/src/Stream/WritableStream.php @@ -39,9 +39,9 @@ public function __construct($stream) public function write($buffer, $length = null) { if ($this->strand) { - throw new StreamLockedException; + throw new StreamLockedException(); } elseif ($this->isClosed()) { - throw new StreamClosedException; + throw new StreamClosedException(); } yield Recoil::suspend( @@ -125,7 +125,7 @@ public function close() ->eventLoop() ->removeWriteStream($this->stream); - $this->strand->resumeWithException(new StreamClosedException); + $this->strand->resumeWithException(new StreamClosedException()); $this->strand = null; } diff --git a/test/suite/Channel/BidirectionalChannelAdaptorTest.php b/test/suite/Channel/BidirectionalChannelAdaptorTest.php index 74c9cb1..f9d4120 100644 --- a/test/suite/Channel/BidirectionalChannelAdaptorTest.php +++ b/test/suite/Channel/BidirectionalChannelAdaptorTest.php @@ -9,8 +9,8 @@ class BidirectionalChannelAdaptorTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->readChannel = Phake::mock(ReadableChannelInterface::CLASS); - $this->writeChannel = Phake::mock(WritableChannelInterface::CLASS); + $this->readChannel = Phake::mock(ReadableChannelInterface::class); + $this->writeChannel = Phake::mock(WritableChannelInterface::class); $this->adaptor = new BidirectionalChannelAdaptor( $this->readChannel, $this->writeChannel diff --git a/test/suite/Channel/ChannelTest.php b/test/suite/Channel/ChannelTest.php index 3178c2c..19fc42e 100644 --- a/test/suite/Channel/ChannelTest.php +++ b/test/suite/Channel/ChannelTest.php @@ -16,8 +16,8 @@ class ChannelTest extends PHPUnit_Framework_TestCase public function setUp() { - $this->kernel = new Kernel; - $this->channel = new Channel; + $this->kernel = new Kernel(); + $this->channel = new Channel(); } public function testMultipleReaders() diff --git a/test/suite/Channel/Exception/ChannelClosedExceptionTest.php b/test/suite/Channel/Exception/ChannelClosedExceptionTest.php index e957a0c..28594c2 100644 --- a/test/suite/Channel/Exception/ChannelClosedExceptionTest.php +++ b/test/suite/Channel/Exception/ChannelClosedExceptionTest.php @@ -8,7 +8,7 @@ class ChannelClosedExceptionTest extends PHPUnit_Framework_TestCase { public function testException() { - $previous = new Exception; + $previous = new Exception(); $exception = new ChannelClosedException($previous); $this->assertSame('Channel is closed.', $exception->getMessage()); diff --git a/test/suite/Channel/Exception/ChannelLockedExceptionTest.php b/test/suite/Channel/Exception/ChannelLockedExceptionTest.php index 16cd08d..e7b57d7 100644 --- a/test/suite/Channel/Exception/ChannelLockedExceptionTest.php +++ b/test/suite/Channel/Exception/ChannelLockedExceptionTest.php @@ -8,7 +8,7 @@ class ChannelLockedExceptionTest extends PHPUnit_Framework_TestCase { public function testException() { - $previous = new Exception; + $previous = new Exception(); $exception = new ChannelLockedException($previous); $this->assertSame('Channel is already in use by another strand.', $exception->getMessage()); diff --git a/test/suite/Channel/ReadableStreamChannelTest.php b/test/suite/Channel/ReadableStreamChannelTest.php index 36cbcd9..b785aa4 100644 --- a/test/suite/Channel/ReadableStreamChannelTest.php +++ b/test/suite/Channel/ReadableStreamChannelTest.php @@ -18,7 +18,7 @@ public function setUp() $this->resource = fopen($this->path, 'r+'); $this->stream = new ReadableStream($this->resource); $this->channel = new ReadableStreamChannel($this->stream); - $this->serializer = new PhpSerializer; + $this->serializer = new PhpSerializer(); } public function tearDown() diff --git a/test/suite/Channel/Serialization/PhpSerializerTest.php b/test/suite/Channel/Serialization/PhpSerializerTest.php index 45ad1ad..4ccc340 100644 --- a/test/suite/Channel/Serialization/PhpSerializerTest.php +++ b/test/suite/Channel/Serialization/PhpSerializerTest.php @@ -7,7 +7,7 @@ class PhpSerializerTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->serializer = new PhpSerializer; + $this->serializer = new PhpSerializer(); } public function testSerialize() diff --git a/test/suite/Channel/Serialization/PhpUnserializerTest.php b/test/suite/Channel/Serialization/PhpUnserializerTest.php index d2d0b86..1ad0cb4 100644 --- a/test/suite/Channel/Serialization/PhpUnserializerTest.php +++ b/test/suite/Channel/Serialization/PhpUnserializerTest.php @@ -7,7 +7,7 @@ class PhpUnserializerTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->unserializer = new PhpUnserializer; + $this->unserializer = new PhpUnserializer(); } public function testFeedMultipleValues() diff --git a/test/suite/Channel/WritableStreamChannelTest.php b/test/suite/Channel/WritableStreamChannelTest.php index 7f1c6d3..d175e20 100644 --- a/test/suite/Channel/WritableStreamChannelTest.php +++ b/test/suite/Channel/WritableStreamChannelTest.php @@ -18,7 +18,7 @@ public function setUp() $this->resource = fopen($this->path, 'w'); $this->stream = new WritableStream($this->resource); $this->channel = new WritableStreamChannel($this->stream); - $this->unserializer = new PhpUnserializer; + $this->unserializer = new PhpUnserializer(); } public function tearDown() diff --git a/test/suite/Coroutine/CoroutineAdaptorTest.php b/test/suite/Coroutine/CoroutineAdaptorTest.php index cdaefb1..a1c2407 100644 --- a/test/suite/Coroutine/CoroutineAdaptorTest.php +++ b/test/suite/Coroutine/CoroutineAdaptorTest.php @@ -13,13 +13,13 @@ class CoroutineAdaptorTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->strand = Phake::mock(StrandInterface::CLASS); - $this->adaptor = new CoroutineAdaptor; + $this->strand = Phake::mock(StrandInterface::class); + $this->adaptor = new CoroutineAdaptor(); } public function testAdaptPassThru() { - $coroutine = Phake::mock(CoroutineInterface::CLASS); + $coroutine = Phake::mock(CoroutineInterface::class); $this->assertSame( $coroutine, @@ -37,7 +37,7 @@ function () { $coroutine = $this->adaptor->adapt($this->strand, $generator); - $this->assertInstanceOf(GeneratorCoroutine::CLASS, $coroutine); + $this->assertInstanceOf(GeneratorCoroutine::class, $coroutine); $this->expectOutputString('123'); $coroutine->call($this->strand); @@ -45,17 +45,17 @@ function () { public function testAdaptWithPromise() { - $promise = Phake::mock(PromiseInterface::CLASS); + $promise = Phake::mock(PromiseInterface::class); $coroutine = $this->adaptor->adapt($this->strand, $promise); - $this->assertInstanceOf(PromiseCoroutine::CLASS, $coroutine); + $this->assertInstanceOf(PromiseCoroutine::class, $coroutine); } public function testAdaptWithArray() { $coroutine = $this->adaptor->adapt($this->strand, ['a', 'b', 'c']); - $this->assertInstanceOf(KernelApiCall::CLASS, $coroutine); + $this->assertInstanceOf(KernelApiCall::class, $coroutine); $this->assertSame('all', $coroutine->name()); $this->assertSame([['a', 'b', 'c']], $coroutine->arguments()); } @@ -64,7 +64,7 @@ public function testAdaptWithNull() { $coroutine = $this->adaptor->adapt($this->strand, null); - $this->assertInstanceOf(KernelApiCall::CLASS, $coroutine); + $this->assertInstanceOf(KernelApiCall::class, $coroutine); $this->assertSame('cooperate', $coroutine->name()); } @@ -80,8 +80,8 @@ public function testAdaptFailure() public function testAdaptProvider() { - $provider = Phake::mock(CoroutineProviderInterface::CLASS); - $coroutine = Phake::mock(CoroutineInterface::CLASS); + $provider = Phake::mock(CoroutineProviderInterface::class); + $coroutine = Phake::mock(CoroutineInterface::class); Phake::when($provider) ->coroutine($this->identicalTo($this->strand)) @@ -95,8 +95,8 @@ public function testAdaptProvider() public function testAdaptNestedProvider() { - $provider = Phake::mock(CoroutineProviderInterface::CLASS); - $coroutine = Phake::mock(CoroutineInterface::CLASS); + $provider = Phake::mock(CoroutineProviderInterface::class); + $coroutine = Phake::mock(CoroutineInterface::class); Phake::when($provider) ->coroutine($this->identicalTo($this->strand)) diff --git a/test/suite/Coroutine/GeneratorCoroutineTest.php b/test/suite/Coroutine/GeneratorCoroutineTest.php index 3937d25..173016c 100644 --- a/test/suite/Coroutine/GeneratorCoroutineTest.php +++ b/test/suite/Coroutine/GeneratorCoroutineTest.php @@ -14,7 +14,7 @@ class GeneratorCoroutineTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->kernel = new Kernel; + $this->kernel = new Kernel(); } public function testCall() diff --git a/test/suite/Coroutine/PromiseCoroutineTest.php b/test/suite/Coroutine/PromiseCoroutineTest.php index 37d9ff0..633200f 100644 --- a/test/suite/Coroutine/PromiseCoroutineTest.php +++ b/test/suite/Coroutine/PromiseCoroutineTest.php @@ -2,13 +2,14 @@ namespace Recoil\Coroutine; use Exception; -use Recoil\Coroutine\Exception\PromiseRejectedException; -use Recoil\Kernel\Kernel; -use Recoil\Recoil; use PHPUnit_Framework_TestCase; use React\Promise\Deferred; use React\Promise\FulfilledPromise; +use React\Promise\Promise; use React\Promise\RejectedPromise; +use Recoil\Coroutine\Exception\PromiseRejectedException; +use Recoil\Kernel\Kernel; +use Recoil\Recoil; /** * @covers Recoil\Coroutine\PromiseCoroutine @@ -18,7 +19,7 @@ class PromiseCoroutineTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->kernel = new Kernel; + $this->kernel = new Kernel(); } public function testFulfilledPromise() @@ -75,13 +76,13 @@ public function testRejectedPromiseWithNonExceptionReason() $this->kernel->eventLoop()->run(); - $this->assertInstanceOf(PromiseRejectedException::CLASS, $exception); + $this->assertInstanceOf(PromiseRejectedException::class, $exception); $this->assertSame('This is the exception.', $exception->reason()); } public function testTerminateThenFulfill() { - $deferred = new Deferred; + $deferred = new Deferred(); $promise = $deferred->promise(); $promiseCoroutine = new PromiseCoroutine($promise); @@ -107,31 +108,31 @@ public function testTerminateThenFulfill() $this->assertFalse($resumed); } - public function testCancelThenReject() + public function testTerminateThenReject() { - $deferred = new Deferred; - $promise = $deferred->promise(); + $cancelled = false; + $promiseCanceller = function () use (&$cancelled) { + $cancelled = true; + }; + + $promise = new Promise(function () {}, $promiseCanceller); $promiseCoroutine = new PromiseCoroutine($promise); - $resumed = null; - $coroutine = function () use (&$resumed, $promiseCoroutine) { - $resumed = false; + $coroutine = function () use ($promiseCoroutine) { yield $promiseCoroutine; - $resumed = true; }; $strand = $this->kernel->execute($coroutine()); - $canceller = function () use ($deferred, $strand) { + $canceller = function () use ($strand) { $strand->terminate(); yield; - $deferred->reject(); }; $this->kernel->execute($canceller()); $this->kernel->eventLoop()->run(); - $this->assertFalse($resumed); + $this->assertTrue($cancelled); } } diff --git a/test/suite/Kernel/Api/KernelApiCallTest.php b/test/suite/Kernel/Api/KernelApiCallTest.php index 7cd2689..0b62023 100644 --- a/test/suite/Kernel/Api/KernelApiCallTest.php +++ b/test/suite/Kernel/Api/KernelApiCallTest.php @@ -12,7 +12,7 @@ class KernelApiCallTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->api = Phake::partialMock(KernelApi::CLASS); + $this->api = Phake::partialMock(KernelApi::class); $this->kernel = new Kernel(null, $this->api); } diff --git a/test/suite/Kernel/Api/KernelApiTest.php b/test/suite/Kernel/Api/KernelApiTest.php index b4794eb..1cd1b83 100644 --- a/test/suite/Kernel/Api/KernelApiTest.php +++ b/test/suite/Kernel/Api/KernelApiTest.php @@ -16,7 +16,7 @@ class KernelApiTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->kernel = new Kernel; + $this->kernel = new Kernel(); $this->tolerance = 0.02; } @@ -348,7 +348,7 @@ public function testExecute() $this->kernel->eventLoop()->run(); - $this->assertInstanceOf(StrandInterface::CLASS, $strand); + $this->assertInstanceOf(StrandInterface::class, $strand); } public function testStop() diff --git a/test/suite/Kernel/Api/SelectTest.php b/test/suite/Kernel/Api/SelectTest.php index f1269bb..59174af 100644 --- a/test/suite/Kernel/Api/SelectTest.php +++ b/test/suite/Kernel/Api/SelectTest.php @@ -9,7 +9,7 @@ class SelectTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->kernel = new Kernel; + $this->kernel = new Kernel(); } public function testSelect() diff --git a/test/suite/Kernel/Api/SleepTest.php b/test/suite/Kernel/Api/SleepTest.php index 1783db7..42b1ac2 100644 --- a/test/suite/Kernel/Api/SleepTest.php +++ b/test/suite/Kernel/Api/SleepTest.php @@ -10,7 +10,7 @@ class SleepTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->kernel = new Kernel; + $this->kernel = new Kernel(); $this->tolerance = 0.02; } diff --git a/test/suite/Kernel/Api/TimeoutTest.php b/test/suite/Kernel/Api/TimeoutTest.php index 84aff0b..bafc8e2 100644 --- a/test/suite/Kernel/Api/TimeoutTest.php +++ b/test/suite/Kernel/Api/TimeoutTest.php @@ -11,7 +11,7 @@ class TimeoutTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->kernel = new Kernel; + $this->kernel = new Kernel(); } public function testTimeout() diff --git a/test/suite/Kernel/Api/WaitAllTest.php b/test/suite/Kernel/Api/WaitAllTest.php index b8c4f00..c19c804 100644 --- a/test/suite/Kernel/Api/WaitAllTest.php +++ b/test/suite/Kernel/Api/WaitAllTest.php @@ -52,7 +52,7 @@ function () { ]); // Do not allow the exception to propagate to verify that the non-failed - // co-routine is terminated (the "X" is never echoed). + // coroutine is terminated (the "X" is never echoed). } catch (Exception $e) { $this->assertSame('This is the exception.', $e->getMessage()); @@ -84,9 +84,9 @@ function () { ]); // Do not allow the exception to propagate to verify that the non-failed - // co-routine is terminated (the "X" is never echoed). + // coroutine is terminated (the "X" is never echoed). } catch (Exception $e) { - $this->assertInstanceOf(StrandTerminatedException::CLASS, $e); + $this->assertInstanceOf(StrandTerminatedException::class, $e); return; } diff --git a/test/suite/Kernel/Exception/StrandTerminatedExceptionTest.php b/test/suite/Kernel/Exception/StrandTerminatedExceptionTest.php index c14ba86..db4ae07 100644 --- a/test/suite/Kernel/Exception/StrandTerminatedExceptionTest.php +++ b/test/suite/Kernel/Exception/StrandTerminatedExceptionTest.php @@ -7,7 +7,7 @@ class StrandTerminatedExceptionTest extends PHPUnit_Framework_TestCase { public function testException() { - $exception = new StrandTerminatedException; + $exception = new StrandTerminatedException(); $this->assertSame('Execution has terminated.', $exception->getMessage()); } diff --git a/test/suite/Kernel/Exception/TimeoutExceptionTest.php b/test/suite/Kernel/Exception/TimeoutExceptionTest.php index df91d38..71b9f64 100644 --- a/test/suite/Kernel/Exception/TimeoutExceptionTest.php +++ b/test/suite/Kernel/Exception/TimeoutExceptionTest.php @@ -7,7 +7,7 @@ class TimeoutExceptionTest extends PHPUnit_Framework_TestCase { public function testException() { - $exception = new TimeoutException; + $exception = new TimeoutException(); $this->assertSame('Execution has timed out.', $exception->getMessage()); } diff --git a/test/suite/Kernel/KernelFunctionalTest.php b/test/suite/Kernel/KernelFunctionalTest.php index ca60598..6e9ad01 100644 --- a/test/suite/Kernel/KernelFunctionalTest.php +++ b/test/suite/Kernel/KernelFunctionalTest.php @@ -14,7 +14,7 @@ class KernelFunctionalTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->kernel = new Kernel; + $this->kernel = new Kernel(); } /** diff --git a/test/suite/Kernel/KernelTest.php b/test/suite/Kernel/KernelTest.php index 90017dd..3a646c6 100644 --- a/test/suite/Kernel/KernelTest.php +++ b/test/suite/Kernel/KernelTest.php @@ -12,15 +12,15 @@ class KernelTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->kernel = new Kernel; + $this->kernel = new Kernel(); } public function testConstructorDefaults() { - $this->assertInstanceOf(KernelApi::CLASS, $this->kernel->api()); - $this->assertInstanceOf(CoroutineAdaptor::CLASS, $this->kernel->coroutineAdaptor()); - $this->assertInstanceOf(StrandFactory::CLASS, $this->kernel->strandFactory()); - $this->assertInstanceOf(LoopInterface::CLASS, $this->kernel->eventLoop()); + $this->assertInstanceOf(KernelApi::class, $this->kernel->api()); + $this->assertInstanceOf(CoroutineAdaptor::class, $this->kernel->coroutineAdaptor()); + $this->assertInstanceOf(StrandFactory::class, $this->kernel->strandFactory()); + $this->assertInstanceOf(LoopInterface::class, $this->kernel->eventLoop()); } public function testStop() diff --git a/test/suite/Kernel/Strand/StrandFunctionalTest.php b/test/suite/Kernel/Strand/StrandFunctionalTest.php index 3166cec..80fb690 100644 --- a/test/suite/Kernel/Strand/StrandFunctionalTest.php +++ b/test/suite/Kernel/Strand/StrandFunctionalTest.php @@ -13,7 +13,7 @@ class StrandFunctionalTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->kernel = new Kernel; + $this->kernel = new Kernel(); } /** diff --git a/test/suite/RecoilTest.php b/test/suite/RecoilTest.php index 0df0c9a..f7dd268 100644 --- a/test/suite/RecoilTest.php +++ b/test/suite/RecoilTest.php @@ -27,7 +27,7 @@ function () { echo 'test'; yield; }, - new StreamSelectLoop + new StreamSelectLoop() ); } } diff --git a/test/suite/Stream/BidirectionalStreamAdaptorTest.php b/test/suite/Stream/BidirectionalStreamAdaptorTest.php index 7ce174b..191d432 100644 --- a/test/suite/Stream/BidirectionalStreamAdaptorTest.php +++ b/test/suite/Stream/BidirectionalStreamAdaptorTest.php @@ -9,8 +9,8 @@ class BidirectionalStreamAdaptorTest extends PHPUnit_Framework_TestCase { public function setUp() { - $this->readStream = Phake::mock(ReadableStreamInterface::CLASS); - $this->writeStream = Phake::mock(WritableStreamInterface::CLASS); + $this->readStream = Phake::mock(ReadableStreamInterface::class); + $this->writeStream = Phake::mock(WritableStreamInterface::class); $this->adaptor = new BidirectionalStreamAdaptor( $this->readStream, $this->writeStream diff --git a/test/suite/Stream/Exception/StreamClosedExceptionTest.php b/test/suite/Stream/Exception/StreamClosedExceptionTest.php index 8bedcab..c505a66 100644 --- a/test/suite/Stream/Exception/StreamClosedExceptionTest.php +++ b/test/suite/Stream/Exception/StreamClosedExceptionTest.php @@ -8,7 +8,7 @@ class StreamClosedExceptionTest extends PHPUnit_Framework_TestCase { public function testException() { - $previous = new Exception; + $previous = new Exception(); $exception = new StreamClosedException($previous); $this->assertSame('Stream is closed.', $exception->getMessage()); diff --git a/test/suite/Stream/Exception/StreamLockedExceptionTest.php b/test/suite/Stream/Exception/StreamLockedExceptionTest.php index 62a7b91..0e61f31 100644 --- a/test/suite/Stream/Exception/StreamLockedExceptionTest.php +++ b/test/suite/Stream/Exception/StreamLockedExceptionTest.php @@ -8,7 +8,7 @@ class StreamLockedExceptionTest extends PHPUnit_Framework_TestCase { public function testException() { - $previous = new Exception; + $previous = new Exception(); $exception = new StreamLockedException($previous); $this->assertSame('Stream is already in use by another strand.', $exception->getMessage()); diff --git a/test/suite/Stream/Exception/StreamReadExceptionTest.php b/test/suite/Stream/Exception/StreamReadExceptionTest.php index 24375cf..9fa2c7f 100644 --- a/test/suite/Stream/Exception/StreamReadExceptionTest.php +++ b/test/suite/Stream/Exception/StreamReadExceptionTest.php @@ -8,7 +8,7 @@ class StreamReadExceptionTest extends PHPUnit_Framework_TestCase { public function testException() { - $previous = new Exception; + $previous = new Exception(); $exception = new StreamReadException($previous); $this->assertSame('An error occurred while reading from the stream.', $exception->getMessage()); diff --git a/test/suite/Stream/Exception/StreamWriteExceptionTest.php b/test/suite/Stream/Exception/StreamWriteExceptionTest.php index 75ec5a0..1d0d875 100644 --- a/test/suite/Stream/Exception/StreamWriteExceptionTest.php +++ b/test/suite/Stream/Exception/StreamWriteExceptionTest.php @@ -8,7 +8,7 @@ class StreamWriteExceptionTest extends PHPUnit_Framework_TestCase { public function testException() { - $previous = new Exception; + $previous = new Exception(); $exception = new StreamWriteException($previous); $this->assertSame('An error occurred while writing to the stream.', $exception->getMessage()); diff --git a/test/suite/Stream/ReadableReactStreamTest.php b/test/suite/Stream/ReadableReactStreamTest.php index 47b0472..fcd9a83 100644 --- a/test/suite/Stream/ReadableReactStreamTest.php +++ b/test/suite/Stream/ReadableReactStreamTest.php @@ -17,12 +17,12 @@ public function createStream() { $this->reactStream = new Stream($this->resource, $this->eventLoop); - return Phake::partialMock(ReadableReactStream::CLASS, $this->reactStream); + return Phake::partialMock(ReadableReactStream::class, $this->reactStream); } public function testReadFailure() { - $this->setExpectedException(StreamReadException::CLASS); + $this->setExpectedException(StreamReadException::class); Phake::when($this->eventLoop) ->removeReadStream(Phake::anyParameters()) @@ -30,7 +30,7 @@ public function testReadFailure() function () { $this->reactStream->emit( 'error', - [new Exception, $this->reactStream] + [new Exception(), $this->reactStream] ); } ); @@ -49,7 +49,7 @@ public function testCloseBeforeEnd() ->onStreamEnd(Phake::anyParameters()) ->thenReturn(null); - $this->setExpectedException(StreamClosedException::CLASS); + $this->setExpectedException(StreamClosedException::class); Recoil::run( function () { diff --git a/test/suite/Stream/ReadableStreamTest.php b/test/suite/Stream/ReadableStreamTest.php index 422946c..95f9582 100644 --- a/test/suite/Stream/ReadableStreamTest.php +++ b/test/suite/Stream/ReadableStreamTest.php @@ -17,7 +17,7 @@ public function createStream() public function testReadFailure() { - $this->setExpectedException(StreamReadException::CLASS); + $this->setExpectedException(StreamReadException::class); Phake::when($this->eventLoop) ->removeReadStream(Phake::anyParameters()) diff --git a/test/suite/Stream/WritableReactStreamTest.php b/test/suite/Stream/WritableReactStreamTest.php index 72bad04..0b25674 100644 --- a/test/suite/Stream/WritableReactStreamTest.php +++ b/test/suite/Stream/WritableReactStreamTest.php @@ -36,12 +36,12 @@ function () { public function testWriteError() { - $this->setExpectedException(StreamWriteException::CLASS); + $this->setExpectedException(StreamWriteException::class); Recoil::run( function () { $coroutine = function () { - $this->stream->onStreamError(new Exception); + $this->stream->onStreamError(new Exception()); yield Recoil::noop(); };