diff --git a/composer.json b/composer.json index 79921091..0b0315ef 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "require-dev": { "satooshi/php-coveralls": "~1.0", "phpunit/phpunit": "^8.5 || ^9", - "react/event-loop": "^1.0 || ^0.5 || ^0.4.2" + "react/event-loop": "^1.0 || ^0.5 || ^0.4.2", + "rector/rector": "^2.0" }, "suggest": { "react/event-loop": "Used for scheduling async operations" diff --git a/demo/bootstrap.php b/demo/bootstrap.php index d21dbb45..84106c34 100644 --- a/demo/bootstrap.php +++ b/demo/bootstrap.php @@ -30,9 +30,9 @@ function asString($value) { $createStdoutObserver = function ($prefix = '') { return new Rx\Observer\CallbackObserver( - function ($value) use ($prefix) { echo $prefix . "Next value: " . asString($value) . "\n"; }, - function ($error) use ($prefix) { echo $prefix . "Exception: " . $error->getMessage() . "\n"; }, - function () use ($prefix) { echo $prefix . "Complete!\n"; } + function ($value) use ($prefix): void { echo $prefix . "Next value: " . asString($value) . "\n"; }, + function ($error) use ($prefix): void { echo $prefix . "Exception: " . $error->getMessage() . "\n"; }, + function () use ($prefix): void { echo $prefix . "Complete!\n"; } ); }; @@ -42,6 +42,6 @@ function () use ($prefix) { echo $prefix . "Complete!\n"; } Scheduler::setDefaultFactory(function () use ($loop) { return new Scheduler\EventLoopScheduler($loop); }); -register_shutdown_function(function () use ($loop) { +register_shutdown_function(function () use ($loop): void { $loop->run(); }); diff --git a/demo/create/create.php b/demo/create/create.php index f550e6bd..9451797f 100644 --- a/demo/create/create.php +++ b/demo/create/create.php @@ -9,7 +9,7 @@ $observer->onNext(42); $observer->onCompleted(); - return new CallbackDisposable(function () { + return new CallbackDisposable(function (): void { echo "Disposed\n"; }); }); diff --git a/demo/create/createObservable.php b/demo/create/createObservable.php index bf0bd067..1874ae93 100644 --- a/demo/create/createObservable.php +++ b/demo/create/createObservable.php @@ -9,7 +9,7 @@ $observer->onNext(42); $observer->onCompleted(); - return new CallbackDisposable(function () { + return new CallbackDisposable(function (): void { echo "Disposed\n"; }); }); diff --git a/demo/custom-operator/Rot13Operator.php b/demo/custom-operator/Rot13Operator.php index 7476e6b5..a12e4fde 100644 --- a/demo/custom-operator/Rot13Operator.php +++ b/demo/custom-operator/Rot13Operator.php @@ -15,7 +15,7 @@ class Rot13Operator implements OperatorInterface public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { return $observable->subscribe( - function ($json) use ($observer) { + function ($json) use ($observer): void { $observer->onNext(str_rot13($json)); }, [$observer, 'onError'], diff --git a/demo/delay/delay.php b/demo/delay/delay.php index 0f266f39..552dd354 100644 --- a/demo/delay/delay.php +++ b/demo/delay/delay.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/../bootstrap.php'; \Rx\Observable::interval(1000) - ->doOnNext(function ($x) { + ->doOnNext(function ($x): void { echo 'Side effect: ' . $x . "\n"; }) ->delay(500) diff --git a/demo/do/do.php b/demo/do/do.php index dc6abe2a..57b8baf2 100644 --- a/demo/do/do.php +++ b/demo/do/do.php @@ -4,13 +4,13 @@ $source = \Rx\Observable::range(0, 3) ->do( - function ($x) { + function ($x): void { echo 'Do Next:', $x, PHP_EOL; }, - function (Throwable $err) { + function (Throwable $err): void { echo 'Do Error:', $err->getMessage(), PHP_EOL; }, - function () { + function (): void { echo 'Do Completed', PHP_EOL; } ); diff --git a/demo/do/doOnCompleted.php b/demo/do/doOnCompleted.php index 7bbf9e4a..05bdc342 100644 --- a/demo/do/doOnCompleted.php +++ b/demo/do/doOnCompleted.php @@ -3,7 +3,7 @@ require_once __DIR__ . '/../bootstrap.php'; $source = \Rx\Observable::empty() - ->doOnCompleted(function () { + ->doOnCompleted(function (): void { echo 'Do Completed', PHP_EOL; }); diff --git a/demo/do/doOnError.php b/demo/do/doOnError.php index 84185694..3851034a 100644 --- a/demo/do/doOnError.php +++ b/demo/do/doOnError.php @@ -3,7 +3,7 @@ require_once __DIR__ . '/../bootstrap.php'; $source = \Rx\Observable::error(new Exception('Oops')) - ->doOnError(function (Throwable $err) { + ->doOnError(function (Throwable $err): void { echo 'Do Error:', $err->getMessage(), PHP_EOL; }); diff --git a/demo/do/doOnNext.php b/demo/do/doOnNext.php index 086023df..ec50cebe 100644 --- a/demo/do/doOnNext.php +++ b/demo/do/doOnNext.php @@ -3,7 +3,7 @@ require_once __DIR__ . '/../bootstrap.php'; $source = \Rx\Observable::range(0, 3) - ->doOnNext(function ($x) { + ->doOnNext(function ($x): void { echo 'Do Next:', $x, PHP_EOL; }); diff --git a/demo/finally/finally-error.php b/demo/finally/finally-error.php index f1567ae0..5f6e9c16 100644 --- a/demo/finally/finally-error.php +++ b/demo/finally/finally-error.php @@ -9,7 +9,7 @@ } return $value; }) - ->finally(function() { + ->finally(function(): void { echo "Finally\n"; }) ->subscribe($stdoutObserver); diff --git a/demo/finally/finally.php b/demo/finally/finally.php index c41ce58d..7f269287 100644 --- a/demo/finally/finally.php +++ b/demo/finally/finally.php @@ -3,7 +3,7 @@ require_once __DIR__ . '/../bootstrap.php'; Rx\Observable::range(1, 3) - ->finally(function() { + ->finally(function(): void { echo "Finally\n"; }) ->subscribe($stdoutObserver); diff --git a/demo/groupBy/groupBy.php b/demo/groupBy/groupBy.php index af161ece..88f9c961 100644 --- a/demo/groupBy/groupBy.php +++ b/demo/groupBy/groupBy.php @@ -17,6 +17,6 @@ function ($key) { return $key; } ) - ->subscribe(function ($groupedObserver) use ($createStdoutObserver) { + ->subscribe(function ($groupedObserver) use ($createStdoutObserver): void { $groupedObserver->subscribe($createStdoutObserver($groupedObserver->getKey() . ": ")); }); diff --git a/demo/groupBy/groupByUntil.php b/demo/groupBy/groupByUntil.php index 69bc04ed..bcbb2584 100644 --- a/demo/groupBy/groupByUntil.php +++ b/demo/groupBy/groupByUntil.php @@ -34,17 +34,17 @@ function ($x) { }); $subscription = $source->subscribe(new CallbackObserver( - function (\Rx\Observable $obs) { + function (\Rx\Observable $obs): void { // Print the count $obs->count()->subscribe(new CallbackObserver( - function ($x) { + function ($x): void { echo 'Count: ', $x, PHP_EOL; })); }, - function (Throwable $err) { + function (Throwable $err): void { echo 'Error', $err->getMessage(), PHP_EOL; }, - function () { + function (): void { echo 'Completed', PHP_EOL; })); diff --git a/demo/promise/toPromise.php b/demo/promise/toPromise.php index 860a8870..ec7bdcb9 100644 --- a/demo/promise/toPromise.php +++ b/demo/promise/toPromise.php @@ -5,6 +5,6 @@ $promise = \Rx\Observable::of(42) ->toPromise(); -$promise->then(function ($value) { +$promise->then(function ($value): void { echo "Value: {$value}\n"; }); diff --git a/demo/publish/publish.php b/demo/publish/publish.php index 5e7288de..4905760d 100644 --- a/demo/publish/publish.php +++ b/demo/publish/publish.php @@ -7,7 +7,7 @@ $source = $interval ->take(2) - ->doOnNext(function ($x) { + ->doOnNext(function ($x): void { echo "Side effect\n"; }); diff --git a/demo/publish/publishLast.php b/demo/publish/publishLast.php index 20094787..00b6b399 100644 --- a/demo/publish/publishLast.php +++ b/demo/publish/publishLast.php @@ -6,7 +6,7 @@ $source = $range ->take(2) - ->doOnNext(function ($x) { + ->doOnNext(function ($x): void { echo "Side effect\n"; }); diff --git a/demo/publish/publishValue.php b/demo/publish/publishValue.php index 8b7d43a0..2fbf825c 100644 --- a/demo/publish/publishValue.php +++ b/demo/publish/publishValue.php @@ -6,7 +6,7 @@ $source = $range ->take(2) - ->doOnNext(function ($x) { + ->doOnNext(function ($x): void { echo "Side effect\n"; }); diff --git a/demo/recursive-scheduler/recursive-scheduler.php b/demo/recursive-scheduler/recursive-scheduler.php index 63440c1f..a2f28673 100644 --- a/demo/recursive-scheduler/recursive-scheduler.php +++ b/demo/recursive-scheduler/recursive-scheduler.php @@ -18,7 +18,7 @@ public function __construct($value) public function _subscribe(\Rx\ObserverInterface $observer): \Rx\DisposableInterface { - return \Rx\Scheduler::getDefault()->scheduleRecursive(function ($reschedule) use ($observer) { + return \Rx\Scheduler::getDefault()->scheduleRecursive(function ($reschedule) use ($observer): void { $observer->onNext($this->value); $reschedule(); }); @@ -31,14 +31,14 @@ public function _subscribe(\Rx\ObserverInterface $observer): \Rx\DisposableInter $observable = new RecursiveReturnObservable(21); $disposable = $observable->subscribe($stdoutObserver); -Loop::repeat(100, function () { +Loop::repeat(100, function (): void { $memory = memory_get_usage() / 1024; $formatted = number_format($memory, 3) . 'K'; echo "Current memory usage: {$formatted}\n"; }); // after a second we'll dispose the 21 observable -Loop::delay(1000, function () use ($disposable) { +Loop::delay(1000, function () use ($disposable): void { echo "Disposing 21 observable.\n"; $disposable->dispose(); }); diff --git a/demo/repeat/repeatWhen.php b/demo/repeat/repeatWhen.php index 88ca3969..7fe44115 100644 --- a/demo/repeat/repeatWhen.php +++ b/demo/repeat/repeatWhen.php @@ -9,7 +9,7 @@ return $acc + $x; }, 0) ->delay(1000) - ->doOnNext(function () { + ->doOnNext(function (): void { echo "1 second delay", PHP_EOL; }) ->takeWhile(function ($count) { diff --git a/demo/replay/replay.php b/demo/replay/replay.php index 7a33bbdf..d61b3c91 100644 --- a/demo/replay/replay.php +++ b/demo/replay/replay.php @@ -6,7 +6,7 @@ $source = $interval ->take(2) - ->doOnNext(function ($x) { + ->doOnNext(function ($x): void { echo $x, ' something', PHP_EOL; echo 'Side effect', PHP_EOL; }); diff --git a/demo/share/share.php b/demo/share/share.php index 5a10daf1..6e150fa2 100644 --- a/demo/share/share.php +++ b/demo/share/share.php @@ -5,7 +5,7 @@ //With Share $source = \Rx\Observable::interval(1000) ->take(2) - ->doOnNext(function ($x) { + ->doOnNext(function ($x): void { echo "Side effect\n"; }); diff --git a/demo/share/shareReplay.php b/demo/share/shareReplay.php index 59bd8771..edd63afa 100644 --- a/demo/share/shareReplay.php +++ b/demo/share/shareReplay.php @@ -6,7 +6,7 @@ $source = $interval ->take(4) - ->doOnNext(function ($x) { + ->doOnNext(function ($x): void { echo 'Side effect', PHP_EOL; }); diff --git a/demo/share/shareValue.php b/demo/share/shareValue.php index 133fc028..a1a43d5a 100644 --- a/demo/share/shareValue.php +++ b/demo/share/shareValue.php @@ -4,7 +4,7 @@ $source = \Rx\Observable::interval(1000) ->take(2) - ->doOnNext(function ($x) { + ->doOnNext(function ($x): void { echo "Side effect\n"; }); diff --git a/demo/share/singleInstance.php b/demo/share/singleInstance.php index 5ab9bf0e..53ab5332 100644 --- a/demo/share/singleInstance.php +++ b/demo/share/singleInstance.php @@ -6,7 +6,7 @@ $source = $interval ->take(2) - ->do(function () { + ->do(function (): void { echo 'Side effect', PHP_EOL; }); @@ -16,7 +16,7 @@ $single->subscribe($createStdoutObserver('SourceA ')); $single->subscribe($createStdoutObserver('SourceB ')); -\Rx\Observable::timer(5000)->subscribe(function () use ($single, &$createStdoutObserver) { +\Rx\Observable::timer(5000)->subscribe(function () use ($single, &$createStdoutObserver): void { // resubscribe two times again, more than 5 seconds later, // long after the original two subscriptions have ended $single->subscribe($createStdoutObserver('SourceC ')); diff --git a/demo/subscribeOn/subscribeOn.php b/demo/subscribeOn/subscribeOn.php index c7c6f8e7..34abbfea 100644 --- a/demo/subscribeOn/subscribeOn.php +++ b/demo/subscribeOn/subscribeOn.php @@ -10,7 +10,7 @@ $loop = Factory::create(); $observable = Rx\Observable::create(function (ObserverInterface $observer) use ($loop) { - $handler = function () use ($observer) { + $handler = function () use ($observer): void { $observer->onNext(42); $observer->onCompleted(); }; @@ -18,7 +18,7 @@ // Change scheduler for here $timer = $loop->addTimer(0.001, $handler); - return new CallbackDisposable(function () use ($loop, $timer) { + return new CallbackDisposable(function () use ($loop, $timer): void { // And change scheduler for here if ($timer) { $loop->cancelTimer($timer); diff --git a/demo/test.php b/demo/test.php index 6affc7ec..9a3963ab 100644 --- a/demo/test.php +++ b/demo/test.php @@ -8,7 +8,7 @@ function run_cmd($file) { $output, $exit_code ); - return array($exit_code, implode("\n", $output)); + return [$exit_code, implode("\n", $output)]; } function run_demo($file) { @@ -38,7 +38,7 @@ function has_expect($file) { } function strip_cwd($cwd, $absolute_path) { - $is_prefix = 0 === strpos($absolute_path, $cwd); + $is_prefix = str_starts_with($absolute_path, $cwd); if (!$is_prefix) { return $absolute_path; } diff --git a/demo/toArray/toArray.php b/demo/toArray/toArray.php index 8d19fbac..5e181f9d 100644 --- a/demo/toArray/toArray.php +++ b/demo/toArray/toArray.php @@ -10,7 +10,7 @@ $subscription = $source->toArray() ->subscribe(new CallbackObserver( - function ($array) use ($observer) { + function ($array) use ($observer): void { $observer->onNext(json_encode($array)); }, [$observer, "onError"], diff --git a/demo/zip/zip.php b/demo/zip/zip.php index 1ea94175..b99f72e6 100644 --- a/demo/zip/zip.php +++ b/demo/zip/zip.php @@ -17,7 +17,7 @@ $subscription = $source ->subscribe(new CallbackObserver( - function ($array) use ($observer) { + function ($array) use ($observer): void { $observer->onNext(json_encode($array)); }, [$observer, 'onError'], diff --git a/docs/build-docs.php b/docs/build-docs.php index 95813adb..871fe7a0 100644 --- a/docs/build-docs.php +++ b/docs/build-docs.php @@ -10,12 +10,12 @@ require_once __DIR__ . '/doc-writer.php'; require_once __DIR__ . '/utils.php'; -function println($line) { +function println($line): void { $args = func_get_args(); echo call_user_func_array('sprintf', $args) . "\n"; } -function run_lint() { +function run_lint(): void { $docs = load_all_docs(); println("Successfully loaded documentation for %d observables/operators\n", count($docs) @@ -33,7 +33,7 @@ function run_lint() { exit(0); } -function run_reactivex() { +function run_reactivex(): void { $allDocs = load_all_docs(); $docs = array_filter($allDocs, function ($doc) { @@ -74,14 +74,14 @@ function($item) { return $item->reactivexId; } exit(0); } -function run_usage() { +function run_usage(): void { println("Usage: $argv[0] "); println(" lint Verifies that documentation can be loaded"); println(" reactivex Updates the reactivex documentation"); exit(1); } -function main($argv) { +function main($argv): void { if (count($argv) !== 2) { run_usage(); } diff --git a/docs/doc-loader.php b/docs/doc-loader.php index a075555c..479a7c45 100644 --- a/docs/doc-loader.php +++ b/docs/doc-loader.php @@ -132,7 +132,7 @@ function has_documentation_tag(\ReflectionMethod $method) { } function load_all_docs() { - $observable = new \ReflectionClass('Rx\Observable'); + $observable = new \ReflectionClass(\Rx\Observable::class); $possibleMethods = $observable ->getMethods(ReflectionMethod::IS_STATIC|ReflectionMethod::IS_PUBLIC); diff --git a/docs/doc-writer.php b/docs/doc-writer.php index 0b596456..30d4ee47 100644 --- a/docs/doc-writer.php +++ b/docs/doc-writer.php @@ -12,7 +12,7 @@ function load_all_reactivex_docs($docsPath) { return $docsPerId; } -function update_documentation($path, $docs) { +function update_documentation($path, $docs): void { $htmlDocs = build_documentation($docs); $currentDocumentation = file_get_contents($path); $currentLines = explode("\n", $currentDocumentation); @@ -67,7 +67,7 @@ function get_replace_position($lines) { break; } } - return array($start, $end - $start + 1); + return [$start, $end - $start + 1]; } function build_documentation($docs) { diff --git a/docs/utils.php b/docs/utils.php index eb5c281b..f2afb33f 100644 --- a/docs/utils.php +++ b/docs/utils.php @@ -2,7 +2,7 @@ abstract class Str { public static function contains($haystack, $needle) { - return false !== strpos($haystack, $needle); + return str_contains($haystack, $needle); } public static function containsAny($haystack, $needles) { @@ -20,7 +20,7 @@ public static function firstWord($haystack) { } public static function startsWith($haystack, $needle) { - return 0 === strpos($haystack, $needle); + return str_starts_with($haystack, $needle); } public static function substringAfter($haystack, $needle) { @@ -62,5 +62,5 @@ function run_cmd($cmd) { $output = []; $exitCode = 0; exec($cmd, $output, $exitCode); - return array($exitCode, $output); + return [$exitCode, $output]; } diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..e3278ded --- /dev/null +++ b/rector.php @@ -0,0 +1,22 @@ +withPaths([ + __DIR__ . '/demo', + __DIR__ . '/docs', + __DIR__ . '/src', + __DIR__ . '/test', + ]) + ->withPhpVersion(80400) + ->withPhpSets() + ->withTypeCoverageLevel(2) + ->withDeadCodeLevel(0) + ->withCodeQualityLevel(0) + ->withRules([ + ExplicitNullableParamTypeRector::class, + ]); diff --git a/src/Disposable/RefCountDisposable.php b/src/Disposable/RefCountDisposable.php index 59d0e67d..5718902b 100644 --- a/src/Disposable/RefCountDisposable.php +++ b/src/Disposable/RefCountDisposable.php @@ -38,7 +38,7 @@ public function getDisposable() return $this->createInnerDisposable(); } - return new CallbackDisposable(function () { + return new CallbackDisposable(function (): void { }); // no op } @@ -57,7 +57,7 @@ private function createInnerDisposable(): DisposableInterface $this->count++; $isInnerDisposed = false; - return new CallbackDisposable(function () use (&$isInnerDisposed) { + return new CallbackDisposable(function () use (&$isInnerDisposed): void { if ($this->isDisposed()) { return; } diff --git a/src/Disposable/ScheduledDisposable.php b/src/Disposable/ScheduledDisposable.php index 3e6372eb..2f59d3c2 100644 --- a/src/Disposable/ScheduledDisposable.php +++ b/src/Disposable/ScheduledDisposable.php @@ -32,7 +32,7 @@ public function dispose() $this->isDisposed = true; - $this->scheduler->schedule(function () { + $this->scheduler->schedule(function (): void { $this->disposable->dispose(); }); } diff --git a/src/Disposable/SingleAssignmentDisposable.php b/src/Disposable/SingleAssignmentDisposable.php index cbf5ddaa..11ff03bf 100644 --- a/src/Disposable/SingleAssignmentDisposable.php +++ b/src/Disposable/SingleAssignmentDisposable.php @@ -27,7 +27,7 @@ public function dispose() } } - public function setDisposable(DisposableInterface $disposable = null) + public function setDisposable(?DisposableInterface $disposable = null) { if ($this->current) { throw new RuntimeException('Disposable has already been assigned.'); diff --git a/src/Observable.php b/src/Observable.php index a10d2e0d..f59cd053 100644 --- a/src/Observable.php +++ b/src/Observable.php @@ -90,7 +90,7 @@ abstract class Observable implements ObservableInterface * @operator * @reactivex subscribe */ - public function subscribe($onNextOrObserver = null, callable $onError = null, callable $onCompleted = null): DisposableInterface + public function subscribe($onNextOrObserver = null, ?callable $onError = null, ?callable $onCompleted = null): DisposableInterface { if ($onNextOrObserver instanceof ObserverInterface) { return $this->_subscribe($onNextOrObserver); @@ -103,7 +103,7 @@ public function subscribe($onNextOrObserver = null, callable $onError = null, ca $observer = new CallbackObserver( $onNextOrObserver === null ? null - : function ($value) use ($onNextOrObserver, &$observer, &$disposable) { + : function ($value) use ($onNextOrObserver, &$observer, &$disposable): void { try { $onNextOrObserver($value); } catch (\Throwable $throwable) { @@ -134,7 +134,7 @@ protected abstract function _subscribe(ObserverInterface $observer): DisposableI * @param callable|null $onCompleted * @return DisposableInterface */ - public function subscribeCallback(callable $onNext = null, callable $onError = null, callable $onCompleted = null): DisposableInterface + public function subscribeCallback(?callable $onNext = null, ?callable $onError = null, ?callable $onCompleted = null): DisposableInterface { $observer = new CallbackObserver($onNext, $onError, $onCompleted); @@ -167,7 +167,7 @@ public static function create(callable $subscribeAction): Observable * @operator * @reactivex interval */ - public static function interval(int $interval, AsyncSchedulerInterface $scheduler = null): IntervalObservable + public static function interval(int $interval, ?AsyncSchedulerInterface $scheduler = null): IntervalObservable { return new IntervalObservable($interval, $scheduler ?: Scheduler::getAsync()); } @@ -183,7 +183,7 @@ public static function interval(int $interval, AsyncSchedulerInterface $schedule * @operator * @reactivex just */ - public static function of($value, SchedulerInterface $scheduler = null): ReturnObservable + public static function of($value, ?SchedulerInterface $scheduler = null): ReturnObservable { return new ReturnObservable($value, $scheduler ?: Scheduler::getDefault()); } @@ -196,7 +196,7 @@ public static function of($value, SchedulerInterface $scheduler = null): ReturnO * @param SchedulerInterface|null $scheduler * @return ReturnObservable */ - public static function just($value, SchedulerInterface $scheduler = null): ReturnObservable + public static function just($value, ?SchedulerInterface $scheduler = null): ReturnObservable { return static::of($value, $scheduler); } @@ -211,7 +211,7 @@ public static function just($value, SchedulerInterface $scheduler = null): Retur * @operator * @reactivex empty-never-throw */ - public static function empty(SchedulerInterface $scheduler = null): EmptyObservable + public static function empty(?SchedulerInterface $scheduler = null): EmptyObservable { return new EmptyObservable($scheduler ?: Scheduler::getDefault()); } @@ -223,7 +223,7 @@ public static function empty(SchedulerInterface $scheduler = null): EmptyObserva * @param SchedulerInterface|null $scheduler * @return EmptyObservable */ - public static function emptyObservable(SchedulerInterface $scheduler = null): EmptyObservable + public static function emptyObservable(?SchedulerInterface $scheduler = null): EmptyObservable { return static::empty($scheduler); } @@ -253,7 +253,7 @@ public static function never(): NeverObservable * @operator * @reactivex empty-never-throw */ - public static function error(\Throwable $error, SchedulerInterface $scheduler = null): ErrorObservable + public static function error(\Throwable $error, ?SchedulerInterface $scheduler = null): ErrorObservable { return new ErrorObservable($error, $scheduler ?: Scheduler::getImmediate()); } @@ -270,7 +270,7 @@ public static function error(\Throwable $error, SchedulerInterface $scheduler = */ public function merge(ObservableInterface $otherObservable): Observable { - return (new AnonymousObservable(function (ObserverInterface $observer) use ($otherObservable) { + return (new AnonymousObservable(function (ObserverInterface $observer) use ($otherObservable): void { $observer->onNext($this); $observer->onNext($otherObservable); $observer->onCompleted(); @@ -304,7 +304,7 @@ public function mergeAll(): Observable * @operator * @reactivex from */ - public static function fromArray(array $array, SchedulerInterface $scheduler = null): ArrayObservable + public static function fromArray(array $array, ?SchedulerInterface $scheduler = null): ArrayObservable { return new ArrayObservable($array, $scheduler ?: Scheduler::getDefault()); } @@ -320,7 +320,7 @@ public static function fromArray(array $array, SchedulerInterface $scheduler = n * @operator * @reactivex from */ - public static function fromIterator(\Iterator $iterator, SchedulerInterface $scheduler = null): IteratorObservable + public static function fromIterator(\Iterator $iterator, ?SchedulerInterface $scheduler = null): IteratorObservable { return new IteratorObservable($iterator, $scheduler ?: Scheduler::getDefault()); } @@ -336,7 +336,7 @@ public static function fromIterator(\Iterator $iterator, SchedulerInterface $sch * @operator * @reactivex defer */ - public static function defer(callable $factory, SchedulerInterface $scheduler = null): Observable + public static function defer(callable $factory, ?SchedulerInterface $scheduler = null): Observable { return static::empty($scheduler) ->lift(function () use ($factory) { @@ -358,7 +358,7 @@ public static function defer(callable $factory, SchedulerInterface $scheduler = * @operator * @reactivex range */ - public static function range(int $start, int $count, SchedulerInterface $scheduler = null): RangeObservable + public static function range(int $start, int $count, ?SchedulerInterface $scheduler = null): RangeObservable { return new RangeObservable($start, $count, $scheduler ?: Scheduler::getDefault()); } @@ -375,12 +375,12 @@ public static function range(int $start, int $count, SchedulerInterface $schedul * @operator * @reactivex start */ - public static function start(callable $action, SchedulerInterface $scheduler = null): Observable + public static function start(callable $action, ?SchedulerInterface $scheduler = null): Observable { $scheduler = $scheduler ?? Scheduler::getDefault(); $subject = new AsyncSubject(); - $scheduler->schedule(function () use ($subject, $action) { + $scheduler->schedule(function () use ($subject, $action): void { $result = null; try { $result = $action(); @@ -731,7 +731,7 @@ public function takeLast(int $count): Observable * @operator * @reactivex groupBy */ - public function groupBy(callable $keySelector, callable $elementSelector = null, callable $keySerializer = null): Observable + public function groupBy(callable $keySelector, ?callable $elementSelector = null, ?callable $keySerializer = null): Observable { return $this->groupByUntil($keySelector, $elementSelector, function () { return static::never(); @@ -751,7 +751,7 @@ public function groupBy(callable $keySelector, callable $elementSelector = null, * @operator * @reactivex groupBy */ - public function groupByUntil(callable $keySelector, callable $elementSelector = null, callable $durationSelector = null, callable $keySerializer = null): Observable + public function groupByUntil(callable $keySelector, ?callable $elementSelector = null, ?callable $durationSelector = null, ?callable $keySerializer = null): Observable { return $this->lift(function () use ($keySelector, $elementSelector, $durationSelector, $keySerializer) { return new GroupByUntilOperator($keySelector, $elementSelector, $durationSelector, $keySerializer); @@ -835,7 +835,7 @@ public function reduce(callable $accumulator, $seed = null): Observable * @operator * @reactivex distinct */ - public function distinct(callable $comparer = null): Observable + public function distinct(?callable $comparer = null): Observable { return $this->lift(function () use ($comparer) { return new DistinctOperator(null, $comparer); @@ -853,7 +853,7 @@ public function distinct(callable $comparer = null): Observable * @operator * @reactivex distinct */ - public function distinctKey(callable $keySelector, callable $comparer = null): Observable + public function distinctKey(callable $keySelector, ?callable $comparer = null): Observable { return $this->lift(function () use ($keySelector, $comparer) { return new DistinctOperator($keySelector, $comparer); @@ -870,7 +870,7 @@ public function distinctKey(callable $keySelector, callable $comparer = null): O * @operator * @reactivex distinct */ - public function distinctUntilChanged(callable $comparer = null): Observable + public function distinctUntilChanged(?callable $comparer = null): Observable { return $this->lift(function () use ($comparer) { return new DistinctUntilChangedOperator(null, $comparer); @@ -889,7 +889,7 @@ public function distinctUntilChanged(callable $comparer = null): Observable * @operator * @reactivex distinct */ - public function distinctUntilKeyChanged(callable $keySelector = null, callable $comparer = null): Observable + public function distinctUntilKeyChanged(?callable $keySelector = null, ?callable $comparer = null): Observable { return $this->lift(function () use ($keySelector, $comparer) { return new DistinctUntilChangedOperator($keySelector, $comparer); @@ -920,7 +920,7 @@ public function distinctUntilKeyChanged(callable $keySelector = null, callable $ * @operator * @reactivex do */ - public function do($onNextOrObserver = null, callable $onError = null, callable $onCompleted = null): Observable + public function do($onNextOrObserver = null, ?callable $onError = null, ?callable $onCompleted = null): Observable { if ($onNextOrObserver instanceof ObserverInterface) { $observer = $onNextOrObserver; @@ -1084,7 +1084,7 @@ public function skipUntil(ObservableInterface $other): Observable * @operator * @reactivex timer */ - public static function timer(int $dueTime, AsyncSchedulerInterface $scheduler = null): TimerObservable + public static function timer(int $dueTime, ?AsyncSchedulerInterface $scheduler = null): TimerObservable { return new TimerObservable($dueTime, $scheduler ?: Scheduler::getAsync()); } @@ -1147,7 +1147,7 @@ public function concat(ObservableInterface $observable): Observable * @operator * @reactivex flatMap */ - public function concatMap(callable $selector, callable $resultSelector = null): Observable + public function concatMap(callable $selector, ?callable $resultSelector = null): Observable { return $this->lift(function () use ($selector, $resultSelector) { return new ConcatMapOperator(new ObservableFactoryWrapper($selector), $resultSelector); @@ -1176,7 +1176,7 @@ public function concatMap(callable $selector, callable $resultSelector = null): * @operator * @reactivex flatMap */ - public function concatMapTo(ObservableInterface $observable, callable $resultSelector = null): Observable + public function concatMapTo(ObservableInterface $observable, ?callable $resultSelector = null): Observable { return $this->concatMap(function () use ($observable) { return $observable; @@ -1210,7 +1210,7 @@ public function concatAll(): Observable * @operator * @reactivex count */ - public function count(callable $predicate = null): Observable + public function count(?callable $predicate = null): Observable { return $this->lift(function () use ($predicate) { return new CountOperator($predicate); @@ -1231,7 +1231,7 @@ public function count(callable $predicate = null): Observable * @operator * @reactivex publish */ - public function multicast(Subject $subject, callable $selector = null): Observable + public function multicast(Subject $subject, ?callable $selector = null): Observable { return $selector ? new MulticastObservable($this, function () use ($subject) { @@ -1253,7 +1253,7 @@ public function multicast(Subject $subject, callable $selector = null): Observab * @operator * @reactivex publish */ - public function multicastWithSelector(callable $subjectSelector, callable $selector = null): MulticastObservable + public function multicastWithSelector(callable $subjectSelector, ?callable $selector = null): MulticastObservable { return new MulticastObservable($this, $subjectSelector, $selector); } @@ -1270,7 +1270,7 @@ public function multicastWithSelector(callable $subjectSelector, callable $selec * @operator * @reactivex publish */ - public function publish(callable $selector = null): Observable + public function publish(?callable $selector = null): Observable { return $this->multicast(new Subject(), $selector); } @@ -1287,7 +1287,7 @@ public function publish(callable $selector = null): Observable * @operator * @reactivex publish */ - public function publishLast(callable $selector = null): Observable + public function publishLast(?callable $selector = null): Observable { return $this->multicast(new AsyncSubject(), $selector); } @@ -1305,7 +1305,7 @@ public function publishLast(callable $selector = null): Observable * @operator * @reactivex publish */ - public function publishValue($initialValue, callable $selector = null): Observable + public function publishValue($initialValue, ?callable $selector = null): Observable { return $this->multicast(new BehaviorSubject($initialValue), $selector); } @@ -1352,7 +1352,7 @@ public function singleInstance(): Observable if (!$hasObservable) { $hasObservable = true; $observable = $source - ->finally(function () use (&$hasObservable) { + ->finally(function () use (&$hasObservable): void { $hasObservable = false; }) ->publish() @@ -1403,7 +1403,7 @@ public function shareValue($initialValue): RefCountObservable * @operator * @reactivex replay */ - public function replay(callable $selector = null, int $bufferSize = null, int $windowSize = null, SchedulerInterface $scheduler = null): Observable + public function replay(?callable $selector = null, ?int $bufferSize = null, ?int $windowSize = null, ?SchedulerInterface $scheduler = null): Observable { return $this->multicast(new ReplaySubject($bufferSize, $windowSize, $scheduler ?: Scheduler::getDefault()), $selector); } @@ -1425,7 +1425,7 @@ public function replay(callable $selector = null, int $bufferSize = null, int $w * @operator * @reactivex replay */ - public function shareReplay(int $bufferSize, int $windowSize = null, SchedulerInterface $scheduler = null): RefCountObservable + public function shareReplay(int $bufferSize, ?int $windowSize = null, ?SchedulerInterface $scheduler = null): RefCountObservable { return $this->replay(null, $bufferSize, $windowSize, $scheduler)->refCount(); } @@ -1445,7 +1445,7 @@ public function shareReplay(int $bufferSize, int $windowSize = null, SchedulerIn * @operator * @reactivex zip */ - public function zip(array $observables, callable $selector = null): Observable + public function zip(array $observables, ?callable $selector = null): Observable { return $this->lift(function () use ($observables, $selector) { return new ZipOperator($observables, $selector); @@ -1463,7 +1463,7 @@ public function zip(array $observables, callable $selector = null): Observable * @operator * @reactivex zip */ - public static function forkJoin(array $observables = [], callable $resultSelector = null): ForkJoinObservable + public static function forkJoin(array $observables = [], ?callable $resultSelector = null): ForkJoinObservable { return new ForkJoinObservable($observables, $resultSelector); } @@ -1518,7 +1518,7 @@ public function retryWhen(callable $notifier): Observable * @operator * @reactivex combinelatest */ - public function combineLatest(array $observables, callable $selector = null): Observable + public function combineLatest(array $observables, ?callable $selector = null): Observable { return $this->lift(function () use ($observables, $selector) { return new CombineLatestOperator($observables, $selector); @@ -1536,7 +1536,7 @@ public function combineLatest(array $observables, callable $selector = null): Ob * @operator * @reactivex combinelatest */ - public function withLatestFrom(array $observables, callable $selector = null): Observable + public function withLatestFrom(array $observables, ?callable $selector = null): Observable { return $this->lift(function () use ($observables, $selector) { return new WithLatestFromOperator($observables, $selector); @@ -1626,7 +1626,7 @@ public function subscribeOn(SchedulerInterface $scheduler): Observable * @operator * @reactivex delay */ - public function delay(int $delay, AsyncSchedulerInterface $scheduler = null): Observable + public function delay(int $delay, ?AsyncSchedulerInterface $scheduler = null): Observable { return $this->lift(function () use ($delay, $scheduler) { return new DelayOperator($delay, $scheduler ?: Scheduler::getAsync()); @@ -1646,7 +1646,7 @@ public function delay(int $delay, AsyncSchedulerInterface $scheduler = null): Ob * @operator * @reactivex timeout */ - public function timeout(int $timeout, ObservableInterface $timeoutObservable = null, AsyncSchedulerInterface $scheduler = null): Observable + public function timeout(int $timeout, ?ObservableInterface $timeoutObservable = null, ?AsyncSchedulerInterface $scheduler = null): Observable { return $this->lift(function () use ($timeout, $timeoutObservable, $scheduler) { return new TimeoutOperator($timeout, $timeoutObservable, $scheduler ?: Scheduler::getAsync()); @@ -1667,7 +1667,7 @@ public function timeout(int $timeout, ObservableInterface $timeoutObservable = n * @operator * @reactivex buffer */ - public function bufferWithCount(int $count, int $skip = null): Observable + public function bufferWithCount(int $count, ?int $skip = null): Observable { return $this->lift(function () use ($count, $skip) { return new BufferWithCountOperator($count, $skip); @@ -1714,7 +1714,7 @@ public function catchError(callable $selector): Observable * @operator * @reactivex startwith */ - public function startWith($startValue, SchedulerInterface $scheduler = null): Observable + public function startWith($startValue, ?SchedulerInterface $scheduler = null): Observable { return $this->startWithArray([$startValue], $scheduler); } @@ -1730,7 +1730,7 @@ public function startWith($startValue, SchedulerInterface $scheduler = null): Ob * @operator * @reactivex startwith */ - public function startWithArray(array $startArray, SchedulerInterface $scheduler = null): Observable + public function startWithArray(array $startArray, ?SchedulerInterface $scheduler = null): Observable { return $this->lift(function () use ($startArray, $scheduler) { return new StartWithArrayOperator($startArray, $scheduler ?: Scheduler::getDefault()); @@ -1748,7 +1748,7 @@ public function startWithArray(array $startArray, SchedulerInterface $scheduler * @operator * @reactivex min */ - public function min(callable $comparer = null): Observable + public function min(?callable $comparer = null): Observable { return $this->lift(function () use ($comparer) { return new MinOperator($comparer); @@ -1766,7 +1766,7 @@ public function min(callable $comparer = null): Observable * @operator * @reactivex max */ - public function max(callable $comparer = null): Observable + public function max(?callable $comparer = null): Observable { return $this->lift(function () use ($comparer) { return new MaxOperator($comparer); @@ -1813,7 +1813,7 @@ public function dematerialize(): Observable * @operator * @reactivex timestamp */ - public function timestamp(SchedulerInterface $scheduler = null): Observable + public function timestamp(?SchedulerInterface $scheduler = null): Observable { return $this->lift(function () use ($scheduler) { return new TimestampOperator($scheduler ?: Scheduler::getDefault()); @@ -1907,7 +1907,7 @@ public function partition(callable $predicate): array * @operator * @reactivex amb */ - public static function race(array $observables, SchedulerInterface $scheduler = null): Observable + public static function race(array $observables, ?SchedulerInterface $scheduler = null): Observable { if (count($observables) === 1) { return $observables[0]; @@ -2004,7 +2004,7 @@ public function pluck($property): Observable * @operator * @reactivex debounce */ - public function throttle(int $throttleDuration, SchedulerInterface $scheduler = null): Observable + public function throttle(int $throttleDuration, ?SchedulerInterface $scheduler = null): Observable { return $this->lift(function () use ($throttleDuration, $scheduler) { return new ThrottleOperator($throttleDuration, $scheduler ?: Scheduler::getDefault()); @@ -2069,7 +2069,7 @@ public static function fromPromise(PromiseInterface $promise): Observable * @return PromiseInterface * @throws \InvalidArgumentException */ - public function toPromise(Deferred $deferred = null): PromiseInterface + public function toPromise(?Deferred $deferred = null): PromiseInterface { return Promise::fromObservable($this, $deferred); } diff --git a/src/Observable/AnonymousObservable.php b/src/Observable/AnonymousObservable.php index edcfd693..b8041048 100644 --- a/src/Observable/AnonymousObservable.php +++ b/src/Observable/AnonymousObservable.php @@ -27,7 +27,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $autoDetachObserver->setDisposable($subscribeAction($autoDetachObserver)); - return new CallbackDisposable(function () use ($autoDetachObserver) { + return new CallbackDisposable(function () use ($autoDetachObserver): void { $autoDetachObserver->dispose(); }); } diff --git a/src/Observable/ArrayObservable.php b/src/Observable/ArrayObservable.php index 7b1be03e..312ae4dc 100644 --- a/src/Observable/ArrayObservable.php +++ b/src/Observable/ArrayObservable.php @@ -28,7 +28,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $keys = array_keys($values); $count = 0; - return $this->scheduler->scheduleRecursive(function ($reschedule) use (&$observer, &$values, $max, &$count, $keys) { + return $this->scheduler->scheduleRecursive(function ($reschedule) use (&$observer, &$values, $max, &$count, $keys): void { if ($count < $max) { $observer->onNext($values[$keys[$count]]); $count++; diff --git a/src/Observable/ConnectableObservable.php b/src/Observable/ConnectableObservable.php index 377fc32f..44ba266d 100644 --- a/src/Observable/ConnectableObservable.php +++ b/src/Observable/ConnectableObservable.php @@ -34,7 +34,7 @@ class ConnectableObservable extends Observable * @param Observable $source * @param \Rx\Subject\Subject $subject */ - public function __construct(Observable $source, Subject $subject = null) + public function __construct(Observable $source, ?Subject $subject = null) { $this->sourceObservable = $source->asObservable(); $this->subject = $subject ?: new Subject(); @@ -54,7 +54,7 @@ public function connect(): DisposableInterface $this->hasSubscription = true; - $connectableDisposable = new CallbackDisposable(function () { + $connectableDisposable = new CallbackDisposable(function (): void { $this->hasSubscription = false; }); diff --git a/src/Observable/EmptyObservable.php b/src/Observable/EmptyObservable.php index 57b4b3b6..204cf645 100644 --- a/src/Observable/EmptyObservable.php +++ b/src/Observable/EmptyObservable.php @@ -20,7 +20,7 @@ public function __construct(SchedulerInterface $scheduler) protected function _subscribe(ObserverInterface $observer): DisposableInterface { - return $this->scheduler->schedule(function () use ($observer) { + return $this->scheduler->schedule(function () use ($observer): void { $observer->onCompleted(); }); } diff --git a/src/Observable/ErrorObservable.php b/src/Observable/ErrorObservable.php index 53a95d58..07ffdb0b 100644 --- a/src/Observable/ErrorObservable.php +++ b/src/Observable/ErrorObservable.php @@ -22,7 +22,7 @@ public function __construct(\Throwable $error, SchedulerInterface $scheduler) protected function _subscribe(ObserverInterface $observer): DisposableInterface { - return $this->scheduler->schedule(function () use ($observer) { + return $this->scheduler->schedule(function () use ($observer): void { $observer->onError($this->error); }); } diff --git a/src/Observable/ForkJoinObservable.php b/src/Observable/ForkJoinObservable.php index d7f35221..e110844e 100644 --- a/src/Observable/ForkJoinObservable.php +++ b/src/Observable/ForkJoinObservable.php @@ -23,7 +23,7 @@ class ForkJoinObservable extends Observable private $resultSelector; - public function __construct(array $observables = [], callable $resultSelector = null) + public function __construct(array $observables = [], ?callable $resultSelector = null) { $this->observables = $observables; $this->resultSelector = $resultSelector; @@ -43,11 +43,11 @@ public function _subscribe(ObserverInterface $observer): DisposableInterface foreach ($this->observables as $i => $observable) { $innerDisp = $observable->subscribe( - function ($v) use ($i) { + function ($v) use ($i): void { $this->values[$i] = $v; }, [$autoObs, 'onError'], - function () use ($len, $i, $autoObs) { + function () use ($len, $i, $autoObs): void { $this->completed++; if (!array_key_exists($i, $this->values)) { diff --git a/src/Observable/GroupedObservable.php b/src/Observable/GroupedObservable.php index 36ba1d33..6da0e5e7 100644 --- a/src/Observable/GroupedObservable.php +++ b/src/Observable/GroupedObservable.php @@ -16,7 +16,7 @@ class GroupedObservable extends Observable private $key; private $underlyingObservable; - public function __construct($key, ObservableInterface $underlyingObservable, RefCountDisposable $mergedDisposable = null) + public function __construct($key, ObservableInterface $underlyingObservable, ?RefCountDisposable $mergedDisposable = null) { $this->key = $key; diff --git a/src/Observable/IntervalObservable.php b/src/Observable/IntervalObservable.php index 90845c1e..87818692 100644 --- a/src/Observable/IntervalObservable.php +++ b/src/Observable/IntervalObservable.php @@ -32,7 +32,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $counter = 0; return $this->scheduler->schedulePeriodic( - function () use (&$counter, $observer) { + function () use (&$counter, $observer): void { $observer->onNext($counter++); }, $this->interval, // this is to match RxJS behavior which delays the first item by the interval diff --git a/src/Observable/IteratorObservable.php b/src/Observable/IteratorObservable.php index 3bfb3958..805720ae 100644 --- a/src/Observable/IteratorObservable.php +++ b/src/Observable/IteratorObservable.php @@ -15,7 +15,7 @@ class IteratorObservable extends Observable private $scheduler; - public function __construct(\Iterator $items, SchedulerInterface $scheduler = null) + public function __construct(\Iterator $items, ?SchedulerInterface $scheduler = null) { $this->items = $items; $this->scheduler = $scheduler; @@ -25,7 +25,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface { $key = 0; - $action = function ($reschedule) use (&$observer, &$key) { + $action = function ($reschedule) use (&$observer, &$key): void { try { if (null === $key || !$this->items->valid()) { diff --git a/src/Observable/RangeObservable.php b/src/Observable/RangeObservable.php index 785033a0..8a52138c 100644 --- a/src/Observable/RangeObservable.php +++ b/src/Observable/RangeObservable.php @@ -28,7 +28,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface { $i = 0; - return $this->scheduler->scheduleRecursive(function ($reschedule) use (&$observer, &$i) { + return $this->scheduler->scheduleRecursive(function ($reschedule) use (&$observer, &$i): void { if ($i < $this->count) { $observer->onNext($this->start + $i); $i++; diff --git a/src/Observable/RefCountObservable.php b/src/Observable/RefCountObservable.php index 970d055d..425c7639 100644 --- a/src/Observable/RefCountObservable.php +++ b/src/Observable/RefCountObservable.php @@ -41,7 +41,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $this->connectableSubscription = $this->source->connect(); } - return new CallbackDisposable(function () use ($subscription) { + return new CallbackDisposable(function () use ($subscription): void { $subscription->dispose(); $this->count--; diff --git a/src/Observable/ReturnObservable.php b/src/Observable/ReturnObservable.php index c777e148..04ca12dc 100644 --- a/src/Observable/ReturnObservable.php +++ b/src/Observable/ReturnObservable.php @@ -25,11 +25,11 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface { $disposable = new CompositeDisposable(); - $disposable->add($this->scheduler->schedule(function () use ($observer) { + $disposable->add($this->scheduler->schedule(function () use ($observer): void { $observer->onNext($this->value); })); - $disposable->add($this->scheduler->schedule(function () use ($observer) { + $disposable->add($this->scheduler->schedule(function () use ($observer): void { $observer->onCompleted(); })); diff --git a/src/Observable/TimerObservable.php b/src/Observable/TimerObservable.php index 1402b7a0..60fe3ac9 100644 --- a/src/Observable/TimerObservable.php +++ b/src/Observable/TimerObservable.php @@ -24,7 +24,7 @@ public function __construct(int $dueTime, AsyncSchedulerInterface $scheduler) protected function _subscribe(ObserverInterface $observer): DisposableInterface { return $this->scheduler->schedule( - function () use ($observer) { + function () use ($observer): void { $observer->onNext(0); $observer->onCompleted(); }, diff --git a/src/ObservableInterface.php b/src/ObservableInterface.php index 754118f6..b74fec36 100644 --- a/src/ObservableInterface.php +++ b/src/ObservableInterface.php @@ -13,5 +13,5 @@ interface ObservableInterface * @return DisposableInterface * @throws \InvalidArgumentException */ - public function subscribe($onNextOrObserver = null, callable $onError = null, callable $onCompleted = null): DisposableInterface; + public function subscribe($onNextOrObserver = null, ?callable $onError = null, ?callable $onCompleted = null): DisposableInterface; } diff --git a/src/Observer/AutoDetachObserver.php b/src/Observer/AutoDetachObserver.php index fd6a31c1..acbbf3ff 100644 --- a/src/Observer/AutoDetachObserver.php +++ b/src/Observer/AutoDetachObserver.php @@ -21,7 +21,7 @@ public function __construct(ObserverInterface $observer) $this->disposable = new SingleAssignmentDisposable(); } - public function setDisposable(DisposableInterface $disposable = null) + public function setDisposable(?DisposableInterface $disposable = null) { $disposable = $disposable ?: new EmptyDisposable(); diff --git a/src/Observer/CallbackObserver.php b/src/Observer/CallbackObserver.php index 2234c028..c3cb5eb2 100644 --- a/src/Observer/CallbackObserver.php +++ b/src/Observer/CallbackObserver.php @@ -15,14 +15,14 @@ class CallbackObserver extends AbstractObserver /** @var callable|null */ private $onCompleted; - public function __construct(callable $onNext = null, callable $onError = null, callable $onCompleted = null) + public function __construct(?callable $onNext = null, ?callable $onError = null, ?callable $onCompleted = null) { - $default = function () { + $default = function (): void { }; $this->onNext = $this->getOrDefault($onNext, $default); - $this->onError = $this->getOrDefault($onError, function ($e) { + $this->onError = $this->getOrDefault($onError, function ($e): void { throw $e; }); @@ -45,7 +45,7 @@ protected function next($value) ($this->onNext)($value); } - private function getOrDefault(callable $callback = null, $default = null): callable + private function getOrDefault(?callable $callback = null, $default = null): callable { if (null === $callback) { return $default; diff --git a/src/Observer/DoObserver.php b/src/Observer/DoObserver.php index 04bfc094..a3ce4e81 100644 --- a/src/Observer/DoObserver.php +++ b/src/Observer/DoObserver.php @@ -17,14 +17,14 @@ class DoObserver implements ObserverInterface /** @var callable|null */ private $onCompleted; - public function __construct(callable $onNext = null, callable $onError = null, callable $onCompleted = null) + public function __construct(?callable $onNext = null, ?callable $onError = null, ?callable $onCompleted = null) { - $default = function () { + $default = function (): void { }; $this->onNext = $this->getOrDefault($onNext, $default); - $this->onError = $this->getOrDefault($onError, function ($e) { + $this->onError = $this->getOrDefault($onError, function ($e): void { throw $e; }); @@ -46,7 +46,7 @@ public function onNext($value) ($this->onNext)($value); } - private function getOrDefault(callable $callback = null, $default = null): callable + private function getOrDefault(?callable $callback = null, $default = null): callable { if (null === $callback) { return $default; diff --git a/src/Observer/ScheduledObserver.php b/src/Observer/ScheduledObserver.php index a3dc7de2..f6b2cb87 100644 --- a/src/Observer/ScheduledObserver.php +++ b/src/Observer/ScheduledObserver.php @@ -43,21 +43,21 @@ public function __construct(SchedulerInterface $scheduler, ObserverInterface $ob protected function completed() { - $this->queue[] = function () { + $this->queue[] = function (): void { $this->observer->onCompleted(); }; } protected function next($value) { - $this->queue[] = function () use ($value) { + $this->queue[] = function () use ($value): void { $this->observer->onNext($value); }; } protected function error(\Throwable $error) { - $this->queue[] = function () use ($error) { + $this->queue[] = function () use ($error): void { $this->observer->onError($error); }; } @@ -76,7 +76,7 @@ public function ensureActive() $this->disposable->setDisposable( $this->scheduler->scheduleRecursive( - function ($recurse) { + function ($recurse): void { $parent = $this; if (count($parent->queue) > 0) { $work = array_shift($parent->queue); diff --git a/src/Operator/BufferWithCountOperator.php b/src/Operator/BufferWithCountOperator.php index b41dd826..ba9002b0 100644 --- a/src/Operator/BufferWithCountOperator.php +++ b/src/Operator/BufferWithCountOperator.php @@ -26,7 +26,7 @@ final class BufferWithCountOperator implements OperatorInterface * @param int $skip * @throws \InvalidArgumentException */ - public function __construct(int $count, int $skip = null) + public function __construct(int $count, ?int $skip = null) { if ($count < 1) { throw new \InvalidArgumentException('count must be greater than or equal to 1'); @@ -49,7 +49,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $currentGroups = []; return $observable->subscribe(new CallbackObserver( - function ($x) use (&$currentGroups, $observer) { + function ($x) use (&$currentGroups, $observer): void { if ($this->index % $this->skip === 0) { $currentGroups[] = []; } @@ -63,10 +63,10 @@ function ($x) use (&$currentGroups, $observer) { } } }, - function ($err) use ($observer) { + function ($err) use ($observer): void { $observer->onError($err); }, - function () use (&$currentGroups, $observer) { + function () use (&$currentGroups, $observer): void { foreach ($currentGroups as &$group) { $observer->onNext($group); } diff --git a/src/Operator/CatchErrorOperator.php b/src/Operator/CatchErrorOperator.php index 77d95a33..eddc73e9 100644 --- a/src/Operator/CatchErrorOperator.php +++ b/src/Operator/CatchErrorOperator.php @@ -28,7 +28,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $isDisposed = false; $disposable = new CompositeDisposable(); - $onError = function (\Throwable $e) use (&$isDisposed, $observer, $observable, $disposable) { + $onError = function (\Throwable $e) use (&$isDisposed, $observer, $observable, $disposable): void { if ($isDisposed) { return; @@ -57,7 +57,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $disposable->add($subscription); - $disposable->add(new CallbackDisposable(function () use (&$isDisposed) { + $disposable->add(new CallbackDisposable(function () use (&$isDisposed): void { $isDisposed = true; })); diff --git a/src/Operator/CombineLatestOperator.php b/src/Operator/CombineLatestOperator.php index a53dce7d..7671ae71 100644 --- a/src/Operator/CombineLatestOperator.php +++ b/src/Operator/CombineLatestOperator.php @@ -18,7 +18,7 @@ final class CombineLatestOperator implements OperatorInterface /** @var callable */ private $resultSelector; - public function __construct(array $observables, callable $resultSelector = null) + public function __construct(array $observables, ?callable $resultSelector = null) { if (null === $resultSelector) { $resultSelector = function () { @@ -53,7 +53,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $hasValue[$key] = false; $cbObserver = new CallbackObserver( - function ($value) use ($count, &$hasValue, $key, &$values, $observer, &$waitingForValues, &$waitingToComplete) { + function ($value) use ($count, &$hasValue, $key, &$values, $observer, &$waitingForValues, &$waitingToComplete): void { // If an observable has completed before it has emitted, we need to complete right away if ($waitingForValues > $waitingToComplete) { @@ -77,7 +77,7 @@ function ($value) use ($count, &$hasValue, $key, &$values, $observer, &$waitingF } }, [$observer, 'onError'], - function () use (&$waitingToComplete, $observer) { + function () use (&$waitingToComplete, $observer): void { $waitingToComplete--; if ($waitingToComplete === 0) { $observer->onCompleted(); diff --git a/src/Operator/ConcatAllOperator.php b/src/Operator/ConcatAllOperator.php index f749a02f..4155a41d 100644 --- a/src/Operator/ConcatAllOperator.php +++ b/src/Operator/ConcatAllOperator.php @@ -45,7 +45,7 @@ public function __construct() public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { $subscription = $observable->subscribe(new CallbackObserver( - function (ObservableInterface $innerObservable) use ($observable, $observer) { + function (ObservableInterface $innerObservable) use ($observable, $observer): void { try { if ($this->startBuffering === true) { @@ -53,7 +53,7 @@ function (ObservableInterface $innerObservable) use ($observable, $observer) { return; } - $onCompleted = function () use (&$subscribeToInner, $observer) { + $onCompleted = function () use (&$subscribeToInner, $observer): void { $this->disposable->remove($this->innerDisposable); $this->innerDisposable->dispose(); @@ -73,7 +73,7 @@ function (ObservableInterface $innerObservable) use ($observable, $observer) { } }; - $subscribeToInner = function ($observable) use ($observer, &$onCompleted) { + $subscribeToInner = function ($observable) use ($observer, &$onCompleted): void { $callbackObserver = new CallbackObserver( [$observer, 'onNext'], [$observer, 'onError'], @@ -94,7 +94,7 @@ function (ObservableInterface $innerObservable) use ($observable, $observer) { } }, [$observer, 'onError'], - function () use ($observer) { + function () use ($observer): void { $this->sourceCompleted = true; if ($this->innerCompleted === true) { $observer->onCompleted(); diff --git a/src/Operator/ConcatMapOperator.php b/src/Operator/ConcatMapOperator.php index 208f4293..4dc26f9a 100644 --- a/src/Operator/ConcatMapOperator.php +++ b/src/Operator/ConcatMapOperator.php @@ -16,7 +16,7 @@ final class ConcatMapOperator implements OperatorInterface /** @var callable */ private $resultSelector; - public function __construct(callable $selector, callable $resultSelector = null) + public function __construct(callable $selector, ?callable $resultSelector = null) { $this->selector = $selector; $this->resultSelector = $resultSelector; diff --git a/src/Operator/ConcatOperator.php b/src/Operator/ConcatOperator.php index 40e0834c..9f6cc251 100644 --- a/src/Operator/ConcatOperator.php +++ b/src/Operator/ConcatOperator.php @@ -34,7 +34,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $cbObserver = new CallbackObserver( [$observer, 'onNext'], [$observer, 'onError'], - function () use ($observer, $disp) { + function () use ($observer, $disp): void { $disp->setDisposable($this->subsequentObservable->subscribe($observer)); } ); diff --git a/src/Operator/CountOperator.php b/src/Operator/CountOperator.php index 2f0a3eef..50dffcb9 100644 --- a/src/Operator/CountOperator.php +++ b/src/Operator/CountOperator.php @@ -14,7 +14,7 @@ final class CountOperator implements OperatorInterface private $count = 0; private $predicate; - public function __construct(callable $predicate = null) + public function __construct(?callable $predicate = null) { $this->predicate = $predicate; } @@ -22,7 +22,7 @@ public function __construct(callable $predicate = null) public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { $callbackObserver = new CallbackObserver( - function ($x) use ($observer) { + function ($x) use ($observer): void { if ($this->predicate === null) { $this->count++; @@ -38,7 +38,7 @@ function ($x) use ($observer) { } }, [$observer, 'onError'], - function () use ($observer) { + function () use ($observer): void { $observer->onNext($this->count); $observer->onCompleted(); } diff --git a/src/Operator/DefaultIfEmptyOperator.php b/src/Operator/DefaultIfEmptyOperator.php index 01e61ffd..d7556311 100644 --- a/src/Operator/DefaultIfEmptyOperator.php +++ b/src/Operator/DefaultIfEmptyOperator.php @@ -27,12 +27,12 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs { $disposable = new SerialDisposable(); $cbObserver = new CallbackObserver( - function ($x) use ($observer) { + function ($x) use ($observer): void { $this->passThrough = true; $observer->onNext($x); }, [$observer, 'onError'], - function () use ($observer, $disposable) { + function () use ($observer, $disposable): void { if (!$this->passThrough) { $disposable->setDisposable($this->observable->subscribe($observer)); return; diff --git a/src/Operator/DelayOperator.php b/src/Operator/DelayOperator.php index 6e486683..9cf06547 100644 --- a/src/Operator/DelayOperator.php +++ b/src/Operator/DelayOperator.php @@ -45,14 +45,14 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs return new Timestamped($x->getTimestampMillis() + $this->delayTime, $x->getValue()); }) ->subscribe(new CallbackObserver( - function (Timestamped $x) use ($observer) { + function (Timestamped $x) use ($observer): void { if ($x->getValue() instanceof Notification\OnErrorNotification) { $x->getValue()->accept($observer); return; } $this->queue->enqueue($x); if ($this->schedulerDisposable === null) { - $doScheduledStuff = function () use ($observer, &$doScheduledStuff) { + $doScheduledStuff = function () use ($observer, &$doScheduledStuff): void { while ((!$this->queue->isEmpty()) && $this->scheduler->now() >= $this->queue->bottom()->getTimestampMillis()) { /** @var Timestamped $item */ $item = $this->queue->dequeue(); @@ -77,7 +77,7 @@ function (Timestamped $x) use ($observer) { [$observer, 'onError'] )); - return new CallbackDisposable(function () use ($disp) { + return new CallbackDisposable(function () use ($disp): void { if ($this->schedulerDisposable) { $this->schedulerDisposable->dispose(); } diff --git a/src/Operator/DematerializeOperator.php b/src/Operator/DematerializeOperator.php index 791cf0de..00a65664 100644 --- a/src/Operator/DematerializeOperator.php +++ b/src/Operator/DematerializeOperator.php @@ -15,7 +15,7 @@ final class DematerializeOperator implements OperatorInterface public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { return $observable->subscribe(new CallbackObserver( - function (Notification $x) use ($observer) { + function (Notification $x) use ($observer): void { $x->accept($observer); }, [$observer, 'onError'], diff --git a/src/Operator/DistinctOperator.php b/src/Operator/DistinctOperator.php index 095c63f3..9acf1283 100644 --- a/src/Operator/DistinctOperator.php +++ b/src/Operator/DistinctOperator.php @@ -20,7 +20,7 @@ final class DistinctOperator implements OperatorInterface /** @var callable */ protected $comparer; - public function __construct(callable $keySelector = null, callable $comparer = null) + public function __construct(?callable $keySelector = null, ?callable $comparer = null) { $this->comparer = $comparer; $this->keySelector = $keySelector; diff --git a/src/Operator/DistinctUntilChangedOperator.php b/src/Operator/DistinctUntilChangedOperator.php index 11a98ab5..3a6fb74f 100644 --- a/src/Operator/DistinctUntilChangedOperator.php +++ b/src/Operator/DistinctUntilChangedOperator.php @@ -15,7 +15,7 @@ final class DistinctUntilChangedOperator implements OperatorInterface protected $comparer; - public function __construct(callable $keySelector = null, callable $comparer = null) + public function __construct(?callable $keySelector = null, ?callable $comparer = null) { $this->comparer = $comparer ?: function ($x, $y) { return $x == $y; diff --git a/src/Operator/FilterOperator.php b/src/Operator/FilterOperator.php index a6e7bea7..ff025381 100644 --- a/src/Operator/FilterOperator.php +++ b/src/Operator/FilterOperator.php @@ -21,7 +21,7 @@ public function __construct(callable $predicate) public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { $selectObserver = new CallbackObserver( - function ($nextValue) use ($observer) { + function ($nextValue) use ($observer): void { $shouldFire = false; try { $shouldFire = ($this->predicate)($nextValue); diff --git a/src/Operator/GroupByUntilOperator.php b/src/Operator/GroupByUntilOperator.php index 62946d73..1ab260b9 100644 --- a/src/Operator/GroupByUntilOperator.php +++ b/src/Operator/GroupByUntilOperator.php @@ -22,7 +22,7 @@ final class GroupByUntilOperator implements OperatorInterface private $keySerializer; private $map = []; - public function __construct(callable $keySelector, callable $elementSelector = null, callable $durationSelector = null, callable $keySerializer = null) + public function __construct(callable $keySelector, ?callable $elementSelector = null, ?callable $durationSelector = null, ?callable $keySerializer = null) { if (null === $elementSelector) { $elementSelector = function ($elem) { @@ -54,7 +54,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $refCountDisposable = new RefCountDisposable($groupDisposable); $sourceEmits = true; - $handleError = function (\Throwable $e) use ($observer, &$sourceEmits) { + $handleError = function (\Throwable $e) use ($observer, &$sourceEmits): void { foreach ($this->map as $w) { $w->onError($e); } @@ -64,7 +64,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs }; $subscription = $observable->subscribe( - function ($element) use ($observer, $handleError, $refCountDisposable, $groupDisposable, &$sourceEmits) { + function ($element) use ($observer, $handleError, $refCountDisposable, $groupDisposable, &$sourceEmits): void { try { $key = call_user_func($this->keySelector, $element); $serializedKey = call_user_func($this->keySerializer, $key); @@ -98,7 +98,7 @@ function ($element) use ($observer, $handleError, $refCountDisposable, $groupDis $durationSubscription = $duration->take(1)->subscribe( null, $handleError, - function () use ($groupDisposable, $md, $writer, $serializedKey) { + function () use ($groupDisposable, $md, $writer, $serializedKey): void { unset($this->map[$serializedKey]); $writer->onCompleted(); @@ -120,7 +120,7 @@ function () use ($groupDisposable, $md, $writer, $serializedKey) { $this->map[$serializedKey]->onNext($element); }, $handleError, - function () use ($observer, &$sourceEmits) { + function () use ($observer, &$sourceEmits): void { foreach ($this->map as $w) { $w->onCompleted(); } @@ -131,7 +131,7 @@ function () use ($observer, &$sourceEmits) { $groupDisposable->add($subscription); - return new CallbackDisposable(function () use (&$sourceEmits, $refCountDisposable) { + return new CallbackDisposable(function () use (&$sourceEmits, $refCountDisposable): void { $sourceEmits = false; $refCountDisposable->dispose(); }); diff --git a/src/Operator/IsEmptyOperator.php b/src/Operator/IsEmptyOperator.php index d8bf7ca8..9c0278de 100644 --- a/src/Operator/IsEmptyOperator.php +++ b/src/Operator/IsEmptyOperator.php @@ -12,12 +12,12 @@ final class IsEmptyOperator implements OperatorInterface public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { return $observable->subscribe( - function() use ($observer) { + function() use ($observer): void { $observer->onNext(false); $observer->onCompleted(); }, [$observer, 'onError'], - function() use ($observer) { + function() use ($observer): void { $observer->onNext(true); $observer->onCompleted(); } diff --git a/src/Operator/MapOperator.php b/src/Operator/MapOperator.php index 38436d79..5b7de0e6 100644 --- a/src/Operator/MapOperator.php +++ b/src/Operator/MapOperator.php @@ -26,7 +26,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $disposable = new CompositeDisposable(); $selectObserver = new CallbackObserver( - function ($nextValue) use ($observer, &$disposed) { + function ($nextValue) use ($observer, &$disposed): void { $value = null; try { @@ -42,7 +42,7 @@ function ($nextValue) use ($observer, &$disposed) { [$observer, 'onCompleted'] ); - $disposable->add(new CallbackDisposable(function () use (&$disposed) { + $disposable->add(new CallbackDisposable(function () use (&$disposed): void { $disposed = true; })); diff --git a/src/Operator/MaterializeOperator.php b/src/Operator/MaterializeOperator.php index 6859fcfc..bafcfbdc 100644 --- a/src/Operator/MaterializeOperator.php +++ b/src/Operator/MaterializeOperator.php @@ -17,14 +17,14 @@ final class MaterializeOperator implements OperatorInterface public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { return $observable->subscribe(new CallbackObserver( - function ($x) use ($observer) { + function ($x) use ($observer): void { $observer->onNext(new OnNextNotification($x)); }, - function ($error) use ($observer) { + function ($error) use ($observer): void { $observer->onNext(new OnErrorNotification($error)); $observer->onCompleted(); }, - function () use ($observer) { + function () use ($observer): void { $observer->onNext(new OnCompletedNotification()); $observer->onCompleted(); } diff --git a/src/Operator/MaxOperator.php b/src/Operator/MaxOperator.php index d444dd5e..72e43598 100644 --- a/src/Operator/MaxOperator.php +++ b/src/Operator/MaxOperator.php @@ -13,7 +13,7 @@ final class MaxOperator implements OperatorInterface { private $comparer; - public function __construct(callable $comparer = null) + public function __construct(?callable $comparer = null) { if ($comparer === null) { $comparer = function ($x, $y) { @@ -30,7 +30,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $comparing = false; return $observable->subscribe(new CallbackObserver( - function ($x) use (&$comparing, &$previousMax, $observer) { + function ($x) use (&$comparing, &$previousMax, $observer): void { if (!$comparing) { $comparing = true; $previousMax = $x; @@ -48,7 +48,7 @@ function ($x) use (&$comparing, &$previousMax, $observer) { } }, [$observer, 'onError'], - function () use (&$comparing, &$previousMax, $observer) { + function () use (&$comparing, &$previousMax, $observer): void { if ($comparing) { $observer->onNext($previousMax); $observer->onCompleted(); diff --git a/src/Operator/MergeAllOperator.php b/src/Operator/MergeAllOperator.php index 5cd63403..707f7d67 100644 --- a/src/Operator/MergeAllOperator.php +++ b/src/Operator/MergeAllOperator.php @@ -22,19 +22,19 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $group->add($sourceSubscription); $callbackObserver = new CallbackObserver( - function (ObservableInterface $innerSource) use (&$group, &$isStopped, $observer) { + function (ObservableInterface $innerSource) use (&$group, &$isStopped, $observer): void { $innerSubscription = new SingleAssignmentDisposable(); $group->add($innerSubscription); $innerSubscription->setDisposable( $innerSource->subscribe(new CallbackObserver( - function ($nextValue) use ($observer) { + function ($nextValue) use ($observer): void { $observer->onNext($nextValue); }, - function ($error) use ($observer) { + function ($error) use ($observer): void { $observer->onError($error); }, - function () use (&$group, &$innerSubscription, &$isStopped, $observer) { + function () use (&$group, &$innerSubscription, &$isStopped, $observer): void { $group->remove($innerSubscription); if ($isStopped && $group->count() === 1) { @@ -45,7 +45,7 @@ function () use (&$group, &$innerSubscription, &$isStopped, $observer) { ); }, [$observer, 'onError'], - function () use (&$group, &$isStopped, $observer) { + function () use (&$group, &$isStopped, $observer): void { $isStopped = true; if ($group->count() === 1) { $observer->onCompleted(); diff --git a/src/Operator/MinOperator.php b/src/Operator/MinOperator.php index 4bd85389..1c9f4307 100644 --- a/src/Operator/MinOperator.php +++ b/src/Operator/MinOperator.php @@ -13,7 +13,7 @@ final class MinOperator implements OperatorInterface { private $comparer; - public function __construct(callable $comparer = null) + public function __construct(?callable $comparer = null) { if ($comparer === null) { $comparer = function ($x, $y) { @@ -30,7 +30,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $comparing = false; return $observable->subscribe(new CallbackObserver( - function ($x) use (&$comparing, &$previousMin, $observer) { + function ($x) use (&$comparing, &$previousMin, $observer): void { if (!$comparing) { $comparing = true; $previousMin = $x; @@ -48,7 +48,7 @@ function ($x) use (&$comparing, &$previousMin, $observer) { } }, [$observer, 'onError'], - function () use (&$comparing, &$previousMin, $observer) { + function () use (&$comparing, &$previousMin, $observer): void { if ($comparing) { $observer->onNext($previousMin); $observer->onCompleted(); diff --git a/src/Operator/RaceOperator.php b/src/Operator/RaceOperator.php index b5438267..1fd908cc 100644 --- a/src/Operator/RaceOperator.php +++ b/src/Operator/RaceOperator.php @@ -37,11 +37,11 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs { $callbackObserver = new CallbackObserver( - function (Observable $innerObservable) { + function (Observable $innerObservable): void { $this->observables[] = $innerObservable; }, [$observer, 'onError'], - function () use ($observer) { + function () use ($observer): void { if (count($this->observables) === 0) { $observer->onCompleted(); @@ -68,7 +68,7 @@ function () use ($observer) { private function subscribeToResult(ObservableInterface $observable, ObserverInterface $observer, $outerIndex) { return $observable->subscribe(new CallbackObserver( - function ($value) use ($observer, $outerIndex) { + function ($value) use ($observer, $outerIndex): void { if (!$this->hasFirst) { $this->hasFirst = true; diff --git a/src/Operator/ReduceOperator.php b/src/Operator/ReduceOperator.php index 6ff158f9..1b6c9e91 100644 --- a/src/Operator/ReduceOperator.php +++ b/src/Operator/ReduceOperator.php @@ -33,7 +33,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $accumulation = null; $hasValue = false; $cbObserver = new CallbackObserver( - function ($x) use ($observer, &$hasAccumulation, &$accumulation, &$hasValue) { + function ($x) use ($observer, &$hasAccumulation, &$accumulation, &$hasValue): void { $hasValue = true; @@ -48,10 +48,10 @@ function ($x) use ($observer, &$hasAccumulation, &$accumulation, &$hasValue) { $observer->onError($e); } }, - function ($e) use ($observer) { + function ($e) use ($observer): void { $observer->onError($e); }, - function () use ($observer, &$hasAccumulation, &$accumulation, &$hasValue) { + function () use ($observer, &$hasAccumulation, &$accumulation, &$hasValue): void { if ($hasValue) { $observer->onNext($accumulation); } else { diff --git a/src/Operator/RepeatOperator.php b/src/Operator/RepeatOperator.php index e11ccdae..99096ae8 100644 --- a/src/Operator/RepeatOperator.php +++ b/src/Operator/RepeatOperator.php @@ -30,11 +30,11 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $disposable = new SerialDisposable(); - $subscribe = function () use (&$disposable, $observable, $observer, &$completeCount, &$subscribe) { + $subscribe = function () use (&$disposable, $observable, $observer, &$completeCount, &$subscribe): void { $disposable->setDisposable($observable->subscribe(new CallbackObserver( [$observer, 'onNext'], [$observer, 'onError'], - function () use (&$completeCount, $observable, $observer, &$disposable, &$subscribe) { + function () use (&$completeCount, $observable, $observer, &$disposable, &$subscribe): void { $completeCount++; if ($this->repeatCount === -1 || $completeCount < $this->repeatCount) { $subscribe(); @@ -49,7 +49,7 @@ function () use (&$completeCount, $observable, $observer, &$disposable, &$subscr $subscribe(); - return new CallbackDisposable(function () use (&$disposable) { + return new CallbackDisposable(function () use (&$disposable): void { $disposable->dispose(); }); } diff --git a/src/Operator/RepeatWhenOperator.php b/src/Operator/RepeatWhenOperator.php index ccc84cfe..f30d328c 100644 --- a/src/Operator/RepeatWhenOperator.php +++ b/src/Operator/RepeatWhenOperator.php @@ -52,12 +52,12 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $outerDisposable = new SerialDisposable(); $this->disposable->add($outerDisposable); - $subscribe = function () use ($outerDisposable, $observable, $observer, &$subscribe) { + $subscribe = function () use ($outerDisposable, $observable, $observer, &$subscribe): void { $this->sourceComplete = false; $outerSubscription = $observable->subscribe(new CallbackObserver( [$observer, 'onNext'], [$observer, 'onError'], - function () use ($observer, &$subscribe, $outerDisposable) { + function () use ($observer, &$subscribe, $outerDisposable): void { $this->sourceComplete = true; if (!$this->repeat) { $observer->onCompleted(); @@ -72,14 +72,14 @@ function () use ($observer, &$subscribe, $outerDisposable) { }; $notifierDisposable = $this->notifier->subscribe(new CallbackObserver( - function () use (&$subscribe) { + function () use (&$subscribe): void { $subscribe(); }, - function ($ex) use ($observer) { + function ($ex) use ($observer): void { $this->repeat = false; $observer->onError($ex); }, - function () use ($observer) { + function () use ($observer): void { $this->repeat = false; if ($this->sourceComplete) { $observer->onCompleted(); diff --git a/src/Operator/RetryOperator.php b/src/Operator/RetryOperator.php index b2eaf85b..f02b915a 100644 --- a/src/Operator/RetryOperator.php +++ b/src/Operator/RetryOperator.php @@ -27,7 +27,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $getNewObserver = function () use ($observable, $observer, $disposable, &$getNewObserver) { return new CallbackObserver( [$observer, 'onNext'], - function ($error) use ($observable, $observer, $disposable, &$getNewObserver) { + function ($error) use ($observable, $observer, $disposable, &$getNewObserver): void { $this->retryCount--; if ($this->retryCount === 0) { $observer->onError($error); @@ -37,7 +37,7 @@ function ($error) use ($observable, $observer, $disposable, &$getNewObserver) { $subscription = $observable->subscribe($getNewObserver()); $disposable->setDisposable($subscription); }, - function () use ($observer) { + function () use ($observer): void { $observer->onCompleted(); $this->retryCount = 0; } @@ -47,7 +47,7 @@ function () use ($observer) { $subscription = $observable->subscribe($getNewObserver()); $disposable->setDisposable($subscription); - return new CallbackDisposable(function () use (&$disposable) { + return new CallbackDisposable(function () use (&$disposable): void { $disposable->dispose(); }); } diff --git a/src/Operator/RetryWhenOperator.php b/src/Operator/RetryWhenOperator.php index 17a91350..c96427c7 100644 --- a/src/Operator/RetryWhenOperator.php +++ b/src/Operator/RetryWhenOperator.php @@ -36,7 +36,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs return new EmptyDisposable(); } - $subscribeToSource = function () use ($observer, $disposable, $observable, &$sourceError, $errors, &$sourceDisposable, &$innerCompleted) { + $subscribeToSource = function () use ($observer, $disposable, $observable, &$sourceError, $errors, &$sourceDisposable, &$innerCompleted): void { $sourceError = false; $sourceDisposable = $observable->subscribe(new CallbackObserver( [$observer, 'onNext'], @@ -47,7 +47,7 @@ function ($err) use ( &$sourceDisposable, &$innerCompleted, $observer - ) { + ): void { $sourceError = true; $disposable->remove($sourceDisposable); $sourceDisposable->dispose(); @@ -65,14 +65,14 @@ function ($err) use ( }; $whenDisposable = $when->subscribe(new CallbackObserver( - function ($x) use ($subscribeToSource, &$sourceError) { + function ($x) use ($subscribeToSource, &$sourceError): void { if ($sourceError) { $sourceError = false; $subscribeToSource(); } }, [$observer, 'onError'], - function () use (&$innerCompleted, &$sourceError, $observer) { + function () use (&$innerCompleted, &$sourceError, $observer): void { $innerCompleted = true; if ($sourceError) { $observer->onCompleted(); diff --git a/src/Operator/ScanOperator.php b/src/Operator/ScanOperator.php index 3b38a4b3..0d2958eb 100644 --- a/src/Operator/ScanOperator.php +++ b/src/Operator/ScanOperator.php @@ -28,7 +28,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $accumulation = $this->seed; $hasSeed = $this->seed !== null; $cbObserver = new CallbackObserver( - function ($x) use ($observer, &$hasAccumulation, &$accumulation, &$hasSeed, &$hasValue) { + function ($x) use ($observer, &$hasAccumulation, &$accumulation, &$hasSeed, &$hasValue): void { $hasValue = true; if ($hasAccumulation) { $accumulation = ($this->tryCatch($this->accumulator))($accumulation, $x); @@ -43,7 +43,7 @@ function ($x) use ($observer, &$hasAccumulation, &$accumulation, &$hasSeed, &$ha $observer->onNext($accumulation); }, [$observer, 'onError'], - function () use ($observer, &$hasValue, &$hasSeed) { + function () use ($observer, &$hasValue, &$hasSeed): void { if (!$hasValue && $hasSeed) { $observer->onNext($this->seed); } diff --git a/src/Operator/SkipLastOperator.php b/src/Operator/SkipLastOperator.php index 45f97c68..cbde72f6 100644 --- a/src/Operator/SkipLastOperator.php +++ b/src/Operator/SkipLastOperator.php @@ -28,7 +28,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs { $this->q = []; $cbObserver = new CallbackObserver( - function ($x) use ($observer) { + function ($x) use ($observer): void { $this->q[] = $x; if (count($this->q) > $this->count) { $observer->onNext(array_shift($this->q)); diff --git a/src/Operator/SkipOperator.php b/src/Operator/SkipOperator.php index 56c6f6cf..6b3d62c6 100644 --- a/src/Operator/SkipOperator.php +++ b/src/Operator/SkipOperator.php @@ -27,7 +27,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $remaining = $this->count; $cbObserver = new CallbackObserver( - function ($nextValue) use ($observer, &$remaining) { + function ($nextValue) use ($observer, &$remaining): void { if ($remaining <= 0) { $observer->onNext($nextValue); } else { diff --git a/src/Operator/SkipUntilOperator.php b/src/Operator/SkipUntilOperator.php index f38107d2..a00f10b2 100644 --- a/src/Operator/SkipUntilOperator.php +++ b/src/Operator/SkipUntilOperator.php @@ -28,28 +28,28 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs /** @var DisposableInterface $otherDisposable */ $otherDisposable = $this->other->subscribe(new CallbackObserver( - function ($x) use (&$isOpen, &$otherDisposable) { + function ($x) use (&$isOpen, &$otherDisposable): void { $isOpen = true; $otherDisposable->dispose(); }, - function ($e) use ($observer) { + function ($e) use ($observer): void { $observer->onError($e); }, - function () use (&$otherDisposable) { + function () use (&$otherDisposable): void { $otherDisposable->dispose(); } )); $sourceDisposable = $observable->subscribe(new CallbackObserver( - function ($x) use ($observer, &$isOpen) { + function ($x) use ($observer, &$isOpen): void { if ($isOpen) { $observer->onNext($x); } }, - function ($e) use ($observer) { + function ($e) use ($observer): void { $observer->onError($e); }, - function () use ($observer, &$isOpen) { + function () use ($observer, &$isOpen): void { if ($isOpen) { $observer->onCompleted(); } diff --git a/src/Operator/SkipWhileOperator.php b/src/Operator/SkipWhileOperator.php index 2e2206b8..53395cd3 100644 --- a/src/Operator/SkipWhileOperator.php +++ b/src/Operator/SkipWhileOperator.php @@ -26,7 +26,7 @@ public function __construct(callable $predicate) public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { $callbackObserver = new CallbackObserver( - function ($value) use ($observer, $observable) { + function ($value) use ($observer, $observable): void { try { if ($this->isSkipping) { diff --git a/src/Operator/SubscribeOnOperator.php b/src/Operator/SubscribeOnOperator.php index 473f4dcb..ad0bd573 100644 --- a/src/Operator/SubscribeOnOperator.php +++ b/src/Operator/SubscribeOnOperator.php @@ -28,7 +28,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $disposable->setDisposable($singleDisposable); $singleDisposable->setDisposable( - $this->scheduler->schedule(function () use ($disposable, $observer, $observable) { + $this->scheduler->schedule(function () use ($disposable, $observer, $observable): void { $subscription = $observable->subscribe($observer); $disposable->setDisposable(new ScheduledDisposable($this->scheduler, $subscription)); }) diff --git a/src/Operator/SwitchFirstOperator.php b/src/Operator/SwitchFirstOperator.php index 1dafe55c..b102281d 100644 --- a/src/Operator/SwitchFirstOperator.php +++ b/src/Operator/SwitchFirstOperator.php @@ -25,7 +25,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $disposable->add($singleDisposable); $callbackObserver = new CallbackObserver( - function (Observable $x) use ($disposable, $observer) { + function (Observable $x) use ($disposable, $observer): void { if ($this->hasCurrent) { return; } @@ -37,7 +37,7 @@ function (Observable $x) use ($disposable, $observer) { $innerSub = $x->subscribe(new CallbackObserver( [$observer, 'onNext'], [$observer, 'onError'], - function () use ($disposable, $inner, $observer) { + function () use ($disposable, $inner, $observer): void { $disposable->remove($inner); $this->hasCurrent = false; @@ -50,7 +50,7 @@ function () use ($disposable, $inner, $observer) { $inner->setDisposable($innerSub); }, [$observer, 'onError'], - function () use ($disposable, $observer) { + function () use ($disposable, $observer): void { $this->isStopped = true; if (!$this->hasCurrent && $disposable->count() === 1) { $observer->onCompleted(); diff --git a/src/Operator/SwitchLatestOperator.php b/src/Operator/SwitchLatestOperator.php index e3b5ad46..72cc1dfc 100644 --- a/src/Operator/SwitchLatestOperator.php +++ b/src/Operator/SwitchLatestOperator.php @@ -36,7 +36,7 @@ public function __construct() public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { - $onNext = function ($innerSource) use ($observer) { + $onNext = function ($innerSource) use ($observer): void { $innerDisposable = new SingleAssignmentDisposable(); $id = ++$this->latest; @@ -45,17 +45,17 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $this->innerSubscription->setDisposable($innerDisposable); $innerCallbackObserver = new CallbackObserver( - function ($x) use ($id, $observer) { + function ($x) use ($id, $observer): void { if ($this->latest === $id) { $observer->onNext($x); } }, - function ($e) use ($id, $observer) { + function ($e) use ($id, $observer): void { if ($this->latest === $id) { $observer->onError($e); } }, - function () use ($id, $observer) { + function () use ($id, $observer): void { if ($this->latest === $id) { $this->hasLatest = false; if ($this->isStopped) { @@ -72,7 +72,7 @@ function () use ($id, $observer) { $callbackObserver = new CallbackObserver( $onNext, [$observer, 'onError'], - function () use ($observer) { + function () use ($observer): void { $this->isStopped = true; if (!$this->hasLatest) { $observer->onCompleted(); diff --git a/src/Operator/TakeLastOperator.php b/src/Operator/TakeLastOperator.php index 81e3cae3..aba138f5 100644 --- a/src/Operator/TakeLastOperator.php +++ b/src/Operator/TakeLastOperator.php @@ -29,7 +29,7 @@ public function __construct(int $count) public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { $callbackObserver = new CallbackObserver( - function ($nextValue) use ($observer) { + function ($nextValue) use ($observer): void { $this->items[] = $nextValue; if (count($this->items) > $this->count) { @@ -37,7 +37,7 @@ function ($nextValue) use ($observer) { } }, [$observer, 'onError'], - function () use ($observer) { + function () use ($observer): void { while (count($this->items) > 0) { $observer->onNext(array_shift($this->items)); diff --git a/src/Operator/TakeOperator.php b/src/Operator/TakeOperator.php index f9585e96..1382103a 100644 --- a/src/Operator/TakeOperator.php +++ b/src/Operator/TakeOperator.php @@ -27,7 +27,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $remaining = $this->count; $callbackObserver = new CallbackObserver( - function ($nextValue) use ($observer, &$remaining) { + function ($nextValue) use ($observer, &$remaining): void { if ($remaining > 0) { $remaining--; $observer->onNext($nextValue); diff --git a/src/Operator/TakeWhileOperator.php b/src/Operator/TakeWhileOperator.php index 8d0fb35b..e5332c82 100644 --- a/src/Operator/TakeWhileOperator.php +++ b/src/Operator/TakeWhileOperator.php @@ -22,7 +22,7 @@ public function __construct(callable $predicate, bool $inclusive = false) public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { - $onNext = function ($value) use ($observer) { + $onNext = function ($value) use ($observer): void { try { if (($this->predicate)($value)) { $observer->onNext($value); diff --git a/src/Operator/ThrottleOperator.php b/src/Operator/ThrottleOperator.php index 41dc9684..e92fd0b1 100644 --- a/src/Operator/ThrottleOperator.php +++ b/src/Operator/ThrottleOperator.php @@ -35,7 +35,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $innerDisp = new SerialDisposable(); $disp = $observable->subscribe(new CallbackObserver( - function ($x) use ($innerDisp, $observer) { + function ($x) use ($innerDisp, $observer): void { $now = $this->scheduler->now(); if ($this->nextSend <= $now) { $innerDisp->setDisposable(new EmptyDisposable()); @@ -47,7 +47,7 @@ function ($x) use ($innerDisp, $observer) { $newDisp = Observable::of($x, $this->scheduler) ->delay($this->nextSend - $now, $this->scheduler) ->subscribe(new CallbackObserver( - function ($x) use ($observer) { + function ($x) use ($observer): void { $observer->onNext($x); $this->nextSend = $this->scheduler->now() + $this->throttleTime - 1; if ($this->completed) { @@ -59,11 +59,11 @@ function ($x) use ($observer) { $innerDisp->setDisposable($newDisp); }, - function (\Throwable $e) use ($observer, $innerDisp) { + function (\Throwable $e) use ($observer, $innerDisp): void { $innerDisp->dispose(); $observer->onError($e); }, - function () use ($observer) { + function () use ($observer): void { $this->completed = true; if ($this->nextSend === 0) { $observer->onCompleted(); diff --git a/src/Operator/TimeoutOperator.php b/src/Operator/TimeoutOperator.php index 4802f805..fe60b992 100644 --- a/src/Operator/TimeoutOperator.php +++ b/src/Operator/TimeoutOperator.php @@ -13,6 +13,7 @@ use Rx\ObserverInterface; use Rx\AsyncSchedulerInterface; use Rx\Exception\TimeoutException; +use Rx\Scheduler; final class TimeoutOperator implements OperatorInterface { @@ -22,14 +23,14 @@ final class TimeoutOperator implements OperatorInterface private $timeoutObservable; - public function __construct(int $timeout, ObservableInterface $timeoutObservable = null, AsyncSchedulerInterface $scheduler) + public function __construct(int $timeout, ?ObservableInterface $timeoutObservable = null, ?AsyncSchedulerInterface $scheduler = null) { $this->timeout = $timeout; - $this->scheduler = $scheduler; + $this->scheduler = $scheduler ?: Scheduler::getAsync(); $this->timeoutObservable = $timeoutObservable; if ($this->timeoutObservable === null) { - $this->timeoutObservable = new ErrorObservable(new TimeoutException('timeout'), $scheduler); + $this->timeoutObservable = new ErrorObservable(new TimeoutException('timeout'), $this->scheduler); } } @@ -42,7 +43,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $sourceDisposable = new EmptyDisposable(); - $doTimeout = function () use ($observer, $disposable, &$sourceDisposable) { + $doTimeout = function () use ($observer, $disposable, &$sourceDisposable): void { $disposable->remove($sourceDisposable); $sourceDisposable->dispose(); $disposable->add($this->timeoutObservable->subscribe($observer)); @@ -51,7 +52,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $doTimeoutDisposable = $this->scheduler->schedule($doTimeout, $this->timeout); $disposable->add($doTimeoutDisposable); - $rescheduleTimeout = function () use ($disposable, &$doTimeoutDisposable, $doTimeout) { + $rescheduleTimeout = function () use ($disposable, &$doTimeoutDisposable, $doTimeout): void { $disposable->remove($doTimeoutDisposable); $doTimeoutDisposable->dispose(); @@ -60,15 +61,15 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs }; $sourceDisposable = $observable->subscribe(new CallbackObserver( - function ($x) use ($observer, $rescheduleTimeout) { + function ($x) use ($observer, $rescheduleTimeout): void { $rescheduleTimeout(); $observer->onNext($x); }, - function ($err) use ($observer, $rescheduleTimeout) { + function ($err) use ($observer, $rescheduleTimeout): void { $rescheduleTimeout(); $observer->onError($err); }, - function () use ($observer, $rescheduleTimeout) { + function () use ($observer, $rescheduleTimeout): void { $rescheduleTimeout(); $observer->onCompleted(); } diff --git a/src/Operator/TimestampOperator.php b/src/Operator/TimestampOperator.php index 7dbddf2e..e0247c19 100644 --- a/src/Operator/TimestampOperator.php +++ b/src/Operator/TimestampOperator.php @@ -15,7 +15,7 @@ final class TimestampOperator implements OperatorInterface { private $scheduler; - public function __construct(SchedulerInterface $scheduler = null) + public function __construct(?SchedulerInterface $scheduler = null) { $this->scheduler = $scheduler; } @@ -23,7 +23,7 @@ public function __construct(SchedulerInterface $scheduler = null) public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { return $observable->subscribe(new CallbackObserver( - function ($x) use ($observer) { + function ($x) use ($observer): void { $observer->onNext(new Timestamped($this->scheduler->now(), $x)); }, [$observer, 'onError'], diff --git a/src/Operator/ToArrayOperator.php b/src/Operator/ToArrayOperator.php index 19c5acdc..88efe482 100644 --- a/src/Operator/ToArrayOperator.php +++ b/src/Operator/ToArrayOperator.php @@ -17,11 +17,11 @@ final class ToArrayOperator implements OperatorInterface public function __invoke(ObservableInterface $observable, ObserverInterface $observer): DisposableInterface { $cbObserver = new CallbackObserver( - function ($x) { + function ($x): void { $this->arr[] = $x; }, [$observer, 'onError'], - function () use ($observer) { + function () use ($observer): void { $observer->onNext($this->arr); $observer->onCompleted(); } diff --git a/src/Operator/WithLatestFromOperator.php b/src/Operator/WithLatestFromOperator.php index 5062fea4..79c52260 100644 --- a/src/Operator/WithLatestFromOperator.php +++ b/src/Operator/WithLatestFromOperator.php @@ -18,7 +18,7 @@ final class WithLatestFromOperator implements OperatorInterface /** @var callable */ private $resultSelector; - public function __construct(array $observables, callable $resultSelector = null) + public function __construct(array $observables, ?callable $resultSelector = null) { if (null === $resultSelector) { $resultSelector = function () { @@ -49,12 +49,12 @@ public function __invoke(ObservableInterface $source, ObserverInterface $observe $sad = new SingleAssignmentDisposable(); $subscription = $o->subscribe( - function ($value) use ($key, &$values, $count, &$hasAllValues) { + function ($value) use ($key, &$values, $count, &$hasAllValues): void { $values[$key] = $value; $hasAllValues = $count === count($values); }, [$observer, 'onError'], - function () { + function (): void { //noop }); @@ -64,7 +64,7 @@ function () { $outerSad = new SingleAssignmentDisposable(); $outerSad->setDisposable($source->subscribe( - function ($value) use ($observer, &$values, &$hasAllValues) { + function ($value) use ($observer, &$values, &$hasAllValues): void { ksort($values); $allValues = array_merge([$value], $values); diff --git a/src/Operator/ZipOperator.php b/src/Operator/ZipOperator.php index 674661bd..f09db2df 100644 --- a/src/Operator/ZipOperator.php +++ b/src/Operator/ZipOperator.php @@ -30,7 +30,7 @@ final class ZipOperator implements OperatorInterface /** @var bool[] */ private $completed = []; - public function __construct(array $sources, callable $resultSelector = null) + public function __construct(array $sources, ?callable $resultSelector = null) { $this->sources = $sources; @@ -61,7 +61,7 @@ public function __invoke(ObservableInterface $observable, ObserverInterface $obs $source = $this->sources[$i]; $cbObserver = new CallbackObserver( - function ($x) use ($i, $observer) { + function ($x) use ($i, $observer): void { // if there is another item in the sequence after one of the other source // observables completes, we need to complete at this time to match the // behavior of RxJS @@ -94,10 +94,10 @@ function ($x) use ($i, $observer) { $observer->onError($e); } }, - function ($e) use ($observer) { + function ($e) use ($observer): void { $observer->onError($e); }, - function () use ($i, $observer) { + function () use ($i, $observer): void { $this->completesRemaining--; $this->completed[$i] = true; if ($this->completesRemaining === 0) { diff --git a/src/React/Promise.php b/src/React/Promise.php index bd384191..6714ce55 100644 --- a/src/React/Promise.php +++ b/src/React/Promise.php @@ -44,23 +44,23 @@ public static function rejected($exception): ReactPromise * @return ReactPromise * @throws \InvalidArgumentException */ - public static function fromObservable(ObservableInterface $observable, Deferred $deferred = null): ReactPromise + public static function fromObservable(ObservableInterface $observable, ?Deferred $deferred = null): ReactPromise { - $d = $deferred ?: new Deferred(function () use (&$subscription) { + $d = $deferred ?: new Deferred(function () use (&$subscription): void { $subscription->dispose(); }); $value = null; $subscription = $observable->subscribe( - function ($v) use (&$value) { + function ($v) use (&$value): void { $value = $v; }, - function ($error) use ($d) { + function ($error) use ($d): void { $d->reject($error); }, - function () use ($d, &$value) { + function () use ($d, &$value): void { $d->resolve($value); } ); @@ -80,11 +80,11 @@ public static function toObservable(PromiseInterface $promise): Observable $subject = new AsyncSubject(); $p = $promise->then( - function ($value) use ($subject) { + function ($value) use ($subject): void { $subject->onNext($value); $subject->onCompleted(); }, - function ($error) use ($subject) { + function ($error) use ($subject): void { $error = $error instanceof \Throwable ? $error : new RejectedPromiseException($error); $subject->onError($error); } @@ -92,7 +92,7 @@ function ($error) use ($subject) { return new AnonymousObservable(function ($observer) use ($subject, $p) { $disp = $subject->subscribe($observer); - return new CallbackDisposable(function () use ($p, $disp) { + return new CallbackDisposable(function () use ($p, $disp): void { $disp->dispose(); if (\method_exists($p, 'cancel')) { $p->cancel(); diff --git a/src/Scheduler/EventLoopScheduler.php b/src/Scheduler/EventLoopScheduler.php index 98059a1b..29924ee5 100644 --- a/src/Scheduler/EventLoopScheduler.php +++ b/src/Scheduler/EventLoopScheduler.php @@ -29,7 +29,7 @@ public function __construct($timerCallableOrLoop) $this->delayCallback = $timerCallableOrLoop instanceof LoopInterface ? function ($ms, $callable) use ($timerCallableOrLoop) { $timer = $timerCallableOrLoop->addTimer($ms / 1000, $callable); - return new CallbackDisposable(function () use ($timer, $timerCallableOrLoop) { + return new CallbackDisposable(function () use ($timer, $timerCallableOrLoop): void { $timerCallableOrLoop->cancelTimer($timer); }); } : @@ -56,7 +56,7 @@ public function scheduleAbsoluteWithState($state, int $dueTime, callable $action { $disp = new CompositeDisposable([ parent::scheduleAbsoluteWithState($state, $dueTime, $action), - new CallbackDisposable(function () use ($dueTime) { + new CallbackDisposable(function () use ($dueTime): void { if ($dueTime > $this->nextTimer) { return; } diff --git a/src/Scheduler/ImmediateScheduler.php b/src/Scheduler/ImmediateScheduler.php index 42278aca..39217d5c 100644 --- a/src/Scheduler/ImmediateScheduler.php +++ b/src/Scheduler/ImmediateScheduler.php @@ -28,11 +28,11 @@ public function scheduleRecursive(callable $action): DisposableInterface $goAgain = true; $disposable = new CompositeDisposable(); - $recursiveAction = function () use ($action, &$goAgain, $disposable) { + $recursiveAction = function () use ($action, &$goAgain, $disposable): void { while ($goAgain) { $goAgain = false; $disposable->add($this->schedule(function () use ($action, &$goAgain) { - return $action(function () use (&$goAgain) { + return $action(function () use (&$goAgain): void { $goAgain = true; }); })); diff --git a/src/Scheduler/VirtualTimeScheduler.php b/src/Scheduler/VirtualTimeScheduler.php index 161723e2..11712fdc 100644 --- a/src/Scheduler/VirtualTimeScheduler.php +++ b/src/Scheduler/VirtualTimeScheduler.php @@ -44,9 +44,9 @@ public function scheduleRecursive(callable $action): DisposableInterface $goAgain = true; $disposable = new SerialDisposable(); - $recursiveAction = function () use ($action, &$goAgain, $disposable, &$recursiveAction) { - $disposable->setDisposable($this->schedule(function () use ($action, &$recursiveAction) { - $action(function () use (&$recursiveAction) { + $recursiveAction = function () use ($action, &$goAgain, $disposable, &$recursiveAction): void { + $disposable->setDisposable($this->schedule(function () use ($action, &$recursiveAction): void { + $action(function () use (&$recursiveAction): void { $recursiveAction(); }); })); @@ -88,7 +88,7 @@ public function scheduleAbsoluteWithState($state, int $dueTime, callable $action $this->queue->enqueue($scheduledItem); - return new CallbackDisposable(function () use ($scheduledItem) { + return new CallbackDisposable(function () use ($scheduledItem): void { $scheduledItem->getDisposable()->dispose(); $this->queue->remove($scheduledItem); }); @@ -112,7 +112,7 @@ public function schedulePeriodic(callable $action, $delay, $period): DisposableI $disposable = new SerialDisposable(); - $doActionAndReschedule = function () use (&$nextTime, $period, $disposable, $action, &$doActionAndReschedule) { + $doActionAndReschedule = function () use (&$nextTime, $period, $disposable, $action, &$doActionAndReschedule): void { $action(); $nextTime += $period; $delay = $nextTime - $this->now(); diff --git a/src/Subject/ReplaySubject.php b/src/Subject/ReplaySubject.php index e0ac85d8..19740662 100644 --- a/src/Subject/ReplaySubject.php +++ b/src/Subject/ReplaySubject.php @@ -35,7 +35,7 @@ class ReplaySubject extends Subject /** @var SchedulerInterface */ private $scheduler; - public function __construct(int $bufferSize = null, int $windowSize = null, SchedulerInterface $scheduler = null) + public function __construct(?int $bufferSize = null, ?int $windowSize = null, ?SchedulerInterface $scheduler = null) { $bufferSize = $bufferSize ?? $this->maxSafeInt; @@ -146,7 +146,7 @@ public function onError(\Throwable $exception) private function createRemovableDisposable($subject, $observer): DisposableInterface { - return new CallbackDisposable(function () use ($observer, $subject) { + return new CallbackDisposable(function () use ($observer, $subject): void { $observer->dispose(); if (!$subject->isDisposed()) { array_splice($subject->observers, (int)array_search($observer, $subject->observers, true), 1); diff --git a/src/Testing/ColdObservable.php b/src/Testing/ColdObservable.php index fce41240..bd95652d 100644 --- a/src/Testing/ColdObservable.php +++ b/src/Testing/ColdObservable.php @@ -38,7 +38,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $notification = $message->getValue(); $time = $message->getTime(); - $schedule = function (Notification $innerNotification) use (&$disposable, &$currentObservable, $observer, $scheduler, $time, &$isDisposed) { + $schedule = function (Notification $innerNotification) use (&$disposable, &$currentObservable, $observer, $scheduler, $time, &$isDisposed): void { $disposable->add($scheduler->scheduleRelativeWithState(null, $time, function () use ($observer, $innerNotification, &$isDisposed) { if (!$isDisposed) { $innerNotification->accept($observer); @@ -52,7 +52,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $subscriptions = &$this->subscriptions; - return new CallbackDisposable(function () use (&$currentObservable, $index, $observer, $scheduler, &$subscriptions, &$isDisposed) { + return new CallbackDisposable(function () use (&$currentObservable, $index, $observer, $scheduler, &$subscriptions, &$isDisposed): void { $isDisposed = true; $subscriptions[$index] = new Subscription($subscriptions[$index]->getSubscribed(), $scheduler->getClock()); }); diff --git a/src/Testing/HotObservable.php b/src/Testing/HotObservable.php index a86bdfed..7f95c26b 100644 --- a/src/Testing/HotObservable.php +++ b/src/Testing/HotObservable.php @@ -28,7 +28,7 @@ public function __construct(TestScheduler $scheduler, array $messages) $time = $message->getTime(); $notification = $message->getValue(); - $schedule = function (Notification $innerNotification) use (&$currentObservable, $scheduler, $time) { + $schedule = function (Notification $innerNotification) use (&$currentObservable, $scheduler, $time): void { $scheduler->scheduleAbsolute($time, function () use (&$currentObservable, $innerNotification) { $observers = $currentObservable->getObservers(); @@ -56,7 +56,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $index = count($this->subscriptions) - 1; $scheduler = $this->scheduler; - return new CallbackDisposable(function () use (&$currentObservable, $index, $observer, $scheduler, &$subscriptions) { + return new CallbackDisposable(function () use (&$currentObservable, $index, $observer, $scheduler, &$subscriptions): void { $currentObservable->removeObserver($observer); $subscriptions[$index] = new Subscription($subscriptions[$index]->getSubscribed(), $scheduler->getClock()); }); diff --git a/src/Testing/Recorded.php b/src/Testing/Recorded.php index 50356d7b..baa1bafd 100644 --- a/src/Testing/Recorded.php +++ b/src/Testing/Recorded.php @@ -10,7 +10,7 @@ class Recorded private $value; private $comparer; - public function __construct(int $time, $value, callable $comparer = null) + public function __construct(int $time, $value, ?callable $comparer = null) { $this->time = $time; $this->value = $value; diff --git a/src/Testing/TestSubject.php b/src/Testing/TestSubject.php index 9be8929f..bb2b71bb 100644 --- a/src/Testing/TestSubject.php +++ b/src/Testing/TestSubject.php @@ -35,7 +35,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $this->subscribeCount++; $this->observer = $observer; - return new CallbackDisposable(function () { + return new CallbackDisposable(function (): void { $this->dispose(); }); diff --git a/test/Rx/Disposable/BinaryDisposableTest.php b/test/Rx/Disposable/BinaryDisposableTest.php index 60b4b323..2cf44219 100644 --- a/test/Rx/Disposable/BinaryDisposableTest.php +++ b/test/Rx/Disposable/BinaryDisposableTest.php @@ -12,17 +12,17 @@ class BinaryDisposableTest extends TestCase /** * @test */ - public function it_disposes_the_binary_disposable() + public function it_disposes_the_binary_disposable(): void { $disposed1 = false; - $d1 = new CallbackDisposable(function () use (&$disposed1) { + $d1 = new CallbackDisposable(function () use (&$disposed1): void { $disposed1 = true; }); $disposed2 = false; - $d2 = new CallbackDisposable(function () use (&$disposed2) { + $d2 = new CallbackDisposable(function () use (&$disposed2): void { $disposed2 = true; }); @@ -42,17 +42,17 @@ public function it_disposes_the_binary_disposable() /** * @test */ - public function it_does_nothing_if_disposed_twice() + public function it_does_nothing_if_disposed_twice(): void { $disposed1 = 0; - $d1 = new CallbackDisposable(function () use (&$disposed1) { + $d1 = new CallbackDisposable(function () use (&$disposed1): void { $disposed1++; }); $disposed2 = 0; - $d2 = new CallbackDisposable(function () use (&$disposed2) { + $d2 = new CallbackDisposable(function () use (&$disposed2): void { $disposed2++; }); diff --git a/test/Rx/Disposable/CallbackDisposableTest.php b/test/Rx/Disposable/CallbackDisposableTest.php index d1fa65a6..f64b09ed 100644 --- a/test/Rx/Disposable/CallbackDisposableTest.php +++ b/test/Rx/Disposable/CallbackDisposableTest.php @@ -11,10 +11,10 @@ class CallbackDisposableTest extends TestCase /** * @test */ - public function it_calls_the_callback_on_dispose() + public function it_calls_the_callback_on_dispose(): void { $disposed = false; - $disposable = new CallbackDisposable(function() use (&$disposed) { $disposed = true; }); + $disposable = new CallbackDisposable(function() use (&$disposed): void { $disposed = true; }); $this->assertFalse($disposed); @@ -26,11 +26,11 @@ public function it_calls_the_callback_on_dispose() /** * @test */ - public function it_only_disposes_once() + public function it_only_disposes_once(): void { $disposed = false; $invocations = 0; - $disposable = new CallbackDisposable(function () use (&$disposed, &$invocations) { + $disposable = new CallbackDisposable(function () use (&$disposed, &$invocations): void { $invocations++; $disposed = true; }); diff --git a/test/Rx/Disposable/CompositeDisposableTest.php b/test/Rx/Disposable/CompositeDisposableTest.php index e9d50950..99ae224c 100644 --- a/test/Rx/Disposable/CompositeDisposableTest.php +++ b/test/Rx/Disposable/CompositeDisposableTest.php @@ -11,11 +11,11 @@ class CompositeDisposableTest extends TestCase /** * @test */ - public function it_exposes_the_amount_of_disposables_composed() + public function it_exposes_the_amount_of_disposables_composed(): void { - $d1 = new CallbackDisposable(function(){}); - $d2 = new CallbackDisposable(function(){}); - $disposable = new CompositeDisposable(array($d1, $d2)); + $d1 = new CallbackDisposable(function(): void{}); + $d2 = new CallbackDisposable(function(): void{}); + $disposable = new CompositeDisposable([$d1, $d2]); $this->assertEquals(2, $disposable->count()); } @@ -23,12 +23,12 @@ public function it_exposes_the_amount_of_disposables_composed() /** * @test */ - public function it_can_be_checked_if_it_contains_a_disposable() + public function it_can_be_checked_if_it_contains_a_disposable(): void { - $d1 = new CallbackDisposable(function(){}); - $d2 = new CallbackDisposable(function(){}); - $d3 = new CallbackDisposable(function(){}); - $disposable = new CompositeDisposable(array($d1, $d2)); + $d1 = new CallbackDisposable(function(): void{}); + $d2 = new CallbackDisposable(function(): void{}); + $d3 = new CallbackDisposable(function(): void{}); + $disposable = new CompositeDisposable([$d1, $d2]); $this->assertTrue($disposable->contains($d1)); $this->assertTrue($disposable->contains($d2)); @@ -38,11 +38,11 @@ public function it_can_be_checked_if_it_contains_a_disposable() /** * @test */ - public function a_disposable_can_be_added_after_creation() + public function a_disposable_can_be_added_after_creation(): void { - $d1 = new CallbackDisposable(function(){}); - $d2 = new CallbackDisposable(function(){}); - $disposable = new CompositeDisposable(array($d1)); + $d1 = new CallbackDisposable(function(): void{}); + $d2 = new CallbackDisposable(function(): void{}); + $disposable = new CompositeDisposable([$d1]); $this->assertEquals(1, $disposable->count()); $this->assertFalse($disposable->contains($d2)); @@ -55,13 +55,13 @@ public function a_disposable_can_be_added_after_creation() /** * @test */ - public function disposing_disposes_all_disposables() + public function disposing_disposes_all_disposables(): void { $disposed1 = false; $disposed2 = false; - $d1 = new CallbackDisposable(function() use (&$disposed1){ $disposed1 = true; }); - $d2 = new CallbackDisposable(function() use (&$disposed2){ $disposed2 = true; }); - $disposable = new CompositeDisposable(array($d1, $d2)); + $d1 = new CallbackDisposable(function() use (&$disposed1): void{ $disposed1 = true; }); + $d2 = new CallbackDisposable(function() use (&$disposed2): void{ $disposed2 = true; }); + $disposable = new CompositeDisposable([$d1, $d2]); $disposable->dispose(); @@ -72,13 +72,13 @@ public function disposing_disposes_all_disposables() /** * @test */ - public function disposing_disposes_all_disposables_only_once() + public function disposing_disposes_all_disposables_only_once(): void { $disposed1 = 0; $disposed2 = 0; - $d1 = new CallbackDisposable(function() use (&$disposed1){ $disposed1++; }); - $d2 = new CallbackDisposable(function() use (&$disposed2){ $disposed2++; }); - $disposable = new CompositeDisposable(array($d1, $d2)); + $d1 = new CallbackDisposable(function() use (&$disposed1): void{ $disposed1++; }); + $d2 = new CallbackDisposable(function() use (&$disposed2): void{ $disposed2++; }); + $disposable = new CompositeDisposable([$d1, $d2]); $this->assertEquals(0, $disposed1); $this->assertEquals(0, $disposed2); @@ -97,13 +97,13 @@ public function disposing_disposes_all_disposables_only_once() /** * @test */ - public function it_disposes_newly_added_disposables_when_already_disposed() + public function it_disposes_newly_added_disposables_when_already_disposed(): void { $disposed1 = false; $disposed2 = false; - $d1 = new CallbackDisposable(function() use (&$disposed1){ $disposed1 = true; }); - $d2 = new CallbackDisposable(function() use (&$disposed2){ $disposed2 = true; }); - $disposable = new CompositeDisposable(array($d1)); + $d1 = new CallbackDisposable(function() use (&$disposed1): void{ $disposed1 = true; }); + $d2 = new CallbackDisposable(function() use (&$disposed2): void{ $disposed2 = true; }); + $disposable = new CompositeDisposable([$d1]); $disposable->dispose(); $disposable->add($d2); @@ -114,12 +114,12 @@ public function it_disposes_newly_added_disposables_when_already_disposed() /** * @test */ - public function a_disposable_can_be_removed() + public function a_disposable_can_be_removed(): void { $disposed2 = false; - $d1 = new CallbackDisposable(function(){}); - $d2 = new CallbackDisposable(function() use (&$disposed2){ $disposed2 = true; }); - $disposable = new CompositeDisposable(array($d1, $d2)); + $d1 = new CallbackDisposable(function(): void{}); + $d2 = new CallbackDisposable(function() use (&$disposed2): void{ $disposed2 = true; }); + $disposable = new CompositeDisposable([$d1, $d2]); $disposable->remove($d2); @@ -129,12 +129,12 @@ public function a_disposable_can_be_removed() /** * @test */ - public function a_removed_disposable_is_disposed() + public function a_removed_disposable_is_disposed(): void { $disposed2 = false; - $d1 = new CallbackDisposable(function(){}); - $d2 = new CallbackDisposable(function() use (&$disposed2){ $disposed2 = true; }); - $disposable = new CompositeDisposable(array($d1, $d2)); + $d1 = new CallbackDisposable(function(): void{}); + $d2 = new CallbackDisposable(function() use (&$disposed2): void{ $disposed2 = true; }); + $disposable = new CompositeDisposable([$d1, $d2]); $this->assertTrue($disposable->remove($d2)); $this->assertTrue($disposed2); @@ -143,13 +143,13 @@ public function a_removed_disposable_is_disposed() /** * @test */ - public function removing_when_disposed_has_no_effect() + public function removing_when_disposed_has_no_effect(): void { - $disposable = new CompositeDisposable(array()); + $disposable = new CompositeDisposable([]); $disposable->dispose(); $disposed1 = false; - $d1 = new CallbackDisposable(function() use (&$disposed1){ $disposed1 = true; }); + $d1 = new CallbackDisposable(function() use (&$disposed1): void{ $disposed1 = true; }); $removed = $disposable->remove($d1); @@ -161,12 +161,12 @@ public function removing_when_disposed_has_no_effect() /** * @test */ - public function removing_a_disposable_that_is_not_contained_has_no_effect() + public function removing_a_disposable_that_is_not_contained_has_no_effect(): void { - $disposable = new CompositeDisposable(array()); + $disposable = new CompositeDisposable([]); $disposed1 = false; - $d1 = new CallbackDisposable(function() use (&$disposed1){ $disposed1 = true; }); + $d1 = new CallbackDisposable(function() use (&$disposed1): void{ $disposed1 = true; }); $removed = $disposable->remove($d1); @@ -178,13 +178,13 @@ public function removing_a_disposable_that_is_not_contained_has_no_effect() /** * @test */ - public function clear_disposes_all_contained_disposables_but_not_the_composite_disposable() + public function clear_disposes_all_contained_disposables_but_not_the_composite_disposable(): void { $disposed1 = false; $disposed2 = false; - $d1 = new CallbackDisposable(function() use (&$disposed1){ $disposed1 = true; }); - $d2 = new CallbackDisposable(function() use (&$disposed2){ $disposed2 = true; }); - $disposable = new CompositeDisposable(array($d1, $d2)); + $d1 = new CallbackDisposable(function() use (&$disposed1): void{ $disposed1 = true; }); + $d2 = new CallbackDisposable(function() use (&$disposed2): void{ $disposed2 = true; }); + $disposable = new CompositeDisposable([$d1, $d2]); $disposable->clear(); @@ -192,7 +192,7 @@ public function clear_disposes_all_contained_disposables_but_not_the_composite_d $this->assertTrue($disposed2); $disposed3 = false; - $d3 = new CallbackDisposable(function() use (&$disposed3){ $disposed3 = true; }); + $d3 = new CallbackDisposable(function() use (&$disposed3): void{ $disposed3 = true; }); $disposable->add($d3); $this->assertFalse($disposed3); @@ -202,11 +202,11 @@ public function clear_disposes_all_contained_disposables_but_not_the_composite_d * @test * @doesNotPerformAssertions */ - public function it_can_be_disposed_multiple_times() + public function it_can_be_disposed_multiple_times(): void { - $d1 = new CallbackDisposable(function(){}); - $d2 = new CallbackDisposable(function(){}); - $disposable = new CompositeDisposable(array($d1, $d2)); + $d1 = new CallbackDisposable(function(): void{}); + $d2 = new CallbackDisposable(function(): void{}); + $disposable = new CompositeDisposable([$d1, $d2]); $disposable->dispose(); $disposable->dispose(); @@ -217,7 +217,7 @@ public function it_can_be_disposed_multiple_times() * * see https://github.com/ReactiveX/RxPHP/issues/107 */ - public function it_can_distinguish_and_dispose_of_correct_disposable() + public function it_can_distinguish_and_dispose_of_correct_disposable(): void { // factory to create 2 disposables that evaluate the same with == $getSimilarDisposables = function () { @@ -234,7 +234,7 @@ public function it_can_distinguish_and_dispose_of_correct_disposable() // all future sets of disp should immediately dispose $compositeDisposable->remove($disposables[0]); $wasDisposed = false; - $disposables[0]->setDisposable(new CallbackDisposable(function () use (&$wasDisposed) { + $disposables[0]->setDisposable(new CallbackDisposable(function () use (&$wasDisposed): void { $wasDisposed = true; })); $this->assertTrue($wasDisposed); @@ -247,7 +247,7 @@ public function it_can_distinguish_and_dispose_of_correct_disposable() // all future sets of disp should immediately dispose $compositeDisposable->remove($disposables[1]); $wasDisposed = false; - $disposables[1]->setDisposable(new CallbackDisposable(function () use (&$wasDisposed) { + $disposables[1]->setDisposable(new CallbackDisposable(function () use (&$wasDisposed): void { $wasDisposed = true; })); $this->assertTrue($wasDisposed); @@ -256,7 +256,7 @@ public function it_can_distinguish_and_dispose_of_correct_disposable() /** * @test */ - public function it_knows_what_it_contains() + public function it_knows_what_it_contains(): void { // factory to create 2 disposables that evaluate the same with == $getSimilarDisposables = function () { diff --git a/test/Rx/Disposable/EmptyDisposableTest.php b/test/Rx/Disposable/EmptyDisposableTest.php index d8e11087..89e0c208 100644 --- a/test/Rx/Disposable/EmptyDisposableTest.php +++ b/test/Rx/Disposable/EmptyDisposableTest.php @@ -12,7 +12,7 @@ class EmptyDisposableTest extends TestCase * @test * @doesNotPerformAssertions */ - public function it_can_be_disposed() + public function it_can_be_disposed(): void { $disposable = new EmptyDisposable(); diff --git a/test/Rx/Disposable/RefCountDisposableTest.php b/test/Rx/Disposable/RefCountDisposableTest.php index cf4701b8..2756c137 100644 --- a/test/Rx/Disposable/RefCountDisposableTest.php +++ b/test/Rx/Disposable/RefCountDisposableTest.php @@ -12,7 +12,7 @@ class RefCountDisposableTest extends TestCase /** * @test */ - public function it_holds_a_reference_to_one_disposable() + public function it_holds_a_reference_to_one_disposable(): void { $d = new BooleanDisposable(); $r = new RefCountDisposable($d); @@ -26,7 +26,7 @@ public function it_holds_a_reference_to_one_disposable() /** * @test */ - public function it_disposes_if_all_references_are_disposed() + public function it_disposes_if_all_references_are_disposed(): void { $d = new BooleanDisposable(); $r = new RefCountDisposable($d); @@ -47,7 +47,7 @@ public function it_disposes_if_all_references_are_disposed() /** * @test */ - public function it_disposes_after_last_reference_is_disposed() + public function it_disposes_after_last_reference_is_disposed(): void { $d = new BooleanDisposable(); $r = new RefCountDisposable($d); @@ -68,7 +68,7 @@ public function it_disposes_after_last_reference_is_disposed() /** * @test */ - public function it_does_not_dispose_the_primary_if_refcount_inner_disposable_is_disposed_multiple_times() + public function it_does_not_dispose_the_primary_if_refcount_inner_disposable_is_disposed_multiple_times(): void { $d = new BooleanDisposable(); $r = new RefCountDisposable($d); @@ -92,10 +92,10 @@ public function it_does_not_dispose_the_primary_if_refcount_inner_disposable_is_ /** * @test */ - public function it_does_not_dispose_the_primary_if_already_disposed_via_refcount() + public function it_does_not_dispose_the_primary_if_already_disposed_via_refcount(): void { $called = 0; - $d = new CallbackDisposable(function() use (&$called) { $called++; }); + $d = new CallbackDisposable(function() use (&$called): void { $called++; }); $r = new RefCountDisposable($d); $r->dispose(); @@ -107,10 +107,10 @@ public function it_does_not_dispose_the_primary_if_already_disposed_via_refcount /** * @test */ - public function it_does_not_dispose_the_primary_if_already_disposed() + public function it_does_not_dispose_the_primary_if_already_disposed(): void { $called = 0; - $d = new CallbackDisposable(function() use (&$called) { $called++; }); + $d = new CallbackDisposable(function() use (&$called): void { $called++; }); $r = new RefCountDisposable($d); $d1 = $r->getDisposable(); @@ -126,10 +126,10 @@ public function it_does_not_dispose_the_primary_if_already_disposed() /** * @test */ - public function it_returns_a_noop_disposable_if_primary_is_already_disposed() + public function it_returns_a_noop_disposable_if_primary_is_already_disposed(): void { $called = 0; - $d = new CallbackDisposable(function() use (&$called) { $called++; }); + $d = new CallbackDisposable(function() use (&$called): void { $called++; }); $r = new RefCountDisposable($d); $r->dispose(); diff --git a/test/Rx/Disposable/ScheduledDisposableTest.php b/test/Rx/Disposable/ScheduledDisposableTest.php index 7554f32c..dc2222bb 100644 --- a/test/Rx/Disposable/ScheduledDisposableTest.php +++ b/test/Rx/Disposable/ScheduledDisposableTest.php @@ -13,11 +13,11 @@ class ScheduledDisposableTest extends TestCase /** * @test */ - public function it_disposes_the_scheduled_disposable() + public function it_disposes_the_scheduled_disposable(): void { $disposed1 = false; - $d1 = new CallbackDisposable(function () use (&$disposed1) { + $d1 = new CallbackDisposable(function () use (&$disposed1): void { $disposed1 = true; }); @@ -39,11 +39,11 @@ public function it_disposes_the_scheduled_disposable() /** * @test */ - public function it_does_nothing_if_disposed_twice() + public function it_does_nothing_if_disposed_twice(): void { $disposed1 = 0; - $d1 = new CallbackDisposable(function () use (&$disposed1) { + $d1 = new CallbackDisposable(function () use (&$disposed1): void { $disposed1++; }); diff --git a/test/Rx/Disposable/SerialDisposableTest.php b/test/Rx/Disposable/SerialDisposableTest.php index e9dc4fd2..d70ebe17 100644 --- a/test/Rx/Disposable/SerialDisposableTest.php +++ b/test/Rx/Disposable/SerialDisposableTest.php @@ -12,10 +12,10 @@ class SerialDisposableTest extends TestCase /** * @test */ - public function it_disposes_the_assigned_disposable() + public function it_disposes_the_assigned_disposable(): void { $disposed1 = false; - $d1 = new CallbackDisposable(function () use (&$disposed1) { + $d1 = new CallbackDisposable(function () use (&$disposed1): void { $disposed1 = true; }); $disposable = new SerialDisposable(); @@ -32,10 +32,10 @@ public function it_disposes_the_assigned_disposable() /** * @test */ - public function it_disposes_the_assigned_disposable_on_reassignment() + public function it_disposes_the_assigned_disposable_on_reassignment(): void { $disposed1 = false; - $d1 = new CallbackDisposable(function () use (&$disposed1) { $disposed1 = true; }); + $d1 = new CallbackDisposable(function () use (&$disposed1): void { $disposed1 = true; }); $d2 = new EmptyDisposable(); $disposable = new SerialDisposable(); @@ -53,10 +53,10 @@ public function it_disposes_the_assigned_disposable_on_reassignment() /** * @test */ - public function it_unsets_the_disposable_on_dispose() + public function it_unsets_the_disposable_on_dispose(): void { $disposed1 = false; - $d1 = new CallbackDisposable(function () use (&$disposed1) { + $d1 = new CallbackDisposable(function () use (&$disposed1): void { $disposed1 = true; }); $disposable = new SerialDisposable(); @@ -75,12 +75,12 @@ public function it_unsets_the_disposable_on_dispose() /** * @test */ - public function it_disposes_the_assigned_disposable_if_already_disposed() + public function it_disposes_the_assigned_disposable_if_already_disposed(): void { $disposed1 = false; $disposed2 = false; - $d1 = new CallbackDisposable(function() use (&$disposed1){ $disposed1 = true; }); - $d2 = new CallbackDisposable(function() use (&$disposed2){ $disposed2 = true; }); + $d1 = new CallbackDisposable(function() use (&$disposed1): void{ $disposed1 = true; }); + $d2 = new CallbackDisposable(function() use (&$disposed2): void{ $disposed2 = true; }); $disposable = new SerialDisposable(); $disposable->setDisposable($d1); diff --git a/test/Rx/Disposable/SingleAssignmentDisposableTest.php b/test/Rx/Disposable/SingleAssignmentDisposableTest.php index 90fc3fe2..ca88f1bb 100644 --- a/test/Rx/Disposable/SingleAssignmentDisposableTest.php +++ b/test/Rx/Disposable/SingleAssignmentDisposableTest.php @@ -11,10 +11,10 @@ class SingleAssignmentDisposableTest extends TestCase /** * @test */ - public function it_disposes_the_assigned_disposable() + public function it_disposes_the_assigned_disposable(): void { $disposed1 = false; - $d1 = new CallbackDisposable(function() use (&$disposed1){ $disposed1 = true; }); + $d1 = new CallbackDisposable(function() use (&$disposed1): void{ $disposed1 = true; }); $disposable = new SingleAssignmentDisposable(); $disposable->setDisposable($d1); @@ -29,11 +29,11 @@ public function it_disposes_the_assigned_disposable() /** * @test */ - public function it_disposes_newly_set_disposable_if_already_disposed() + public function it_disposes_newly_set_disposable_if_already_disposed(): void { $disposed1 = false; - $d1 = new CallbackDisposable(function() use (&$disposed1){ $disposed1 = true; }); - $d2 = new CallbackDisposable(function(){}); + $d1 = new CallbackDisposable(function() use (&$disposed1): void{ $disposed1 = true; }); + $d2 = new CallbackDisposable(function(): void{}); $disposable = new SingleAssignmentDisposable(); $disposable->setDisposable($d2); @@ -49,11 +49,11 @@ public function it_disposes_newly_set_disposable_if_already_disposed() /** * @test */ - public function it_cannot_be_assignmed_multiple_times() + public function it_cannot_be_assignmed_multiple_times(): void { $this->expectException(\RuntimeException::class); - $d1 = new CallbackDisposable(function(){}); - $d2 = new CallbackDisposable(function(){}); + $d1 = new CallbackDisposable(function(): void{}); + $d2 = new CallbackDisposable(function(): void{}); $disposable = new SingleAssignmentDisposable(); $disposable->setDisposable($d1); diff --git a/test/Rx/Functional/ColdObservableTest.php b/test/Rx/Functional/ColdObservableTest.php index 57155d1a..86775021 100644 --- a/test/Rx/Functional/ColdObservableTest.php +++ b/test/Rx/Functional/ColdObservableTest.php @@ -9,23 +9,23 @@ class ColdObservableTest extends FunctionalTestCase /** * @test */ - public function it_calls_relative_to_subscribe_time() + public function it_calls_relative_to_subscribe_time(): void { - $xs = $this->createColdObservable(array( + $xs = $this->createColdObservable([ onNext(50, "foo"), onNext(75, "Bar"), onCompleted(105) - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs) { return $xs; }); $this->assertCount(3, $results->getMessages()); - $this->assertMessages(array( + $this->assertMessages([ onNext(250, "foo"), onNext(275, "Bar"), onCompleted(305) - ), $results->getMessages()); + ], $results->getMessages()); } } diff --git a/test/Rx/Functional/FunctionalTestCase.php b/test/Rx/Functional/FunctionalTestCase.php index 21c4fab1..b74b4aec 100644 --- a/test/Rx/Functional/FunctionalTestCase.php +++ b/test/Rx/Functional/FunctionalTestCase.php @@ -122,12 +122,12 @@ protected function createColdObservable(array $events) return new ColdObservable($this->scheduler, $events); } - protected function createCold(string $events, array $eventMap = [], \Exception $customError = null) + protected function createCold(string $events, array $eventMap = [], ?\Exception $customError = null) { return new ColdObservable($this->scheduler, $this->convertMarblesToMessages($events, $eventMap, $customError)); } - protected function createHot(string $events, array $eventMap = [], \Exception $customError = null) + protected function createHot(string $events, array $eventMap = [], ?\Exception $customError = null) { return new HotObservable($this->scheduler, $this->convertMarblesToMessages($events, $eventMap, $customError, 200)); } @@ -142,7 +142,7 @@ protected function createTestScheduler() return new TestScheduler(); } - protected function convertMarblesToMessages(string $marbles, array $eventMap = [], \Exception $customError = null, $subscribePoint = 0) + protected function convertMarblesToMessages(string $marbles, array $eventMap = [], ?\Exception $customError = null, $subscribePoint = 0) { /** @var Recorded $events */ $events = []; @@ -183,7 +183,7 @@ protected function convertMarblesToMessages(string $marbles, array $eventMap = [ continue 2; default: $eventKey = $marbles[$i]; - $events[] = onNext($now, isset($eventMap[$eventKey]) ? $eventMap[$eventKey] : $marbles[$i]); + $events[] = onNext($now, $eventMap[$eventKey] ?? $marbles[$i]); continue 2; } } @@ -206,13 +206,13 @@ protected function convertMessagesToMarbles($messages) $lastTime = $time; $value->accept( - function ($x) use (&$output) { + function ($x) use (&$output): void { $output .= $x; }, - function (\Exception $e) use (&$output) { + function (\Exception $e) use (&$output): void { $output .= '#'; }, - function () use (&$output) { + function () use (&$output): void { $output .= '|'; } ); @@ -291,7 +291,7 @@ protected function convertMarblesToDisposeTime(string $marbles, $startTime = 0) return $disposeAt; } - public function expectObservable(Observable $observable, string $disposeMarble = null): ExpectObservableToBe + public function expectObservable(Observable $observable, ?string $disposeMarble = null): ExpectObservableToBe { if ($disposeMarble) { $disposeAt = $this->convertMarblesToDisposeTime($disposeMarble, 200); @@ -317,7 +317,7 @@ public function __construct(array $messages) $this->messages = $messages; } - public function toBe(string $expected, array $values = [], string $errorMessage = null) + public function toBe(string $expected, array $values = [], ?string $errorMessage = null) { $error = $errorMessage ? new \Exception($errorMessage) : null; @@ -359,5 +359,5 @@ public function toBe(string $subscriptionsMarbles); interface ExpectObservableToBe { - public function toBe(string $expected, array $values = [], string $errorMessage = null); + public function toBe(string $expected, array $values = [], ?string $errorMessage = null); } diff --git a/test/Rx/Functional/MarbleTest.php b/test/Rx/Functional/MarbleTest.php index 897895aa..2b8ee4e6 100644 --- a/test/Rx/Functional/MarbleTest.php +++ b/test/Rx/Functional/MarbleTest.php @@ -7,7 +7,7 @@ class MarbleTest extends FunctionalTestCase { - public function testColdMarble() + public function testColdMarble(): void { $c = $this->createCold('----1----3---|'); @@ -22,7 +22,7 @@ public function testColdMarble() ], $result->getMessages()); } - public function testHotMarble() + public function testHotMarble(): void { $h = $this->createHot('-1-^--a--b---|'); @@ -37,7 +37,7 @@ public function testHotMarble() ], $result->getMessages()); } - public function testColdMarbleWithEqualMessages() + public function testColdMarbleWithEqualMessages(): void { $marbles1 = '----1-^--a--b---| '; $marbles2 = ' 1-^--a--b---|---'; @@ -48,7 +48,7 @@ public function testColdMarbleWithEqualMessages() ); } - public function testMessageConversion() + public function testMessageConversion(): void { $messages = [ onNext(230, 'a'), @@ -59,7 +59,7 @@ public function testMessageConversion() $this->assertEquals('---a--b---|', $this->convertMessagesToMarbles($messages)); } - public function testSomethingElse() + public function testSomethingElse(): void { $cold = '--1--2--|'; $expected = '--2--3--|'; @@ -71,7 +71,7 @@ public function testSomethingElse() $this->assertEquals($expected, $this->convertMessagesToMarbles($results->getMessages())); } - public function testMarbleValues() + public function testMarbleValues(): void { $marbles = '--a--b--c--|'; $values = [ @@ -90,7 +90,7 @@ public function testMarbleValues() ], $messages); } - public function testMarbleValuesDontMatch() + public function testMarbleValuesDontMatch(): void { $marbles = '--a--b--c--|'; $values = [ @@ -109,7 +109,7 @@ public function testMarbleValuesDontMatch() ], $messages); } - public function testMarbleWithMissingValues() + public function testMarbleWithMissingValues(): void { $marbles = '--a--b--c--|'; $values = [ @@ -126,7 +126,7 @@ public function testMarbleWithMissingValues() ], $messages); } - public function testGroupedMarbleValues() + public function testGroupedMarbleValues(): void { $marbles = '---(abc)--|'; @@ -140,7 +140,7 @@ public function testGroupedMarbleValues() ], $messages); } - public function testMultipleGroupedMarbleValues() + public function testMultipleGroupedMarbleValues(): void { $marbles = '--(abc)---(dfa)--|'; $values = [ @@ -160,7 +160,7 @@ public function testMultipleGroupedMarbleValues() ], $messages); } - public function testGroupedMarkerAndComplete() + public function testGroupedMarkerAndComplete(): void { $marbles = '--a---b--(c|)'; @@ -174,7 +174,7 @@ public function testGroupedMarkerAndComplete() ], $messages); } - public function testGroupedMarkerAndError() + public function testGroupedMarkerAndError(): void { $marbles = '--a---(b#)--c--|'; @@ -189,7 +189,7 @@ public function testGroupedMarkerAndError() ], $messages); } - public function testSubscriptions() + public function testSubscriptions(): void { $marbles = '--^-----!---^!--'; @@ -200,7 +200,7 @@ public function testSubscriptions() ], $subscriptions); } - public function testSubscriptionsMissingUnsubscribeMarker() + public function testSubscriptionsMissingUnsubscribeMarker(): void { $marbles = '--^--'; @@ -210,7 +210,7 @@ public function testSubscriptionsMissingUnsubscribeMarker() ], $subscriptions); } - public function testSubscriptionsGroup() + public function testSubscriptionsGroup(): void { $marbles = '--(^!)'; @@ -223,7 +223,7 @@ public function testSubscriptionsGroup() /** */ - public function testSubscriptionsInvalidMarkers() + public function testSubscriptionsInvalidMarkers(): void { $this->expectException(\Rx\MarbleDiagramException::class); $marbles = '--^--a--!-'; @@ -232,7 +232,7 @@ public function testSubscriptionsInvalidMarkers() /** */ - public function testSubscriptionsMultipleSubscribeMarkers() + public function testSubscriptionsMultipleSubscribeMarkers(): void { $this->expectException(\Rx\MarbleDiagramException::class); $marbles = '--^-^---!-'; @@ -241,14 +241,14 @@ public function testSubscriptionsMultipleSubscribeMarkers() /** */ - public function testSubscriptionsMultipleUnsubscribeMarkers() + public function testSubscriptionsMultipleUnsubscribeMarkers(): void { $this->expectException(\Rx\MarbleDiagramException::class); $marbles = '--^---!-!-'; $this->convertMarblesToSubscriptions($marbles); } - public function testMapMarble() + public function testMapMarble(): void { $cold = '--1--2--|'; $subs = '^ !'; @@ -264,7 +264,7 @@ public function testMapMarble() $this->expectSubscriptions($e1->getSubscriptions())->toBe($subs); } - public function testMapErrorMarble() + public function testMapErrorMarble(): void { $cold = '--x--|'; $subs = '^ ! '; @@ -272,7 +272,7 @@ public function testMapErrorMarble() $e1 = $this->createCold($cold, ['x' => 42]); - $r = $e1->map(function ($x) { + $r = $e1->map(function ($x): void { throw new \Exception('too bad'); }); @@ -280,7 +280,7 @@ public function testMapErrorMarble() $this->expectSubscriptions($e1->getSubscriptions())->toBe($subs); } - public function testMapDisposeMarble() + public function testMapDisposeMarble(): void { $cold = '--1--2--3--|'; $unsub = ' ! '; @@ -297,7 +297,7 @@ public function testMapDisposeMarble() $this->expectSubscriptions($e1->getSubscriptions())->toBe($subs); } - public function testCountMarble() + public function testCountMarble(): void { $cold = '--a--b--c--|'; $subs = '^ !'; diff --git a/test/Rx/Functional/Observable/ErrorObservableTest.php b/test/Rx/Functional/Observable/ErrorObservableTest.php index 89147a2c..be7d0472 100644 --- a/test/Rx/Functional/Observable/ErrorObservableTest.php +++ b/test/Rx/Functional/Observable/ErrorObservableTest.php @@ -11,7 +11,7 @@ class ErrorObservableTest extends FunctionalTestCase { - public function testErrorObservableWillAcceptThrowable() + public function testErrorObservableWillAcceptThrowable(): void { $throwable = null; diff --git a/test/Rx/Functional/Observable/ForkJoinObservableTest.php b/test/Rx/Functional/Observable/ForkJoinObservableTest.php index 451fe3bf..4f65172e 100644 --- a/test/Rx/Functional/Observable/ForkJoinObservableTest.php +++ b/test/Rx/Functional/Observable/ForkJoinObservableTest.php @@ -13,7 +13,7 @@ class ForkJoinObservableTest extends FunctionalTestCase /** * @test */ - public function forkjoin_joins_last_values() + public function forkjoin_joins_last_values(): void { $e0 = $this->createHotObservable([ onNext(150, 'a'), @@ -50,7 +50,7 @@ public function forkjoin_joins_last_values() /** * @test */ - public function forkjoin_allows_null() + public function forkjoin_allows_null(): void { $e0 = $this->createHotObservable([ onNext(150, 'a'), @@ -87,7 +87,7 @@ public function forkjoin_allows_null() /** * @test */ - public function forkjoin_joins_last_values_with_selector() + public function forkjoin_joins_last_values_with_selector(): void { $e0 = $this->createHotObservable([ onNext(150, 'a'), @@ -126,7 +126,7 @@ public function forkjoin_joins_last_values_with_selector() /** * @test */ - public function forkjoin_accepts_single_observable() + public function forkjoin_accepts_single_observable(): void { $e0 = $this->createHotObservable([ onNext(150, 'a'), @@ -151,7 +151,7 @@ public function forkjoin_accepts_single_observable() /** * @test */ - public function forkjoin_accepts_single_observable_with_selector() + public function forkjoin_accepts_single_observable_with_selector(): void { $e0 = $this->createHotObservable([ onNext(150, 'a'), @@ -178,7 +178,7 @@ public function forkjoin_accepts_single_observable_with_selector() /** * @test */ - public function forkjoin_wont_emit_with_empty_observable() + public function forkjoin_wont_emit_with_empty_observable(): void { $e0 = $this->createHotObservable([ onNext(150, 1), @@ -212,7 +212,7 @@ public function forkjoin_wont_emit_with_empty_observable() /** * @test */ - public function forkjoin_empty_empty() + public function forkjoin_empty_empty(): void { $e0 = $this->createHotObservable([ onNext(150, 1), @@ -240,7 +240,7 @@ public function forkjoin_empty_empty() /** * @test */ - public function forkjoin_none() + public function forkjoin_none(): void { $xs = Observable::forkJoin(); @@ -256,7 +256,7 @@ public function forkjoin_none() /** * @test */ - public function forkjoin_empty_return() + public function forkjoin_empty_return(): void { $e0 = $this->createHotObservable([ onNext(150, 1), @@ -285,7 +285,7 @@ public function forkjoin_empty_return() /** * @test */ - public function forkjoin_return_empty() + public function forkjoin_return_empty(): void { $e0 = $this->createHotObservable([ onNext(150, 1), @@ -314,7 +314,7 @@ public function forkjoin_return_empty() /** * @test */ - public function forkjoin_return_return() + public function forkjoin_return_return(): void { $e0 = $this->createHotObservable([ onNext(150, 1), @@ -345,7 +345,7 @@ public function forkjoin_return_return() /** * @test */ - public function forkjoin_empty_throw() + public function forkjoin_empty_throw(): void { $error = new \Exception(); @@ -376,7 +376,7 @@ public function forkjoin_empty_throw() /** * @test */ - public function forkjoin_throw_empty() + public function forkjoin_throw_empty(): void { $error = new \Exception(); @@ -407,7 +407,7 @@ public function forkjoin_throw_empty() /** * @test */ - public function forkjoin_return_throw() + public function forkjoin_return_throw(): void { $error = new \Exception(); @@ -439,7 +439,7 @@ public function forkjoin_return_throw() /** * @test */ - public function forkjoin_throw_return() + public function forkjoin_throw_return(): void { $error = new \Exception(); @@ -471,7 +471,7 @@ public function forkjoin_throw_return() /** * @test */ - public function forkjoin_throw_inside_selector() + public function forkjoin_throw_inside_selector(): void { $error = new \Exception(); @@ -480,7 +480,7 @@ public function forkjoin_throw_inside_selector() onCompleted(230), ]); - $xs = Observable::forkJoin([$e0], function () use ($error) { + $xs = Observable::forkJoin([$e0], function () use ($error): void { throw $error; }); @@ -496,7 +496,7 @@ public function forkjoin_throw_inside_selector() /** * @test */ - public function forkjoin_disposed_after_emit() + public function forkjoin_disposed_after_emit(): void { $e0 = $this->createHotObservable([ onNext(250, 1), diff --git a/test/Rx/Functional/Observable/IntervalObservableTest.php b/test/Rx/Functional/Observable/IntervalObservableTest.php index fdb3ca12..6407b3ff 100644 --- a/test/Rx/Functional/Observable/IntervalObservableTest.php +++ b/test/Rx/Functional/Observable/IntervalObservableTest.php @@ -13,7 +13,7 @@ class IntervalObservableTest extends FunctionalTestCase /** * @test */ - public function interval_relative_time_basic() + public function interval_relative_time_basic(): void { $results = $this->scheduler->startWithCreate(function () { return new IntervalObservable(100, $this->scheduler); @@ -36,7 +36,7 @@ public function interval_relative_time_basic() /** * @test */ - public function interval_relative_time_zero() + public function interval_relative_time_zero(): void { $results = $this->scheduler->startWithDispose(function () { return new IntervalObservable(0, $this->scheduler); @@ -61,7 +61,7 @@ public function interval_relative_time_zero() /** * @test */ - public function interval_relative_time_Negative() + public function interval_relative_time_Negative(): void { $results = $this->scheduler->startWithDispose(function () { return new IntervalObservable(-1, $this->scheduler); @@ -86,7 +86,7 @@ public function interval_relative_time_Negative() /** * @test */ - public function interval_relative_time_disposed() + public function interval_relative_time_disposed(): void { $results = $this->scheduler->startWithCreate(function () { return new IntervalObservable(1000, $this->scheduler); @@ -98,12 +98,12 @@ public function interval_relative_time_disposed() /** * @test */ - public function interval_relative_time_observer_throws() + public function interval_relative_time_observer_throws(): void { $this->expectException(\Exception::class); $xs = new IntervalObservable(1, $this->scheduler); - $xs->subscribe(new CallbackObserver(function () { + $xs->subscribe(new CallbackObserver(function (): void { throw new \Exception(); })); diff --git a/test/Rx/Functional/Observable/IteratorObservableTest.php b/test/Rx/Functional/Observable/IteratorObservableTest.php index f247d58b..aca42475 100644 --- a/test/Rx/Functional/Observable/IteratorObservableTest.php +++ b/test/Rx/Functional/Observable/IteratorObservableTest.php @@ -14,7 +14,7 @@ class IteratorObservableTest extends FunctionalTestCase /** * @test */ - public function it_schedules_all_elements_from_the_generator() + public function it_schedules_all_elements_from_the_generator(): void { $generator = $this->genOneToThree(); @@ -35,7 +35,7 @@ public function it_schedules_all_elements_from_the_generator() /** * @test */ - public function generator_yields_null() + public function generator_yields_null(): void { $generator = $this->genNull(); @@ -54,7 +54,7 @@ public function generator_yields_null() /** * @test */ - public function generator_yields_one() + public function generator_yields_one(): void { $generator = $this->genOne(); @@ -71,7 +71,7 @@ public function generator_yields_one() /** * @test */ - public function generator_throws_error() + public function generator_throws_error(): void { $error = new \Exception(); $generator = $this->genError($error); @@ -88,7 +88,7 @@ public function generator_throws_error() /** * @test */ - public function generator_dispose() + public function generator_dispose(): void { $generator = $this->genOneToThree(); @@ -104,7 +104,7 @@ public function generator_dispose() /** * @test */ - public function it_schedules_all_elements_from_the_generator_with_return() + public function it_schedules_all_elements_from_the_generator_with_return(): void { $generator = $this->genOneToThreeAndReturn(); @@ -125,19 +125,19 @@ public function it_schedules_all_elements_from_the_generator_with_return() * @test * RxPHP Issue 188 */ - public function it_completes_if_subscribed_second_time_without_return_value() + public function it_completes_if_subscribed_second_time_without_return_value(): void { $generator = $this->genOneToThree(); $results1 = new MockObserver($this->scheduler); - $this->scheduler->scheduleAbsolute(200, function () use ($generator, $results1) { + $this->scheduler->scheduleAbsolute(200, function () use ($generator, $results1): void { Observable::fromIterator($generator, $this->scheduler)->subscribe($results1); }); $results2 = new MockObserver($this->scheduler); - $this->scheduler->scheduleAbsolute(400, function () use ($generator, $results2) { + $this->scheduler->scheduleAbsolute(400, function () use ($generator, $results2): void { Observable::fromIterator($generator, $this->scheduler)->subscribe($results2); }); @@ -159,19 +159,19 @@ public function it_completes_if_subscribed_second_time_without_return_value() * @test * RxPHP Issue 188 */ - public function it_returns_value_if_subscribed_second_time_with_return_value() + public function it_returns_value_if_subscribed_second_time_with_return_value(): void { $generator = $this->genOneToThreeAndReturn(); $results1 = new MockObserver($this->scheduler); - $this->scheduler->scheduleAbsolute(200, function () use ($generator, $results1) { + $this->scheduler->scheduleAbsolute(200, function () use ($generator, $results1): void { Observable::fromIterator($generator, $this->scheduler)->subscribe($results1); }); $results2 = new MockObserver($this->scheduler); - $this->scheduler->scheduleAbsolute(400, function () use ($generator, $results2) { + $this->scheduler->scheduleAbsolute(400, function () use ($generator, $results2): void { Observable::fromIterator($generator, $this->scheduler)->subscribe($results2); }); diff --git a/test/Rx/Functional/Observable/ReturnObservableTest.php b/test/Rx/Functional/Observable/ReturnObservableTest.php index 4c5fb445..f87d4cf5 100644 --- a/test/Rx/Functional/Observable/ReturnObservableTest.php +++ b/test/Rx/Functional/Observable/ReturnObservableTest.php @@ -11,21 +11,21 @@ class ReturnObservableTest extends FunctionalTestCase { - public function testReturnObservableSubscribeTwice() + public function testReturnObservableSubscribeTwice(): void { $o = new ReturnObservable('The Value', Scheduler::getImmediate()); $goodCount = 0; $o->subscribe(new CallbackObserver( - function ($x) use (&$goodCount) { + function ($x) use (&$goodCount): void { $this->assertEquals('The Value', $x); $goodCount++; } )); $o->subscribe(new CallbackObserver( - function ($x) use (&$goodCount) { + function ($x) use (&$goodCount): void { $this->assertEquals('The Value', $x); $goodCount++; } diff --git a/test/Rx/Functional/Observable/TimerObservableTest.php b/test/Rx/Functional/Observable/TimerObservableTest.php index 375c0a7f..f04130f6 100644 --- a/test/Rx/Functional/Observable/TimerObservableTest.php +++ b/test/Rx/Functional/Observable/TimerObservableTest.php @@ -14,7 +14,7 @@ class TimerObservableTest extends FunctionalTestCase /** * @test */ - public function timer_one_shot_relative_time_basic() + public function timer_one_shot_relative_time_basic(): void { $results = $this->scheduler->startWithCreate(function () { return new TimerObservable(300, $this->scheduler); @@ -32,7 +32,7 @@ public function timer_one_shot_relative_time_basic() /** * @test */ - public function timer_one_shot_relative_time_zero() + public function timer_one_shot_relative_time_zero(): void { $results = $this->scheduler->startWithCreate(function () { return new TimerObservable(0, $this->scheduler); @@ -50,7 +50,7 @@ public function timer_one_shot_relative_time_zero() /** * @test */ - public function timer_one_shot_relative_time_zero_non_int() + public function timer_one_shot_relative_time_zero_non_int(): void { $this->expectException(\TypeError::class); $this->scheduler->startWithCreate(function () { @@ -61,7 +61,7 @@ public function timer_one_shot_relative_time_zero_non_int() /** * @test */ - public function timer_one_shot_relative_time_negative() + public function timer_one_shot_relative_time_negative(): void { $results = $this->scheduler->startWithCreate(function () { return new TimerObservable(-1, $this->scheduler); @@ -79,7 +79,7 @@ public function timer_one_shot_relative_time_negative() /** * @test */ - public function timer_one_shot_relative_time_disposed() + public function timer_one_shot_relative_time_disposed(): void { $results = $this->scheduler->startWithCreate(function () { return new TimerObservable(1000, $this->scheduler); @@ -91,7 +91,7 @@ public function timer_one_shot_relative_time_disposed() /** * @test */ - public function timer_one_shot_relative_time_dispose_before_dueTime() + public function timer_one_shot_relative_time_dispose_before_dueTime(): void { $results = $this->scheduler->startWithDispose(function () { return new TimerObservable(500, $this->scheduler); @@ -103,28 +103,28 @@ public function timer_one_shot_relative_time_dispose_before_dueTime() /** * @test */ - public function timer_one_shot_relative_time_throws() + public function timer_one_shot_relative_time_throws(): void { $scheduler1 = new TestScheduler(); $xs = Observable::timer(1, $scheduler1); - $xs->subscribe(function () { + $xs->subscribe(function (): void { throw new \Exception(); }); - $this->assertException(function () use ($scheduler1) { + $this->assertException(function () use ($scheduler1): void { $scheduler1->start(); }); $scheduler2 = new TestScheduler(); $ys = Observable::timer(1, $scheduler2); - $ys->subscribe(null, null, function () { + $ys->subscribe(null, null, function (): void { throw new \Exception(); }); - $this->assertException(function () use ($scheduler2) { + $this->assertException(function () use ($scheduler2): void { $scheduler2->start(); }); } diff --git a/test/Rx/Functional/ObservableTest.php b/test/Rx/Functional/ObservableTest.php index 605a5dc3..0dad6005 100644 --- a/test/Rx/Functional/ObservableTest.php +++ b/test/Rx/Functional/ObservableTest.php @@ -7,7 +7,7 @@ class ObservableTest extends FunctionalTestCase { - public function testExceptionInOnNextByDefaultGoesToErrorAndDisposes() + public function testExceptionInOnNextByDefaultGoesToErrorAndDisposes(): void { $xs = $this->createHotObservable( [ @@ -22,9 +22,9 @@ public function testExceptionInOnNextByDefaultGoesToErrorAndDisposes() $disposable = null; - $this->scheduler->scheduleAbsolute(200, function () use ($xs, $results, &$disposable) { + $this->scheduler->scheduleAbsolute(200, function () use ($xs, $results, &$disposable): void { $disposable = $xs->subscribe( - function ($value) use ($results) { + function ($value) use ($results): void { if ($value === 3) { throw new TestException(); } @@ -35,7 +35,7 @@ function ($value) use ($results) { ); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$disposable) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$disposable): void { $disposable->dispose(); }); diff --git a/test/Rx/Functional/Operator/AsObservableTest.php b/test/Rx/Functional/Operator/AsObservableTest.php index 7e345034..1db1835d 100644 --- a/test/Rx/Functional/Operator/AsObservableTest.php +++ b/test/Rx/Functional/Operator/AsObservableTest.php @@ -21,7 +21,7 @@ public function testAsObservableHides() return ($someObservable->asObservable() !== $someObservable); } - public function testAsObservableNever() + public function testAsObservableNever(): void { $results = $this->scheduler->startWithCreate(function () { @@ -34,7 +34,7 @@ public function testAsObservableNever() ); } - public function testAsObservableEmpty() + public function testAsObservableEmpty(): void { $xs = $this->createHotObservable( @@ -56,7 +56,7 @@ public function testAsObservableEmpty() ); } - public function testAsObservableThrow() + public function testAsObservableThrow(): void { $error = new Exception(); @@ -79,7 +79,7 @@ public function testAsObservableThrow() ); } - public function testAsObservableJust() + public function testAsObservableJust(): void { $xs = $this->createHotObservable( @@ -103,7 +103,7 @@ public function testAsObservableJust() ); } - public function testAsObservableIsNotEager() + public function testAsObservableIsNotEager(): void { $subscribed = false; diff --git a/test/Rx/Functional/Operator/AverageTest.php b/test/Rx/Functional/Operator/AverageTest.php index 2ba8729f..61dc19c1 100644 --- a/test/Rx/Functional/Operator/AverageTest.php +++ b/test/Rx/Functional/Operator/AverageTest.php @@ -13,7 +13,7 @@ class AverageTest extends FunctionalTestCase * * @test */ - public function average_Number_Empty() + public function average_Number_Empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -34,7 +34,7 @@ public function average_Number_Empty() * * @test */ - public function average_Number_Return() + public function average_Number_Return(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -57,7 +57,7 @@ public function average_Number_Return() * * @test */ - public function average_Number_Some() + public function average_Number_Some(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -81,7 +81,7 @@ public function average_Number_Some() * * @test */ - public function average_Number_Throw() + public function average_Number_Throw(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -102,7 +102,7 @@ public function average_Number_Throw() * * @test */ - public function average_Number_Never() + public function average_Number_Never(): void { $xs = $this->createHotObservable([ onNext(150, 1) diff --git a/test/Rx/Functional/Operator/BufferWithCountTest.php b/test/Rx/Functional/Operator/BufferWithCountTest.php index a1203e1f..8d47a95b 100644 --- a/test/Rx/Functional/Operator/BufferWithCountTest.php +++ b/test/Rx/Functional/Operator/BufferWithCountTest.php @@ -11,7 +11,7 @@ class BufferWithCountTest extends FunctionalTestCase /** * @test */ - public function bufferWithCountpartialwindow() + public function bufferWithCountpartialwindow(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -35,7 +35,7 @@ public function bufferWithCountpartialwindow() /** * @test */ - public function bufferWithCountfullwindows() + public function bufferWithCountfullwindows(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -60,7 +60,7 @@ public function bufferWithCountfullwindows() /** * @test */ - public function bufferWithCountfullandpartialwindows() + public function bufferWithCountfullandpartialwindows(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -85,7 +85,7 @@ public function bufferWithCountfullandpartialwindows() /** * @test */ - public function bufferWithCountError() + public function bufferWithCountError(): void { $error = new \Exception(); @@ -110,7 +110,7 @@ public function bufferWithCountError() /** * @test */ - public function bufferWithCountskipless() + public function bufferWithCountskipless(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -137,7 +137,7 @@ public function bufferWithCountskipless() /** * @test */ - public function bufferWithCountskipmore() + public function bufferWithCountskipmore(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -162,7 +162,7 @@ public function bufferWithCountskipmore() /** * @test */ - public function bufferWithCountbasic() + public function bufferWithCountbasic(): void { $xs = $this->createHotObservable([ onNext(100, 1), @@ -197,7 +197,7 @@ public function bufferWithCountbasic() /** * @test */ - public function bufferWithCountdisposed() + public function bufferWithCountdisposed(): void { $xs = $this->createHotObservable([ onNext(100, 1), @@ -229,7 +229,7 @@ public function bufferWithCountdisposed() /** * @test */ - public function bufferWithCount_invalid_skip() + public function bufferWithCount_invalid_skip(): void { $this->expectException(\InvalidArgumentException::class); $xs = $this->createHotObservable([ @@ -247,7 +247,7 @@ public function bufferWithCount_invalid_skip() * @test * */ - public function bufferWithCount_invalid_count() + public function bufferWithCount_invalid_count(): void { $this->expectException(\InvalidArgumentException::class); $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/CatchErrorTest.php b/test/Rx/Functional/Operator/CatchErrorTest.php index 04888e6e..d57ce84d 100644 --- a/test/Rx/Functional/Operator/CatchErrorTest.php +++ b/test/Rx/Functional/Operator/CatchErrorTest.php @@ -14,7 +14,7 @@ class CatchErrorTest extends FunctionalTestCase /** * @test */ - public function catchError_NoErrors() + public function catchError_NoErrors(): void { $o1 = $this->createHotObservable( [ @@ -51,7 +51,7 @@ public function catchError_NoErrors() /** * @test */ - public function catchError_Never() + public function catchError_Never(): void { $o1 = Observable::never(); @@ -77,7 +77,7 @@ public function catchError_Never() /** * @test */ - public function catchError_Empty() + public function catchError_Empty(): void { $o1 = $this->createHotObservable( [ @@ -110,7 +110,7 @@ public function catchError_Empty() /** * @test */ - public function catchError_Return() + public function catchError_Return(): void { $o1 = $this->createHotObservable( [ @@ -145,7 +145,7 @@ public function catchError_Return() /** * @test */ - public function catchError_Error() + public function catchError_Error(): void { $error = new \Exception(); @@ -185,7 +185,7 @@ public function catchError_Error() /** * @test */ - public function catchError_Error_Never() + public function catchError_Error_Never(): void { $error = new \Exception(); @@ -219,7 +219,7 @@ public function catchError_Error_Never() /** * @test */ - public function catchError_Error_Never_Dispose() + public function catchError_Error_Never_Dispose(): void { $error = new \Exception(); @@ -251,7 +251,7 @@ public function catchError_Error_Never_Dispose() /** * @test */ - public function catchError_Error_Error() + public function catchError_Error_Error(): void { $error = new \Exception(); @@ -291,7 +291,7 @@ public function catchError_Error_Error() /** * @test */ - public function catchError_Error_Error_Dispose() + public function catchError_Error_Error_Dispose(): void { $error = new \Exception(); @@ -330,7 +330,7 @@ public function catchError_Error_Error_Dispose() /** * @test */ - public function catchError_HandlerThrows() + public function catchError_HandlerThrows(): void { $error = new \Exception(); @@ -346,7 +346,7 @@ public function catchError_HandlerThrows() ); $results = $this->scheduler->startWithCreate(function () use ($o1, $error2) { - return $o1->catch(function () use ($error2) { + return $o1->catch(function () use ($error2): void { throw $error2; }); @@ -365,7 +365,7 @@ public function catchError_HandlerThrows() /** * @test */ - public function catchError_handler_returns_invalid_string() + public function catchError_handler_returns_invalid_string(): void { $o1 = $this->createHotObservable( [ @@ -395,7 +395,7 @@ public function catchError_handler_returns_invalid_string() /** * @test */ - public function catchError_Nested_OuterCatches() + public function catchError_Nested_OuterCatches(): void { $error = new \Exception(); $firstHandlerCalled = false; @@ -451,7 +451,7 @@ public function catchError_Nested_OuterCatches() /** * @test */ - public function catchError_ThrowFromNestedCatch() + public function catchError_ThrowFromNestedCatch(): void { $error = new \Exception(); $error2 = new \InvalidArgumentException(); @@ -515,7 +515,7 @@ public function catchError_ThrowFromNestedCatch() * does not lose subscription to underlying observable * @test */ - public function catchError_does_not_lose_subscription() + public function catchError_does_not_lose_subscription(): void { $subscribes = 0; $unsubscribes = 0; @@ -523,7 +523,7 @@ public function catchError_does_not_lose_subscription() $tracer = Observable::create(function () use (&$subscribes, &$unsubscribes) { ++$subscribes; - return new CallbackDisposable(function () use (&$unsubscribes) { + return new CallbackDisposable(function () use (&$unsubscribes): void { ++$unsubscribes; }); }); diff --git a/test/Rx/Functional/Operator/CombineLatestTest.php b/test/Rx/Functional/Operator/CombineLatestTest.php index 783c699e..bd52f91e 100644 --- a/test/Rx/Functional/Operator/CombineLatestTest.php +++ b/test/Rx/Functional/Operator/CombineLatestTest.php @@ -19,7 +19,7 @@ public function add($a, $b) /** * @test */ - public function combineLatest_never_never() + public function combineLatest_never_never(): void { $e1 = new NeverObservable(); @@ -36,7 +36,7 @@ public function combineLatest_never_never() /** * @test */ - public function combineLatest_never_empty() + public function combineLatest_never_empty(): void { $e1 = new NeverObservable(); @@ -58,7 +58,7 @@ public function combineLatest_never_empty() /** * @test */ - public function combineLatest_empty_never() + public function combineLatest_empty_never(): void { $e1 = new NeverObservable(); $e2 = $this->createHotObservable( @@ -80,7 +80,7 @@ public function combineLatest_empty_never() /** * @test */ - public function combineLatest_empty_empty() + public function combineLatest_empty_empty(): void { $e1 = $this->createHotObservable( [ @@ -108,7 +108,7 @@ public function combineLatest_empty_empty() /** * @test */ - public function combineLatest_empty_return() + public function combineLatest_empty_return(): void { $e1 = $this->createHotObservable( [ @@ -135,7 +135,7 @@ public function combineLatest_empty_return() /** * @test */ - public function combineLatest_never_return() + public function combineLatest_never_return(): void { $e1 = $this->createHotObservable( [ @@ -157,7 +157,7 @@ public function combineLatest_never_return() /** * @test */ - public function combineLatest_return_return() + public function combineLatest_return_return(): void { $e1 = $this->createHotObservable( [ @@ -192,7 +192,7 @@ public function combineLatest_return_return() /** * @test */ - public function combineLatest_return_return_return() + public function combineLatest_return_return_return(): void { $e1 = $this->createHotObservable( [ @@ -234,7 +234,7 @@ public function combineLatest_return_return_return() /** * @test */ - public function combineLatest_return_return_no_selector() + public function combineLatest_return_return_no_selector(): void { $e1 = $this->createHotObservable( [ @@ -269,7 +269,7 @@ public function combineLatest_return_return_no_selector() /** * @test */ - public function combineLatest_empty_error() + public function combineLatest_empty_error(): void { $error = new \Exception(); @@ -302,7 +302,7 @@ public function combineLatest_empty_error() /** * @test */ - public function combineLatest_error_empty() + public function combineLatest_error_empty(): void { $error = new \Exception(); @@ -335,7 +335,7 @@ public function combineLatest_error_empty() /** * @test */ - public function combineLatest_return_throw() + public function combineLatest_return_throw(): void { $error = new \Exception(); @@ -370,7 +370,7 @@ public function combineLatest_return_throw() /** * @test */ - public function combineLatest_throw_return() + public function combineLatest_throw_return(): void { $error = new \Exception(); @@ -405,7 +405,7 @@ public function combineLatest_throw_return() /** * @test */ - public function combineLatest_throw_throw() + public function combineLatest_throw_throw(): void { $error1 = new \Exception('first'); $error2 = new \Exception('second'); @@ -439,7 +439,7 @@ public function combineLatest_throw_throw() /** * @test */ - public function combineLatest_error_throw() + public function combineLatest_error_throw(): void { $error1 = new \Exception(); $error2 = new \Exception(); @@ -474,7 +474,7 @@ public function combineLatest_error_throw() /** * @test */ - public function combineLatest_throw_error() + public function combineLatest_throw_error(): void { $error1 = new \Exception(); $error2 = new \Exception(); @@ -510,7 +510,7 @@ public function combineLatest_throw_error() /** * @test */ - public function combineLatest_never_throw() + public function combineLatest_never_throw(): void { $error = new \Exception(); @@ -538,7 +538,7 @@ public function combineLatest_never_throw() /** * @test */ - public function combineLatest_throw_never() + public function combineLatest_throw_never(): void { $error = new \Exception(); @@ -566,7 +566,7 @@ public function combineLatest_throw_never() /** * @test */ - public function combineLatest_some_throw() + public function combineLatest_some_throw(): void { $error = new \Exception(); @@ -600,7 +600,7 @@ public function combineLatest_some_throw() /** * @test */ - public function combineLatest_throw_some() + public function combineLatest_throw_some(): void { $error = new \Exception(); @@ -634,7 +634,7 @@ public function combineLatest_throw_some() /** * @test */ - public function combineLatest_throw_after_complete_left() + public function combineLatest_throw_after_complete_left(): void { $error = new \Exception(); @@ -668,7 +668,7 @@ public function combineLatest_throw_after_complete_left() /** * @test */ - public function combineLatest_throw_after_complete_right() + public function combineLatest_throw_after_complete_right(): void { $error = new \Exception(); @@ -702,7 +702,7 @@ public function combineLatest_throw_after_complete_right() /** * @test */ - public function combineLatest_interleaved_with_tail() + public function combineLatest_interleaved_with_tail(): void { $e1 = $this->createHotObservable( @@ -746,7 +746,7 @@ public function combineLatest_interleaved_with_tail() /** * @test */ - public function combineLatest_consecutive() + public function combineLatest_consecutive(): void { $e1 = $this->createHotObservable( [ @@ -783,7 +783,7 @@ public function combineLatest_consecutive() /** * @test */ - public function combineLatest_consecutive_end_with_error_left() + public function combineLatest_consecutive_end_with_error_left(): void { $error = new \Exception(); @@ -820,7 +820,7 @@ public function combineLatest_consecutive_end_with_error_left() /** * @test */ - public function combineLatest_consecutive_end_with_error_right() + public function combineLatest_consecutive_end_with_error_right(): void { $error = new \Exception(); @@ -859,7 +859,7 @@ public function combineLatest_consecutive_end_with_error_right() /** * @test */ - public function combineLatest_selector_throws() + public function combineLatest_selector_throws(): void { $error = new \Exception(); @@ -880,7 +880,7 @@ public function combineLatest_selector_throws() ); $results = $this->scheduler->startWithCreate(function () use ($e1, $e2) { - return $e1->combineLatest([$e2], function () { + return $e1->combineLatest([$e2], function (): void { throw new \Exception(); }); }); @@ -896,7 +896,7 @@ public function combineLatest_selector_throws() /** * @test */ - public function combineLatest_delay() + public function combineLatest_delay(): void { $source1 = Observable::timer(100, $this->scheduler); $source2 = Observable::timer(120, $this->scheduler); @@ -917,7 +917,7 @@ public function combineLatest_delay() /** * @test */ - public function combineLatest_args_order() + public function combineLatest_args_order(): void { $e1 = $this->createHotObservable( diff --git a/test/Rx/Functional/Operator/ComposeTest.php b/test/Rx/Functional/Operator/ComposeTest.php index 48946da9..3910927f 100644 --- a/test/Rx/Functional/Operator/ComposeTest.php +++ b/test/Rx/Functional/Operator/ComposeTest.php @@ -6,7 +6,7 @@ class ComposeTest extends FunctionalTestCase { - public function testSimpleCompose() + public function testSimpleCompose(): void { $xs = $this->createHotObservable( [ diff --git a/test/Rx/Functional/Operator/ConcatAllTest.php b/test/Rx/Functional/Operator/ConcatAllTest.php index accf481c..956a99a9 100644 --- a/test/Rx/Functional/Operator/ConcatAllTest.php +++ b/test/Rx/Functional/Operator/ConcatAllTest.php @@ -12,7 +12,7 @@ class ConcatAllTest extends FunctionalTestCase /** * @test */ - public function concatAll_timer_missing_item() + public function concatAll_timer_missing_item(): void { $xs = $this->createHotObservable([ onNext(201, 0), @@ -38,9 +38,9 @@ public function concatAll_timer_missing_item() /** * @test */ - public function concatAll_errors_when_exception_during_inner_subscribe() + public function concatAll_errors_when_exception_during_inner_subscribe(): void { - $o1 = Observable::create(function () { + $o1 = Observable::create(function (): void { throw new \Exception("Exception in inner subscribe"); }); diff --git a/test/Rx/Functional/Operator/ConcatMapTest.php b/test/Rx/Functional/Operator/ConcatMapTest.php index e0256c47..edd08dcd 100644 --- a/test/Rx/Functional/Operator/ConcatMapTest.php +++ b/test/Rx/Functional/Operator/ConcatMapTest.php @@ -13,7 +13,7 @@ class ConcatMapTest extends FunctionalTestCase /** * @test */ - public function concatMapTo_Then_Complete_Task() + public function concatMapTo_Then_Complete_Task(): void { $xs = Observable::fromArray([4, 3, 2, 1]); $ys = Observable::of(42); @@ -23,13 +23,13 @@ public function concatMapTo_Then_Complete_Task() $xs->concatMapTo($ys) ->subscribe( - function ($x) use (&$results) { + function ($x) use (&$results): void { $results[] = $x; }, - function ($e) { + function ($e): void { $this->fail(); }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); @@ -41,7 +41,7 @@ function () use (&$completed) { /** * @test */ - public function concatMapTo_Then_Error_Task() + public function concatMapTo_Then_Error_Task(): void { $xs = Observable::fromArray([4, 3, 2, 1]); $ys = Observable::error(new \Exception('test')); @@ -52,14 +52,14 @@ public function concatMapTo_Then_Error_Task() $xs->concatMapTo($ys) ->subscribe( - function ($x) use (&$results) { + function ($x) use (&$results): void { $results[] = $x; }, - function (\Exception $e) use (&$results, &$error) { + function (\Exception $e) use (&$results, &$error): void { $error = true; $this->assertSame('test', $e->getMessage()); }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); @@ -71,7 +71,7 @@ function () use (&$completed) { /** * @test */ - public function concatMap_result_Complete_Task() + public function concatMap_result_Complete_Task(): void { $xs = Observable::fromArray([4, 3, 2, 1]); @@ -87,13 +87,13 @@ function ($x, $y, $oi, $ii) { return $x + $y + $oi; }) ->subscribe( - function ($x) use (&$results) { + function ($x) use (&$results): void { $results[] = $x; }, - function ($e) { + function ($e): void { $this->fail(); }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); @@ -105,7 +105,7 @@ function () use (&$completed) { /** * @test */ - public function concatMap_result_Error_Task() + public function concatMap_result_Error_Task(): void { $xs = Observable::fromArray([4, 3, 2, 1]); @@ -118,17 +118,17 @@ public function concatMap_result_Error_Task() function ($x, $i) { return Observable::of($x + $i); }, - function ($x, $y, $i) use ($error) { + function ($x, $y, $i) use ($error): void { throw $error; }) ->subscribe( - function ($x) use (&$results) { + function ($x) use (&$results): void { $results[] = $x; }, - function ($e) use (&$returnError) { + function ($e) use (&$returnError): void { $returnError = $e; }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); @@ -141,7 +141,7 @@ function () use (&$completed) { /** * @test */ - public function concatMap_Then_Complete_Task() + public function concatMap_Then_Complete_Task(): void { $xs = Observable::fromArray([4, 3, 2, 1]); @@ -152,13 +152,13 @@ public function concatMap_Then_Complete_Task() return Observable::of($x + $i); }) ->subscribe( - function ($x) use (&$results) { + function ($x) use (&$results): void { $results[] = $x; }, - function ($e) { + function ($e): void { $this->fail('Should not get an error'); }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); @@ -170,7 +170,7 @@ function () use (&$completed) { /** * @test */ - public function concatMap_Then_Error_Task() + public function concatMap_Then_Error_Task(): void { $xs = Observable::fromArray([4, 3, 2, 1]); @@ -182,14 +182,14 @@ public function concatMap_Then_Error_Task() return Observable::error(new Exception((string)($x + $i))); }) ->subscribe( - function ($x) use (&$results) { + function ($x) use (&$results): void { $results[] = $x; }, - function (\Exception $e) use (&$results, &$error) { + function (\Exception $e) use (&$results, &$error): void { $error = true; $this->assertEquals(4, $e->getMessage()); }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); @@ -201,7 +201,7 @@ function () use (&$completed) { /** * @test */ - public function concatMapTo_Then_Complete_Complete() + public function concatMapTo_Then_Complete_Complete(): void { $xs = $this->createColdObservable( @@ -266,7 +266,7 @@ public function concatMapTo_Then_Complete_Complete() /** * @test */ - public function concatMapTo_Then_Complete_Complete_2() + public function concatMapTo_Then_Complete_Complete_2(): void { $xs = $this->createColdObservable( @@ -331,7 +331,7 @@ public function concatMapTo_Then_Complete_Complete_2() /** * @test */ - public function concatMapTo_Then_Never_Complete() + public function concatMapTo_Then_Never_Complete(): void { $xs = $this->createColdObservable( @@ -406,7 +406,7 @@ public function concatMapTo_Then_Never_Complete() /** * @test */ - public function concatMapTo_Then_Complete_Never() + public function concatMapTo_Then_Complete_Never(): void { $xs = $this->createColdObservable( @@ -454,7 +454,7 @@ public function concatMapTo_Then_Complete_Never() /** * @test */ - public function concatMapTo_Then_Complete_Error() + public function concatMapTo_Then_Complete_Error(): void { $ex = new Exception(); @@ -506,7 +506,7 @@ public function concatMapTo_Then_Complete_Error() /** * @test */ - public function concatMapTo_Then_Error_Complete() + public function concatMapTo_Then_Error_Complete(): void { $ex = new Exception(); @@ -561,7 +561,7 @@ public function concatMapTo_Then_Error_Complete() /** * @test */ - public function concatMapTo_Then_Error_Error() + public function concatMapTo_Then_Error_Error(): void { $ex = new Exception(); @@ -613,7 +613,7 @@ public function concatMapTo_Then_Error_Error() /** * @test */ - public function concatMap_Complete() + public function concatMap_Complete(): void { $xs = $this->createHotObservable([ @@ -683,7 +683,7 @@ public function concatMap_Complete() /** * @test */ - public function concatMap_Complete_OuterNotComplete() + public function concatMap_Complete_OuterNotComplete(): void { @@ -753,7 +753,7 @@ public function concatMap_Complete_OuterNotComplete() /** * @test */ - public function concatMap_Error_Outer() + public function concatMap_Error_Outer(): void { $ex = new Exception(); @@ -822,7 +822,7 @@ public function concatMap_Error_Outer() /** * @test */ - public function concatMap_Error_Inner() + public function concatMap_Error_Inner(): void { $ex = new Exception(); @@ -891,7 +891,7 @@ public function concatMap_Error_Inner() /** * @test */ - public function concatMap_Dispose() + public function concatMap_Dispose(): void { $xs = $this->createHotObservable([ @@ -957,7 +957,7 @@ public function concatMap_Dispose() /** * @test */ - public function concatMap_Throw() + public function concatMap_Throw(): void { $invoked = 0; $ex = new Exception('ex'); @@ -1030,7 +1030,7 @@ public function concatMap_Throw() /** * @test */ - public function concatMap_UseFunction() + public function concatMap_UseFunction(): void { $xs = $this->createHotObservable([ onNext(210, 4), @@ -1077,7 +1077,7 @@ public function concatMap_UseFunction() /** * @test */ - public function concatMap_return_invalid_string() + public function concatMap_return_invalid_string(): void { $xs = $this->createHotObservable([ onNext(5, $this->createColdObservable([ diff --git a/test/Rx/Functional/Operator/ConcatTest.php b/test/Rx/Functional/Operator/ConcatTest.php index 86b2d33e..cc3cdfa9 100644 --- a/test/Rx/Functional/Operator/ConcatTest.php +++ b/test/Rx/Functional/Operator/ConcatTest.php @@ -10,7 +10,7 @@ class ConcatTest extends FunctionalTestCase { - public function testConcatEmptyEmpty() + public function testConcatEmptyEmpty(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -26,7 +26,7 @@ public function testConcatEmptyEmpty() $this->assertMessages([onCompleted(250)], $results->getMessages()); } - public function testConcatEmptyNever() + public function testConcatEmptyNever(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -39,7 +39,7 @@ public function testConcatEmptyNever() $this->assertMessages([], $results->getMessages()); } - public function testConcatNeverEmpty() + public function testConcatNeverEmpty(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -52,7 +52,7 @@ public function testConcatNeverEmpty() $this->assertMessages([], $results->getMessages()); } - public function testConcatNeverNever() + public function testConcatNeverNever(): void { $e1 = Observable::never(); $e2 = Observable::never(); @@ -62,7 +62,7 @@ public function testConcatNeverNever() $this->assertMessages([], $results->getMessages()); } - public function testConcatEmptyThrow() + public function testConcatEmptyThrow(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -78,7 +78,7 @@ public function testConcatEmptyThrow() $this->assertMessages([onError(250, new \Exception('error'))], $results->getMessages()); } - public function testConcatThrowEmpty() + public function testConcatThrowEmpty(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -94,7 +94,7 @@ public function testConcatThrowEmpty() $this->assertMessages([onError(230, new \Exception('error'))], $results->getMessages()); } - public function testConcatThrowThrow() + public function testConcatThrowThrow(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -110,7 +110,7 @@ public function testConcatThrowThrow() $this->assertMessages([onError(230, new \ErrorException())], $results->getMessages()); } - public function testConcatReturnEmpty() + public function testConcatReturnEmpty(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -127,7 +127,7 @@ public function testConcatReturnEmpty() $this->assertMessages([onNext(210, 2), onCompleted(250)], $results->getMessages()); } - public function testConcatEmptyReturn() + public function testConcatEmptyReturn(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -144,7 +144,7 @@ public function testConcatEmptyReturn() $this->assertMessages([onNext(240, 2), onCompleted(250)], $results->getMessages()); } - public function testConcatReturnNever() + public function testConcatReturnNever(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -158,7 +158,7 @@ public function testConcatReturnNever() $this->assertMessages([onNext(210, 2)], $results->getMessages()); } - public function testConcatNeverReturn() + public function testConcatNeverReturn(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -172,7 +172,7 @@ public function testConcatNeverReturn() $this->assertMessages([], $results->getMessages()); } - public function testConcatReturnReturn() + public function testConcatReturnReturn(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -190,7 +190,7 @@ public function testConcatReturnReturn() $this->assertMessages([onNext(220, 2), onNext(240, 3), onCompleted(250)], $results->getMessages()); } - public function testConcatThrowReturn() + public function testConcatThrowReturn(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -207,7 +207,7 @@ public function testConcatThrowReturn() $this->assertMessages([onError(220, new \Exception())], $results->getMessages()); } - public function testConcatReturnThrow() + public function testConcatReturnThrow(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -224,7 +224,7 @@ public function testConcatReturnThrow() $this->assertMessages([onNext(220, 2), onError(250, new \Exception())], $results->getMessages()); } - public function testConcatSomeDataOnBothSides() + public function testConcatSomeDataOnBothSides(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -251,7 +251,7 @@ public function testConcatSomeDataOnBothSides() $results->getMessages()); } - public function testConcatAsArguments() + public function testConcatAsArguments(): void { $xs1 = $this->createColdObservable([ onNext(10, 1), @@ -299,7 +299,7 @@ public function testConcatAsArguments() } - public function testConcatAll() + public function testConcatAll(): void { $sources = Observable::fromArray([ @@ -313,13 +313,13 @@ public function testConcatAll() $completed = false; $sources->concatAll()->subscribe( - function ($x) use (&$res) { + function ($x) use (&$res): void { $res[] = $x; }, - function ($e) { + function ($e): void { $this->fail(); }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); @@ -329,7 +329,7 @@ function () use (&$completed) { } - public function testConcatAllError() + public function testConcatAllError(): void { $sources = Observable::fromArray([ @@ -344,14 +344,14 @@ public function testConcatAllError() $completed = false; $sources->concatAll()->subscribe( - function ($x) use (&$res) { + function ($x) use (&$res): void { $res[] = $x; }, - function ($e) use (&$res, &$error) { + function ($e) use (&$res, &$error): void { $this->assertEquals([0], $res); $error = true; }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); @@ -361,7 +361,7 @@ function () use (&$completed) { } - public function testConcatDispose() + public function testConcatDispose(): void { $o1 = $this->createHotObservable([ onNext(250, 1), diff --git a/test/Rx/Functional/Operator/CountTest.php b/test/Rx/Functional/Operator/CountTest.php index 30a3fee2..f157c9f9 100644 --- a/test/Rx/Functional/Operator/CountTest.php +++ b/test/Rx/Functional/Operator/CountTest.php @@ -9,7 +9,7 @@ class CountTest extends FunctionalTestCase { - public function testCountEmpty() + public function testCountEmpty(): void { $xs = $this->createHotObservable( @@ -32,7 +32,7 @@ public function testCountEmpty() ); } - public function testCountSome() + public function testCountSome(): void { $xs = $this->createHotObservable( [ @@ -57,7 +57,7 @@ public function testCountSome() ); } - public function testCountThrow() + public function testCountThrow(): void { $xs = $this->createHotObservable( @@ -74,7 +74,7 @@ public function testCountThrow() $this->assertMessages([onError(210, new \Exception())], $results->getMessages()); } - public function testCountNever() + public function testCountNever(): void { $xs = $this->createHotObservable( @@ -89,7 +89,7 @@ public function testCountNever() $this->assertMessages([], $results->getMessages()); } - public function testCountPredicateEmptyTrue() + public function testCountPredicateEmptyTrue(): void { $xs = $this->createHotObservable( @@ -114,7 +114,7 @@ public function testCountPredicateEmptyTrue() $this->assertSubscriptions([subscribe(200, 250)], $xs->getSubscriptions()); } - public function testCountPredicateEmptyFalse() + public function testCountPredicateEmptyFalse(): void { $xs = $this->createHotObservable( @@ -140,7 +140,7 @@ public function testCountPredicateEmptyFalse() $this->assertSubscriptions([subscribe(200, 250)], $xs->getSubscriptions()); } - public function testCountPredicateReturnTrue() + public function testCountPredicateReturnTrue(): void { $xs = $this->createHotObservable([onNext(150, 1), onNext(210, 2), onCompleted(250)]); @@ -153,7 +153,7 @@ public function testCountPredicateReturnTrue() $this->assertSubscriptions([subscribe(200, 250)], $xs->getSubscriptions()); } - public function testCountPredicateReturnFalse() + public function testCountPredicateReturnFalse(): void { $xs = $this->createHotObservable( @@ -179,7 +179,7 @@ public function testCountPredicateReturnFalse() $this->assertSubscriptions([subscribe(200, 250)], $xs->getSubscriptions()); } - public function testCountPredicateAllMatched() + public function testCountPredicateAllMatched(): void { $xs = $this->createHotObservable( @@ -207,7 +207,7 @@ public function testCountPredicateAllMatched() $this->assertSubscriptions([subscribe(200, 250)], $xs->getSubscriptions()); } - public function testCountPredicateNoneMatched() + public function testCountPredicateNoneMatched(): void { $xs = $this->createHotObservable( @@ -235,7 +235,7 @@ public function testCountPredicateNoneMatched() $this->assertSubscriptions([subscribe(200, 250)], $xs->getSubscriptions()); } - public function testCountPredicateSomeEven() + public function testCountPredicateSomeEven(): void { $xs = $this->createHotObservable( @@ -261,7 +261,7 @@ public function testCountPredicateSomeEven() $this->assertSubscriptions([subscribe(200, 250)], $xs->getSubscriptions()); } - public function testCountPredicateThrowTrue() + public function testCountPredicateThrowTrue(): void { $xs = $this->createHotObservable( @@ -281,7 +281,7 @@ public function testCountPredicateThrowTrue() $this->assertSubscriptions([subscribe(200, 210)], $xs->getSubscriptions()); } - public function testCountPredicateThrowFalse() + public function testCountPredicateThrowFalse(): void { $xs = $this->createHotObservable( @@ -301,7 +301,7 @@ public function testCountPredicateThrowFalse() $this->assertSubscriptions([subscribe(200, 210)], $xs->getSubscriptions()); } - public function testCountPredicateNever() + public function testCountPredicateNever(): void { $xs = $this->createHotObservable( @@ -321,7 +321,7 @@ public function testCountPredicateNever() $this->assertSubscriptions([subscribe(200, 1000)], $xs->getSubscriptions()); } - public function testCountPredicateThrowsError() + public function testCountPredicateThrowsError(): void { $xs = $this->createHotObservable( @@ -346,7 +346,7 @@ public function testCountPredicateThrowsError() $this->assertSubscriptions([subscribe(200, 230)], $xs->getSubscriptions()); } - public function testCountAfterRange() + public function testCountAfterRange(): void { $xs = Observable::fromArray(range(1, 10), $this->scheduler); diff --git a/test/Rx/Functional/Operator/CreateTest.php b/test/Rx/Functional/Operator/CreateTest.php index 524cc259..6ead01d9 100644 --- a/test/Rx/Functional/Operator/CreateTest.php +++ b/test/Rx/Functional/Operator/CreateTest.php @@ -15,7 +15,7 @@ class CreateTest extends FunctionalTestCase /** * @test */ - public function create_next() + public function create_next(): void { $results = $this->scheduler->startWithCreate(function () { @@ -35,11 +35,11 @@ public function create_next() /** * @test */ - public function create_null_disposable() + public function create_null_disposable(): void { $results = $this->scheduler->startWithCreate(function () { - return Observable::create(function (ObserverInterface $o) { + return Observable::create(function (ObserverInterface $o): void { $o->onNext(1); $o->onNext(2); }); @@ -54,7 +54,7 @@ public function create_null_disposable() /** * @test */ - public function create_completed() + public function create_completed(): void { $results = $this->scheduler->startWithCreate(function () { @@ -75,7 +75,7 @@ public function create_completed() /** * @test */ - public function create_error() + public function create_error(): void { $error = new \Exception(); @@ -98,10 +98,10 @@ public function create_error() /** * @test */ - public function create_throws_errors() + public function create_throws_errors(): void { $this->expectException(\Exception::class); - Observable::create(function ($o) { + Observable::create(function ($o): void { throw new \Exception; })->subscribe(new CallbackObserver()); } @@ -109,7 +109,7 @@ public function create_throws_errors() /** * @test */ - public function create_dispose() + public function create_dispose(): void { $results = $this->scheduler->startWithCreate(function () { @@ -120,31 +120,31 @@ public function create_dispose() $o->onNext(1); $o->onNext(2); - $this->scheduler->scheduleAbsolute(600, function () use ($o, &$isStopped) { + $this->scheduler->scheduleAbsolute(600, function () use ($o, &$isStopped): void { if (!$isStopped) { $o->onNext(3); } }); - $this->scheduler->scheduleAbsolute(700, function () use ($o, &$isStopped) { + $this->scheduler->scheduleAbsolute(700, function () use ($o, &$isStopped): void { if (!$isStopped) { $o->onNext(4); } }); - $this->scheduler->scheduleAbsolute(900, function () use ($o, &$isStopped) { + $this->scheduler->scheduleAbsolute(900, function () use ($o, &$isStopped): void { if (!$isStopped) { $o->onNext(5); } }); - $this->scheduler->scheduleAbsolute(1100, function () use ($o, &$isStopped) { + $this->scheduler->scheduleAbsolute(1100, function () use ($o, &$isStopped): void { if (!$isStopped) { $o->onNext(6); } }); - return new CallbackDisposable(function () use (&$isStopped) { + return new CallbackDisposable(function () use (&$isStopped): void { $isStopped = true; }); }); @@ -163,33 +163,33 @@ public function create_dispose() * @test * */ - public function create_observer_does_not_catch() + public function create_observer_does_not_catch(): void { - $this->assertException(function () { + $this->assertException(function (): void { Observable::create(function (ObserverInterface $o) { $o->onNext(1); return new EmptyDisposable(); - })->subscribe(new CallbackObserver(function () { + })->subscribe(new CallbackObserver(function (): void { throw new \Exception; })); }); - $this->assertException(function () { + $this->assertException(function (): void { Observable::create(function (ObserverInterface $o) { $o->onError(new \Exception()); return new EmptyDisposable(); })->subscribe( new CallbackObserver( null, - function () { + function (): void { throw new \Exception; } ) ); }); - $this->assertException(function () { + $this->assertException(function (): void { Observable::create(function (ObserverInterface $o) { $o->onCompleted(); return new EmptyDisposable(); @@ -197,7 +197,7 @@ function () { new CallbackObserver( null, null, - function () { + function (): void { throw new \Exception; } ) diff --git a/test/Rx/Functional/Operator/CustomTest.php b/test/Rx/Functional/Operator/CustomTest.php index b0621084..40b66ea6 100644 --- a/test/Rx/Functional/Operator/CustomTest.php +++ b/test/Rx/Functional/Operator/CustomTest.php @@ -9,7 +9,7 @@ class CustomTest extends FunctionalTestCase { - public function testCustomOperator() + public function testCustomOperator(): void { $results = $this->scheduler->startWithCreate(function () { return Observable::of(1, $this->scheduler) @@ -22,7 +22,7 @@ public function testCustomOperator() ], $results->getMessages()); } - public function testExternalNamespacedOperator() + public function testExternalNamespacedOperator(): void { $results = $this->scheduler->startWithCreate(function () { return Observable::of(1, $this->scheduler) diff --git a/test/Rx/Functional/Operator/DefaultIfEmptyTest.php b/test/Rx/Functional/Operator/DefaultIfEmptyTest.php index 586dad80..b06fb7b1 100644 --- a/test/Rx/Functional/Operator/DefaultIfEmptyTest.php +++ b/test/Rx/Functional/Operator/DefaultIfEmptyTest.php @@ -14,7 +14,7 @@ class DefaultIfEmptyTest extends FunctionalTestCase /** * @test */ - public function defaultIfEmpty_nonEmpty_1() + public function defaultIfEmpty_nonEmpty_1(): void { $xs = $this->createHotObservable([ @@ -40,7 +40,7 @@ public function defaultIfEmpty_nonEmpty_1() /** * @test */ - public function defaultIfEmpty_nonEmpty_2() + public function defaultIfEmpty_nonEmpty_2(): void { $xs = $this->createHotObservable([ @@ -66,7 +66,7 @@ public function defaultIfEmpty_nonEmpty_2() /** * @test */ - public function defaultIfEmpty_empty_1() + public function defaultIfEmpty_empty_1(): void { $xs = $this->createHotObservable([ @@ -93,7 +93,7 @@ public function defaultIfEmpty_empty_1() /** * @test */ - public function defaultIfEmpty_empty_2() + public function defaultIfEmpty_empty_2(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/DeferTest.php b/test/Rx/Functional/Operator/DeferTest.php index a8eddb0a..bc7e5404 100644 --- a/test/Rx/Functional/Operator/DeferTest.php +++ b/test/Rx/Functional/Operator/DeferTest.php @@ -15,7 +15,7 @@ class DeferTest extends FunctionalTestCase /** * @test */ - public function defer_complete() + public function defer_complete(): void { $invoked = 0; $xs = null; @@ -44,7 +44,7 @@ public function defer_complete() /** * @test */ - public function defer_error() + public function defer_error(): void { $invoked = 0; $xs = null; @@ -73,7 +73,7 @@ public function defer_error() /** * @test */ - public function defer_dispose() + public function defer_dispose(): void { $invoked = 0; $xs = null; @@ -103,12 +103,12 @@ public function defer_dispose() /** * @test */ - public function defer_throw() + public function defer_throw(): void { $invoked = 0; $results = $this->scheduler->startWithCreate(function () use (&$invoked) { - return Observable::defer(function () use (&$invoked) { + return Observable::defer(function () use (&$invoked): void { $invoked++; throw new \Exception('error'); }); @@ -128,7 +128,7 @@ public function defer_throw() /** * @test */ - public function defer_factory_returns_invalid_string() + public function defer_factory_returns_invalid_string(): void { $invoked = 0; @@ -149,12 +149,12 @@ public function defer_factory_returns_invalid_string() /** * @test */ - public function defer_error_while_subscribe_with_immediate_scheduler() + public function defer_error_while_subscribe_with_immediate_scheduler(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('I take exception'); Observable::defer(function () { - return Observable::create(function (ObserverInterface $observer) { + return Observable::create(function (ObserverInterface $observer): void { $observer->onError(new \Exception('I take exception')); }); }, new ImmediateScheduler())->subscribe(); @@ -163,15 +163,15 @@ public function defer_error_while_subscribe_with_immediate_scheduler() /** * @test */ - public function defer_error_while_subscribe_with_immediate_scheduler_passes_through() + public function defer_error_while_subscribe_with_immediate_scheduler_passes_through(): void { $onErrorCalled = false; Observable::defer(function () { - return Observable::create(function (ObserverInterface $observer) { + return Observable::create(function (ObserverInterface $observer): void { $observer->onError(new \Exception('I take exception')); }); - }, new ImmediateScheduler())->subscribe(null, function (\Exception $e) use (&$onErrorCalled) { + }, new ImmediateScheduler())->subscribe(null, function (\Exception $e) use (&$onErrorCalled): void { $onErrorCalled = true; $this->assertEquals('I take exception', $e->getMessage()); }); diff --git a/test/Rx/Functional/Operator/DelayTest.php b/test/Rx/Functional/Operator/DelayTest.php index 607f4749..8bdf72e8 100644 --- a/test/Rx/Functional/Operator/DelayTest.php +++ b/test/Rx/Functional/Operator/DelayTest.php @@ -12,7 +12,7 @@ class DelayTest extends FunctionalTestCase /** * @test */ - public function delay_relative_time_simple_1() + public function delay_relative_time_simple_1(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -47,7 +47,7 @@ public function delay_relative_time_simple_1() /** * @test */ - public function delay_relative_time_simple_2_implementation() + public function delay_relative_time_simple_2_implementation(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -82,7 +82,7 @@ public function delay_relative_time_simple_2_implementation() /** * @test */ - public function delay_relative_time_simple_3_implementation() + public function delay_relative_time_simple_3_implementation(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -117,7 +117,7 @@ public function delay_relative_time_simple_3_implementation() /** * @test */ - public function delay_relative_time_error_1_implementation() + public function delay_relative_time_error_1_implementation(): void { $error = new \Exception(); @@ -154,7 +154,7 @@ public function delay_relative_time_error_1_implementation() /** * @test */ - public function delay_relative_time_error_2_implementation() + public function delay_relative_time_error_2_implementation(): void { $error = new \Exception(); @@ -190,7 +190,7 @@ public function delay_relative_time_error_2_implementation() /** * @test */ - public function delay_empty() + public function delay_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -219,7 +219,7 @@ public function delay_empty() /** * @test */ - public function delay_error() + public function delay_error(): void { $error = new \Exception(); @@ -250,7 +250,7 @@ public function delay_error() /** * @test */ - public function delay_never() + public function delay_never(): void { $xs = $this->createHotObservable([ onNext(150, 1) @@ -277,16 +277,16 @@ public function delay_never() /** * @test */ - public function delay_completes_during_subscribe_without_throwing() + public function delay_completes_during_subscribe_without_throwing(): void { $completes = false; - Observable::create(function ($observer) { + Observable::create(function ($observer): void { $observer->onCompleted(); })->delay(1, $this->scheduler)->subscribe( null, null, - function () use (&$completes) { + function () use (&$completes): void { $completes = true; } ); @@ -299,7 +299,7 @@ function () use (&$completes) { /** * @test */ - public function delay_disposed_after_emit() + public function delay_disposed_after_emit(): void { $xs = $this->createHotObservable([ onNext(150, 1), diff --git a/test/Rx/Functional/Operator/DistinctTest.php b/test/Rx/Functional/Operator/DistinctTest.php index 3e99e2de..5fc8c83c 100644 --- a/test/Rx/Functional/Operator/DistinctTest.php +++ b/test/Rx/Functional/Operator/DistinctTest.php @@ -13,7 +13,7 @@ class DistinctTest extends FunctionalTestCase /** * @test */ - public function distinct_default_comparer_all_distinct() + public function distinct_default_comparer_all_distinct(): void { $xs = $this->createHotObservable([ onNext(280, 4), @@ -47,7 +47,7 @@ public function distinct_default_comparer_all_distinct() /** * @test */ - public function distinct_default_comparer_some_duplicates() + public function distinct_default_comparer_some_duplicates(): void { $xs = $this->createHotObservable([ onNext(280, 4), @@ -79,7 +79,7 @@ public function distinct_default_comparer_some_duplicates() /** * @test */ - public function distinct_default_comparer_some_error() + public function distinct_default_comparer_some_error(): void { $error = new \Exception(); @@ -111,7 +111,7 @@ public function distinct_default_comparer_some_error() /** * @test */ - public function distinct_default_comparer_dispose() + public function distinct_default_comparer_dispose(): void { $xs = $this->createHotObservable([ onNext(280, 4), @@ -141,7 +141,7 @@ public function distinct_default_comparer_dispose() /** * @test */ - public function distinct_CustomComparer_all_distinct() + public function distinct_CustomComparer_all_distinct(): void { $xs = $this->createHotObservable([ onNext(280, 4), @@ -175,7 +175,7 @@ public function distinct_CustomComparer_all_distinct() /** * @test */ - public function distinct_CustomComparer_some_duplicates() + public function distinct_CustomComparer_some_duplicates(): void { $xs = $this->createHotObservable([ onNext(280, 4), @@ -207,7 +207,7 @@ public function distinct_CustomComparer_some_duplicates() * * @test */ - public function distinct_CustomComparer_some_throw() + public function distinct_CustomComparer_some_throw(): void { $error = new \Exception(); @@ -221,7 +221,7 @@ public function distinct_CustomComparer_some_throw() ]); $results = $this->scheduler->startWithCreate(function () use ($xs, $error) { - return $xs->distinct(function ($x) use ($error) { + return $xs->distinct(function ($x) use ($error): void { if ($x === 12) { throw $error; } @@ -244,7 +244,7 @@ public function distinct_CustomComparer_some_throw() /** * @test */ - public function distinct_CustomKey_all_distinct() + public function distinct_CustomKey_all_distinct(): void { $xs = $this->createHotObservable([ onNext(280, ['id' => 4]), @@ -282,7 +282,7 @@ public function distinct_CustomKey_all_distinct() /** * @test */ - public function distinct_CustomKey_some_duplicates() + public function distinct_CustomKey_some_duplicates(): void { $xs = $this->createHotObservable([ @@ -319,7 +319,7 @@ public function distinct_CustomKey_some_duplicates() * * @test */ - public function distinct_CustomKey_some_throw() + public function distinct_CustomKey_some_throw(): void { $error = new \Exception(); @@ -358,7 +358,7 @@ public function distinct_CustomKey_some_throw() /** * @test */ - public function distinct_CustomKey_and_CustomComparer_some_duplicates() + public function distinct_CustomKey_and_CustomComparer_some_duplicates(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/DistinctUntilChangedTest.php b/test/Rx/Functional/Operator/DistinctUntilChangedTest.php index 775f7372..b293eade 100644 --- a/test/Rx/Functional/Operator/DistinctUntilChangedTest.php +++ b/test/Rx/Functional/Operator/DistinctUntilChangedTest.php @@ -16,7 +16,7 @@ class DistinctUntilChangedTest extends FunctionalTestCase /** * @test */ - public function distinct_until_changed_never() + public function distinct_until_changed_never(): void { $results = $this->scheduler->startWithCreate(function () { @@ -32,7 +32,7 @@ public function distinct_until_changed_never() /** * @test */ - public function distinct_until_changed_empty() + public function distinct_until_changed_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -52,7 +52,7 @@ public function distinct_until_changed_empty() /** * @test */ - public function distinct_until_changed_return() + public function distinct_until_changed_return(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -77,7 +77,7 @@ public function distinct_until_changed_return() /** * @test */ - public function distinct_until_changed_throw() + public function distinct_until_changed_throw(): void { $ex = new \Exception('ex'); $xs = $this->createHotObservable([ @@ -95,7 +95,7 @@ public function distinct_until_changed_throw() /** * @test */ - public function distinct_until_changed_all_changes() + public function distinct_until_changed_all_changes(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -136,7 +136,7 @@ public function distinct_until_changed_all_changes() /** * @test */ - public function distinct_until_changed_all_same() + public function distinct_until_changed_all_same(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -165,7 +165,7 @@ public function distinct_until_changed_all_same() /** * @test */ - public function distinct_until_changed_some_changes() + public function distinct_until_changed_some_changes(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -214,7 +214,7 @@ public function distinct_until_changed_some_changes() /** * @test */ - public function distinct_until_changed_comparer_all_different() + public function distinct_until_changed_comparer_all_different(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -255,7 +255,7 @@ public function distinct_until_changed_comparer_all_different() /** * @test */ - public function distinct_until_changed_keyselector_div2() + public function distinct_until_changed_keyselector_div2(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -290,7 +290,7 @@ public function distinct_until_changed_keyselector_div2() /** * @test */ - public function distinct_until_changed_key_selector_throws() + public function distinct_until_changed_key_selector_throws(): void { $xs = $this->createHotObservable([ @@ -300,7 +300,7 @@ public function distinct_until_changed_key_selector_throws() ]); $results = $this->scheduler->startWithCreate(function () use ($xs) { - return $xs->distinctUntilKeyChanged(function ($x) { + return $xs->distinctUntilKeyChanged(function ($x): void { throw new \Exception('ex'); }); }); @@ -311,7 +311,7 @@ public function distinct_until_changed_key_selector_throws() /** * @test */ - public function distinct_until_changed_comparer_throws() + public function distinct_until_changed_comparer_throws(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -321,7 +321,7 @@ public function distinct_until_changed_comparer_throws() ]); $results = $this->scheduler->startWithCreate(function () use ($xs) { - return $xs->distinctUntilChanged(function ($x, $y) { + return $xs->distinctUntilChanged(function ($x, $y): void { throw new \Exception('ex'); }); }); diff --git a/test/Rx/Functional/Operator/DoOnCompletedTest.php b/test/Rx/Functional/Operator/DoOnCompletedTest.php index 792b2aaa..00023b68 100644 --- a/test/Rx/Functional/Operator/DoOnCompletedTest.php +++ b/test/Rx/Functional/Operator/DoOnCompletedTest.php @@ -11,7 +11,7 @@ class DoOnCompletedTest extends FunctionalTestCase /** * @test */ - public function doOnCompleted_should_be_called() + public function doOnCompleted_should_be_called(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -23,7 +23,7 @@ public function doOnCompleted_should_be_called() $called = 0; $this->scheduler->startWithCreate(function () use ($xs, &$called) { - return $xs->doOnCompleted(function () use (&$called) { + return $xs->doOnCompleted(function () use (&$called): void { $called++; }); }); @@ -34,7 +34,7 @@ public function doOnCompleted_should_be_called() /** * @test */ - public function doOnCompleted_should_call_after_resubscription() + public function doOnCompleted_should_call_after_resubscription(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -44,7 +44,7 @@ public function doOnCompleted_should_call_after_resubscription() $messages = []; $xs - ->doOnCompleted(function () use (&$messages) { + ->doOnCompleted(function () use (&$messages): void { $messages[] = onCompleted($this->scheduler->getClock()); }) ->repeat(2) diff --git a/test/Rx/Functional/Operator/DoOnEachOperatorTest.php b/test/Rx/Functional/Operator/DoOnEachOperatorTest.php index c593fd20..1b646d8d 100644 --- a/test/Rx/Functional/Operator/DoOnEachOperatorTest.php +++ b/test/Rx/Functional/Operator/DoOnEachOperatorTest.php @@ -12,7 +12,7 @@ class DoOnEachOperatorTest extends FunctionalTestCase /** * @test */ - public function doOnEach_should_see_all_values() + public function doOnEach_should_see_all_values(): void { $xs = $this->createHotObservable([ @@ -42,7 +42,7 @@ public function doOnEach_should_see_all_values() /** * @test */ - public function doOnEach_plain_action() + public function doOnEach_plain_action(): void { $xs = $this->createHotObservable([ @@ -68,7 +68,7 @@ public function doOnEach_plain_action() /** * @test */ - public function doOnEach_next_completed() + public function doOnEach_next_completed(): void { $xs = $this->createHotObservable([ @@ -92,7 +92,7 @@ function ($x) use (&$i, &$sum) { return $sum -= $x; }, null, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } )); @@ -107,7 +107,7 @@ function () use (&$completed) { /** * @test */ - public function doOnEach_next_completed_never() + public function doOnEach_next_completed_never(): void { $xs = $this->createHotObservable([ onNext(150, 1) @@ -118,12 +118,12 @@ public function doOnEach_next_completed_never() $this->scheduler->startWithCreate(function () use ($xs, &$i, &$completed) { return $xs->do(new CallbackObserver( - function ($x) use (&$i) { + function ($x) use (&$i): void { $i++; }, null, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } )); @@ -137,7 +137,7 @@ function () use (&$completed) { /** * @test */ - public function doOnEach_next_error() + public function doOnEach_next_error(): void { $ex = new \Exception(); @@ -163,7 +163,7 @@ function ($x) use (&$i, &$sum) { return $sum -= $x; }, - function ($e) use (&$sawError, $ex) { + function ($e) use (&$sawError, $ex): void { $sawError = $e === $ex; } )); @@ -178,7 +178,7 @@ function ($e) use (&$sawError, $ex) { /** * @test */ - public function doOnEach_next_error_not() + public function doOnEach_next_error_not(): void { $ex = new \Exception(); @@ -204,7 +204,7 @@ function ($x) use (&$i, &$sum) { return $sum -= $x; }, - function ($e) use (&$sawError, $ex) { + function ($e) use (&$sawError, $ex): void { $sawError = $e === $ex; } )); @@ -219,7 +219,7 @@ function ($e) use (&$sawError, $ex) { /** * @test */ - public function doOnEach_next_error_completed() + public function doOnEach_next_error_completed(): void { $xs = $this->createHotObservable([ @@ -238,14 +238,14 @@ public function doOnEach_next_error_completed() $this->scheduler->startWithCreate(function () use ($xs, &$i, &$sum, &$completed, &$sawError) { return $xs->do(new CallbackObserver( - function ($x) use (&$i, &$sum) { + function ($x) use (&$i, &$sum): void { $i++; $sum -= $x; }, - function () use (&$sawError) { + function () use (&$sawError): void { $sawError = true; }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } )); @@ -261,7 +261,7 @@ function () use (&$completed) { /** * @test */ - public function doOnEach_next_error_completed_error() + public function doOnEach_next_error_completed_error(): void { $ex = new \Exception(); @@ -281,14 +281,14 @@ public function doOnEach_next_error_completed_error() $this->scheduler->startWithCreate(function () use ($xs, &$i, &$sum, &$completed, &$sawError) { return $xs->do(new CallbackObserver( - function ($x) use (&$i, &$sum) { + function ($x) use (&$i, &$sum): void { $i++; $sum -= $x; }, - function () use (&$sawError) { + function () use (&$sawError): void { $sawError = true; }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } )); @@ -305,7 +305,7 @@ function () use (&$completed) { /** * @test */ - public function doOnEach_next_error_completed_never() + public function doOnEach_next_error_completed_never(): void { $xs = $this->createHotObservable([ @@ -318,13 +318,13 @@ public function doOnEach_next_error_completed_never() $this->scheduler->startWithCreate(function () use ($xs, &$i, &$completed, &$sawError) { return $xs->do(new CallbackObserver( - function ($x) use (&$i, &$sum) { + function ($x) use (&$i, &$sum): void { $i++; }, - function () use (&$sawError) { + function () use (&$sawError): void { $sawError = true; }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } )); @@ -339,7 +339,7 @@ function () use (&$completed) { /** * @test */ - public function doOnEach_next_next_throws() + public function doOnEach_next_next_throws(): void { $ex = new \Exception(); @@ -350,7 +350,7 @@ public function doOnEach_next_next_throws() ]); $results = $this->scheduler->startWithCreate(function () use ($xs, $ex) { - return $xs->do(new CallbackObserver(function () use ($ex) { + return $xs->do(new CallbackObserver(function () use ($ex): void { throw $ex; })); }); @@ -362,7 +362,7 @@ public function doOnEach_next_next_throws() /** * @test */ - public function doOnEach_next_completed_next_throws() + public function doOnEach_next_completed_next_throws(): void { $ex = new \Exception(); @@ -374,11 +374,11 @@ public function doOnEach_next_completed_next_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex) { return $xs->do(new CallbackObserver( - function () use ($ex) { + function () use ($ex): void { throw $ex; }, null, - function () { + function (): void { })); }); @@ -389,7 +389,7 @@ function () { /** * @test */ - public function doOnEach_next_completed_completed_throws() + public function doOnEach_next_completed_completed_throws(): void { $ex = new \Exception(); @@ -401,10 +401,10 @@ public function doOnEach_next_completed_completed_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex) { return $xs->do(new CallbackObserver( - function () { + function (): void { }, null, - function () use ($ex) { + function () use ($ex): void { throw $ex; })); }); @@ -416,7 +416,7 @@ function () use ($ex) { /** * @test */ - public function doOnEach_next_error_next_throws() + public function doOnEach_next_error_next_throws(): void { $ex = new \Exception(); @@ -428,10 +428,10 @@ public function doOnEach_next_error_next_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex) { return $xs->do(new CallbackObserver( - function () use ($ex) { + function () use ($ex): void { throw $ex; }, - function () { + function (): void { } )); }); @@ -443,7 +443,7 @@ function () { /** * @test */ - public function doOnEach_next_error_error_throws() + public function doOnEach_next_error_error_throws(): void { $ex1 = new \Exception("error1"); $ex2 = new \Exception("error2"); @@ -455,9 +455,9 @@ public function doOnEach_next_error_error_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex2) { return $xs->do(new CallbackObserver( - function () { + function (): void { }, - function () use ($ex2) { + function () use ($ex2): void { throw $ex2; } )); @@ -471,7 +471,7 @@ function () use ($ex2) { /** * @test */ - public function doOnEach_next_error_completed_next_throws() + public function doOnEach_next_error_completed_next_throws(): void { $ex = new \Exception(); @@ -483,12 +483,12 @@ public function doOnEach_next_error_completed_next_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex) { return $xs->do(new CallbackObserver( - function () use ($ex) { + function () use ($ex): void { throw $ex; }, - function () { + function (): void { }, - function () { + function (): void { } )); }); @@ -500,7 +500,7 @@ function () { /** * @test */ - public function doOnEach_next_error_completed_error_throws() + public function doOnEach_next_error_completed_error_throws(): void { $ex1 = new \Exception("error1"); $ex2 = new \Exception("error2"); @@ -512,12 +512,12 @@ public function doOnEach_next_error_completed_error_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex2) { return $xs->do(new CallbackObserver( - function () { + function (): void { }, - function () use ($ex2) { + function () use ($ex2): void { throw $ex2; }, - function () { + function (): void { } )); }); @@ -529,7 +529,7 @@ function () { /** * @test */ - public function doOnEach_next_error_completed_completed_throws() + public function doOnEach_next_error_completed_completed_throws(): void { $ex = new \Exception(); @@ -542,11 +542,11 @@ public function doOnEach_next_error_completed_completed_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex) { return $xs->do(new CallbackObserver( - function () { + function (): void { }, - function () { + function (): void { }, - function () use ($ex) { + function () use ($ex): void { throw $ex; } )); @@ -559,7 +559,7 @@ function () use ($ex) { /** * @test */ - public function doOnEach_observer_next_throws() + public function doOnEach_observer_next_throws(): void { $ex = new \Exception(); @@ -572,12 +572,12 @@ public function doOnEach_observer_next_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex) { return $xs->do(new CallbackObserver( - function () use ($ex) { + function () use ($ex): void { throw $ex; }, - function () { + function (): void { }, - function () { + function (): void { } )); }); @@ -589,7 +589,7 @@ function () { /** * @test */ - public function doOnEach_observer_error_throws() + public function doOnEach_observer_error_throws(): void { $ex1 = new \Exception("error1"); $ex2 = new \Exception("error2"); @@ -601,12 +601,12 @@ public function doOnEach_observer_error_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex2) { return $xs->do(new CallbackObserver( - function () { + function (): void { }, - function () use ($ex2) { + function () use ($ex2): void { throw $ex2; }, - function () { + function (): void { } )); }); @@ -618,7 +618,7 @@ function () { /** * @test */ - public function doOnEach_observer_completed_throws() + public function doOnEach_observer_completed_throws(): void { $ex = new \Exception(); @@ -630,11 +630,11 @@ public function doOnEach_observer_completed_throws() $results = $this->scheduler->startWithCreate(function () use ($xs, $ex) { return $xs->do(new CallbackObserver( - function () { //noop + function (): void { //noop }, - function () { //noop + function (): void { //noop }, - function () use ($ex) { + function () use ($ex): void { throw $ex; } )); @@ -647,7 +647,7 @@ function () use ($ex) { /** * @test */ - public function do_plain_action() + public function do_plain_action(): void { $xs = $this->createHotObservable([ @@ -673,7 +673,7 @@ public function do_plain_action() /** * @test */ - public function do_next_completed() + public function do_next_completed(): void { $xs = $this->createHotObservable([ @@ -697,7 +697,7 @@ function ($x) use (&$i, &$sum) { return $sum -= $x; }, null, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); @@ -712,7 +712,7 @@ function () use (&$completed) { /** * @test */ - public function do_next_error() + public function do_next_error(): void { $ex = new \Exception(); @@ -738,7 +738,7 @@ function ($x) use (&$i, &$sum) { return $sum -= $x; }, - function ($e) use (&$sawError, $ex) { + function ($e) use (&$sawError, $ex): void { $sawError = $e === $ex; } ); @@ -752,7 +752,7 @@ function ($e) use (&$sawError, $ex) { * @test * */ - public function do_throws_when_args_invalid() + public function do_throws_when_args_invalid(): void { $this->expectException(\InvalidArgumentException::class); $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/DoOnErrorTest.php b/test/Rx/Functional/Operator/DoOnErrorTest.php index a65493ee..1b178449 100644 --- a/test/Rx/Functional/Operator/DoOnErrorTest.php +++ b/test/Rx/Functional/Operator/DoOnErrorTest.php @@ -12,7 +12,7 @@ class DoOnErrorTest extends FunctionalTestCase /** * @test */ - public function doOnError_should_see_errors() + public function doOnError_should_see_errors(): void { $ex = new RuntimeException('boom!'); $xs = $this->createHotObservable([ @@ -26,7 +26,7 @@ public function doOnError_should_see_errors() $error = null; $this->scheduler->startWithCreate(function () use ($xs, &$called, &$error) { - return $xs->doOnError(function ($err) use (&$called, &$error) { + return $xs->doOnError(function ($err) use (&$called, &$error): void { $called++; $error = $err; }); @@ -39,7 +39,7 @@ public function doOnError_should_see_errors() /** * @test */ - public function doOnError_should_call_after_resubscription() + public function doOnError_should_call_after_resubscription(): void { $xs = $this->createColdObservable([ onError(10, new \Exception("Hello")), @@ -49,11 +49,11 @@ public function doOnError_should_call_after_resubscription() $messages = []; $xs - ->doOnError(function ($x) use (&$messages) { + ->doOnError(function ($x) use (&$messages): void { $messages[] = onError($this->scheduler->getClock(), $x); }) ->retry(2) - ->subscribe(null, function () {}, null, $this->scheduler); + ->subscribe(null, function (): void {}, null, $this->scheduler); $this->scheduler->start(); diff --git a/test/Rx/Functional/Operator/DoOnNextTest.php b/test/Rx/Functional/Operator/DoOnNextTest.php index 1f8f660a..7df0ca2e 100644 --- a/test/Rx/Functional/Operator/DoOnNextTest.php +++ b/test/Rx/Functional/Operator/DoOnNextTest.php @@ -11,7 +11,7 @@ class DoOnNextTest extends FunctionalTestCase /** * @test */ - public function doOnNext_should_see_all_values() + public function doOnNext_should_see_all_values(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -40,7 +40,7 @@ public function doOnNext_should_see_all_values() /** * @test */ - public function doOnNext_should_call_after_resubscription() + public function doOnNext_should_call_after_resubscription(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -50,7 +50,7 @@ public function doOnNext_should_call_after_resubscription() $messages = []; $xs - ->doOnNext(function ($x) use (&$messages) { + ->doOnNext(function ($x) use (&$messages): void { $messages[] = onNext($this->scheduler->getClock(), $x); }) ->repeat(2) diff --git a/test/Rx/Functional/Operator/FinallyTest.php b/test/Rx/Functional/Operator/FinallyTest.php index 627169a2..7740ee2a 100644 --- a/test/Rx/Functional/Operator/FinallyTest.php +++ b/test/Rx/Functional/Operator/FinallyTest.php @@ -13,12 +13,12 @@ class FinallyCallTest extends FunctionalTestCase /** * @test */ - public function should_call_finally_after_complete() + public function should_call_finally_after_complete(): void { $completed = false; Observable::fromArray([1, 2, 3]) - ->finally(function() use (&$completed) { + ->finally(function() use (&$completed): void { $completed = true; }) ->subscribe(new CallbackObserver()); @@ -29,7 +29,7 @@ public function should_call_finally_after_complete() /** * @test */ - public function should_call_finally_after_error() + public function should_call_finally_after_error(): void { $thrown = false; @@ -40,10 +40,10 @@ public function should_call_finally_after_error() } return $value; }) - ->finally(function() use (&$thrown) { + ->finally(function() use (&$thrown): void { $thrown = true; }) - ->subscribe(new CallbackObserver(null, function() {})); // Ignore the default error handler + ->subscribe(new CallbackObserver(null, function(): void {})); // Ignore the default error handler $this->assertTrue($thrown); } @@ -51,14 +51,14 @@ public function should_call_finally_after_error() /** * @test */ - public function should_call_finally_upon_disposal() + public function should_call_finally_upon_disposal(): void { $disposed = false; - Observable::create(function(ObserverInterface $obs) { + Observable::create(function(ObserverInterface $obs): void { $obs->onNext(1); }) - ->finally(function() use (&$disposed) { + ->finally(function() use (&$disposed): void { $disposed = true; }) ->subscribe(new CallbackObserver()) @@ -70,14 +70,14 @@ public function should_call_finally_upon_disposal() /** * @test */ - public function should_call_finally_when_synchronously_subscribing_to_and_unsubscribing_from_a_shared_observable() + public function should_call_finally_when_synchronously_subscribing_to_and_unsubscribing_from_a_shared_observable(): void { $disposed = false; - Observable::create(function(ObserverInterface $obs) { + Observable::create(function(ObserverInterface $obs): void { $obs->onNext(1); }) - ->finally(function() use (&$disposed) { + ->finally(function() use (&$disposed): void { $disposed = true; }) ->share() @@ -90,15 +90,15 @@ public function should_call_finally_when_synchronously_subscribing_to_and_unsubs /** * @test */ - public function should_call_two_finally_instances_in_succession_on_a_shared_observable() + public function should_call_two_finally_instances_in_succession_on_a_shared_observable(): void { $invoked = 0; Observable::fromArray([1, 2, 3]) - ->finally(function() use (&$invoked) { + ->finally(function() use (&$invoked): void { $invoked++; }) - ->finally(function() use (&$invoked) { + ->finally(function() use (&$invoked): void { $invoked++; }) ->share() @@ -110,7 +110,7 @@ public function should_call_two_finally_instances_in_succession_on_a_shared_obse /** * @test */ - public function should_handle_empty() + public function should_handle_empty(): void { $executed = false; @@ -119,7 +119,7 @@ public function should_handle_empty() ]); $results = $this->scheduler->startWithCreate(function() use ($xs, &$executed) { - return $xs->finally(function() use (&$executed) { + return $xs->finally(function() use (&$executed): void { $executed = true; }); }); @@ -138,14 +138,14 @@ public function should_handle_empty() /** * @test */ - public function should_handle_never() + public function should_handle_never(): void { $executed = false; $xs = $this->createHotObservable([ ]); $results = $this->scheduler->startWithCreate(function() use ($xs, &$executed) { - return $xs->finally(function() use (&$executed) { + return $xs->finally(function() use (&$executed): void { $executed = true; }); }); @@ -162,7 +162,7 @@ public function should_handle_never() /** * @test */ - public function should_handle_throw() + public function should_handle_throw(): void { $executed = false; @@ -173,7 +173,7 @@ public function should_handle_throw() ]); $results = $this->scheduler->startWithCreate(function() use ($xs, &$executed) { - return $xs->finally(function() use (&$executed) { + return $xs->finally(function() use (&$executed): void { $executed = true; }); }); @@ -192,7 +192,7 @@ public function should_handle_throw() /** * @test */ - public function should_handle_basic_hot_observable() + public function should_handle_basic_hot_observable(): void { $executed = false; @@ -204,7 +204,7 @@ public function should_handle_basic_hot_observable() ]); $results = $this->scheduler->startWithCreate(function() use ($xs, &$executed) { - return $xs->finally(function() use (&$executed) { + return $xs->finally(function() use (&$executed): void { $executed = true; }); }); @@ -226,7 +226,7 @@ public function should_handle_basic_hot_observable() /** * @test */ - public function should_handle_basic_cold_observable() + public function should_handle_basic_cold_observable(): void { $executed = false; @@ -238,7 +238,7 @@ public function should_handle_basic_cold_observable() ]); $results = $this->scheduler->startWithCreate(function() use ($xs, &$executed) { - return $xs->finally(function() use (&$executed) { + return $xs->finally(function() use (&$executed): void { $executed = true; }); }); @@ -260,7 +260,7 @@ public function should_handle_basic_cold_observable() /** * @test */ - public function should_handle_basic_error() + public function should_handle_basic_error(): void { $executed = false; @@ -274,7 +274,7 @@ public function should_handle_basic_error() ]); $results = $this->scheduler->startWithCreate(function() use ($xs, &$executed) { - return $xs->finally(function() use (&$executed) { + return $xs->finally(function() use (&$executed): void { $executed = true; }); }); @@ -296,7 +296,7 @@ public function should_handle_basic_error() /** * @test */ - public function should_handle_unsubscription() + public function should_handle_unsubscription(): void { $executed = false; @@ -307,7 +307,7 @@ public function should_handle_unsubscription() ]); $results = $this->scheduler->startWithDispose(function() use ($xs, &$executed) { - return $xs->finally(function() use (&$executed) { + return $xs->finally(function() use (&$executed): void { $executed = true; }); }, 450); diff --git a/test/Rx/Functional/Operator/FlatMapLatestTest.php b/test/Rx/Functional/Operator/FlatMapLatestTest.php index 241802c2..22305d28 100644 --- a/test/Rx/Functional/Operator/FlatMapLatestTest.php +++ b/test/Rx/Functional/Operator/FlatMapLatestTest.php @@ -12,7 +12,7 @@ class FlatMapLatestTest extends FunctionalTestCase /** * @test */ - public function flatMapLatest_empty() + public function flatMapLatest_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -42,7 +42,7 @@ public function flatMapLatest_empty() /** * @test */ - public function flatMapLatest_inner_empty() + public function flatMapLatest_inner_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -73,7 +73,7 @@ public function flatMapLatest_inner_empty() /** * @test */ - public function flatMapLatest_many() + public function flatMapLatest_many(): void { $xs = $this->createColdObservable([ onNext(100, 4), @@ -120,7 +120,7 @@ public function flatMapLatest_many() /** * @test */ - public function flatMapLatest_errors() + public function flatMapLatest_errors(): void { $error = new \Exception(); @@ -163,7 +163,7 @@ public function flatMapLatest_errors() /** * @test */ - public function flatMapLatest_inner_errors() + public function flatMapLatest_inner_errors(): void { $error = new \Exception(); @@ -207,7 +207,7 @@ public function flatMapLatest_inner_errors() /** * @test */ - public function flatMapLatest_throws() + public function flatMapLatest_throws(): void { $xs = $this->createColdObservable([ onNext(100, 4), @@ -226,7 +226,7 @@ public function flatMapLatest_throws() ]); $results = $this->scheduler->startWithCreate(function () use ($xs, $ys) { - return $xs->flatMapLatest(function () use ($ys) { + return $xs->flatMapLatest(function () use ($ys): void { throw new \Exception('error'); }); }); @@ -242,7 +242,7 @@ public function flatMapLatest_throws() /** * @test */ - public function flatMapLatest_returns_invalid_string() + public function flatMapLatest_returns_invalid_string(): void { $xs = $this->createColdObservable([ onNext(100, 4), @@ -277,7 +277,7 @@ public function flatMapLatest_returns_invalid_string() /** * @test */ - public function flatMapLatest_dispose() + public function flatMapLatest_dispose(): void { $xs = $this->createColdObservable([ onNext(100, 4), @@ -322,7 +322,7 @@ public function flatMapLatest_dispose() /** * @test */ - public function flatMapLatest_dispose_before_outer_completes() + public function flatMapLatest_dispose_before_outer_completes(): void { $xs = $this->createColdObservable([ onNext(100, 4), diff --git a/test/Rx/Functional/Operator/FromArrayTest.php b/test/Rx/Functional/Operator/FromArrayTest.php index 2ac6bce5..cc7d2a20 100644 --- a/test/Rx/Functional/Operator/FromArrayTest.php +++ b/test/Rx/Functional/Operator/FromArrayTest.php @@ -11,7 +11,7 @@ class FromArrayTest extends FunctionalTestCase /** * @test */ - public function it_schedules_all_elements_from_the_array() + public function it_schedules_all_elements_from_the_array(): void { $xs = Observable::fromArray(['foo', 'bar', 'baz'], $this->scheduler); @@ -30,7 +30,7 @@ public function it_schedules_all_elements_from_the_array() /** * @test */ - public function it_calls_on_complete_when_the_array_is_empty() + public function it_calls_on_complete_when_the_array_is_empty(): void { $xs = Observable::fromArray([], $this->scheduler); @@ -46,7 +46,7 @@ public function it_calls_on_complete_when_the_array_is_empty() /** * @test */ - public function fromArray_one() + public function fromArray_one(): void { $xs = Observable::fromArray([1], $this->scheduler); @@ -63,7 +63,7 @@ public function fromArray_one() /** * @test */ - public function fromArray_dispose() + public function fromArray_dispose(): void { $xs = Observable::fromArray(['foo', 'bar', 'baz'], $this->scheduler); diff --git a/test/Rx/Functional/Operator/GroupByTest.php b/test/Rx/Functional/Operator/GroupByTest.php index fd1bc2dd..ffb5ede5 100644 --- a/test/Rx/Functional/Operator/GroupByTest.php +++ b/test/Rx/Functional/Operator/GroupByTest.php @@ -14,7 +14,7 @@ class GroupByTest extends FunctionalTestCase /** * @test */ - public function it_passes_on_complete() + public function it_passes_on_complete(): void { $xs = $this->createHotObservableWithData(); $keyInvoked = 0; @@ -30,19 +30,19 @@ public function it_passes_on_complete() $this->assertEquals(12, $keyInvoked); - $this->assertMessages(array( + $this->assertMessages([ onNext(220, "foo"), onNext(270, "bar"), onNext(350, "baz"), onNext(360, "qux"), onCompleted(570), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_passes_on_error() + public function it_passes_on_error(): void { $xs = $this->createHotObservableWithData(true); $keyInvoked = 0; @@ -58,19 +58,19 @@ public function it_passes_on_error() $this->assertEquals(12, $keyInvoked); - $this->assertMessages(array( + $this->assertMessages([ onNext(220, "foo"), onNext(270, "bar"), onNext(350, "baz"), onNext(360, "qux"), onError(570, new Exception()), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_disposes_the_outer_subscription() + public function it_disposes_the_outer_subscription(): void { $xs = $this->createHotObservableWithData(true); $keyInvoked = 0; @@ -86,17 +86,17 @@ public function it_disposes_the_outer_subscription() $this->assertEquals(5, $keyInvoked); - $this->assertMessages(array( + $this->assertMessages([ onNext(220, "foo"), onNext(270, "bar"), onNext(350, "baz"), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_calls_on_error_if_keyselector_throws() + public function it_calls_on_error_if_keyselector_throws(): void { $xs = $this->createHotObservableWithData(true); $keyInvoked = 0; @@ -117,19 +117,19 @@ public function it_calls_on_error_if_keyselector_throws() $this->assertEquals(10, $keyInvoked); - $this->assertMessages(array( + $this->assertMessages([ onNext(220, "foo"), onNext(270, "bar"), onNext(350, "baz"), onNext(360, "qux"), onError(480, new Exception()), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_calls_on_error_if_elementselector_throws() + public function it_calls_on_error_if_elementselector_throws(): void { $xs = $this->createHotObservableWithData(true); $elementInvoked = 0; @@ -152,41 +152,41 @@ public function it_calls_on_error_if_elementselector_throws() $this->assertEquals(10, $elementInvoked); - $this->assertMessages(array( + $this->assertMessages([ onNext(220, "foo"), onNext(270, "bar"), onNext(350, "baz"), onNext(360, "qux"), onError(480, new Exception()), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_calls_on_error_if_durationselector_throws() + public function it_calls_on_error_if_durationselector_throws(): void { $xs = $this->createHotObservableWithData(true); $results = $this->scheduler->startWithCreate(function() use ($xs) { return $xs->groupByUntil(function($elem) { return $elem; }, null, - function() { throw new Exception(''); } + function(): void { throw new Exception(''); } )->select(function(GroupedObservable $observable) { return $observable->getKey(); }); }); - $this->assertMessages(array( + $this->assertMessages([ onError(220, new Exception()), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_passes_on_error_if_duration_observable_calls_on_error() + public function it_passes_on_error_if_duration_observable_calls_on_error(): void { $xs = $this->createHotObservableWithData(); @@ -196,23 +196,23 @@ public function it_passes_on_error_if_duration_observable_calls_on_error() }, null, function(GroupedObservable $observable) { - return $observable->select(function() { throw new Exception('meh.'); }); + return $observable->select(function(): void { throw new Exception('meh.'); }); })->select(function(GroupedObservable $observable) { return $observable->getKey(); }); }); $this->scheduler->start(); - $this->assertMessages(array( + $this->assertMessages([ onNext(220, 'foo'), onError(220, new Exception()), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_calls_on_completed_on_inner_subscription_if_subscription_expires_otherwise_it_passes() + public function it_calls_on_completed_on_inner_subscription_if_subscription_expires_otherwise_it_passes(): void { $xs = $this->createHotObservableWithData(); @@ -225,71 +225,71 @@ function(GroupedObservable $observable) { } ); - $innerSubscriptions = array(); + $innerSubscriptions = []; $scheduler = $this->scheduler; - $observable->subscribe(function(GroupedObservable $observable) use (&$innerSubscriptions, $scheduler) { + $observable->subscribe(function(GroupedObservable $observable) use (&$innerSubscriptions, $scheduler): void { $observer = new MockObserver($scheduler); $observable->subscribe($observer); - $innerSubscriptions[] = array( + $innerSubscriptions[] = [ 'key' => $observable->getKey(), 'observer' => $observer, - ); + ]; }); $this->scheduler->start(); // on complete gets called after duration is "over" $this->assertCount(4, $innerSubscriptions[0]['observer']->getMessages()); - $this->assertMessages(array( + $this->assertMessages([ onNext(90, "error"), onNext(110, "error"), onNext(130, "error"), onCompleted(130), - ), $innerSubscriptions[0]['observer']->getMessages()); + ], $innerSubscriptions[0]['observer']->getMessages()); $this->assertCount(4, $innerSubscriptions[1]['observer']->getMessages()); - $this->assertMessages(array( + $this->assertMessages([ onNext(220, " foo"), onNext(240, " FoO "), onNext(310, "foO "), onCompleted(310), - ), $innerSubscriptions[1]['observer']->getMessages()); + ], $innerSubscriptions[1]['observer']->getMessages()); $this->assertCount(4, $innerSubscriptions[2]['observer']->getMessages()); - $this->assertMessages(array( + $this->assertMessages([ onNext(270, "baR "), onNext(390, " bar"), onNext(420, " BAR "), onCompleted(420), - ), $innerSubscriptions[2]['observer']->getMessages()); + ], $innerSubscriptions[2]['observer']->getMessages()); $this->assertCount(4, $innerSubscriptions[3]['observer']->getMessages()); - $this->assertMessages(array( + $this->assertMessages([ onNext(350, " Baz "), onNext(480, "baz "), onNext(510, " bAZ "), onCompleted(510), - ), $innerSubscriptions[3]['observer']->getMessages()); + ], $innerSubscriptions[3]['observer']->getMessages()); // Otherwise the original on complete is passed $this->assertCount(2, $innerSubscriptions[4]['observer']->getMessages()); - $this->assertMessages(array( + $this->assertMessages([ onNext(360, " qux "), onCompleted(570), - ), $innerSubscriptions[4]['observer']->getMessages()); + ], $innerSubscriptions[4]['observer']->getMessages()); $this->assertCount(3, $innerSubscriptions[5]['observer']->getMessages()); - $this->assertMessages(array( + $this->assertMessages([ onNext(470, "FOO "), onNext(530, " fOo "), onCompleted(570), - ), $innerSubscriptions[5]['observer']->getMessages()); + ], $innerSubscriptions[5]['observer']->getMessages()); } protected function createHotObservableWithData($error = false) { - return $this->createHotObservable(array( + return $this->createHotObservable([ onNext(90, "error"), onNext(110, "error"), onNext(130, "error"), @@ -309,6 +309,6 @@ protected function createHotObservableWithData($error = false) onNext(580, "error"), onCompleted(600), onError(650, new Exception()), - )); + ]); } } diff --git a/test/Rx/Functional/Operator/GroupByUntilTest.php b/test/Rx/Functional/Operator/GroupByUntilTest.php index 762ba685..fae960fa 100644 --- a/test/Rx/Functional/Operator/GroupByUntilTest.php +++ b/test/Rx/Functional/Operator/GroupByUntilTest.php @@ -15,7 +15,7 @@ class GroupByUntilTest extends FunctionalTestCase /** * @test */ - public function groupByUntilWithKeyComparer() + public function groupByUntilWithKeyComparer(): void { $keyInvoked = 0; @@ -85,7 +85,7 @@ function (Observable $g) { /** * @test */ - public function groupByUntilWithKeyComparerDefaultDurationSelector() + public function groupByUntilWithKeyComparerDefaultDurationSelector(): void { $keyInvoked = 0; @@ -159,7 +159,7 @@ function ($x) { /** * @test */ - public function groupByUntilOuterComplete() + public function groupByUntilOuterComplete(): void { $keyInvoked = 0; $eleInvoked = 0; @@ -232,7 +232,7 @@ function (Observable $g) { /** * @test */ - public function groupByUntilOuterError() + public function groupByUntilOuterError(): void { $error = new \Exception(); @@ -307,7 +307,7 @@ function (Observable $g) { /** * @test */ - public function groupByUntilOuterDispose() + public function groupByUntilOuterDispose(): void { $keyInvoked = 0; $eleInvoked = 0; @@ -381,7 +381,7 @@ function (Observable $g) { /** * @test */ - public function groupByUntilOuterKeyThrow() + public function groupByUntilOuterKeyThrow(): void { $error = new \Exception(); @@ -456,7 +456,7 @@ function (Observable $g) { /** * @test */ - public function groupByUntilOuterEleThrow() + public function groupByUntilOuterEleThrow(): void { $error = new \Exception(); @@ -522,7 +522,7 @@ public function groupByUntilOuterEleThrow() /** * @test */ - public function groupByUntilInnerComplete() + public function groupByUntilInnerComplete(): void { $xs = $this->createHotObservable([ onNext(90, new \Exception()), @@ -552,7 +552,7 @@ public function groupByUntilInnerComplete() $outer = null; $outerSubscription = null; - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use ($xs, &$outer) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use ($xs, &$outer): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -564,17 +564,17 @@ public function groupByUntilInnerComplete() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outer, &$outerSubscription, &$inners, &$results, &$innerSubscriptions) { + function () use (&$outer, &$outerSubscription, &$inners, &$results, &$innerSubscriptions): void { $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use ( &$inners, &$results - ) { + ): void { $result = $this->scheduler->createObserver(); $inners[$group->getKey()] = $group; $results[$group->getKey()] = $result; - $this->scheduler->scheduleRelativeWithState(null, 100, function () use ($group, $result) { + $this->scheduler->scheduleRelativeWithState(null, 100, function () use ($group, $result): void { $innerSubscriptions[$group->getKey()] = $group->subscribe($result); }); }); @@ -583,7 +583,7 @@ function () use (&$outer, &$outerSubscription, &$inners, &$results, &$innerSubsc $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$outerSubscription, &$innerSubscriptions) { + function () use (&$outerSubscription, &$innerSubscriptions): void { $outerSubscription->dispose(); foreach ($innerSubscriptions as $innerSubscription) { $innerSubscription->dispose(); @@ -621,7 +621,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { /** * @test */ - public function groupByUntilInnerCompleteAll() + public function groupByUntilInnerCompleteAll(): void { $xs = $this->createHotObservable([ onNext(90, new \Exception()), @@ -651,7 +651,7 @@ public function groupByUntilInnerCompleteAll() $innerSubscriptions = []; $results = []; - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use ($xs, &$outer) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use ($xs, &$outer): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -663,12 +663,12 @@ public function groupByUntilInnerCompleteAll() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$results, &$innerSubscriptions, &$inners) { + function () use (&$outerSubscription, &$outer, &$results, &$innerSubscriptions, &$inners): void { $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use ( &$inners, &$results, &$innerSubscriptions - ) { + ): void { $result = $this->scheduler->createObserver(); $inners[$group->getKey()] = $group; @@ -681,7 +681,7 @@ function () use (&$outerSubscription, &$outer, &$results, &$innerSubscriptions, $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$outerSubscription, &$innerSubscriptions) { + function () use (&$outerSubscription, &$innerSubscriptions): void { $outerSubscription->dispose(); foreach ($innerSubscriptions as $innerSubscription) { $innerSubscription->dispose(); @@ -726,7 +726,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { /** * @test */ - public function groupByUntilInnerError() + public function groupByUntilInnerError(): void { $error = new \Exception(); @@ -758,7 +758,7 @@ public function groupByUntilInnerError() $innerSubscriptions = []; $results = []; - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -770,13 +770,13 @@ public function groupByUntilInnerError() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$inners, &$results, &$innerSubscriptions) { + function () use (&$outerSubscription, &$outer, &$inners, &$results, &$innerSubscriptions): void { $outerSubscription = $outer->subscribeCallback( function (GroupedObservable $group) use ( &$inners, &$results, &$innerSubscriptions - ) { + ): void { $result = $this->scheduler->createObserver(); $inners[$group->getKey()] = $group; @@ -785,12 +785,12 @@ function (GroupedObservable $group) use ( $this->scheduler->scheduleRelativeWithState( null, 100, - function () use (&$innerSubscriptions, $group, $result) { + function () use (&$innerSubscriptions, $group, $result): void { $innerSubscriptions[$group->getKey()] = $group->subscribe($result); } ); }, - function () { + function (): void { } ); } @@ -798,7 +798,7 @@ function () { $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$outerSubscription, &$innerSubscriptions) { + function () use (&$outerSubscription, &$innerSubscriptions): void { $outerSubscription->dispose(); foreach ($innerSubscriptions as $innerSubscription) { $innerSubscription->dispose(); @@ -836,7 +836,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { /** * @test */ - public function groupByUntilInnerDispose() + public function groupByUntilInnerDispose(): void { $xs = $this->createHotObservable([ onNext(90, new \Exception()), @@ -866,7 +866,7 @@ public function groupByUntilInnerDispose() $outer = null; $outerSubscription = null; - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, &$xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, &$xs): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -878,12 +878,12 @@ public function groupByUntilInnerDispose() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$innerSubscriptions, &$results, &$inners) { + function () use (&$outerSubscription, &$outer, &$innerSubscriptions, &$results, &$inners): void { $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use ( &$inners, &$results, &$innerSubscriptions - ) { + ): void { $result = $this->scheduler->createObserver(); $inners[$group->getKey()] = $group; @@ -894,7 +894,7 @@ function () use (&$outerSubscription, &$outer, &$innerSubscriptions, &$results, } ); - $this->scheduler->scheduleAbsolute(400, function () use (&$outerSubscription, &$innerSubscriptions) { + $this->scheduler->scheduleAbsolute(400, function () use (&$outerSubscription, &$innerSubscriptions): void { $outerSubscription->dispose(); foreach ($innerSubscriptions as $innerSubscription) { $innerSubscription->dispose(); @@ -933,7 +933,7 @@ function () use (&$outerSubscription, &$outer, &$innerSubscriptions, &$results, /** * @test */ - public function groupByUntilInnerKeyThrow() + public function groupByUntilInnerKeyThrow(): void { $error = new \Exception(); $keyInvoked = 0; @@ -968,7 +968,7 @@ public function groupByUntilInnerKeyThrow() $this->scheduler->scheduleAbsolute( TestScheduler::CREATED, - function () use (&$outer, $xs, &$keyInvoked, $error) { + function () use (&$outer, $xs, &$keyInvoked, $error): void { $outer = $xs->groupByUntil(function ($x) use (&$keyInvoked, $error) { $keyInvoked++; if ($keyInvoked === 6) { @@ -985,26 +985,26 @@ function () use (&$outer, $xs, &$keyInvoked, $error) { $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$inners, &$results, &$innerSubscriptions) { + function () use (&$outerSubscription, &$outer, &$inners, &$results, &$innerSubscriptions): void { $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use ( &$inners, &$results, &$innerSubscriptions - ) { + ): void { $result = $this->scheduler->createObserver(); $inners[$group->getKey()] = $group; $results[$group->getKey()] = $result; $innerSubscriptions[$group->getKey()] = $group->subscribe($result); - }, function () { + }, function (): void { }); } ); $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$outerSubscription, &$innerSubscriptions) { + function () use (&$outerSubscription, &$innerSubscriptions): void { $outerSubscription->dispose(); foreach ($innerSubscriptions as $innerSubscription) { $innerSubscription->dispose(); @@ -1041,7 +1041,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { /** * @test */ - public function groupByUntilInnerEleThrow() + public function groupByUntilInnerEleThrow(): void { $error = new \Exception(); $eleInvoked = 0; @@ -1076,7 +1076,7 @@ public function groupByUntilInnerEleThrow() $this->scheduler->scheduleAbsolute( TestScheduler::CREATED, - function () use (&$outer, $xs, &$eleInvoked, $error) { + function () use (&$outer, $xs, &$eleInvoked, $error): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) use (&$eleInvoked, $error) { @@ -1093,26 +1093,26 @@ function () use (&$outer, $xs, &$eleInvoked, $error) { $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$inners, &$results) { + function () use (&$outerSubscription, &$outer, &$inners, &$results): void { $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use ( &$inners, &$results, &$innerSubscriptions - ) { + ): void { $result = $this->scheduler->createObserver(); $inners[$group->getKey()] = $group; $results[$group->getKey()] = $result; $innerSubscriptions[$group->getKey()] = $group->subscribe($result); - }, function () { + }, function (): void { }); } ); $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$outerSubscription, &$innerSubscriptions) { + function () use (&$outerSubscription, &$innerSubscriptions): void { $outerSubscription->dispose(); foreach ($innerSubscriptions as $innerSubscription) { $innerSubscription->dispose(); @@ -1153,7 +1153,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { /** * @test */ - public function groupByUntilOuterIndependence() + public function groupByUntilOuterIndependence(): void { $xs = $this->createHotObservable([ onNext(90, new \Exception()), @@ -1184,7 +1184,7 @@ public function groupByUntilOuterIndependence() $outerSubscription = null; $outerResults = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -1196,13 +1196,13 @@ public function groupByUntilOuterIndependence() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$outerResults, &$inners, &$results) { + function () use (&$outerSubscription, &$outer, &$outerResults, &$inners, &$results): void { $outerSubscription = $outer->subscribe(function (GroupedObservable $group) use ( &$outerResults, &$inners, &$results, &$innerSubscriptions - ) { + ): void { $outerResults->onNext($group->getKey()); $result = $this->scheduler->createObserver(); @@ -1211,9 +1211,9 @@ function () use (&$outerSubscription, &$outer, &$outerResults, &$inners, &$resul $results[$group->getKey()] = $result; $innerSubscriptions[$group->getKey()] = $group->subscribe($result); - }, function ($e) use (&$outerResults) { + }, function ($e) use (&$outerResults): void { $outerResults->onError($e); - }, function () use (&$outerResults) { + }, function () use (&$outerResults): void { $outerResults->onCompleted(); }); } @@ -1221,7 +1221,7 @@ function () use (&$outerSubscription, &$outer, &$outerResults, &$inners, &$resul $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$outerSubscription, &$innerSubscriptions) { + function () use (&$outerSubscription, &$innerSubscriptions): void { $outerSubscription->dispose(); foreach ($innerSubscriptions as $innerSubscription) { $innerSubscription->dispose(); @@ -1229,7 +1229,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { } ); - $this->scheduler->scheduleAbsolute(320, function () use (&$outerSubscription) { + $this->scheduler->scheduleAbsolute(320, function () use (&$outerSubscription): void { $outerSubscription->dispose(); }); @@ -1264,7 +1264,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { /** * @test */ - public function groupByUntilInnerIndependence() + public function groupByUntilInnerIndependence(): void { $xs = $this->createHotObservable([ onNext(90, new \Exception()), @@ -1295,7 +1295,7 @@ public function groupByUntilInnerIndependence() $outerSubscription = null; $outerResults = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -1307,13 +1307,13 @@ public function groupByUntilInnerIndependence() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$outerResults, &$inners, &$results, &$innerSubscriptions) { + function () use (&$outerSubscription, &$outer, &$outerResults, &$inners, &$results, &$innerSubscriptions): void { $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use ( &$outerResults, &$innerSubscriptions, &$results, &$inners - ) { + ): void { $outerResults->onNext($group->getKey()); $result = $this->scheduler->createObserver(); @@ -1322,9 +1322,9 @@ function () use (&$outerSubscription, &$outer, &$outerResults, &$inners, &$resul $results[$group->getKey()] = $result; $innerSubscriptions[$group->getKey()] = $group->subscribe($result); - }, function ($e) use (&$outerResults) { + }, function ($e) use (&$outerResults): void { $outerResults->onError($e); - }, function () use (&$outerResults) { + }, function () use (&$outerResults): void { $outerResults->onCompleted(); }); } @@ -1332,7 +1332,7 @@ function () use (&$outerSubscription, &$outer, &$outerResults, &$inners, &$resul $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$outerSubscription, &$innerSubscriptions) { + function () use (&$outerSubscription, &$innerSubscriptions): void { $outerSubscription->dispose(); foreach ($innerSubscriptions as $innerSubscription) { $innerSubscription->dispose(); @@ -1340,7 +1340,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { } ); - $this->scheduler->scheduleAbsolute(320, function () use (&$innerSubscriptions) { + $this->scheduler->scheduleAbsolute(320, function () use (&$innerSubscriptions): void { $innerSubscriptions['foo']->dispose(); }); @@ -1381,7 +1381,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { /** * @test */ - public function groupByUntilInnerMultipleIndependence() + public function groupByUntilInnerMultipleIndependence(): void { $xs = $this->createHotObservable([ onNext(90, new \Exception()), @@ -1412,7 +1412,7 @@ public function groupByUntilInnerMultipleIndependence() $outerSubscription = null; $outerResults = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -1424,13 +1424,13 @@ public function groupByUntilInnerMultipleIndependence() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use ($outerResults, &$outerSubscription, &$inners, &$results, &$innerSubscriptions, &$outer) { + function () use ($outerResults, &$outerSubscription, &$inners, &$results, &$innerSubscriptions, &$outer): void { $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use ( $outerResults, &$inners, &$results, &$innerSubscriptions - ) { + ): void { $outerResults->onNext($group->getKey()); $result = $this->scheduler->createObserver(); @@ -1439,9 +1439,9 @@ function () use ($outerResults, &$outerSubscription, &$inners, &$results, &$inne $results[$group->getKey()] = $result; $innerSubscriptions[$group->getKey()] = $group->subscribe($result); - }, function ($e) use ($outerResults) { + }, function ($e) use ($outerResults): void { $outerResults->onError($e); - }, function () use ($outerResults) { + }, function () use ($outerResults): void { $outerResults->onCompleted(); }); } @@ -1449,7 +1449,7 @@ function () use ($outerResults, &$outerSubscription, &$inners, &$results, &$inne $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$outerSubscription, &$innerSubscriptions) { + function () use (&$outerSubscription, &$innerSubscriptions): void { $outerSubscription->dispose(); foreach ($innerSubscriptions as $innerSubscription) { $innerSubscription->dispose(); @@ -1457,19 +1457,19 @@ function () use (&$outerSubscription, &$innerSubscriptions) { } ); - $this->scheduler->scheduleAbsolute(320, function () use (&$innerSubscriptions) { + $this->scheduler->scheduleAbsolute(320, function () use (&$innerSubscriptions): void { $innerSubscriptions['foo']->dispose(); }); - $this->scheduler->scheduleAbsolute(280, function () use (&$innerSubscriptions) { + $this->scheduler->scheduleAbsolute(280, function () use (&$innerSubscriptions): void { $innerSubscriptions['bar']->dispose(); }); - $this->scheduler->scheduleAbsolute(355, function () use (&$innerSubscriptions) { + $this->scheduler->scheduleAbsolute(355, function () use (&$innerSubscriptions): void { $innerSubscriptions['baz']->dispose(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$innerSubscriptions) { + $this->scheduler->scheduleAbsolute(400, function () use (&$innerSubscriptions): void { $innerSubscriptions['qux']->dispose(); }); @@ -1503,7 +1503,7 @@ function () use (&$outerSubscription, &$innerSubscriptions) { /** * @test */ - public function groupByUntilInnerEscapeComplete() + public function groupByUntilInnerEscapeComplete(): void { $xs = $this->createHotObservable([ onNext(220, ' foo'), @@ -1520,7 +1520,7 @@ public function groupByUntilInnerEscapeComplete() $outer = null; $outerSubscription = null; - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -1532,20 +1532,20 @@ public function groupByUntilInnerEscapeComplete() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$inner) { + function () use (&$outerSubscription, &$outer, &$inner): void { $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use (&$inner) { return $inner = $group; }); } ); - $this->scheduler->scheduleAbsolute(600, function () use (&$innerSubscription, &$inner, $results) { + $this->scheduler->scheduleAbsolute(600, function () use (&$innerSubscription, &$inner, $results): void { $innerSubscription = $inner->subscribe($results); }); $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$outerSubscription, &$innerSubscription) { + function () use (&$outerSubscription, &$innerSubscription): void { $outerSubscription->dispose(); $innerSubscription->dispose(); } @@ -1565,7 +1565,7 @@ function () use (&$outerSubscription, &$innerSubscription) { /** * @test */ - public function groupByUntilInnerEscapeError() + public function groupByUntilInnerEscapeError(): void { $error = new \Exception(); @@ -1584,7 +1584,7 @@ public function groupByUntilInnerEscapeError() $outer = null; $outerSubscription = null; - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -1596,21 +1596,21 @@ public function groupByUntilInnerEscapeError() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$inner) { - $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use (&$inner) { + function () use (&$outerSubscription, &$outer, &$inner): void { + $outerSubscription = $outer->subscribeCallback(function (GroupedObservable $group) use (&$inner): void { $inner = $group; - }, function () { + }, function (): void { }); } ); - $this->scheduler->scheduleAbsolute(600, function () use (&$innerSubscription, &$inner, $results) { + $this->scheduler->scheduleAbsolute(600, function () use (&$innerSubscription, &$inner, $results): void { $innerSubscription = $inner->subscribe($results); }); $this->scheduler->scheduleAbsolute( TestScheduler::DISPOSED, - function () use (&$innerSubscription, &$outerSubscription) { + function () use (&$innerSubscription, &$outerSubscription): void { $outerSubscription->dispose(); $innerSubscription->dispose(); } @@ -1630,7 +1630,7 @@ function () use (&$innerSubscription, &$outerSubscription) { /** * @test */ - public function groupByUntilInnerEscapeDispose() + public function groupByUntilInnerEscapeDispose(): void { $xs = $this->createHotObservable([ onNext(220, ' foo'), @@ -1647,7 +1647,7 @@ public function groupByUntilInnerEscapeDispose() $outer = null; $outerSubscription = null; - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$outer, $xs): void { $outer = $xs->groupByUntil(function ($x) { return trim(strtolower($x)); }, function ($x) { @@ -1659,22 +1659,22 @@ public function groupByUntilInnerEscapeDispose() $this->scheduler->scheduleAbsolute( TestScheduler::SUBSCRIBED, - function () use (&$outerSubscription, &$outer, &$inner) { - $outerSubscription = $outer->subscribeCallback(function ($group) use (&$inner) { + function () use (&$outerSubscription, &$outer, &$inner): void { + $outerSubscription = $outer->subscribeCallback(function ($group) use (&$inner): void { $inner = $group; }); } ); - $this->scheduler->scheduleAbsolute(290, function () use (&$outerSubscription) { + $this->scheduler->scheduleAbsolute(290, function () use (&$outerSubscription): void { $outerSubscription->dispose(); }); - $this->scheduler->scheduleAbsolute(600, function () use (&$innerSubscription, &$inner, $results) { + $this->scheduler->scheduleAbsolute(600, function () use (&$innerSubscription, &$inner, $results): void { $innerSubscription = $inner->subscribe($results); }); - $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$outerSubscription) { + $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$outerSubscription): void { $outerSubscription->dispose(); }); @@ -1690,7 +1690,7 @@ function () use (&$outerSubscription, &$outer, &$inner) { /** * @test */ - public function groupByUntilDefault() + public function groupByUntilDefault(): void { $keyInvoked = 0; $eleInvoked = 0; @@ -1751,7 +1751,7 @@ public function groupByUntilDefault() /** * @test */ - public function groupByUntilDurationSelectorThrows() + public function groupByUntilDurationSelectorThrows(): void { $error = new \Exception(); $xs = $this->createHotObservable([onNext(210, 'foo')]); @@ -1761,7 +1761,7 @@ public function groupByUntilDurationSelectorThrows() return $x; }, function ($x) { return $x; - }, function () use ($error) { + }, function () use ($error): void { throw $error; }); }); diff --git a/test/Rx/Functional/Operator/IsEmptyTest.php b/test/Rx/Functional/Operator/IsEmptyTest.php index f0c1f0a1..e5cb130b 100644 --- a/test/Rx/Functional/Operator/IsEmptyTest.php +++ b/test/Rx/Functional/Operator/IsEmptyTest.php @@ -10,7 +10,7 @@ class IsEmptyTest extends FunctionalTestCase /** * @test */ - public function should_return_true_if_source_is_empty() + public function should_return_true_if_source_is_empty(): void { $xs = $this->createHotObservable([ onCompleted(300) @@ -33,7 +33,7 @@ public function should_return_true_if_source_is_empty() /** * @test */ - public function should_return_false_if_source_emits_element() + public function should_return_false_if_source_emits_element(): void { $xs = $this->createHotObservable([ onNext(150, 'a'), @@ -58,7 +58,7 @@ public function should_return_false_if_source_emits_element() /** * @test */ - public function should_return_true_if_source_emits_before_subscription() + public function should_return_true_if_source_emits_before_subscription(): void { $xs = $this->createHotObservable([ onNext(150, 'a'), @@ -82,7 +82,7 @@ public function should_return_true_if_source_emits_before_subscription() /** * @test */ - public function should_raise_error_if_source_raise_error() + public function should_raise_error_if_source_raise_error(): void { $e = new \Exception(); @@ -106,7 +106,7 @@ public function should_raise_error_if_source_raise_error() /** * @test */ - public function should_not_complete_if_source_never_emits() + public function should_not_complete_if_source_never_emits(): void { $xs = $this->createHotObservable([]); @@ -123,7 +123,7 @@ public function should_not_complete_if_source_never_emits() /** * @test */ - public function should_return_true_if_source_completes_immediately() + public function should_return_true_if_source_completes_immediately(): void { $xs = $this->createHotObservable([ onCompleted(201), @@ -145,7 +145,7 @@ public function should_return_true_if_source_completes_immediately() /** * @test */ - public function should_allow_unsubscribing_explicitly_and_early() + public function should_allow_unsubscribing_explicitly_and_early(): void { $xs = $this->createHotObservable([ onNext(600, 'a'), @@ -166,7 +166,7 @@ public function should_allow_unsubscribing_explicitly_and_early() /** * @test */ - public function should_not_break_unsubscription_chains_when_result_is_unsubscribed_explicitly() + public function should_not_break_unsubscription_chains_when_result_is_unsubscribed_explicitly(): void { $xs = $this->createHotObservable([ onNext(600, 'a'), diff --git a/test/Rx/Functional/Operator/MaterializeTest.php b/test/Rx/Functional/Operator/MaterializeTest.php index 5321d10c..6b04da81 100644 --- a/test/Rx/Functional/Operator/MaterializeTest.php +++ b/test/Rx/Functional/Operator/MaterializeTest.php @@ -20,7 +20,7 @@ private function getNotificationValue(Notification $notification) } $value = null; - $valueGrabber = function ($v) use (&$value) { + $valueGrabber = function ($v) use (&$value): void { $value = $v; }; @@ -52,7 +52,7 @@ public function materializedNotificationsEqual(Notification $a, Notification $b) /** * @test */ - public function materialize_never() + public function materialize_never(): void { $results = $this->scheduler->startWithCreate(function () { return Observable::never()->materialize(); @@ -64,7 +64,7 @@ public function materialize_never() /** * @test */ - public function materialize_empty() + public function materialize_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -84,7 +84,7 @@ public function materialize_empty() /** * @test */ - public function materialize_return() + public function materialize_return(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -106,7 +106,7 @@ public function materialize_return() /** * @test */ - public function materialize_throw() + public function materialize_throw(): void { $error = new \Exception(); @@ -129,7 +129,7 @@ public function materialize_throw() * @test * @requires function Rx\Observable::dematerialize */ - public function materialize_dematerialize_never() + public function materialize_dematerialize_never(): void { $results = $this->scheduler->startWithCreate(function () { return Observable::never()->materialize()->dematerialize(); @@ -142,7 +142,7 @@ public function materialize_dematerialize_never() * @test * @requires function Rx\Observable::dematerialize */ - public function materialize_dematerialize_empty() + public function materialize_dematerialize_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -162,7 +162,7 @@ public function materialize_dematerialize_empty() * @test * @requires function Rx\Observable::dematerialize */ - public function materialize_dematerialize_return() + public function materialize_dematerialize_return(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -184,7 +184,7 @@ public function materialize_dematerialize_return() * @test * @requires function Rx\Observable::dematerialize */ - public function materialize_dematerialize_throw() + public function materialize_dematerialize_throw(): void { $error = new \Exception(); @@ -205,7 +205,7 @@ public function materialize_dematerialize_throw() /** * @test */ - public function materialize_dispose() + public function materialize_dispose(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -228,7 +228,7 @@ public function materialize_dispose() /** * @test */ - public function materialize_dematerialize_dispose() + public function materialize_dematerialize_dispose(): void { $xs = $this->createHotObservable([ onNext(150, 1), diff --git a/test/Rx/Functional/Operator/MaxTest.php b/test/Rx/Functional/Operator/MaxTest.php index 32b978b7..c3d97dfb 100644 --- a/test/Rx/Functional/Operator/MaxTest.php +++ b/test/Rx/Functional/Operator/MaxTest.php @@ -11,7 +11,7 @@ class MaxTest extends FunctionalTestCase /** * @test */ - public function max_number_empty() + public function max_number_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -30,7 +30,7 @@ public function max_number_empty() /** * @test */ - public function max_number_Return() + public function max_number_Return(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -51,7 +51,7 @@ public function max_number_Return() /** * @test */ - public function max_number_Some() + public function max_number_Some(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -74,7 +74,7 @@ public function max_number_Some() /** * @test */ - public function max_number_throw() + public function max_number_throw(): void { $error = new \Exception(); @@ -95,7 +95,7 @@ public function max_number_throw() /** * @test */ - public function max_number_Never() + public function max_number_Never(): void { $xs = $this->createHotObservable([ onNext(150, 1) @@ -111,7 +111,7 @@ public function max_number_Never() /** * @test */ - public function max_comparer_empty() + public function max_comparer_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -120,7 +120,7 @@ public function max_comparer_empty() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->max(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -132,7 +132,7 @@ public function max_comparer_empty() /** * @test */ - public function max_comparer_return() + public function max_comparer_return(): void { $xs = $this->createHotObservable([ onNext(150, 'z'), @@ -142,7 +142,7 @@ public function max_comparer_return() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->max(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -155,7 +155,7 @@ public function max_comparer_return() /** * @test */ - public function max_comparer_some() + public function max_comparer_some(): void { $xs = $this->createHotObservable([ onNext(150, 'z'), @@ -167,7 +167,7 @@ public function max_comparer_some() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->max(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -180,7 +180,7 @@ public function max_comparer_some() /** * @test */ - public function max_comparer_throw() + public function max_comparer_throw(): void { $error = new \Exception(); @@ -191,7 +191,7 @@ public function max_comparer_throw() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->max(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -203,7 +203,7 @@ public function max_comparer_throw() /** * @test */ - public function max_comparer_never() + public function max_comparer_never(): void { $xs = $this->createHotObservable([ onNext(150, 'z') @@ -211,7 +211,7 @@ public function max_comparer_never() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->max(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -221,7 +221,7 @@ public function max_comparer_never() /** * @test */ - public function max_comparer_throws() + public function max_comparer_throws(): void { $error = new \Exception(); @@ -234,7 +234,7 @@ public function max_comparer_throws() ]); $results = $this->scheduler->startWithCreate(function () use ($xs, $error) { - return $xs->max(function () use ($error) { + return $xs->max(function () use ($error): void { throw $error; }); }); @@ -247,7 +247,7 @@ public function max_comparer_throws() /** * @test */ - public function max_never_dispose() + public function max_never_dispose(): void { $error = new \Exception(); @@ -269,7 +269,7 @@ public function max_never_dispose() /** * @test */ - public function max_some_dispose() + public function max_some_dispose(): void { $error = new \Exception(); diff --git a/test/Rx/Functional/Operator/MergeAllTest.php b/test/Rx/Functional/Operator/MergeAllTest.php index ea60da6f..baaa6ced 100644 --- a/test/Rx/Functional/Operator/MergeAllTest.php +++ b/test/Rx/Functional/Operator/MergeAllTest.php @@ -13,52 +13,52 @@ class MergeAllTest extends FunctionalTestCase /** * @test */ - public function it_passes_on_error_from_sources() + public function it_passes_on_error_from_sources(): void { - $xs = $this->createColdObservable(array( + $xs = $this->createColdObservable([ onNext(100, 4), onNext(200, 2), onNext(300, 3), onNext(400, 1), onCompleted(500) - )); + ]); - $ys = $this->createColdObservable(array( + $ys = $this->createColdObservable([ onNext(50, $xs), onError(200, new Exception()), onCompleted(250) - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($ys) { return $ys->mergeAll(); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(350, 4), onError(400, new Exception()), - ), $results->getMessages()); + ], $results->getMessages()); - $this->assertSubscriptions(array(subscribe(250, 400)), $xs->getSubscriptions()); - $this->assertSubscriptions(array(subscribe(200, 400)), $ys->getSubscriptions()); + $this->assertSubscriptions([subscribe(250, 400)], $xs->getSubscriptions()); + $this->assertSubscriptions([subscribe(200, 400)], $ys->getSubscriptions()); } /** * @test */ - public function it_passes_on_completed_from_sources() + public function it_passes_on_completed_from_sources(): void { - $ys = $this->createHotObservable(array( + $ys = $this->createHotObservable([ onCompleted(250), - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($ys) { return $ys->mergeAll(); }); - $this->assertMessages(array( + $this->assertMessages([ onCompleted(250), - ), $results->getMessages()); + ], $results->getMessages()); - $this->assertSubscriptions(array(subscribe(200, 250)), $ys->getSubscriptions()); + $this->assertSubscriptions([subscribe(200, 250)], $ys->getSubscriptions()); } } diff --git a/test/Rx/Functional/Operator/MergeTest.php b/test/Rx/Functional/Operator/MergeTest.php index 3f607861..c646fa3e 100644 --- a/test/Rx/Functional/Operator/MergeTest.php +++ b/test/Rx/Functional/Operator/MergeTest.php @@ -12,29 +12,29 @@ class MergeTest extends FunctionalTestCase /** * @test */ - public function it_passes_the_last_on_complete() + public function it_passes_the_last_on_complete(): void { - $xs = $this->createColdObservable(array( + $xs = $this->createColdObservable([ onNext(100, 4), onNext(200, 2), onNext(300, 3), onNext(400, 1), onCompleted(500) - )); + ]); - $ys = $this->createColdObservable(array( + $ys = $this->createColdObservable([ onNext(50, 'foo'), onNext(100, 'bar'), onNext(150, 'baz'), onNext(200, 'qux'), onCompleted(250) - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs, $ys) { return $xs->merge($ys); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(250, 'foo'), onNext(300, 4), onNext(300, 'bar'), @@ -44,9 +44,9 @@ public function it_passes_the_last_on_complete() onNext(500, 3), onNext(600, 1), onCompleted(700) - ), $results->getMessages()); + ], $results->getMessages()); - $this->assertSubscriptions(array(subscribe(200, 700)), $xs->getSubscriptions()); - $this->assertSubscriptions(array(subscribe(200, 450)), $ys->getSubscriptions()); + $this->assertSubscriptions([subscribe(200, 700)], $xs->getSubscriptions()); + $this->assertSubscriptions([subscribe(200, 450)], $ys->getSubscriptions()); } } diff --git a/test/Rx/Functional/Operator/MinTest.php b/test/Rx/Functional/Operator/MinTest.php index 09002315..c02ee868 100644 --- a/test/Rx/Functional/Operator/MinTest.php +++ b/test/Rx/Functional/Operator/MinTest.php @@ -11,7 +11,7 @@ class MinTest extends FunctionalTestCase /** * @test */ - public function min_number_empty() + public function min_number_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -30,7 +30,7 @@ public function min_number_empty() /** * @test */ - public function min_number_Return() + public function min_number_Return(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -51,7 +51,7 @@ public function min_number_Return() /** * @test */ - public function min_number_Some() + public function min_number_Some(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -74,7 +74,7 @@ public function min_number_Some() /** * @test */ - public function min_number_throw() + public function min_number_throw(): void { $error = new \Exception(); @@ -95,7 +95,7 @@ public function min_number_throw() /** * @test */ - public function min_number_Never() + public function min_number_Never(): void { $xs = $this->createHotObservable([ onNext(150, 1) @@ -111,7 +111,7 @@ public function min_number_Never() /** * @test */ - public function min_comparer_empty() + public function min_comparer_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -120,7 +120,7 @@ public function min_comparer_empty() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->min(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -132,7 +132,7 @@ public function min_comparer_empty() /** * @test */ - public function min_comparer_return() + public function min_comparer_return(): void { $xs = $this->createHotObservable([ onNext(150, 'z'), @@ -142,7 +142,7 @@ public function min_comparer_return() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->min(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -155,7 +155,7 @@ public function min_comparer_return() /** * @test */ - public function min_comparer_some() + public function min_comparer_some(): void { $xs = $this->createHotObservable([ onNext(150, 'z'), @@ -167,7 +167,7 @@ public function min_comparer_some() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->min(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -180,7 +180,7 @@ public function min_comparer_some() /** * @test */ - public function min_comparer_throw() + public function min_comparer_throw(): void { $error = new \Exception(); @@ -191,7 +191,7 @@ public function min_comparer_throw() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->min(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -203,7 +203,7 @@ public function min_comparer_throw() /** * @test */ - public function min_comparer_never() + public function min_comparer_never(): void { $xs = $this->createHotObservable([ onNext(150, 'z') @@ -211,7 +211,7 @@ public function min_comparer_never() $results = $this->scheduler->startWithCreate(function () use ($xs) { return $xs->min(function ($a, $b) { - return $a > $b ? -1 : ($a < $b ? 1 : 0); + return $b <=> $a; }); }); @@ -221,7 +221,7 @@ public function min_comparer_never() /** * @test */ - public function min_comparer_throws() + public function min_comparer_throws(): void { $error = new \Exception(); @@ -234,7 +234,7 @@ public function min_comparer_throws() ]); $results = $this->scheduler->startWithCreate(function () use ($xs, $error) { - return $xs->min(function () use ($error) { + return $xs->min(function () use ($error): void { throw $error; }); }); @@ -247,7 +247,7 @@ public function min_comparer_throws() /** * @test */ - public function min_never_dispose() + public function min_never_dispose(): void { $error = new \Exception(); @@ -269,7 +269,7 @@ public function min_never_dispose() /** * @test */ - public function min_some_dispose() + public function min_some_dispose(): void { $error = new \Exception(); diff --git a/test/Rx/Functional/Operator/MulticastTest.php b/test/Rx/Functional/Operator/MulticastTest.php index 1e34aae6..641a3abf 100644 --- a/test/Rx/Functional/Operator/MulticastTest.php +++ b/test/Rx/Functional/Operator/MulticastTest.php @@ -25,7 +25,7 @@ public function add($x, $y) /** * @test */ - public function multicast_hot_1() + public function multicast_hot_1(): void { $xs = $this->createHotObservable([ @@ -46,19 +46,19 @@ public function multicast_hot_1() $d2 = null; $subject = new Subject(); - $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject) { + $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject): void { $ys = $xs->multicast($subject); }); - $this->scheduler->scheduleAbsolute(100, function () use (&$d1, &$ys, $observer) { + $this->scheduler->scheduleAbsolute(100, function () use (&$d1, &$ys, $observer): void { $d1 = $ys->subscribe($observer); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$d2, &$ys) { + $this->scheduler->scheduleAbsolute(200, function () use (&$d2, &$ys): void { $d2 = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$d1) { + $this->scheduler->scheduleAbsolute(300, function () use (&$d1): void { $d1->dispose(); }); @@ -84,7 +84,7 @@ public function multicast_hot_1() /** * @test */ - public function multicast_hot_2() + public function multicast_hot_2(): void { $xs = $this->createHotObservable([ @@ -105,20 +105,20 @@ public function multicast_hot_2() $d2 = null; $subject = new Subject(); - $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject) { + $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject): void { $ys = $xs->multicast($subject); }); - $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys) { + $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys): void { $d2 = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$d1, &$ys, $observer) { + $this->scheduler->scheduleAbsolute(200, function () use (&$d1, &$ys, $observer): void { $d1 = $ys->subscribe($observer); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$d1) { + $this->scheduler->scheduleAbsolute(300, function () use (&$d1): void { $d1->dispose(); }); @@ -144,7 +144,7 @@ public function multicast_hot_2() /** * @test */ - public function multicast_hot_3() + public function multicast_hot_3(): void { $xs = $this->createHotObservable([ @@ -165,23 +165,23 @@ public function multicast_hot_3() $d2 = null; $subject = new Subject(); - $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject) { + $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject): void { $ys = $xs->multicast($subject); }); - $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys) { + $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys): void { $d2 = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$d1, &$ys, $observer) { + $this->scheduler->scheduleAbsolute(200, function () use (&$d1, &$ys, $observer): void { $d1 = $ys->subscribe($observer); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$d2) { + $this->scheduler->scheduleAbsolute(300, function () use (&$d2): void { $d2->dispose(); }); - $this->scheduler->scheduleAbsolute(335, function () use (&$d2, &$ys) { + $this->scheduler->scheduleAbsolute(335, function () use (&$d2, &$ys): void { $d2 = $ys->connect(); }); @@ -208,7 +208,7 @@ public function multicast_hot_3() /** * @test */ - public function multicast_hot_error_1() + public function multicast_hot_error_1(): void { $error = new \Exception(); @@ -230,23 +230,23 @@ public function multicast_hot_error_1() $d2 = null; $subject = new Subject(); - $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject) { + $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject): void { $ys = $xs->multicast($subject); }); - $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys) { + $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys): void { $d2 = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$d1, &$ys, $observer) { + $this->scheduler->scheduleAbsolute(200, function () use (&$d1, &$ys, $observer): void { $d1 = $ys->subscribe($observer); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$d2) { + $this->scheduler->scheduleAbsolute(300, function () use (&$d2): void { $d2->dispose(); }); - $this->scheduler->scheduleAbsolute(335, function () use (&$d2, &$ys) { + $this->scheduler->scheduleAbsolute(335, function () use (&$d2, &$ys): void { $d2 = $ys->connect(); }); @@ -275,7 +275,7 @@ public function multicast_hot_error_1() /** * @test */ - public function multicast_hot_error_2() + public function multicast_hot_error_2(): void { $error = new \Exception(); @@ -297,15 +297,15 @@ public function multicast_hot_error_2() $d2 = null; $subject = new Subject(); - $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject) { + $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject): void { $ys = $xs->multicast($subject); }); - $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys) { + $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys): void { $d2 = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$d1, &$ys, $observer) { + $this->scheduler->scheduleAbsolute(400, function () use (&$d1, &$ys, $observer): void { $d1 = $ys->subscribe($observer); }); @@ -328,7 +328,7 @@ public function multicast_hot_error_2() /** * @test */ - public function multicast_hot_completed() + public function multicast_hot_completed(): void { $xs = $this->createHotObservable([ @@ -349,15 +349,15 @@ public function multicast_hot_completed() $d2 = null; $subject = new Subject(); - $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject) { + $this->scheduler->scheduleAbsolute(50, function () use (&$ys, $xs, $subject): void { $ys = $xs->multicast($subject); }); - $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys) { + $this->scheduler->scheduleAbsolute(100, function () use (&$d2, &$ys): void { $d2 = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$d1, &$ys, $observer) { + $this->scheduler->scheduleAbsolute(400, function () use (&$d1, &$ys, $observer): void { $d1 = $ys->subscribe($observer); }); @@ -379,7 +379,7 @@ public function multicast_hot_completed() /** * @test */ - public function multicast_cold_completed() + public function multicast_cold_completed(): void { $xs = $this->createHotObservable([ @@ -426,7 +426,7 @@ function ($ys) { /** * @test */ - public function multicast_cold_error() + public function multicast_cold_error(): void { $error = new \Exception(); @@ -473,7 +473,7 @@ function ($ys) { /** * @test */ - public function multicast_cold_dispose() + public function multicast_cold_dispose(): void { $xs = $this->createHotObservable([ @@ -517,7 +517,7 @@ function ($ys) { /** * @test */ - public function multicast_cold_zip() + public function multicast_cold_zip(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/NeverTest.php b/test/Rx/Functional/Operator/NeverTest.php index f56466b2..22fc8847 100644 --- a/test/Rx/Functional/Operator/NeverTest.php +++ b/test/Rx/Functional/Operator/NeverTest.php @@ -13,7 +13,7 @@ class NeverTest extends FunctionalTestCase /** * @test */ - public function never_basic() + public function never_basic(): void { $xs = Observable::never(); diff --git a/test/Rx/Functional/Operator/PartitionTest.php b/test/Rx/Functional/Operator/PartitionTest.php index ba5b9111..e2be7612 100644 --- a/test/Rx/Functional/Operator/PartitionTest.php +++ b/test/Rx/Functional/Operator/PartitionTest.php @@ -19,7 +19,7 @@ public function isEven($num) /** * @test */ - public function partitionEmpty() + public function partitionEmpty(): void { $xs = $this->createHotObservable([ onNext(180, 5), @@ -33,16 +33,16 @@ public function partitionEmpty() $r1 = $this->scheduler->createObserver(); $r2 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs): void { $observables = $xs->partition([$this, 'isEven']); }); - $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2) { + $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2): void { $s1 = $observables[0]->subscribe($r1); $s2 = $observables[1]->subscribe($r2); }); - $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2) { + $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2): void { $s1->dispose(); $s2->dispose(); }); @@ -64,7 +64,7 @@ public function partitionEmpty() /** * @test */ - public function partitionSingle() + public function partitionSingle(): void { $xs = $this->createHotObservable([ onNext(180, 5), @@ -79,16 +79,16 @@ public function partitionSingle() $r1 = $this->scheduler->createObserver(); $r2 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs): void { $observables = $xs->partition([$this, 'isEven']); }); - $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2) { + $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2): void { $s1 = $observables[0]->subscribe($r1); $s2 = $observables[1]->subscribe($r2); }); - $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2) { + $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2): void { $s1->dispose(); $s2->dispose(); }); @@ -122,7 +122,7 @@ public function partitionSingle() /** * @test */ - public function partitionEach() + public function partitionEach(): void { $xs = $this->createHotObservable([ onNext(180, 5), @@ -138,16 +138,16 @@ public function partitionEach() $r1 = $this->scheduler->createObserver(); $r2 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs): void { $observables = $xs->partition([$this, 'isEven']); }); - $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2) { + $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2): void { $s1 = $observables[0]->subscribe($r1); $s2 = $observables[1]->subscribe($r2); }); - $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2) { + $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2): void { $s1->dispose(); $s2->dispose(); }); @@ -182,7 +182,7 @@ public function partitionEach() /** * @test */ - public function partitionCompleted() + public function partitionCompleted(): void { $xs = $this->createHotObservable([ onNext(180, 5), @@ -200,16 +200,16 @@ public function partitionCompleted() $r1 = $this->scheduler->createObserver(); $r2 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs): void { $observables = $xs->partition([$this, 'isEven']); }); - $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2) { + $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2): void { $s1 = $observables[0]->subscribe($r1); $s2 = $observables[1]->subscribe($r2); }); - $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2) { + $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2): void { $s1->dispose(); $s2->dispose(); }); @@ -246,7 +246,7 @@ public function partitionCompleted() /** * @test */ - public function partitionNotCompleted() + public function partitionNotCompleted(): void { $xs = $this->createHotObservable([ onNext(180, 5), @@ -263,16 +263,16 @@ public function partitionNotCompleted() $r1 = $this->scheduler->createObserver(); $r2 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs): void { $observables = $xs->partition([$this, 'isEven']); }); - $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2) { + $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2): void { $s1 = $observables[0]->subscribe($r1); $s2 = $observables[1]->subscribe($r2); }); - $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2) { + $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2): void { $s1->dispose(); $s2->dispose(); }); @@ -307,7 +307,7 @@ public function partitionNotCompleted() /** * @test */ - public function partitionError() + public function partitionError(): void { $error = new \Exception('error1'); @@ -327,16 +327,16 @@ public function partitionError() $r1 = $this->scheduler->createObserver(); $r2 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs): void { $observables = $xs->partition([$this, 'isEven']); }); - $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2) { + $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2): void { $s1 = $observables[0]->subscribe($r1); $s2 = $observables[1]->subscribe($r2); }); - $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2) { + $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use (&$s1, &$s2): void { $s1->dispose(); $s2->dispose(); }); @@ -371,7 +371,7 @@ public function partitionError() /** * @test */ - public function partitionDisposed() + public function partitionDisposed(): void { $xs = $this->createHotObservable([ onNext(180, 5), @@ -389,16 +389,16 @@ public function partitionDisposed() $r1 = $this->scheduler->createObserver(); $r2 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs) { + $this->scheduler->scheduleAbsolute(TestScheduler::CREATED, function () use (&$observables, $xs): void { $observables = $xs->partition([$this, 'isEven']); }); - $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2) { + $this->scheduler->scheduleAbsolute(TestScheduler::SUBSCRIBED, function () use (&$observables, &$s1, &$s2, $r1, $r2): void { $s1 = $observables[0]->subscribe($r1); $s2 = $observables[1]->subscribe($r2); }); - $this->scheduler->scheduleAbsolute(280, function () use (&$s1, &$s2) { + $this->scheduler->scheduleAbsolute(280, function () use (&$s1, &$s2): void { $s1->dispose(); $s2->dispose(); }); diff --git a/test/Rx/Functional/Operator/PluckTest.php b/test/Rx/Functional/Operator/PluckTest.php index 61c4961d..492b880f 100644 --- a/test/Rx/Functional/Operator/PluckTest.php +++ b/test/Rx/Functional/Operator/PluckTest.php @@ -11,7 +11,7 @@ class PluckTest extends FunctionalTestCase /** * @test */ - public function pluck_completed() + public function pluck_completed(): void { $xs = $this->createHotObservable([ onNext(180, (object)['prop' => 1]), @@ -45,7 +45,7 @@ public function pluck_completed() /** * @test */ - public function pluck_error() + public function pluck_error(): void { $xs = $this->createHotObservable([ onNext(180, ['prop' => 1]), @@ -76,7 +76,7 @@ public function pluck_error() /** * @test */ - public function pluck_completed_array() + public function pluck_completed_array(): void { $xs = $this->createHotObservable([ onNext(180, ['prop' => 1]), @@ -107,7 +107,7 @@ public function pluck_completed_array() /** * @test */ - public function pluck_array_index_missing() + public function pluck_array_index_missing(): void { $xs = $this->createHotObservable([ onNext(180, ['prop' => 1]), @@ -136,7 +136,7 @@ public function pluck_array_index_missing() /** * @test */ - public function pluck_object_property_missing() + public function pluck_object_property_missing(): void { $xs = $this->createHotObservable([ onNext(180, (object)['prop' => 1]), @@ -165,7 +165,7 @@ public function pluck_object_property_missing() /** * @test */ - public function pluck_array_numeric_index() + public function pluck_array_numeric_index(): void { $xs = $this->createHotObservable([ onNext(180, [-1,-1,-1,-1]), @@ -196,7 +196,7 @@ public function pluck_array_numeric_index() /** * @test */ - public function pluck_nested() + public function pluck_nested(): void { $xs = $this->createHotObservable([ onNext(180, [-1,-1,-1,-1]), @@ -227,7 +227,7 @@ public function pluck_nested() /** * @test */ - public function pluck_nested_numeric_key_with_object_properties() + public function pluck_nested_numeric_key_with_object_properties(): void { $xs = $this->createHotObservable([ onNext(180, [-1,-1,-1,-1]), @@ -258,7 +258,7 @@ public function pluck_nested_numeric_key_with_object_properties() /** * @test */ - public function pluck_object_property_null() + public function pluck_object_property_null(): void { $xs = $this->createHotObservable([ onNext(180, (object)['prop' => 1]), @@ -289,7 +289,7 @@ public function pluck_object_property_null() /** * @test */ - public function pluck_array_assoc_null() + public function pluck_array_assoc_null(): void { $xs = $this->createHotObservable([ onNext(180, ['prop' => 1]), diff --git a/test/Rx/Functional/Operator/PublishLastTest.php b/test/Rx/Functional/Operator/PublishLastTest.php index b1d00946..a2690c16 100644 --- a/test/Rx/Functional/Operator/PublishLastTest.php +++ b/test/Rx/Functional/Operator/PublishLastTest.php @@ -19,7 +19,7 @@ public function add($x, $y) /** * @test */ - public function publishLast_basic() + public function publishLast_basic(): void { $xs = $this->createHotObservable([ @@ -46,39 +46,39 @@ public function publishLast_basic() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publishLast(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -101,7 +101,7 @@ public function publishLast_basic() /** * @test */ - public function publishLast_error() + public function publishLast_error(): void { $error = new \Exception(); @@ -130,31 +130,31 @@ public function publishLast_error() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publishLast(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -179,7 +179,7 @@ public function publishLast_error() /** * @test */ - public function publishLast_complete() + public function publishLast_complete(): void { $xs = $this->createHotObservable([ @@ -206,31 +206,31 @@ public function publishLast_complete() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publishLast(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -257,7 +257,7 @@ public function publishLast_complete() /** * @test */ - public function publishLast_dispose() + public function publishLast_dispose(): void { $xs = $this->createHotObservable([ @@ -284,39 +284,39 @@ public function publishLast_dispose() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publishLast(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(350, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(350, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -338,7 +338,7 @@ public function publishLast_dispose() /** * @test */ - public function publishLast_multiple_connections() + public function publishLast_multiple_connections(): void { $xs = new NeverObservable(); $ys = $xs->publishLast(); @@ -360,7 +360,7 @@ public function publishLast_multiple_connections() /** * @test */ - public function publishLast_zip_complete() + public function publishLast_zip_complete(): void { $xs = $this->createHotObservable([ @@ -403,7 +403,7 @@ public function publishLast_zip_complete() /** * @test */ - public function publishLast_zip_errorr() + public function publishLast_zip_errorr(): void { $error = new \Exception(); @@ -447,7 +447,7 @@ public function publishLast_zip_errorr() /** * @test */ - public function publishLast_zip_dispose() + public function publishLast_zip_dispose(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/PublishTest.php b/test/Rx/Functional/Operator/PublishTest.php index 4c11bb8b..21acdbd7 100644 --- a/test/Rx/Functional/Operator/PublishTest.php +++ b/test/Rx/Functional/Operator/PublishTest.php @@ -23,7 +23,7 @@ public function add($x, $y) /** * @test */ - public function publish_cold_zip() + public function publish_cold_zip(): void { $xs = $this->createHotObservable([ @@ -66,7 +66,7 @@ public function publish_cold_zip() /** * @test */ - public function refCount_connects_on_first() + public function refCount_connects_on_first(): void { $xs = $this->createHotObservable([ @@ -100,7 +100,7 @@ public function refCount_connects_on_first() /** * @test */ - public function refCount_not_connected() + public function refCount_not_connected(): void { $disconnected = false; @@ -111,7 +111,7 @@ public function refCount_not_connected() $count++; return new AnonymousObservable(function () use (&$disconnected) { - return new CallbackDisposable(function () use (&$disconnected) { + return new CallbackDisposable(function () use (&$disconnected): void { $disconnected = true; }); }); @@ -156,7 +156,7 @@ public function refCount_not_connected() /** * @test */ - public function refCount_publish_basic() + public function refCount_publish_basic(): void { $xs = $this->createHotObservable([ @@ -183,39 +183,39 @@ public function refCount_publish_basic() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publish(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -246,7 +246,7 @@ public function refCount_publish_basic() /** * @test */ - public function publish_error() + public function publish_error(): void { $error = new \Exception(); @@ -275,31 +275,31 @@ public function publish_error() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publish(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -330,7 +330,7 @@ public function publish_error() /** * @test */ - public function publish_complete() + public function publish_complete(): void { $xs = $this->createHotObservable([ @@ -357,31 +357,31 @@ public function publish_complete() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publish(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -413,7 +413,7 @@ public function publish_complete() /** * @test */ - public function publish_dispose() + public function publish_dispose(): void { $xs = $this->createHotObservable([ @@ -440,39 +440,39 @@ public function publish_dispose() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publish(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(350, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(350, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -498,7 +498,7 @@ public function publish_dispose() /** * @test */ - public function publish_lambda_zip_complete() + public function publish_lambda_zip_complete(): void { $xs = $this->createHotObservable([ onNext(110, 7), @@ -550,7 +550,7 @@ public function publish_lambda_zip_complete() /** * @test */ - public function publish_lambda_zip_error() + public function publish_lambda_zip_error(): void { $error = new \Exception(); @@ -605,7 +605,7 @@ public function publish_lambda_zip_error() /** * @test */ - public function publish_lambda_zip_dispose() + public function publish_lambda_zip_dispose(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/PublishValueTest.php b/test/Rx/Functional/Operator/PublishValueTest.php index c6fe36db..c0bd5d43 100644 --- a/test/Rx/Functional/Operator/PublishValueTest.php +++ b/test/Rx/Functional/Operator/PublishValueTest.php @@ -19,7 +19,7 @@ public function add($x, $y) /** * @test */ - public function publishLast_basic() + public function publishLast_basic(): void { $xs = $this->createHotObservable([ @@ -46,39 +46,39 @@ public function publishLast_basic() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publishValue(1979); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -109,7 +109,7 @@ public function publishLast_basic() /** * @test */ - public function publishValue_error() + public function publishValue_error(): void { $error = new \Exception(); @@ -138,31 +138,31 @@ public function publishValue_error() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publishValue(1979); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -194,7 +194,7 @@ public function publishValue_error() /** * @test */ - public function publishValue_complete() + public function publishValue_complete(): void { $xs = $this->createHotObservable([ @@ -221,31 +221,31 @@ public function publishValue_complete() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publishValue(1979); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -278,7 +278,7 @@ public function publishValue_complete() /** * @test */ - public function publishValue_dispose() + public function publishValue_dispose(): void { $xs = $this->createHotObservable([ @@ -305,39 +305,39 @@ public function publishValue_dispose() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->publishValue(1979); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(350, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(350, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -362,7 +362,7 @@ public function publishValue_dispose() /** * @test */ - public function publishValue_multiple_connections() + public function publishValue_multiple_connections(): void { $xs = new NeverObservable(); $ys = $xs->publishValue(1979); @@ -384,7 +384,7 @@ public function publishValue_multiple_connections() /** * @test */ - public function publishValue_zip_complete() + public function publishValue_zip_complete(): void { $xs = $this->createHotObservable([ @@ -438,7 +438,7 @@ public function publishValue_zip_complete() /** * @test */ - public function publishValue_zip_error() + public function publishValue_zip_error(): void { $error = new \Exception(); @@ -494,7 +494,7 @@ public function publishValue_zip_error() /** * @test */ - public function publishValue_zip_dispose() + public function publishValue_zip_dispose(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/RaceTest.php b/test/Rx/Functional/Operator/RaceTest.php index a9670aee..02467010 100644 --- a/test/Rx/Functional/Operator/RaceTest.php +++ b/test/Rx/Functional/Operator/RaceTest.php @@ -12,7 +12,7 @@ class RaceTest extends FunctionalTestCase /** * @test */ - public function race_never_2() + public function race_never_2(): void { $n1 = Observable::never(); $n2 = Observable::never(); @@ -30,7 +30,7 @@ public function race_never_2() /** * @test */ - public function race_never_3() + public function race_never_3(): void { $n1 = Observable::never(); $n2 = Observable::never(); @@ -49,7 +49,7 @@ public function race_never_3() /** * @test */ - public function race_never_empty() + public function race_never_empty(): void { $n1 = Observable::never(); $e = $this->createHotObservable([ @@ -72,7 +72,7 @@ public function race_never_empty() /** * @test */ - public function race_empty_never() + public function race_empty_never(): void { $n1 = Observable::never(); $e = $this->createHotObservable([ @@ -95,7 +95,7 @@ public function race_empty_never() /** * @test */ - public function race_regular_should_dispose_loser() + public function race_regular_should_dispose_loser(): void { $sourceNotDisposed = false; @@ -105,7 +105,7 @@ public function race_regular_should_dispose_loser() onNext(150, 1), onNext(220, 2), onError(230, $error) - ])->doOnNext(function () use (&$sourceNotDisposed) { + ])->doOnNext(function () use (&$sourceNotDisposed): void { $sourceNotDisposed = true; }); @@ -133,7 +133,7 @@ public function race_regular_should_dispose_loser() /** * @test */ - public function race_throws_before_election() + public function race_throws_before_election(): void { $sourceNotDisposed = false; @@ -148,7 +148,7 @@ public function race_throws_before_election() onNext(150, 1), onNext(220, 3), onCompleted(250) - ])->doOnNext(function () use (&$sourceNotDisposed) { + ])->doOnNext(function () use (&$sourceNotDisposed): void { $sourceNotDisposed = true; }); @@ -169,7 +169,7 @@ public function race_throws_before_election() /** * @test */ - public function race_none() + public function race_none(): void { $results = $this->scheduler->startWithCreate(function () { return Observable::race([], $this->scheduler); @@ -181,7 +181,7 @@ public function race_none() /** * @test */ - public function race_one() + public function race_one(): void { $e = $this->createHotObservable([ onNext(150, 1), diff --git a/test/Rx/Functional/Operator/RangeTest.php b/test/Rx/Functional/Operator/RangeTest.php index a4381c84..5435ee25 100644 --- a/test/Rx/Functional/Operator/RangeTest.php +++ b/test/Rx/Functional/Operator/RangeTest.php @@ -14,7 +14,7 @@ class RangeTest extends FunctionalTestCase /** * @test */ - public function range_zero() + public function range_zero(): void { $results = $this->scheduler->startWithCreate(function () { @@ -32,7 +32,7 @@ public function range_zero() /** * @test */ - public function range_one() + public function range_one(): void { $results = $this->scheduler->startWithCreate(function () { @@ -51,7 +51,7 @@ public function range_one() /** * @test */ - public function range_five() + public function range_five(): void { $results = $this->scheduler->startWithCreate(function () { @@ -74,7 +74,7 @@ public function range_five() /** * @test */ - public function range_dispose() + public function range_dispose(): void { $results = $this->scheduler->startWithDispose(function () { diff --git a/test/Rx/Functional/Operator/ReduceTest.php b/test/Rx/Functional/Operator/ReduceTest.php index 3a0afb3e..d09ff67b 100644 --- a/test/Rx/Functional/Operator/ReduceTest.php +++ b/test/Rx/Functional/Operator/ReduceTest.php @@ -16,7 +16,7 @@ class ReduceTest extends FunctionalTestCase /** * @test */ - public function reduce_with_seed_empty() + public function reduce_with_seed_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -36,7 +36,7 @@ public function reduce_with_seed_empty() /** * @test */ - public function reduce_with_seed_return() + public function reduce_with_seed_return(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -56,7 +56,7 @@ public function reduce_with_seed_return() /** * @test */ - public function reduce_with_seed_throw() + public function reduce_with_seed_throw(): void { $ex = new \Exception('ex'); $xs = $this->createHotObservable([ @@ -76,7 +76,7 @@ public function reduce_with_seed_throw() /** * @test */ - public function reduce_with_seed_never() + public function reduce_with_seed_never(): void { $xs = $this->createHotObservable([ onNext(150, 1) @@ -94,7 +94,7 @@ public function reduce_with_seed_never() /** * @test */ - public function reduce_with_seed_range() + public function reduce_with_seed_range(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -118,7 +118,7 @@ public function reduce_with_seed_range() /** * @test */ - public function reduce_without_seed_empty() + public function reduce_without_seed_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -142,7 +142,7 @@ public function reduce_without_seed_empty() /** * @test */ - public function reduce_without_seed_return() + public function reduce_without_seed_return(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -162,7 +162,7 @@ public function reduce_without_seed_return() /** * @test */ - public function reduce_without_seed_throw() + public function reduce_without_seed_throw(): void { $ex = new \Exception('ex'); $xs = $this->createHotObservable([ @@ -182,7 +182,7 @@ public function reduce_without_seed_throw() /** * @test */ - public function reduce_without_seed_never() + public function reduce_without_seed_never(): void { $xs = $this->createHotObservable([ onNext(150, 1) @@ -200,7 +200,7 @@ public function reduce_without_seed_never() /** * @test */ - public function reduce_without_seed_range() + public function reduce_without_seed_range(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -224,7 +224,7 @@ public function reduce_without_seed_range() /** * @test */ - public function reduce_accumulator_throws() + public function reduce_accumulator_throws(): void { $xs = $this->createHotObservable( [ @@ -235,7 +235,7 @@ public function reduce_accumulator_throws() ]); $results = $this->scheduler->startWithCreate(function () use ($xs) { - return $xs->reduce(function () { + return $xs->reduce(function (): void { throw new \Exception(); }); }); @@ -246,7 +246,7 @@ public function reduce_accumulator_throws() /** * @test */ - public function reduce_accumulator_throws_with_seed() + public function reduce_accumulator_throws_with_seed(): void { $xs = $this->createHotObservable( [ @@ -257,7 +257,7 @@ public function reduce_accumulator_throws_with_seed() ]); $results = $this->scheduler->startWithCreate(function () use ($xs) { - return $xs->reduce(function () { + return $xs->reduce(function (): void { throw new \Exception(); }, 42); }); @@ -268,7 +268,7 @@ public function reduce_accumulator_throws_with_seed() /** * @test */ - public function reduce_with_falsy_seed_range() + public function reduce_with_falsy_seed_range(): void { $xs = $this->createHotObservable([ onNext(150, 1), diff --git a/test/Rx/Functional/Operator/RepeatTest.php b/test/Rx/Functional/Operator/RepeatTest.php index 3e698842..a7f93fd3 100644 --- a/test/Rx/Functional/Operator/RepeatTest.php +++ b/test/Rx/Functional/Operator/RepeatTest.php @@ -16,7 +16,7 @@ class RepeatTest extends FunctionalTestCase /** * @test */ - public function repeat_Observable_basic() + public function repeat_Observable_basic(): void { $xs = $this->createColdObservable([ onNext(100, 1), @@ -58,7 +58,7 @@ public function repeat_Observable_basic() /** * @test */ - public function repeat_Observable_infinite() + public function repeat_Observable_infinite(): void { $xs = $this->createColdObservable([ onNext(100, 1), @@ -90,7 +90,7 @@ public function repeat_Observable_infinite() /** * @test */ - public function repeat_Observable_error() + public function repeat_Observable_error(): void { $error = new \Exception(); @@ -126,7 +126,7 @@ public function repeat_Observable_error() /** * @test */ - public function repeat_Observable_throws_1() + public function repeat_Observable_throws_1(): void { $this->expectException(\Exception::class); $scheduler1 = new TestScheduler(); @@ -134,7 +134,7 @@ public function repeat_Observable_throws_1() $xs = (new ReturnObservable(1, $scheduler1))->repeat(); $xs->subscribe(new CallbackObserver( - function ($x) { + function ($x): void { throw new \Exception(); } )); @@ -145,7 +145,7 @@ function ($x) { /** * @test */ - public function repeat_Observable_throws_2() + public function repeat_Observable_throws_2(): void { $this->expectException(\Exception::class); $scheduler2 = new TestScheduler(); @@ -154,7 +154,7 @@ public function repeat_Observable_throws_2() $xs->subscribe(new CallbackObserver( null, - function ($x) { + function ($x): void { throw new \Exception(); } )); @@ -166,7 +166,7 @@ function ($x) { * @test * @doesNotPerformAssertions */ - public function repeat_Observable_throws_3() + public function repeat_Observable_throws_3(): void { $scheduler3 = new TestScheduler(); $xs = (new ReturnObservable(1, $scheduler3))->repeat(); @@ -174,12 +174,12 @@ public function repeat_Observable_throws_3() $disp = $xs->subscribe(new CallbackObserver( null, null, - function () { + function (): void { throw new \Exception; } )); - $scheduler3->scheduleAbsolute(210, function () use ($disp) { + $scheduler3->scheduleAbsolute(210, function () use ($disp): void { $disp->dispose(); }); @@ -189,10 +189,10 @@ function () { /** * @test */ - public function repeat_Observable_throws_4() + public function repeat_Observable_throws_4(): void { $this->expectException(\Exception::class); - $xs = (new AnonymousObservable(function () { + $xs = (new AnonymousObservable(function (): void { throw new \Exception; }))->repeat(); @@ -202,7 +202,7 @@ public function repeat_Observable_throws_4() /** * @test */ - public function repeat_Observable_repeat_count_basic() + public function repeat_Observable_repeat_count_basic(): void { $xs = $this->createColdObservable([ onNext(5, 1), @@ -244,7 +244,7 @@ public function repeat_Observable_repeat_count_basic() /** * @test */ - public function repeat_Observable_repeat_count_dispose() + public function repeat_Observable_repeat_count_dispose(): void { $xs = $this->createColdObservable([ onNext(5, 1), @@ -280,7 +280,7 @@ public function repeat_Observable_repeat_count_dispose() /** * @test */ - public function repeat_Observable_repeat_count_infinite() + public function repeat_Observable_repeat_count_infinite(): void { $xs = $this->createColdObservable([ onNext(100, 1), @@ -312,7 +312,7 @@ public function repeat_Observable_repeat_count_infinite() /** * @test */ - public function repeat_Observable_repeat_count_error() + public function repeat_Observable_repeat_count_error(): void { $error = new \Exception(); @@ -348,7 +348,7 @@ public function repeat_Observable_repeat_count_error() /** * @test */ - public function repeat_Observable_repeat_count_throws_1() + public function repeat_Observable_repeat_count_throws_1(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('from onNext'); @@ -356,7 +356,7 @@ public function repeat_Observable_repeat_count_throws_1() $xs = (new ReturnObservable(1, $scheduler1))->repeat(3); $xs->subscribe(new CallbackObserver( - function ($x) { + function ($x): void { throw new \Exception('from onNext'); } )); @@ -367,7 +367,7 @@ function ($x) { /** * @test */ - public function repeat_Observable_repeat_count_throws_2() + public function repeat_Observable_repeat_count_throws_2(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('from onError'); @@ -377,7 +377,7 @@ public function repeat_Observable_repeat_count_throws_2() $xs->subscribe(new CallbackObserver( null, - function ($x) { + function ($x): void { throw new \Exception('from onError'); } )); @@ -388,7 +388,7 @@ function ($x) { /** * @test */ - public function repeat_Observable_repeat_count_throws_3() + public function repeat_Observable_repeat_count_throws_3(): void { $this->expectException(\Exception::class); $scheduler3 = new TestScheduler(); @@ -398,7 +398,7 @@ public function repeat_Observable_repeat_count_throws_3() $xs->subscribe(new CallbackObserver( null, null, - function () { + function (): void { throw new \Exception('from onCompleted'); } )); @@ -409,11 +409,11 @@ function () { /** * @test */ - public function repeat_Observable_repeat_count_throws_4() + public function repeat_Observable_repeat_count_throws_4(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('from Anon'); - $xss = (new AnonymousObservable(function () { + $xss = (new AnonymousObservable(function (): void { throw new \Exception('from Anon'); }))->repeat(3); @@ -423,7 +423,7 @@ public function repeat_Observable_repeat_count_throws_4() /** * @test */ - public function repeat_returns_empty_when_count_is_zero() + public function repeat_returns_empty_when_count_is_zero(): void { $xs = $this->createColdObservable([ onNext(5, 1), diff --git a/test/Rx/Functional/Operator/RepeatWhenTest.php b/test/Rx/Functional/Operator/RepeatWhenTest.php index 611203ef..6595c638 100644 --- a/test/Rx/Functional/Operator/RepeatWhenTest.php +++ b/test/Rx/Functional/Operator/RepeatWhenTest.php @@ -13,7 +13,7 @@ class RepeatWhenTest extends FunctionalTestCase /** * @test */ - public function repeatWhen_never() + public function repeatWhen_never(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -38,7 +38,7 @@ public function repeatWhen_never() /** * @test */ - public function repeatWhen_Observable_never() + public function repeatWhen_Observable_never(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -70,7 +70,7 @@ public function repeatWhen_Observable_never() /** * @test */ - public function repeatWhen_Observable_empty() + public function repeatWhen_Observable_empty(): void { $xs = $this->createColdObservable([ onNext(100, 1), @@ -100,7 +100,7 @@ public function repeatWhen_Observable_empty() /** * @test */ - public function repeatWhen_next_error() + public function repeatWhen_next_error(): void { $error = new Exception("test"); @@ -137,7 +137,7 @@ public function repeatWhen_next_error() /** * @test */ - public function repeatWhen_Observable_complete() + public function repeatWhen_Observable_complete(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -165,7 +165,7 @@ public function repeatWhen_Observable_complete() /** * @test */ - public function repeatWhen_Observable_next_complete() + public function repeatWhen_Observable_next_complete(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -202,7 +202,7 @@ public function repeatWhen_Observable_next_complete() /** * @test */ - public function repeatWhen_Observable_infinite() + public function repeatWhen_Observable_infinite(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -229,7 +229,7 @@ public function repeatWhen_Observable_infinite() /** * @test */ - public function repeatWhen_Observable_dispose() + public function repeatWhen_Observable_dispose(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -259,7 +259,7 @@ public function repeatWhen_Observable_dispose() /** * @test */ - public function repeatWhen_Observable_dispose_second() + public function repeatWhen_Observable_dispose_second(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -294,7 +294,7 @@ public function repeatWhen_Observable_dispose_second() /** * @test */ - public function repeatWhen_Observable_dispose_between() + public function repeatWhen_Observable_dispose_between(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -327,7 +327,7 @@ public function repeatWhen_Observable_dispose_between() /** * @test */ - public function repeatWhen_notifier_throws() + public function repeatWhen_notifier_throws(): void { $xs = $this->createColdObservable([ onNext(150, 1), @@ -339,7 +339,7 @@ public function repeatWhen_notifier_throws() ]); $results = $this->scheduler->startWithCreate(function () use ($xs) { - return $xs->repeatWhen(function (Observable $attempts) { + return $xs->repeatWhen(function (Observable $attempts): void { throw new Exception('error'); }); }); @@ -354,7 +354,7 @@ public function repeatWhen_notifier_throws() /** * @test */ - public function repeatWhen_notifier_returns_invalid_string() + public function repeatWhen_notifier_returns_invalid_string(): void { $xs = $this->createColdObservable([ onNext(150, 1), diff --git a/test/Rx/Functional/Operator/ReplayTest.php b/test/Rx/Functional/Operator/ReplayTest.php index c195fa4f..38359c2f 100644 --- a/test/Rx/Functional/Operator/ReplayTest.php +++ b/test/Rx/Functional/Operator/ReplayTest.php @@ -13,7 +13,7 @@ class ReplayTest extends FunctionalTestCase /** * @test */ - public function replay_count_basic() + public function replay_count_basic(): void { $xs = $this->createHotObservable([ @@ -40,39 +40,39 @@ public function replay_count_basic() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->replay(null, 3, null, $this->scheduler); }); - $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -102,7 +102,7 @@ public function replay_count_basic() /** * @test */ - public function replay_count_error() + public function replay_count_error(): void { $error = new \Exception(); @@ -131,31 +131,31 @@ public function replay_count_error() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->replay(null, 3, null, $this->scheduler); }); - $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -185,7 +185,7 @@ public function replay_count_error() /** * @test */ - public function replay_count_complete() + public function replay_count_complete(): void { $xs = $this->createHotObservable([ @@ -212,31 +212,31 @@ public function replay_count_complete() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->replay(null, 3, null, $this->scheduler); }); - $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -267,7 +267,7 @@ public function replay_count_complete() /** * @test */ - public function replay_count_dispose() + public function replay_count_dispose(): void { $xs = $this->createHotObservable([ @@ -294,39 +294,39 @@ public function replay_count_dispose() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->replay(null, 3, null, $this->scheduler); }); - $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(475, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(475, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -353,7 +353,7 @@ public function replay_count_dispose() /** * @test */ - public function replay_count_multiple_connections() + public function replay_count_multiple_connections(): void { $xs = new NeverObservable(); $ys = $xs->replay(null, 3); @@ -375,7 +375,7 @@ public function replay_count_multiple_connections() /** * @test */ - public function replay_count_zip_complete() + public function replay_count_zip_complete(): void { $xs = $this->createHotObservable([ @@ -443,7 +443,7 @@ public function replay_count_zip_complete() /** * @test */ - public function replay_count_zip_error() + public function replay_count_zip_error(): void { $error = new \Exception(); @@ -508,7 +508,7 @@ public function replay_count_zip_error() /** * @test */ - public function replay_count_zip_dispose() + public function replay_count_zip_dispose(): void { $xs = $this->createHotObservable([ @@ -563,7 +563,7 @@ public function replay_count_zip_dispose() /** * @test */ - public function replay_time_basic() + public function replay_time_basic(): void { $xs = $this->createHotObservable([ @@ -590,39 +590,39 @@ public function replay_time_basic() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->replay(null, null, 150, $this->scheduler); }); - $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -652,7 +652,7 @@ public function replay_time_basic() /** * @test */ - public function replay_time_error() + public function replay_time_error(): void { $error = new \Exception(); @@ -681,31 +681,31 @@ public function replay_time_error() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->replay(null, null, 75, $this->scheduler); }); - $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -733,7 +733,7 @@ public function replay_time_error() /** * @test */ - public function replay_time_complete() + public function replay_time_complete(): void { $xs = $this->createHotObservable([ @@ -760,31 +760,31 @@ public function replay_time_complete() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->replay(null, null, 85, $this->scheduler); }); - $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -812,7 +812,7 @@ public function replay_time_complete() /** * @test */ - public function replay_time_dispose() + public function replay_time_dispose(): void { $xs = $this->createHotObservable([ @@ -839,39 +839,39 @@ public function replay_time_dispose() $results = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->replay(null, null, 100, $this->scheduler); }); - $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription) { + $this->scheduler->scheduleAbsolute(450, function () use (&$ys, $xs, $results, &$subscription): void { $subscription = $ys->subscribe($results); }); - $this->scheduler->scheduleAbsolute(475, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(475, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(300, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(400, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(500, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(550, function () use (&$connection): void { $connection->dispose(); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys) { + $this->scheduler->scheduleAbsolute(650, function () use (&$connection, &$ys): void { $connection = $ys->connect(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$connection) { + $this->scheduler->scheduleAbsolute(800, function () use (&$connection): void { $connection->dispose(); }); @@ -898,7 +898,7 @@ public function replay_time_dispose() /** * @test */ - public function replay_time_multiple_connections() + public function replay_time_multiple_connections(): void { $xs = new NeverObservable(); $ys = $xs->replay(null, null, 100); @@ -920,7 +920,7 @@ public function replay_time_multiple_connections() /** * @test */ - public function replay_time_zip_complete() + public function replay_time_zip_complete(): void { $xs = $this->createHotObservable([ @@ -985,7 +985,7 @@ public function replay_time_zip_complete() /** * @test */ - public function replay_time_zip_errorr() + public function replay_time_zip_errorr(): void { $error = new \Exception(); @@ -1049,7 +1049,7 @@ public function replay_time_zip_errorr() /** * @test */ - public function replay_time_zip_dispose() + public function replay_time_zip_dispose(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/RetryTest.php b/test/Rx/Functional/Operator/RetryTest.php index b9c8af7b..8cc796d1 100644 --- a/test/Rx/Functional/Operator/RetryTest.php +++ b/test/Rx/Functional/Operator/RetryTest.php @@ -14,7 +14,7 @@ class RetryTest extends FunctionalTestCase { - public function testRetryObservableBasic() + public function testRetryObservableBasic(): void { $xs = $this->createColdObservable([ onNext(100, 1), @@ -45,7 +45,7 @@ public function testRetryObservableBasic() ); } - public function testRetryObservableInfinite() + public function testRetryObservableInfinite(): void { $xs = $this->createColdObservable([ onNext(100, 1), @@ -74,7 +74,7 @@ public function testRetryObservableInfinite() ); } - public function testRetryObservableError() + public function testRetryObservableError(): void { $error = new \Exception(); @@ -118,7 +118,7 @@ public function testRetryObservableError() ); } - public function testRetryObservableThrows() + public function testRetryObservableThrows(): void { $scheduler1 = new TestScheduler(); @@ -126,7 +126,7 @@ public function testRetryObservableThrows() $xs->subscribe( new CallbackObserver( - function () { + function (): void { throw new \Exception(); } )); @@ -151,7 +151,7 @@ function () { $d = $ys->subscribe( new CallbackObserver( null, - function ($err) { + function ($err): void { throw $err; } )); @@ -170,7 +170,7 @@ function ($err) { new CallbackObserver( null, null, - function () { + function (): void { throw new \Exception(); } )); @@ -185,7 +185,7 @@ function () { $this->assertNotNull($exception); } - public function testRetryObservableRetryCountBasic() + public function testRetryObservableRetryCountBasic(): void { $error = new \Exception(); @@ -228,7 +228,7 @@ public function testRetryObservableRetryCountBasic() ); } - public function testRetryObservableRetryCountDispose() + public function testRetryObservableRetryCountDispose(): void { $error = new \Exception(); @@ -265,7 +265,7 @@ public function testRetryObservableRetryCountDispose() ); } - public function testRetryRetryCountDispose() + public function testRetryRetryCountDispose(): void { $xs = $this->createColdObservable( [ @@ -296,7 +296,7 @@ public function testRetryRetryCountDispose() ); } - public function testRetryObservableCompletes() + public function testRetryObservableCompletes(): void { $xs = $this->createColdObservable( [ @@ -329,13 +329,13 @@ public function testRetryObservableCompletes() ); } - public function testRetryObservableRetryCountThrows() + public function testRetryObservableRetryCountThrows(): void { $scheduler1 = new TestScheduler(); $xs = (new ReturnObservable(1, $scheduler1))->retry(3); - $xs->subscribe(function () { + $xs->subscribe(function (): void { throw new \Exception(); }); @@ -351,7 +351,7 @@ public function testRetryObservableRetryCountThrows() $ys = (new ErrorObservable(new \Exception(), $scheduler2))->retry(100); - $d = $ys->subscribe(null, function ($err) { + $d = $ys->subscribe(null, function ($err): void { throw $err; }); @@ -365,7 +365,7 @@ public function testRetryObservableRetryCountThrows() $zs = (new ReturnObservable(1, $scheduler3))->retry(100); - $zs->subscribe(null, null, function () { + $zs->subscribe(null, null, function (): void { throw new \Exception(); }); @@ -377,7 +377,7 @@ public function testRetryObservableRetryCountThrows() } $this->assertNotNull($exception); - $xss = (new AnonymousObservable(function () { + $xss = (new AnonymousObservable(function (): void { throw new \Exception(); }))->retry(100); @@ -390,7 +390,7 @@ public function testRetryObservableRetryCountThrows() $this->assertNotNull($exception); } - public function testWithImmediateSchedulerWithRecursion() + public function testWithImmediateSchedulerWithRecursion(): void { $completed = false; $emitted = null; @@ -405,11 +405,11 @@ public function testWithImmediateSchedulerWithRecursion() ->retry(3) ->take(1) ->subscribe(new CallbackObserver( - function ($x) use (&$emitted) { + function ($x) use (&$emitted): void { $emitted = $x; }, null, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } )); diff --git a/test/Rx/Functional/Operator/RetryWhenTest.php b/test/Rx/Functional/Operator/RetryWhenTest.php index 4b284f77..0d769ee2 100644 --- a/test/Rx/Functional/Operator/RetryWhenTest.php +++ b/test/Rx/Functional/Operator/RetryWhenTest.php @@ -12,7 +12,7 @@ class RetryWhenTest extends FunctionalTestCase /** * @test */ - public function retryWhen_never() + public function retryWhen_never(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -37,7 +37,7 @@ public function retryWhen_never() /** * @test */ - public function retryWhen_Observable_never() + public function retryWhen_Observable_never(): void { $error = new \Exception(); @@ -71,7 +71,7 @@ public function retryWhen_Observable_never() /** * @test */ - public function retryWhen_never_completed() + public function retryWhen_never_completed(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -104,7 +104,7 @@ public function retryWhen_never_completed() /** * @test */ - public function retryWhen_Observable_Empty() + public function retryWhen_Observable_Empty(): void { $xs = $this->createColdObservable([ onNext(100, 1), @@ -134,7 +134,7 @@ public function retryWhen_Observable_Empty() /** * @test */ - public function retryWhen_Observable_Next_Error() + public function retryWhen_Observable_Next_Error(): void { $error = new \Exception(); @@ -173,7 +173,7 @@ public function retryWhen_Observable_Next_Error() /** * @test */ - public function retryWhen_Observable_complete() + public function retryWhen_Observable_complete(): void { $error = new \Exception(); @@ -204,7 +204,7 @@ public function retryWhen_Observable_complete() /** * @test */ - public function retryWhen_Observable_next_complete() + public function retryWhen_Observable_next_complete(): void { $error = new \Exception(); @@ -242,7 +242,7 @@ public function retryWhen_Observable_next_complete() /** * @test */ - public function retryWhen_Observable_infinite() + public function retryWhen_Observable_infinite(): void { $error = new \Exception(); @@ -269,7 +269,7 @@ public function retryWhen_Observable_infinite() ], $xs->getSubscriptions()); } - public function testRetryWhenDispose() + public function testRetryWhenDispose(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -306,7 +306,7 @@ public function testRetryWhenDispose() ], $xs->getSubscriptions()); } - public function testRetryWhenDisposeBetweenSourceSubscriptions() + public function testRetryWhenDisposeBetweenSourceSubscriptions(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -337,7 +337,7 @@ public function testRetryWhenDisposeBetweenSourceSubscriptions() ], $xs->getSubscriptions()); } - public function testRetryWhenInnerEmitsBeforeOuterError() + public function testRetryWhenInnerEmitsBeforeOuterError(): void { $xs = $this->createColdObservable([ onNext(10, 1), @@ -366,7 +366,7 @@ public function testRetryWhenInnerEmitsBeforeOuterError() ], $xs->getSubscriptions()); } - public function testRetryWhenSelectorThrows() + public function testRetryWhenSelectorThrows(): void { $error = new \Exception(); @@ -379,7 +379,7 @@ public function testRetryWhenSelectorThrows() ]); $results = $this->scheduler->startWithDispose(function () use ($xs, $error) { - return $xs->retryWhen(function () use ($error) { + return $xs->retryWhen(function () use ($error): void { throw $error; }); }, 285); @@ -391,7 +391,7 @@ public function testRetryWhenSelectorThrows() $this->assertSubscriptions([], $xs->getSubscriptions()); } - public function testRetryWhenSelectorReturnsInvalidString() + public function testRetryWhenSelectorReturnsInvalidString(): void { $error = new \Exception(); diff --git a/test/Rx/Functional/Operator/ScanTest.php b/test/Rx/Functional/Operator/ScanTest.php index 77f5d34d..2ae298b5 100644 --- a/test/Rx/Functional/Operator/ScanTest.php +++ b/test/Rx/Functional/Operator/ScanTest.php @@ -9,7 +9,7 @@ class ScanTest extends FunctionalTestCase { - public function testScanSeedNever() + public function testScanSeedNever(): void { $seed = 42; @@ -22,7 +22,7 @@ public function testScanSeedNever() $this->assertMessages([], $results->getMessages()); } - public function testScanSeedEmpty() + public function testScanSeedEmpty(): void { $seed = 42; @@ -48,7 +48,7 @@ public function testScanSeedEmpty() } - public function testScanSeedReturn() + public function testScanSeedReturn(): void { $seed = 42; @@ -75,7 +75,7 @@ public function testScanSeedReturn() ); } - public function testScanSeedThrow() + public function testScanSeedThrow(): void { $ex = new \Exception('ex'); @@ -102,7 +102,7 @@ public function testScanSeedThrow() ); } - public function testScanSeedSomeData() + public function testScanSeedSomeData(): void { $seed = 1; @@ -136,7 +136,7 @@ public function testScanSeedSomeData() ); } - public function testScanNoSeedNever() + public function testScanNoSeedNever(): void { $results = $this->scheduler->startWithCreate(function () { return Observable::never()->scan(function ($acc, $x) { @@ -150,7 +150,7 @@ public function testScanNoSeedNever() ); } - public function testScanNoSeedEmpty() + public function testScanNoSeedEmpty(): void { $xs = $this->createHotObservable( [ @@ -173,7 +173,7 @@ public function testScanNoSeedEmpty() ); } - public function testScanNoSeedReturn() + public function testScanNoSeedReturn(): void { $xs = $this->createHotObservable( [ @@ -198,7 +198,7 @@ public function testScanNoSeedReturn() ); } - public function testScanNoSeedThrow() + public function testScanNoSeedThrow(): void { $ex = new \Exception('ex'); @@ -223,7 +223,7 @@ public function testScanNoSeedThrow() ); } - public function testScanNoSeedSomeData() + public function testScanNoSeedSomeData(): void { $xs = $this->createHotObservable( [ @@ -258,7 +258,7 @@ public function testScanNoSeedSomeData() /** * @test */ - public function scan_accumulator_throws() + public function scan_accumulator_throws(): void { $xs = $this->createHotObservable( [ @@ -269,7 +269,7 @@ public function scan_accumulator_throws() ]); $results = $this->scheduler->startWithCreate(function () use ($xs) { - return $xs->scan(function () { + return $xs->scan(function (): void { throw new \Exception(); }); }); @@ -280,7 +280,7 @@ public function scan_accumulator_throws() /** * @test */ - public function scan_accumulator_throws_with_seed() + public function scan_accumulator_throws_with_seed(): void { $xs = $this->createHotObservable( [ @@ -291,7 +291,7 @@ public function scan_accumulator_throws_with_seed() ]); $results = $this->scheduler->startWithCreate(function () use ($xs) { - return $xs->scan(function () { + return $xs->scan(function (): void { throw new \Exception(); }, 42); }); diff --git a/test/Rx/Functional/Operator/SelectManyTest.php b/test/Rx/Functional/Operator/SelectManyTest.php index 6c2c30c3..a269ef10 100644 --- a/test/Rx/Functional/Operator/SelectManyTest.php +++ b/test/Rx/Functional/Operator/SelectManyTest.php @@ -13,29 +13,29 @@ class SelectManyTest extends FunctionalTestCase /** * @test */ - public function it_passes_the_last_on_complete() + public function it_passes_the_last_on_complete(): void { - $xs = $this->createColdObservable(array( + $xs = $this->createColdObservable([ onNext(100, 4), onNext(200, 2), onNext(300, 3), onNext(400, 1), onCompleted(500) - )); + ]); - $ys = $this->createColdObservable(array( + $ys = $this->createColdObservable([ onNext(50, 'foo'), onNext(100, 'bar'), onNext(150, 'baz'), onNext(200, 'qux'), onCompleted(250) - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs, $ys) { return $xs->selectMany(function() use ($ys) { return $ys; }); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(350, "foo"), // 1 onNext(400, "bar"), // 1 onNext(450, "baz"), // 1 @@ -53,76 +53,76 @@ public function it_passes_the_last_on_complete() onNext(750, "baz"), // 4 onNext(800, "qux"), // 4 onCompleted(850) - ), $results->getMessages()); + ], $results->getMessages()); - $this->assertSubscriptions(array(subscribe(200, 700)), $xs->getSubscriptions()); - $this->assertSubscriptions(array(subscribe(300, 550), subscribe(400, 650), subscribe(500, 750), subscribe(600, 850)), $ys->getSubscriptions()); + $this->assertSubscriptions([subscribe(200, 700)], $xs->getSubscriptions()); + $this->assertSubscriptions([subscribe(300, 550), subscribe(400, 650), subscribe(500, 750), subscribe(600, 850)], $ys->getSubscriptions()); } /** * @test */ - public function it_passes_on_error() + public function it_passes_on_error(): void { - $xs = $this->createColdObservable(array( + $xs = $this->createColdObservable([ onNext(100, 4), onNext(200, 2), onNext(300, 3), onNext(400, 1), onCompleted(510) - )); + ]); - $ys = $this->createColdObservable(array( + $ys = $this->createColdObservable([ onNext(50, 'foo'), onNext(100, 'bar'), onNext(150, 'baz'), onError(210, new Exception()), onCompleted(250), - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs, $ys) { return $xs->selectMany(function() use ($ys) { return $ys; }); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(350, "foo"), // 1 onNext(400, "bar"), // 1 onNext(450, "baz"), // 1 onNext(450, "foo"), // 2 onNext(500, "bar"), // 2 onError(510, new Exception()), // 1 - ), $results->getMessages()); + ], $results->getMessages()); - $this->assertSubscriptions(array(subscribe(200, 510)), $xs->getSubscriptions()); - $this->assertSubscriptions(array(subscribe(300, 510), subscribe(400, 510), subscribe(500, 510)), $ys->getSubscriptions()); + $this->assertSubscriptions([subscribe(200, 510)], $xs->getSubscriptions()); + $this->assertSubscriptions([subscribe(300, 510), subscribe(400, 510), subscribe(500, 510)], $ys->getSubscriptions()); } /** * @test */ - public function flatMapTo_it_passes_the_last_on_complete() + public function flatMapTo_it_passes_the_last_on_complete(): void { - $xs = $this->createColdObservable(array( + $xs = $this->createColdObservable([ onNext(100, 4), onNext(200, 2), onNext(300, 3), onNext(400, 1), onCompleted(500) - )); + ]); - $ys = $this->createColdObservable(array( + $ys = $this->createColdObservable([ onNext(50, 'foo'), onNext(100, 'bar'), onNext(150, 'baz'), onNext(200, 'qux'), onCompleted(250) - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs, $ys) { return $xs->flatMapTo($ys); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(350, "foo"), // 1 onNext(400, "bar"), // 1 onNext(450, "baz"), // 1 @@ -140,54 +140,54 @@ public function flatMapTo_it_passes_the_last_on_complete() onNext(750, "baz"), // 4 onNext(800, "qux"), // 4 onCompleted(850) - ), $results->getMessages()); + ], $results->getMessages()); - $this->assertSubscriptions(array(subscribe(200, 700)), $xs->getSubscriptions()); - $this->assertSubscriptions(array(subscribe(300, 550), subscribe(400, 650), subscribe(500, 750), subscribe(600, 850)), $ys->getSubscriptions()); + $this->assertSubscriptions([subscribe(200, 700)], $xs->getSubscriptions()); + $this->assertSubscriptions([subscribe(300, 550), subscribe(400, 650), subscribe(500, 750), subscribe(600, 850)], $ys->getSubscriptions()); } /** * @test */ - public function flatMapTo_it_passes_on_error() + public function flatMapTo_it_passes_on_error(): void { - $xs = $this->createColdObservable(array( + $xs = $this->createColdObservable([ onNext(100, 4), onNext(200, 2), onNext(300, 3), onNext(400, 1), onCompleted(510) - )); + ]); - $ys = $this->createColdObservable(array( + $ys = $this->createColdObservable([ onNext(50, 'foo'), onNext(100, 'bar'), onNext(150, 'baz'), onError(210, new Exception()), onCompleted(250), - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs, $ys) { return $xs->flatMapTo($ys); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(350, "foo"), // 1 onNext(400, "bar"), // 1 onNext(450, "baz"), // 1 onNext(450, "foo"), // 2 onNext(500, "bar"), // 2 onError(510, new Exception()), // 1 - ), $results->getMessages()); + ], $results->getMessages()); - $this->assertSubscriptions(array(subscribe(200, 510)), $xs->getSubscriptions()); - $this->assertSubscriptions(array(subscribe(300, 510), subscribe(400, 510), subscribe(500, 510)), $ys->getSubscriptions()); + $this->assertSubscriptions([subscribe(200, 510)], $xs->getSubscriptions()); + $this->assertSubscriptions([subscribe(300, 510), subscribe(400, 510), subscribe(500, 510)], $ys->getSubscriptions()); } /** * @test */ - public function flatMap_it_errors_with_bad_return() + public function flatMap_it_errors_with_bad_return(): void { $xs = $this->createColdObservable([ onNext(100, 4), diff --git a/test/Rx/Functional/Operator/SelectTest.php b/test/Rx/Functional/Operator/SelectTest.php index 6cbcfd25..f6d22fd8 100644 --- a/test/Rx/Functional/Operator/SelectTest.php +++ b/test/Rx/Functional/Operator/SelectTest.php @@ -14,14 +14,14 @@ class SelectTest extends FunctionalTestCase /** * @test */ - public function calls_on_error_if_selector_throws_an_exception() + public function calls_on_error_if_selector_throws_an_exception(): void { $xs = $this->createHotObservable([ onNext(500, 42), ]); $results = $this->scheduler->startWithCreate(function () use ($xs) { - return $xs->select(function () { + return $xs->select(function (): void { throw new Exception(); }); }); @@ -32,7 +32,7 @@ public function calls_on_error_if_selector_throws_an_exception() /** * @test */ - public function select_calls_on_completed() + public function select_calls_on_completed(): void { $xs = $this->createHotObservable([ onCompleted(500), @@ -48,7 +48,7 @@ public function select_calls_on_completed() /** * @test */ - public function select_calls_on_error() + public function select_calls_on_error(): void { $xs = $this->createHotObservable([ onError(500, new Exception()), @@ -64,7 +64,7 @@ public function select_calls_on_error() /** * @test */ - public function select_calls_selector() + public function select_calls_selector(): void { $xs = $this->createHotObservable([ onNext(100, 2), @@ -92,7 +92,7 @@ public function select_calls_selector() /** * @test */ - public function map_with_index_dispose_inside_selector() + public function map_with_index_dispose_inside_selector(): void { $xs = $this->createHotObservable([ onNext(100, 4), @@ -118,7 +118,7 @@ public function map_with_index_dispose_inside_selector() })->subscribe($results) ); - $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use ($d) { + $this->scheduler->scheduleAbsolute(TestScheduler::DISPOSED, function () use ($d): void { $d->dispose(); }); @@ -140,7 +140,7 @@ public function map_with_index_dispose_inside_selector() /** * @test */ - public function map_with_index_completed() + public function map_with_index_completed(): void { $xs = $this->createHotObservable([ onNext(180, 5), @@ -182,7 +182,7 @@ public function map_with_index_completed() /** * @test */ - public function map_with_index_not_completed() + public function map_with_index_not_completed(): void { $xs = $this->createHotObservable([ onNext(180, 5), @@ -219,7 +219,7 @@ public function map_with_index_not_completed() /** * @test */ - public function map_with_index_error() + public function map_with_index_error(): void { $error = new Exception(); @@ -263,7 +263,7 @@ public function map_with_index_error() /** * @test */ - public function map_with_index_throws() + public function map_with_index_throws(): void { $error = new Exception(); @@ -307,7 +307,7 @@ public function map_with_index_throws() /** * @test */ - public function mapTo_value() + public function mapTo_value(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -334,7 +334,7 @@ public function mapTo_value() /** * @test */ - public function map_and_map_Optimization() + public function map_and_map_Optimization(): void { $invoked1 = 0; diff --git a/test/Rx/Functional/Operator/SingleInstanceTest.php b/test/Rx/Functional/Operator/SingleInstanceTest.php index 49c16224..c30376a8 100644 --- a/test/Rx/Functional/Operator/SingleInstanceTest.php +++ b/test/Rx/Functional/Operator/SingleInstanceTest.php @@ -13,7 +13,7 @@ class SingleInstanceTest extends FunctionalTestCase /** * @test */ - public function singleInstance_basic() + public function singleInstance_basic(): void { $xs = $this->createColdObservable([ onNext(100, 1), @@ -27,18 +27,18 @@ public function singleInstance_basic() $results2 = $this->scheduler->createObserver(); $disposable = null; - $this->scheduler->scheduleAbsolute($this->scheduler::CREATED, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute($this->scheduler::CREATED, function () use (&$ys, $xs): void { $ys = $xs->singleInstance(); }); - $this->scheduler->scheduleAbsolute($this->scheduler::SUBSCRIBED, function () use (&$ys, &$disposable, $results1, $results2) { + $this->scheduler->scheduleAbsolute($this->scheduler::SUBSCRIBED, function () use (&$ys, &$disposable, $results1, $results2): void { $disposable = new CompositeDisposable([ $ys->subscribe($results1), $ys->subscribe($results2) ]); }); - $this->scheduler->scheduleAbsolute($this->scheduler::DISPOSED, function () use (&$disposable) { + $this->scheduler->scheduleAbsolute($this->scheduler::DISPOSED, function () use (&$disposable): void { $disposable->dispose(); }); @@ -66,7 +66,7 @@ public function singleInstance_basic() /** * @test */ - public function singleInstance_subscribe_after_stopped() + public function singleInstance_subscribe_after_stopped(): void { $xs = $this->createColdObservable([ onNext(100, 1), @@ -80,19 +80,19 @@ public function singleInstance_subscribe_after_stopped() $results2 = $this->scheduler->createObserver(); $disposable = new SerialDisposable(); - $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs) { + $this->scheduler->scheduleAbsolute(100, function () use (&$ys, $xs): void { $ys = $xs->singleInstance(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $disposable, $results1) { + $this->scheduler->scheduleAbsolute(200, function () use (&$ys, $disposable, $results1): void { $disposable->setDisposable($ys->subscribe($results1)); }); - $this->scheduler->scheduleAbsolute(600, function () use (&$ys, $disposable, $results2) { + $this->scheduler->scheduleAbsolute(600, function () use (&$ys, $disposable, $results2): void { $disposable->setDisposable($ys->subscribe($results2)); }); - $this->scheduler->scheduleAbsolute(900, function () use (&$disposable) { + $this->scheduler->scheduleAbsolute(900, function () use (&$disposable): void { $disposable->dispose(); }); diff --git a/test/Rx/Functional/Operator/SkipLastTest.php b/test/Rx/Functional/Operator/SkipLastTest.php index 384c485b..09374f16 100644 --- a/test/Rx/Functional/Operator/SkipLastTest.php +++ b/test/Rx/Functional/Operator/SkipLastTest.php @@ -12,7 +12,7 @@ class SkipLastTest extends FunctionalTestCase { /** */ - public function testSkipLastNegative() + public function testSkipLastNegative(): void { $this->expectException(\InvalidArgumentException::class); $xs = $this->createHotObservable( @@ -36,7 +36,7 @@ public function testSkipLastNegative() } - public function testSkipLastZeroCompleted() + public function testSkipLastZeroCompleted(): void { $xs = $this->createHotObservable( @@ -81,7 +81,7 @@ public function testSkipLastZeroCompleted() ); } - public function testSkipLastZeroError() + public function testSkipLastZeroError(): void { $ex = new \Exception('ex'); @@ -126,7 +126,7 @@ public function testSkipLastZeroError() ); } - public function testSkipLastZeroDisposed() + public function testSkipLastZeroDisposed(): void { $xs = $this->createHotObservable( @@ -169,7 +169,7 @@ public function testSkipLastZeroDisposed() ); } - public function testSkipLastOneCompleted() + public function testSkipLastOneCompleted(): void { $xs = $this->createHotObservable( @@ -214,7 +214,7 @@ public function testSkipLastOneCompleted() ); } - public function testSkipLastOneError() + public function testSkipLastOneError(): void { $ex = new \Exception('ex'); @@ -260,7 +260,7 @@ public function testSkipLastOneError() ); } - public function testSkipLastOneDisposed() + public function testSkipLastOneDisposed(): void { $xs = $this->createHotObservable( @@ -302,7 +302,7 @@ public function testSkipLastOneDisposed() ); } - public function testSkipLastThreeCompleted() + public function testSkipLastThreeCompleted(): void { $xs = $this->createHotObservable( @@ -344,7 +344,7 @@ public function testSkipLastThreeCompleted() ); } - public function testSkipLastThreeError() + public function testSkipLastThreeError(): void { $ex = new \Exception('ex'); @@ -387,7 +387,7 @@ public function testSkipLastThreeError() ); } - public function testSkipLastThreeDisposed() + public function testSkipLastThreeDisposed(): void { $xs = $this->createHotObservable( diff --git a/test/Rx/Functional/Operator/SkipTest.php b/test/Rx/Functional/Operator/SkipTest.php index f51b5758..bd6ab9a2 100644 --- a/test/Rx/Functional/Operator/SkipTest.php +++ b/test/Rx/Functional/Operator/SkipTest.php @@ -15,7 +15,7 @@ class SkipTest extends FunctionalTestCase /** * @test */ - public function it_throws_an_exception_on_negative_amounts() + public function it_throws_an_exception_on_negative_amounts(): void { $this->expectException(\InvalidArgumentException::class); $observable = new ReturnObservable(42, $this->scheduler); @@ -27,73 +27,73 @@ public function it_throws_an_exception_on_negative_amounts() /** * @test */ - public function it_passes_on_complete() + public function it_passes_on_complete(): void { - $xs = $this->createHotObservable(array( + $xs = $this->createHotObservable([ onNext(300, 21), onNext(500, 42), onNext(800, 84), onCompleted(820), - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs) { return $xs->skip(0); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(300, 21), onNext(500, 42), onNext(800, 84), onCompleted(820), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_skips_one_value() + public function it_skips_one_value(): void { $scheduler = $this->createTestScheduler(); - $xs = $this->createHotObservable(array( + $xs = $this->createHotObservable([ onNext(300, 21), onNext(500, 42), onNext(800, 84), onCompleted(820), - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs) { return $xs->skip(1); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(500, 42), onNext(800, 84), onCompleted(820), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_skips_multiple_values() + public function it_skips_multiple_values(): void { $scheduler = $this->createTestScheduler(); - $xs = $this->createHotObservable(array( + $xs = $this->createHotObservable([ onNext(300, 21), onNext(500, 42), onNext(800, 84), onNext(850, 168), onCompleted(870), - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs) { return $xs->skip(2); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(800, 84), onNext(850, 168), onCompleted(870), - ), $results->getMessages()); + ], $results->getMessages()); } } diff --git a/test/Rx/Functional/Operator/SkipUntilTest.php b/test/Rx/Functional/Operator/SkipUntilTest.php index 9ff7f109..83ee490a 100644 --- a/test/Rx/Functional/Operator/SkipUntilTest.php +++ b/test/Rx/Functional/Operator/SkipUntilTest.php @@ -12,7 +12,7 @@ class SkipUntilTest extends FunctionalTestCase { - public function testSkipUntilSomeDataNext() + public function testSkipUntilSomeDataNext(): void { $l = $this->createHotObservable( @@ -49,7 +49,7 @@ public function testSkipUntilSomeDataNext() ); } - public function testSkipUntilSomeDataError() + public function testSkipUntilSomeDataError(): void { $error = new \Exception(); @@ -83,7 +83,7 @@ public function testSkipUntilSomeDataError() ); } - public function testSkipUntilSomeDataEmpty() + public function testSkipUntilSomeDataEmpty(): void { $l = $this->createHotObservable( @@ -117,7 +117,7 @@ public function testSkipUntilSomeDataEmpty() } - public function testSkipUntilNeverNext() + public function testSkipUntilNeverNext(): void { $l = Observable::never(); @@ -142,7 +142,7 @@ public function testSkipUntilNeverNext() ); } - public function testSkipUntilNeverError() + public function testSkipUntilNeverError(): void { $error = new \Exception(); @@ -168,7 +168,7 @@ public function testSkipUntilNeverError() ); } - public function testSkipUntilSomeDataNever() + public function testSkipUntilSomeDataNever(): void { $l = $this->createHotObservable( @@ -194,7 +194,7 @@ public function testSkipUntilSomeDataNever() ); } - public function testSkipUntilNeverEmpty() + public function testSkipUntilNeverEmpty(): void { $l = Observable::never(); @@ -216,7 +216,7 @@ public function testSkipUntilNeverEmpty() ); } - public function testSkipUntilNeverNever() + public function testSkipUntilNeverNever(): void { $l = Observable::never(); @@ -233,7 +233,7 @@ public function testSkipUntilNeverNever() ); } - public function testSkipUntilHasCompletedCausesDisposal() + public function testSkipUntilHasCompletedCausesDisposal(): void { $disposed = false; @@ -250,7 +250,7 @@ public function testSkipUntilHasCompletedCausesDisposal() ); $r = new AnonymousObservable(function () use (&$disposed) { - return new CallbackDisposable(function () use (&$disposed) { + return new CallbackDisposable(function () use (&$disposed): void { $disposed = true; }); }); @@ -268,7 +268,7 @@ public function testSkipUntilHasCompletedCausesDisposal() } - public function testCanCompleteInSubscribeAction() + public function testCanCompleteInSubscribeAction(): void { $completed = false; $emitted = null; @@ -276,14 +276,14 @@ public function testCanCompleteInSubscribeAction() Observable::of(1) ->skipUntil(Observable::of(1)) ->subscribe( - function ($x) use (&$emitted) { + function ($x) use (&$emitted): void { if ($emitted !== null) { $this->fail('emitted should be null'); } $emitted = $x; }, null, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } ); diff --git a/test/Rx/Functional/Operator/SkipWhileTest.php b/test/Rx/Functional/Operator/SkipWhileTest.php index ebef8fdf..ecfa4508 100644 --- a/test/Rx/Functional/Operator/SkipWhileTest.php +++ b/test/Rx/Functional/Operator/SkipWhileTest.php @@ -12,7 +12,7 @@ class SkipWhileTest extends FunctionalTestCase /** * @test */ - public function skipWhile_complete_before() + public function skipWhile_complete_before(): void { $xs = $this->createHotObservable( [ @@ -62,7 +62,7 @@ public function skipWhile_complete_before() /** * @test */ - public function skipWhile_complete_after() + public function skipWhile_complete_after(): void { $xs = $this->createHotObservable( [ @@ -115,7 +115,7 @@ public function skipWhile_complete_after() /** * @test */ - public function skipWhile_error_before() + public function skipWhile_error_before(): void { $error = new \Exception(); @@ -167,7 +167,7 @@ public function skipWhile_error_before() /** * @test */ - public function skipWhile_error_after() + public function skipWhile_error_after(): void { $error = new \Exception(); @@ -222,7 +222,7 @@ public function skipWhile_error_after() /** * @test */ - public function skipWhile_dispose_before() + public function skipWhile_dispose_before(): void { $xs = $this->createHotObservable( @@ -270,7 +270,7 @@ public function skipWhile_dispose_before() /** * @test */ - public function skipWhile_dispose_after() + public function skipWhile_dispose_after(): void { $xs = $this->createHotObservable( @@ -322,7 +322,7 @@ public function skipWhile_dispose_after() /** * @test */ - public function skipWhile_zero() + public function skipWhile_zero(): void { $xs = $this->createHotObservable( @@ -383,7 +383,7 @@ public function skipWhile_zero() /** * @test */ - public function skipWhile_throw() + public function skipWhile_throw(): void { $xs = $this->createHotObservable( @@ -437,7 +437,7 @@ public function skipWhile_throw() /** * @test */ - public function skipWhile_index() + public function skipWhile_index(): void { $xs = $this->createHotObservable( @@ -506,7 +506,7 @@ private function isPrime($num) * The sqrt can be an aproximation, hence just for the sake of * security, one rounds it to the next highest integer value. */ - for ($i = 3; $i <= ceil(sqrt($num)); $i = $i + 2) { + for ($i = 3; $i <= ceil(sqrt($num)); $i += 2) { if ($num % $i == 0) return false; } diff --git a/test/Rx/Functional/Operator/StartTest.php b/test/Rx/Functional/Operator/StartTest.php index bf54ac67..b669d1a7 100644 --- a/test/Rx/Functional/Operator/StartTest.php +++ b/test/Rx/Functional/Operator/StartTest.php @@ -12,12 +12,12 @@ class StartTest extends FunctionalTestCase /** * @test */ - public function start_action() + public function start_action(): void { $done = false; $results = $this->scheduler->startWithCreate(function () use (&$done) { - return Observable::start(function () use (&$done) { + return Observable::start(function () use (&$done): void { $done = true; }, $this->scheduler); }); @@ -36,7 +36,7 @@ public function start_action() /** * @test */ - public function start_action_number() + public function start_action_number(): void { $results = $this->scheduler->startWithCreate(function () { return Observable::start(function () { @@ -56,11 +56,11 @@ public function start_action_number() /** * @test */ - public function start_with_error() + public function start_with_error(): void { $error = new \Exception(); $results = $this->scheduler->startWithCreate(function () use ($error) { - return Observable::start(function () use ($error) { + return Observable::start(function () use ($error): void { throw $error; }, $this->scheduler); }); diff --git a/test/Rx/Functional/Operator/StartWithTest.php b/test/Rx/Functional/Operator/StartWithTest.php index 05085219..b1cd8653 100644 --- a/test/Rx/Functional/Operator/StartWithTest.php +++ b/test/Rx/Functional/Operator/StartWithTest.php @@ -13,7 +13,7 @@ class StartWithTest extends FunctionalTestCase /** * @test */ - public function startWith_never() + public function startWith_never(): void { $xs = $this->createHotObservable([ onNext(150, 1) @@ -31,7 +31,7 @@ public function startWith_never() /** * @test */ - public function startWith_empty() + public function startWith_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -51,7 +51,7 @@ public function startWith_empty() /** * @test */ - public function startWith_one() + public function startWith_one(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -73,7 +73,7 @@ public function startWith_one() /** * @test */ - public function startWith_multiple() + public function startWith_multiple(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -97,7 +97,7 @@ public function startWith_multiple() /** * @test */ - public function startWith_multiple_before() + public function startWith_multiple_before(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -120,7 +120,7 @@ public function startWith_multiple_before() /** * @test */ - public function startWith_error() + public function startWith_error(): void { $error = new \Exception(); diff --git a/test/Rx/Functional/Operator/SubscribeOnTest.php b/test/Rx/Functional/Operator/SubscribeOnTest.php index c9af49fb..8bd83352 100644 --- a/test/Rx/Functional/Operator/SubscribeOnTest.php +++ b/test/Rx/Functional/Operator/SubscribeOnTest.php @@ -11,7 +11,7 @@ class SubscribeOnTest extends FunctionalTestCase /** * @test */ - public function subscribeOn_normal() + public function subscribeOn_normal(): void { $xs = $this->createHotObservable( [ @@ -39,7 +39,7 @@ public function subscribeOn_normal() /** * @test */ - public function subscribeOn_error() + public function subscribeOn_error(): void { $error = new \Exception(); @@ -68,7 +68,7 @@ public function subscribeOn_error() /** * @test */ - public function subscribeOn_empty() + public function subscribeOn_empty(): void { $xs = $this->createHotObservable( [ @@ -94,7 +94,7 @@ public function subscribeOn_empty() /** * @test */ - public function subscribeOn_never() + public function subscribeOn_never(): void { $xs = $this->createHotObservable([onNext(150, 1)]); diff --git a/test/Rx/Functional/Operator/SumTest.php b/test/Rx/Functional/Operator/SumTest.php index 83c8050b..28a48afd 100644 --- a/test/Rx/Functional/Operator/SumTest.php +++ b/test/Rx/Functional/Operator/SumTest.php @@ -13,7 +13,7 @@ class SumTest extends FunctionalTestCase * * @test */ - public function sum_number_empty() + public function sum_number_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -35,7 +35,7 @@ public function sum_number_empty() * * @test */ - public function sum_number_return() + public function sum_number_return(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -58,7 +58,7 @@ public function sum_number_return() * * @test */ - public function sum_number_some() + public function sum_number_some(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -83,7 +83,7 @@ public function sum_number_some() * * @test */ - public function sum_number_throw() + public function sum_number_throw(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -104,7 +104,7 @@ public function sum_number_throw() * * @test */ - public function sum_number_never() + public function sum_number_never(): void { $xs = $this->createHotObservable([ onNext(150, 1) diff --git a/test/Rx/Functional/Operator/SwitchFirstTest.php b/test/Rx/Functional/Operator/SwitchFirstTest.php index c8e39483..58cf9c2b 100644 --- a/test/Rx/Functional/Operator/SwitchFirstTest.php +++ b/test/Rx/Functional/Operator/SwitchFirstTest.php @@ -11,7 +11,7 @@ class SwitchFirstTest extends FunctionalTestCase /** * @test */ - public function switchFirst_Data() + public function switchFirst_Data(): void { $xs = $this->createHotObservable([ @@ -62,7 +62,7 @@ public function switchFirst_Data() /** * @test */ - public function switchFirst_inner_throws() + public function switchFirst_inner_throws(): void { $error = new \Exception(); @@ -116,7 +116,7 @@ public function switchFirst_inner_throws() /** * @test */ - public function switchFirst_first_inner_throws() + public function switchFirst_first_inner_throws(): void { $error = new \Exception(); @@ -165,7 +165,7 @@ public function switchFirst_first_inner_throws() /** * @test */ - public function switchFirst_outer_throws() + public function switchFirst_outer_throws(): void { $error = new \Exception(); @@ -209,7 +209,7 @@ public function switchFirst_outer_throws() /** * @test */ - public function switchFirst_no_inner() + public function switchFirst_no_inner(): void { $xs = $this->createHotObservable([ @@ -231,7 +231,7 @@ public function switchFirst_no_inner() /** * @test */ - public function switchFirst_inner_completes() + public function switchFirst_inner_completes(): void { $xs = $this->createHotObservable([ @@ -269,7 +269,7 @@ public function switchFirst_inner_completes() /** * @test */ - public function switchFirst_Dispose() + public function switchFirst_Dispose(): void { $xs = $this->createHotObservable([ @@ -317,7 +317,7 @@ public function switchFirst_Dispose() /** * @test */ - public function switchFirst_Inner_Completes_Last() + public function switchFirst_Inner_Completes_Last(): void { $xs = $this->createHotObservable([ @@ -368,7 +368,7 @@ public function switchFirst_Inner_Completes_Last() /** * @test */ - public function switchFirst_Subsequent() + public function switchFirst_Subsequent(): void { $xs = $this->createHotObservable([ @@ -415,7 +415,7 @@ public function switchFirst_Subsequent() /** * @test */ - public function switchFirst_SkipsOneObservable() + public function switchFirst_SkipsOneObservable(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/SwitchLatestTest.php b/test/Rx/Functional/Operator/SwitchLatestTest.php index fb1a0ebd..634bd66c 100644 --- a/test/Rx/Functional/Operator/SwitchLatestTest.php +++ b/test/Rx/Functional/Operator/SwitchLatestTest.php @@ -12,7 +12,7 @@ class SwitchLatestTest extends FunctionalTestCase /** * @test */ - public function switchLatest_Data() + public function switchLatest_Data(): void { $xs = $this->createHotObservable([ @@ -67,7 +67,7 @@ public function switchLatest_Data() /** * @test */ - public function switchLatest_inner_throws() + public function switchLatest_inner_throws(): void { $error = new \Exception(); @@ -120,7 +120,7 @@ public function switchLatest_inner_throws() /** * @test */ - public function switchLatest_outer_throws() + public function switchLatest_outer_throws(): void { $error = new \Exception(); @@ -166,7 +166,7 @@ public function switchLatest_outer_throws() /** * @test */ - public function switchLatest_no_inner() + public function switchLatest_no_inner(): void { $xs = $this->createHotObservable([ @@ -188,7 +188,7 @@ public function switchLatest_no_inner() /** * @test */ - public function switchLatest_inner_completes() + public function switchLatest_inner_completes(): void { $xs = $this->createHotObservable([ @@ -226,7 +226,7 @@ public function switchLatest_inner_completes() /** * @test */ - public function switchLatest_Dispose() + public function switchLatest_Dispose(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/TakeLastTest.php b/test/Rx/Functional/Operator/TakeLastTest.php index 1bc7a4dc..52dc9581 100644 --- a/test/Rx/Functional/Operator/TakeLastTest.php +++ b/test/Rx/Functional/Operator/TakeLastTest.php @@ -12,7 +12,7 @@ class TakeLastTest extends FunctionalTestCase /** * @test */ - public function takeLast_zero_completed() + public function takeLast_zero_completed(): void { $xs = $this->createHotObservable([ onNext(180, 1), @@ -43,7 +43,7 @@ public function takeLast_zero_completed() /** * @test */ - public function takeLast_zero_error() + public function takeLast_zero_error(): void { $error = new Exception('error'); @@ -77,7 +77,7 @@ public function takeLast_zero_error() /** * @test */ - public function takeLast_zero_disposed() + public function takeLast_zero_disposed(): void { $xs = $this->createHotObservable([ onNext(180, 1), @@ -105,7 +105,7 @@ public function takeLast_zero_disposed() /** * @test */ - public function takeLast_one_completed() + public function takeLast_one_completed(): void { $xs = $this->createHotObservable([ onNext(180, 1), @@ -137,7 +137,7 @@ public function takeLast_one_completed() /** * @test */ - public function takeLast_one_error() + public function takeLast_one_error(): void { $error = new Exception('error'); @@ -172,7 +172,7 @@ public function takeLast_one_error() /** * @test */ - public function takeLast_one_disposed() + public function takeLast_one_disposed(): void { $xs = $this->createHotObservable([ onNext(180, 1), @@ -200,7 +200,7 @@ public function takeLast_one_disposed() /** * @test */ - public function takeLast_three_completed() + public function takeLast_three_completed(): void { $xs = $this->createHotObservable([ onNext(180, 1), @@ -234,7 +234,7 @@ public function takeLast_three_completed() /** * @test */ - public function takeLast_three_error() + public function takeLast_three_error(): void { $error = new Exception('error'); @@ -269,7 +269,7 @@ public function takeLast_three_error() /** * @test */ - public function takeLast_three_disposed() + public function takeLast_three_disposed(): void { $xs = $this->createHotObservable([ onNext(180, 1), @@ -297,7 +297,7 @@ public function takeLast_three_disposed() /** * @test */ - public function takeLast_invalid_count() + public function takeLast_invalid_count(): void { $this->expectException(\InvalidArgumentException::class); $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/TakeTest.php b/test/Rx/Functional/Operator/TakeTest.php index e3eed00e..0fcb0979 100644 --- a/test/Rx/Functional/Operator/TakeTest.php +++ b/test/Rx/Functional/Operator/TakeTest.php @@ -15,7 +15,7 @@ class TakeTest extends FunctionalTestCase /** * @test */ - public function it_throws_an_exception_on_negative_amounts() + public function it_throws_an_exception_on_negative_amounts(): void { $this->expectException(\InvalidArgumentException::class); $observable = new ReturnObservable(42, $this->scheduler); @@ -27,7 +27,7 @@ public function it_throws_an_exception_on_negative_amounts() /** * @test */ - public function it_passes_on_complete() + public function it_passes_on_complete(): void { $xs = $this->createHotObservable([ onNext(300, 21), @@ -51,7 +51,7 @@ public function it_passes_on_complete() /** * @test */ - public function it_calls_on_complete_after_last_value() + public function it_calls_on_complete_after_last_value(): void { $scheduler = $this->createTestScheduler(); $xs = $this->createHotObservable([ @@ -75,7 +75,7 @@ public function it_calls_on_complete_after_last_value() /** * @test */ - public function take_zero_calls_on_completed() + public function take_zero_calls_on_completed(): void { $xs = $this->createHotObservable([ diff --git a/test/Rx/Functional/Operator/TakeUntilTest.php b/test/Rx/Functional/Operator/TakeUntilTest.php index 7ba83b4b..f18117eb 100644 --- a/test/Rx/Functional/Operator/TakeUntilTest.php +++ b/test/Rx/Functional/Operator/TakeUntilTest.php @@ -15,7 +15,7 @@ class TakeUntilTest extends FunctionalTestCase /** * @test */ - public function takeUntil_preempt_some_data_next() + public function takeUntil_preempt_some_data_next(): void { $l = $this->createHotObservable([ onNext(150, 1), @@ -57,7 +57,7 @@ public function takeUntil_preempt_some_data_next() /** * @test */ - public function takeUntil_preempt_some_data_error() + public function takeUntil_preempt_some_data_error(): void { $error = new \Exception(); @@ -93,7 +93,7 @@ public function takeUntil_preempt_some_data_error() /** * @test */ - public function takeUntil_preempt_some_data_empty() + public function takeUntil_preempt_some_data_empty(): void { $l = $this->createHotObservable([ onNext(150, 1), @@ -130,7 +130,7 @@ public function takeUntil_preempt_some_data_empty() /** * @test */ - public function takeUntil_preempt_some_data_never() + public function takeUntil_preempt_some_data_never(): void { $l = $this->createHotObservable([ onNext(150, 1), @@ -163,7 +163,7 @@ public function takeUntil_preempt_some_data_never() /** * @test */ - public function takeUntil_preempt_never_next() + public function takeUntil_preempt_never_next(): void { $l = Observable::never(); @@ -188,7 +188,7 @@ public function takeUntil_preempt_never_next() /** * @test */ - public function takeUntil_preempt_never_error() + public function takeUntil_preempt_never_error(): void { $error = new \Exception(); @@ -216,7 +216,7 @@ public function takeUntil_preempt_never_error() /** * @test */ - public function takeUntil_preempt_never_empty() + public function takeUntil_preempt_never_empty(): void { $l = Observable::never(); @@ -235,7 +235,7 @@ public function takeUntil_preempt_never_empty() /** * @test */ - public function takeUntil_preempt_never_never() + public function takeUntil_preempt_never_never(): void { $l = Observable::never(); @@ -251,7 +251,7 @@ public function takeUntil_preempt_never_never() /** * @test */ - public function takeUntil_before_first_produced() + public function takeUntil_before_first_produced(): void { $l = $this->createHotObservable([ onNext(150, 1), @@ -281,7 +281,7 @@ public function takeUntil_before_first_produced() /** * @test */ - public function takeUntil_before_first_produced_remain_silent_and_proper_disposed() + public function takeUntil_before_first_produced_remain_silent_and_proper_disposed(): void { $sourceNotDisposed = false; @@ -290,7 +290,7 @@ public function takeUntil_before_first_produced_remain_silent_and_proper_dispose onNext(150, 1), onError(215, new \Exception()), onCompleted(240) - ])->doOnNext(function () use (&$sourceNotDisposed) { + ])->doOnNext(function () use (&$sourceNotDisposed): void { $sourceNotDisposed = true; }); @@ -319,7 +319,7 @@ public function takeUntil_before_first_produced_remain_silent_and_proper_dispose /** * @test */ - public function takeUntil_no_preempt_after_last_produced_proper_disposed_signal() + public function takeUntil_no_preempt_after_last_produced_proper_disposed_signal(): void { $sourceNotDisposed = false; @@ -334,7 +334,7 @@ public function takeUntil_no_preempt_after_last_produced_proper_disposed_signal( onNext(150, 1), onNext(250, 2), onCompleted(260) - ])->doOnNext(function () use (&$sourceNotDisposed) { + ])->doOnNext(function () use (&$sourceNotDisposed): void { $sourceNotDisposed = true; }); @@ -357,13 +357,13 @@ public function takeUntil_no_preempt_after_last_produced_proper_disposed_signal( /** * @test */ - public function takeUntil_should_subscribe_to_the_notifier_first_with_immediate_scheduler() + public function takeUntil_should_subscribe_to_the_notifier_first_with_immediate_scheduler(): void { $emissions = 0; $source = Observable::range(1, 10); $notification = new Subject(); $source->takeUntil($notification) - ->subscribe(new CallbackObserver(function($value) use (&$emissions, $notification) { + ->subscribe(new CallbackObserver(function($value) use (&$emissions, $notification): void { if ($value === 5) { $notification->onNext(true); } diff --git a/test/Rx/Functional/Operator/TakeWhileTest.php b/test/Rx/Functional/Operator/TakeWhileTest.php index 5fd24541..7feca699 100644 --- a/test/Rx/Functional/Operator/TakeWhileTest.php +++ b/test/Rx/Functional/Operator/TakeWhileTest.php @@ -12,7 +12,7 @@ class TakeWhileTest extends FunctionalTestCase /** * @test */ - public function takeWhile_never() + public function takeWhile_never(): void { $xs = $this->createHotObservable([ onNext(90, -1), @@ -57,7 +57,7 @@ public function takeWhile_never() /** * @test */ - public function takeWhile_complete_after() + public function takeWhile_complete_after(): void { $xs = $this->createHotObservable([ onNext(90, -1), @@ -102,7 +102,7 @@ public function takeWhile_complete_after() /** * @test */ - public function takeWhile_error_before() + public function takeWhile_error_before(): void { $error = new \Exception(); @@ -146,7 +146,7 @@ public function takeWhile_error_before() /** * @test */ - public function takeWhile_error_after() + public function takeWhile_error_after(): void { $xs = $this->createHotObservable([ onNext(90, -1), @@ -191,7 +191,7 @@ public function takeWhile_error_after() /** * @test */ - public function takeWhile_dispose_before() + public function takeWhile_dispose_before(): void { $xs = $this->createHotObservable([ onNext(90, -1), @@ -233,7 +233,7 @@ public function takeWhile_dispose_before() /** * @test */ - public function takeWhile_dispose_after() + public function takeWhile_dispose_after(): void { $xs = $this->createHotObservable([ @@ -279,7 +279,7 @@ public function takeWhile_dispose_after() /** * @test */ - public function takeWhile_zero() + public function takeWhile_zero(): void { $xs = $this->createHotObservable([ onNext(90, -1), @@ -321,7 +321,7 @@ public function takeWhile_zero() /** * @test */ - public function takeWhile_throw() + public function takeWhile_throw(): void { $error = new \Exception(); @@ -368,7 +368,7 @@ public function takeWhile_throw() /** * @test */ - public function takeWhile_index() + public function takeWhile_index(): void { $xs = $this->createHotObservable([ onNext(90, -1), @@ -432,7 +432,7 @@ private function isPrime($num) * The sqrt can be an aproximation, hence just for the sake of * security, one rounds it to the next highest integer value. */ - for ($i = 3; $i <= ceil(sqrt($num)); $i = $i + 2) { + for ($i = 3; $i <= ceil(sqrt($num)); $i += 2) { if ($num % $i === 0) { return false; } @@ -444,7 +444,7 @@ private function isPrime($num) /** * @test */ - public function takeWhile_inclusive() + public function takeWhile_inclusive(): void { $error = new \Exception(); diff --git a/test/Rx/Functional/Operator/ThrottleTest.php b/test/Rx/Functional/Operator/ThrottleTest.php index 447f5ad3..1cade83a 100644 --- a/test/Rx/Functional/Operator/ThrottleTest.php +++ b/test/Rx/Functional/Operator/ThrottleTest.php @@ -15,7 +15,7 @@ class ThrottleTest extends FunctionalTestCase /** * @test */ - public function throttle_completed() + public function throttle_completed(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -47,7 +47,7 @@ public function throttle_completed() /** * @test */ - public function throttle_never() + public function throttle_never(): void { $xs = $this->createHotObservable([ onNext(150, 1) @@ -67,7 +67,7 @@ public function throttle_never() /** * @test */ - public function throttle_empty() + public function throttle_empty(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -90,7 +90,7 @@ public function throttle_empty() /** * @test */ - public function throttle_error() + public function throttle_error(): void { $error = new \Exception(); @@ -122,7 +122,7 @@ public function throttle_error() /** * @test */ - public function throttle_no_end() + public function throttle_no_end(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -152,7 +152,7 @@ public function throttle_no_end() /** * @test */ - public function throttle_dispose() + public function throttle_dispose(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -181,7 +181,7 @@ public function throttle_dispose() /** * @test */ - public function throttle_dispose_with_value_waiting() + public function throttle_dispose_with_value_waiting(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -210,7 +210,7 @@ public function throttle_dispose_with_value_waiting() /** * @test */ - public function throttle_quiet_observable_emits_immediately() + public function throttle_quiet_observable_emits_immediately(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -235,7 +235,7 @@ public function throttle_quiet_observable_emits_immediately() /** * @test */ - public function throttle_noisy_observable_drops_items() + public function throttle_noisy_observable_drops_items(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -270,7 +270,7 @@ public function throttle_noisy_observable_drops_items() /** * @test */ - public function throttle_scheduler_overrides_subscribe_scheduler() + public function throttle_scheduler_overrides_subscribe_scheduler(): void { $scheduler = $this->createMock(SchedulerInterface::class); $scheduler->expects($this->exactly(2)) diff --git a/test/Rx/Functional/Operator/TimeoutTest.php b/test/Rx/Functional/Operator/TimeoutTest.php index 5ac567bf..f32c7b2e 100644 --- a/test/Rx/Functional/Operator/TimeoutTest.php +++ b/test/Rx/Functional/Operator/TimeoutTest.php @@ -13,7 +13,7 @@ class TimeoutTest extends FunctionalTestCase /** * @test */ - public function timeout_in_time() + public function timeout_in_time(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -45,7 +45,7 @@ public function timeout_in_time() /** * @test */ - public function timeout_relative_time_timeout_occurs_with_default_error() + public function timeout_relative_time_timeout_occurs_with_default_error(): void { $xs = $this->createHotObservable([ onNext(410, 1) @@ -73,7 +73,7 @@ public function timeout_relative_time_timeout_occurs_with_default_error() /** * @test */ - public function timeout_relative_time_timeout_occurs_with_custom_error() + public function timeout_relative_time_timeout_occurs_with_custom_error(): void { $errObs = new ErrorObservable(new \Exception(), $this->scheduler); @@ -107,7 +107,7 @@ public function timeout_relative_time_timeout_occurs_with_custom_error() /** * @test */ - public function timeout_out_of_time() + public function timeout_out_of_time(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -146,7 +146,7 @@ public function timeout_out_of_time() /** * @test */ - public function timeout_timeout_occurs_1() + public function timeout_timeout_occurs_1(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -195,7 +195,7 @@ public function timeout_timeout_occurs_1() /** * @test */ - public function timeout_timeout_occurs_2() + public function timeout_timeout_occurs_2(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -247,7 +247,7 @@ public function timeout_timeout_occurs_2() /** * @test */ - public function timeout_timeout_occurs_never() + public function timeout_timeout_occurs_never(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -290,7 +290,7 @@ public function timeout_timeout_occurs_never() /** * @test */ - public function timeout_timeout_occurs_completed() + public function timeout_timeout_occurs_completed(): void { $xs = $this->createHotObservable([ onCompleted(500) @@ -329,7 +329,7 @@ public function timeout_timeout_occurs_completed() /** * @test */ - public function timeout_timeout_occurs_Error() + public function timeout_timeout_occurs_Error(): void { $xs = $this->createHotObservable([ onError(500, new \Exception()) @@ -368,7 +368,7 @@ public function timeout_timeout_occurs_Error() /** * @test */ - public function timeout_timeout_does_not_occur_completed() + public function timeout_timeout_does_not_occur_completed(): void { $xs = $this->createHotObservable([ onCompleted(250) @@ -406,7 +406,7 @@ public function timeout_timeout_does_not_occur_completed() /** * @test */ - public function timeout_timeout_does_not_occur_Error() + public function timeout_timeout_does_not_occur_Error(): void { $xs = $this->createHotObservable([ onError(250, new \Exception()) @@ -444,7 +444,7 @@ public function timeout_timeout_does_not_occur_Error() /** * @test */ - public function timeout_timeout_does_not_occur() + public function timeout_timeout_does_not_occur(): void { $xs = $this->createHotObservable([ onNext(70, 1), diff --git a/test/Rx/Functional/Operator/TimestampTest.php b/test/Rx/Functional/Operator/TimestampTest.php index 33cf8b79..359398ea 100644 --- a/test/Rx/Functional/Operator/TimestampTest.php +++ b/test/Rx/Functional/Operator/TimestampTest.php @@ -13,7 +13,7 @@ class TimestampTest extends FunctionalTestCase /** * @test */ - public function timestamp_regular() + public function timestamp_regular(): void { $xs = $this->createHotObservable([ onNext(150, 1), @@ -42,7 +42,7 @@ public function timestamp_regular() /** * @test */ - public function timestamp_empty() + public function timestamp_empty(): void { $results = $this->scheduler->startWithCreate(function () { return Observable::empty($this->scheduler)->timestamp($this->scheduler); @@ -56,7 +56,7 @@ public function timestamp_empty() /** * @test */ - public function timestamp_error() + public function timestamp_error(): void { $error = new \Exception(); @@ -72,7 +72,7 @@ public function timestamp_error() /** * @test */ - public function timestamp_never() + public function timestamp_never(): void { $results = $this->scheduler->startWithCreate(function () { return Observable::never()->timestamp($this->scheduler); @@ -84,7 +84,7 @@ public function timestamp_never() /** * @test */ - public function timestamp_dispose() + public function timestamp_dispose(): void { $xs = $this->createHotObservable([ onNext(150, 1), diff --git a/test/Rx/Functional/Operator/ToArrayTest.php b/test/Rx/Functional/Operator/ToArrayTest.php index bf388f4d..5848d8d3 100644 --- a/test/Rx/Functional/Operator/ToArrayTest.php +++ b/test/Rx/Functional/Operator/ToArrayTest.php @@ -11,7 +11,7 @@ class ToArrayTest extends FunctionalTestCase { - public function testToArrayCompleted() + public function testToArrayCompleted(): void { $xs = $this->createHotObservable( @@ -39,7 +39,7 @@ public function testToArrayCompleted() } - public function testToArrayError() + public function testToArrayError(): void { $error = new \Exception(); @@ -74,7 +74,7 @@ public function testToArrayError() ); } - public function testToArrayDisposed() + public function testToArrayDisposed(): void { $xs = $this->createHotObservable( diff --git a/test/Rx/Functional/Operator/WhereTest.php b/test/Rx/Functional/Operator/WhereTest.php index 4c4e6465..c474c36b 100644 --- a/test/Rx/Functional/Operator/WhereTest.php +++ b/test/Rx/Functional/Operator/WhereTest.php @@ -13,7 +13,7 @@ class WhereTest extends FunctionalTestCase /** * @test */ - public function it_filters_all_on_false() + public function it_filters_all_on_false(): void { $xs = $this->createHotObservableWithData(); @@ -22,15 +22,15 @@ public function it_filters_all_on_false() }); - $this->assertMessages(array( + $this->assertMessages([ onCompleted(820), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_passes_all_on_true() + public function it_passes_all_on_true(): void { $xs = $this->createHotObservableWithData(); @@ -38,60 +38,60 @@ public function it_passes_all_on_true() return $xs->where(function($elem) { return true; }); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(300, 21), onNext(500, 42), onNext(800, 84), onCompleted(820), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function it_passes_on_error() + public function it_passes_on_error(): void { $exception = new Exception(); - $xs = $this->createHotObservable(array( + $xs = $this->createHotObservable([ onNext(500, 42), onError(820, $exception), - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs) { return $xs->where(function($elem) { return $elem === 42; }); }); - $this->assertMessages(array( + $this->assertMessages([ onNext(500, 42), onError(820, $exception), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function calls_on_error_if_predicate_throws_an_exception() + public function calls_on_error_if_predicate_throws_an_exception(): void { - $xs = $this->createHotObservable(array( + $xs = $this->createHotObservable([ onNext(500, 42), - )); + ]); $results = $this->scheduler->startWithCreate(function() use ($xs) { - return $xs->where(function() { throw new Exception(); }); + return $xs->where(function(): void { throw new Exception(); }); }); - $this->assertMessages(array(onError(500, new Exception())), $results->getMessages()); + $this->assertMessages([onError(500, new Exception())], $results->getMessages()); } protected function createHotObservableWithData() { - return $this->createHotObservable(array( + return $this->createHotObservable([ onNext(100, 2), onNext(300, 21), onNext(500, 42), onNext(800, 84), onCompleted(820), - )); + ]); } } diff --git a/test/Rx/Functional/Operator/WithLatestFromTest.php b/test/Rx/Functional/Operator/WithLatestFromTest.php index aacb2d4f..6d630f64 100644 --- a/test/Rx/Functional/Operator/WithLatestFromTest.php +++ b/test/Rx/Functional/Operator/WithLatestFromTest.php @@ -17,7 +17,7 @@ public function add($a, $b) /** * @test */ - public function withLatestFrom_never_never() + public function withLatestFrom_never_never(): void { $e1 = new NeverObservable(); $e2 = new NeverObservable(); @@ -32,7 +32,7 @@ public function withLatestFrom_never_never() /** * @test */ - public function withLatestFrom_never_empty() + public function withLatestFrom_never_empty(): void { $e1 = new NeverObservable(); $e2 = $this->createHotObservable( @@ -52,7 +52,7 @@ public function withLatestFrom_never_empty() /** * @test */ - public function withLatestFrom_empty_never() + public function withLatestFrom_empty_never(): void { $e1 = new NeverObservable(); $e2 = $this->createHotObservable( @@ -72,7 +72,7 @@ public function withLatestFrom_empty_never() /** * @test */ - public function withLatestFrom_empty_empty() + public function withLatestFrom_empty_empty(): void { $e1 = $this->createHotObservable( [ @@ -107,7 +107,7 @@ public function withLatestFrom_empty_empty() /** * @test */ - public function withLatestFrom_empty_return() + public function withLatestFrom_empty_return(): void { $e1 = $this->createHotObservable( [ @@ -142,7 +142,7 @@ public function withLatestFrom_empty_return() /** * @test */ - public function withLatestFrom_return_empty() + public function withLatestFrom_return_empty(): void { $e1 = $this->createHotObservable( [ @@ -177,7 +177,7 @@ public function withLatestFrom_return_empty() /** * @test */ - public function withLatestFrom_never_return() + public function withLatestFrom_never_return(): void { $e1 = $this->createHotObservable( [ @@ -203,7 +203,7 @@ public function withLatestFrom_never_return() /** * @test */ - public function withLatestFrom_return_never() + public function withLatestFrom_return_never(): void { $e1 = $this->createHotObservable( [ @@ -225,7 +225,7 @@ public function withLatestFrom_return_never() /** * @test */ - public function withLatestFrom_return_return() + public function withLatestFrom_return_return(): void { $e1 = $this->createHotObservable( [ @@ -267,7 +267,7 @@ public function withLatestFrom_return_return() /** * @test */ - public function withLatestFrom_return_return_no_selector() + public function withLatestFrom_return_return_no_selector(): void { $e1 = $this->createHotObservable( [ @@ -309,7 +309,7 @@ public function withLatestFrom_return_return_no_selector() /** * @test */ - public function withLatestFrom_empty_error() + public function withLatestFrom_empty_error(): void { $error = new \Exception(); @@ -350,7 +350,7 @@ public function withLatestFrom_empty_error() /** * @test */ - public function withLatestFrom_error_empty() + public function withLatestFrom_error_empty(): void { $error = new \Exception(); @@ -391,7 +391,7 @@ public function withLatestFrom_error_empty() /** * @test */ - public function withLatestFrom_return_throw() + public function withLatestFrom_return_throw(): void { $error = new \Exception(); @@ -433,7 +433,7 @@ public function withLatestFrom_return_throw() /** * @test */ - public function withLatestFrom_throw_return() + public function withLatestFrom_throw_return(): void { $error = new \Exception(); @@ -475,7 +475,7 @@ public function withLatestFrom_throw_return() /** * @test */ - public function withLatestFrom_throw_throw() + public function withLatestFrom_throw_throw(): void { $error1 = new \Exception('first'); $error2 = new \Exception('second'); @@ -517,7 +517,7 @@ public function withLatestFrom_throw_throw() /** * @test */ - public function withLatestFrom_error_throw() + public function withLatestFrom_error_throw(): void { $error1 = new \Exception(); $error2 = new \Exception(); @@ -560,7 +560,7 @@ public function withLatestFrom_error_throw() /** * @test */ - public function withLatestFrom_throw_error() + public function withLatestFrom_throw_error(): void { $error1 = new \Exception(); $error2 = new \Exception(); @@ -603,7 +603,7 @@ public function withLatestFrom_throw_error() /** * @test */ - public function withLatestFrom_never_throw() + public function withLatestFrom_never_throw(): void { $error = new \Exception(); @@ -631,7 +631,7 @@ public function withLatestFrom_never_throw() /** * @test */ - public function withLatestFrom_throw_never() + public function withLatestFrom_throw_never(): void { $error = new \Exception(); @@ -659,7 +659,7 @@ public function withLatestFrom_throw_never() /** * @test */ - public function withLatestFrom_some_throw() + public function withLatestFrom_some_throw(): void { $error = new \Exception(); @@ -701,7 +701,7 @@ public function withLatestFrom_some_throw() /** * @test */ - public function withLatestFrom_throw_some() + public function withLatestFrom_throw_some(): void { $error = new \Exception(); @@ -743,7 +743,7 @@ public function withLatestFrom_throw_some() /** * @test */ - public function withLatestFrom_throw_after_complete_left() + public function withLatestFrom_throw_after_complete_left(): void { $error = new \Exception(); @@ -785,7 +785,7 @@ public function withLatestFrom_throw_after_complete_left() /** * @test */ - public function withLatestFrom_throw_after_complete_right() + public function withLatestFrom_throw_after_complete_right(): void { $error = new \Exception(); @@ -819,7 +819,7 @@ public function withLatestFrom_throw_after_complete_right() /** * @test */ - public function withLatestFrom_interleaved_with_tail() + public function withLatestFrom_interleaved_with_tail(): void { $e1 = $this->createHotObservable( @@ -866,7 +866,7 @@ public function withLatestFrom_interleaved_with_tail() /** * @test */ - public function withLatestFrom_consecutive() + public function withLatestFrom_consecutive(): void { $e1 = $this->createHotObservable( [ @@ -910,7 +910,7 @@ public function withLatestFrom_consecutive() /** * @test */ - public function withLatestFrom_consecutive_array() + public function withLatestFrom_consecutive_array(): void { $e1 = $this->createHotObservable( [ @@ -954,7 +954,7 @@ public function withLatestFrom_consecutive_array() /** * @test */ - public function withLatestFrom_consecutive_end_with_error_left() + public function withLatestFrom_consecutive_end_with_error_left(): void { $error = new \Exception(); @@ -999,7 +999,7 @@ public function withLatestFrom_consecutive_end_with_error_left() /** * @test */ - public function withLatestFrom_consecutive_end_with_error_right() + public function withLatestFrom_consecutive_end_with_error_right(): void { $error = new \Exception(); @@ -1038,7 +1038,7 @@ public function withLatestFrom_consecutive_end_with_error_right() /** * @test */ - public function withLatestFrom_selector_throws() + public function withLatestFrom_selector_throws(): void { $error = new \Exception(); @@ -1059,7 +1059,7 @@ public function withLatestFrom_selector_throws() ); $results = $this->scheduler->startWithCreate(function () use ($e1, $e2) { - return $e1->withLatestFrom([$e2], function () { + return $e1->withLatestFrom([$e2], function (): void { throw new \Exception(); }); }); @@ -1083,7 +1083,7 @@ public function withLatestFrom_selector_throws() /** * @test */ - public function withLatestFrom_return_return_dispose() + public function withLatestFrom_return_return_dispose(): void { $e1 = $this->createHotObservable( [ @@ -1121,7 +1121,7 @@ public function withLatestFrom_return_return_dispose() ], $e2->getSubscriptions()); } - public function testWithLatestFrom_multiple_dispose_no_selector() + public function testWithLatestFrom_multiple_dispose_no_selector(): void { $e1 = $this->createHotObservable( [ @@ -1171,7 +1171,7 @@ public function testWithLatestFrom_multiple_dispose_no_selector() ], $e3->getSubscriptions()); } - public function testWithLatestFrom_multiple_dispose_with_selector() + public function testWithLatestFrom_multiple_dispose_with_selector(): void { $e1 = $this->createHotObservable( [ @@ -1223,7 +1223,7 @@ public function testWithLatestFrom_multiple_dispose_with_selector() ], $e3->getSubscriptions()); } - public function testWithLatestFrom_multiple_with_selector() + public function testWithLatestFrom_multiple_with_selector(): void { $e1 = $this->createHotObservable( [ diff --git a/test/Rx/Functional/Operator/ZipTest.php b/test/Rx/Functional/Operator/ZipTest.php index beb08b74..3df13054 100644 --- a/test/Rx/Functional/Operator/ZipTest.php +++ b/test/Rx/Functional/Operator/ZipTest.php @@ -12,7 +12,7 @@ class ZipTest extends FunctionalTestCase { - public function testZipNArySymmetric() + public function testZipNArySymmetric(): void { $e0 = $this->createHotObservable([ onNext(150, 1), @@ -55,7 +55,7 @@ public function testZipNArySymmetric() $this->assertSubscriptions([subscribe(200, 420)], $e0->getSubscriptions()); } - public function testZipNArySymmetricSelector() + public function testZipNArySymmetricSelector(): void { $e0 = $this->createHotObservable([ onNext(150, 1), @@ -100,7 +100,7 @@ public function testZipNArySymmetricSelector() $this->assertSubscriptions([subscribe(200, 420)], $e0->getSubscriptions()); } - public function testZipNeverNever() + public function testZipNeverNever(): void { $o1 = new NeverObservable(); $o2 = new NeverObservable(); @@ -112,7 +112,7 @@ public function testZipNeverNever() $this->assertMessages([], $results->getMessages()); } - public function testZipNeverEmpty() + public function testZipNeverEmpty(): void { $o1 = new NeverObservable(); $o2 = $this->createHotObservable([ @@ -127,7 +127,7 @@ public function testZipNeverEmpty() $this->assertMessages([], $results->getMessages()); } - public function testZipEmptyEmpty() + public function testZipEmptyEmpty(): void { $o1 = $this->createHotObservable([ onNext(150, 1), @@ -145,7 +145,7 @@ public function testZipEmptyEmpty() $this->assertMessages([onCompleted(210)], $results->getMessages()); } - public function testZipEmptyNonEmpty() + public function testZipEmptyNonEmpty(): void { $o1 = $this->createHotObservable([ onNext(150, 1), @@ -164,7 +164,7 @@ public function testZipEmptyNonEmpty() $this->assertMessages([onCompleted(215)], $results->getMessages()); } - public function testZipNonEmptyEmpty() + public function testZipNonEmptyEmpty(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -183,7 +183,7 @@ public function testZipNonEmptyEmpty() $this->assertMessages([onCompleted(215)], $results->getMessages()); } - public function testZipNeverNonEmpty() + public function testZipNeverNonEmpty(): void { $e1 = $this->createHotObservable([ onNext(150, 1), @@ -199,7 +199,7 @@ public function testZipNeverNonEmpty() $this->assertMessages([], $results->getMessages()); } - public function testZipEmptyError() + public function testZipEmptyError(): void { $error = new \Exception(); @@ -221,7 +221,7 @@ public function testZipEmptyError() ], $results->getMessages()); } - public function testZipNeverError() + public function testZipNeverError(): void { $error = new \Exception(); @@ -240,7 +240,7 @@ public function testZipNeverError() ], $results->getMessages()); } - public function testZipErrorError() + public function testZipErrorError(): void { $error1 = new \Exception("error1"); $error2 = new \Exception("error2"); @@ -263,7 +263,7 @@ public function testZipErrorError() ], $results->getMessages()); } - public function testZipSomeError() + public function testZipSomeError(): void { $error = new \Exception(); @@ -286,7 +286,7 @@ public function testZipSomeError() ], $results->getMessages()); } - public function testZipSomeDataAsymmetric() + public function testZipSomeDataAsymmetric(): void { $msgs1 = [ onNext(205, 0), @@ -316,7 +316,7 @@ public function testZipSomeDataAsymmetric() ], $results->getMessages()); } - public function testZipSomeDataSymmetric() + public function testZipSomeDataSymmetric(): void { $msgs1 = [ onNext(205, 0), @@ -344,7 +344,7 @@ public function testZipSomeDataSymmetric() ], $results->getMessages()); } - public function testZipSelectorThrows() + public function testZipSelectorThrows(): void { $error = new \Exception(); @@ -377,7 +377,7 @@ public function testZipSelectorThrows() ], $results->getMessages()); } - public function testZipRightCompletesFirst() + public function testZipRightCompletesFirst(): void { $o = $this->createHotObservable([ onNext(150, 1), @@ -414,7 +414,7 @@ public function add($x, $y) return $x + $y; } - public function testZipWithImmediateScheduler() + public function testZipWithImmediateScheduler(): void { $scheduler = new ImmediateScheduler(); @@ -429,7 +429,7 @@ public function testZipWithImmediateScheduler() $result = null; $source->toArray()->subscribe(new CallbackObserver( - function ($x) use (&$result) { + function ($x) use (&$result): void { $result = $x; } )); @@ -446,7 +446,7 @@ function ($x) use (&$result) { $result = null; $source->count()->subscribe(new CallbackObserver( - function ($x) use (&$result) { + function ($x) use (&$result): void { $result = $x; } )); diff --git a/test/Rx/Functional/Promise/FromPromiseTest.php b/test/Rx/Functional/Promise/FromPromiseTest.php index 16483c8e..9e826e28 100644 --- a/test/Rx/Functional/Promise/FromPromiseTest.php +++ b/test/Rx/Functional/Promise/FromPromiseTest.php @@ -16,20 +16,20 @@ class FromPromiseTest extends FunctionalTestCase * @test * */ - public function from_promise_success() + public function from_promise_success(): void { $p = \React\Promise\resolve(42); $source = Observable::fromPromise($p); $source->subscribe( - function ($x) { + function ($x): void { $this->assertEquals(42, $x); }, - function ($error) { + function ($error): void { $this->assertFalse(true); }, - function () { + function (): void { $this->assertTrue(true); }); } @@ -38,20 +38,20 @@ function () { * @test * */ - public function from_promise_failure() + public function from_promise_failure(): void { $p = \React\Promise\reject(new RejectedPromiseException('error')); $source = Observable::fromPromise($p); $source->subscribe( - function ($x) { + function ($x): void { $this->assertFalse(true); }, - function (Exception $error) { + function (Exception $error): void { $this->assertInstanceOf(RejectedPromiseException::class, $error); }, - function () { + function (): void { $this->assertFalse(true); }); } @@ -59,7 +59,7 @@ function () { /** * @test */ - public function two_observables_one_delayed() + public function two_observables_one_delayed(): void { $p = \React\Promise\resolve(1); diff --git a/test/Rx/Functional/Promise/ToPromiseTest.php b/test/Rx/Functional/Promise/ToPromiseTest.php index cade09e9..d40280db 100644 --- a/test/Rx/Functional/Promise/ToPromiseTest.php +++ b/test/Rx/Functional/Promise/ToPromiseTest.php @@ -14,13 +14,13 @@ class ToPromiseTest extends FunctionalTestCase * @test * */ - public function promise_success() + public function promise_success(): void { $promise = Observable::of(42)->toPromise(); $result = null; - $promise->then(function ($value) use (&$result) { + $promise->then(function ($value) use (&$result): void { $result = $value; }); @@ -31,16 +31,16 @@ public function promise_success() * @test * */ - public function promise_failure() + public function promise_failure(): void { $promise = Observable::error(new Exception('some error'))->toPromise(); $error = null; $promise->then( - function () { + function (): void { }, - function ($ex) use (&$error) { + function ($ex) use (&$error): void { $error = $ex; }); @@ -51,7 +51,7 @@ function ($ex) use (&$error) { * @test * */ - public function promise_within_promise_success() + public function promise_within_promise_success(): void { $promise1 = \React\Promise\resolve(42); @@ -59,7 +59,7 @@ public function promise_within_promise_success() $result = null; - $promise2->then(function ($value) use (&$result) { + $promise2->then(function ($value) use (&$result): void { $result = $value; }); @@ -70,7 +70,7 @@ public function promise_within_promise_success() * @test * */ - public function promise_within_promise_failure() + public function promise_within_promise_failure(): void { $promise1 = \React\Promise\reject(new Exception('some error')); @@ -79,9 +79,9 @@ public function promise_within_promise_failure() $error = null; $promise2->then( - function () { + function (): void { }, - function (Exception $ex) use (&$error) { + function (Exception $ex) use (&$error): void { $error = $ex; }); @@ -92,13 +92,13 @@ function (Exception $ex) use (&$error) { * @test * */ - public function promise_cancel() + public function promise_cancel(): void { $disposed = false; $promise = Observable::timer(1000) ->mapTo(42) - ->finally(function () use (&$disposed) { + ->finally(function () use (&$disposed): void { $disposed = true; }) ->toPromise(); @@ -107,7 +107,7 @@ public function promise_cancel() $promise->cancel(); - $promise->then(function ($value) use (&$result) { + $promise->then(function ($value) use (&$result): void { $result = $value; }); diff --git a/test/Rx/Functional/React/PromiseFactoryTest.php b/test/Rx/Functional/React/PromiseFactoryTest.php index 8fc4dd56..6a20064f 100644 --- a/test/Rx/Functional/React/PromiseFactoryTest.php +++ b/test/Rx/Functional/React/PromiseFactoryTest.php @@ -13,7 +13,7 @@ class PromiseFactoryTest extends FunctionalTestCase /** * @test */ - public function from_promise_success() + public function from_promise_success(): void { $source = PromiseFactory::toObservable(function() { return Promise::resolved(42); @@ -23,16 +23,16 @@ public function from_promise_success() return $source; }); - $this->assertMessages(array( + $this->assertMessages([ onNext(200, 42), onCompleted(200), - ), $results->getMessages()); + ], $results->getMessages()); } /** * @test */ - public function from_promise_reject_non_exception() + public function from_promise_reject_non_exception(): void { $source = PromiseFactory::toObservable(function () { return Promise::rejected(42); @@ -42,7 +42,7 @@ public function from_promise_reject_non_exception() $source->subscribe( [$this, 'fail'], - function ($err) use (&$theException) { + function ($err) use (&$theException): void { $theException = $err; }, [$this, 'fail'], @@ -58,7 +58,7 @@ function ($err) use (&$theException) { /** * @test */ - public function from_promise_reject() + public function from_promise_reject(): void { $error = new Exception("Test exception"); @@ -70,7 +70,7 @@ public function from_promise_reject() $source->subscribe( [$this, 'fail'], - function ($err) use (&$theException) { + function ($err) use (&$theException): void { $theException = $err; }, [$this, 'fail'], diff --git a/test/Rx/Functional/React/PromiseFromObservableTest.php b/test/Rx/Functional/React/PromiseFromObservableTest.php index 88829fed..d9a723ef 100644 --- a/test/Rx/Functional/React/PromiseFromObservableTest.php +++ b/test/Rx/Functional/React/PromiseFromObservableTest.php @@ -15,17 +15,17 @@ class PromiseFromObservableTest extends FunctionalTestCase * @test * */ - public function promise_success() + public function promise_success(): void { $source = Observable::of(42); $promise = Promise::fromObservable($source); $promise->then( - function ($value) { + function ($value): void { $this->assertEquals(42, $value); }, - function () { + function (): void { $this->assertTrue(false); }); } @@ -34,7 +34,7 @@ function () { * @test * */ - public function promise_failure() + public function promise_failure(): void { $source = (new Subject()); $source->onError(new Exception("some error")); @@ -42,10 +42,10 @@ public function promise_failure() $promise = Promise::fromObservable($source); $promise->then( - function ($value) { + function ($value): void { $this->assertTrue(false); }, - function ($error) { + function ($error): void { $this->assertEquals($error, new Exception("some error")); }); } diff --git a/test/Rx/Functional/React/PromiseToObservableTest.php b/test/Rx/Functional/React/PromiseToObservableTest.php index 4dd4991e..a50414a4 100644 --- a/test/Rx/Functional/React/PromiseToObservableTest.php +++ b/test/Rx/Functional/React/PromiseToObservableTest.php @@ -16,20 +16,20 @@ class PromiseToObservableTest extends FunctionalTestCase * @test * */ - public function from_promise_success() + public function from_promise_success(): void { $p = Promise::resolved(42); $source = Promise::toObservable($p); $source->subscribe(new CallbackObserver( - function ($x) { + function ($x): void { $this->assertEquals(42, $x); }, - function ($error) { + function ($error): void { $this->assertFalse(true); }, - function () { + function (): void { $this->assertTrue(true); })); } @@ -38,23 +38,23 @@ function () { * @test * */ - public function from_promise_failure() + public function from_promise_failure(): void { - $p = new ReactPromise(function () { + $p = new ReactPromise(function (): void { 1 / 0; }); $source = Promise::toObservable($p); $source->subscribe(new CallbackObserver( - function ($x) { + function ($x): void { $this->assertFalse(true); }, - function (\Throwable $error) { + function (\Throwable $error): void { $this->assertStringContainsStringIgnoringCase('division by zero', $error->getMessage()); }, - function () { + function (): void { $this->assertFalse(true); })); @@ -63,17 +63,17 @@ function () { /** * @test */ - public function to_observable_cancels_on_dispose() + public function to_observable_cancels_on_dispose(): void { $canceled = false; - $deferred = new Deferred(function () use (&$canceled) { + $deferred = new Deferred(function () use (&$canceled): void { $canceled = true; }); $o = Promise::toObservable($deferred->promise()); - $this->scheduler->schedule(function () use ($deferred) { + $this->scheduler->schedule(function () use ($deferred): void { $deferred->resolve(1); }, 300); @@ -93,11 +93,11 @@ public function to_observable_cancels_on_dispose() /** * @test */ - public function two_observables_one_delayed() + public function two_observables_one_delayed(): void { $canceled = false; - $deferred = new Deferred(function () use (&$canceled) { + $deferred = new Deferred(function () use (&$canceled): void { $canceled = true; }); @@ -131,18 +131,18 @@ public function two_observables_one_delayed() /** * @test */ - public function two_observables_one_disposed_before_resolve() + public function two_observables_one_disposed_before_resolve(): void { $canceled = false; - $deferred = new Deferred(function () use (&$canceled) { + $deferred = new Deferred(function () use (&$canceled): void { $canceled = true; }); $o1 = Promise::toObservable($deferred->promise()); $o2 = Promise::toObservable($deferred->promise())->delay(100, $this->scheduler); - $this->scheduler->schedule(function () use ($deferred) { + $this->scheduler->schedule(function () use ($deferred): void { $deferred->resolve(1); }, 100); @@ -151,7 +151,7 @@ public function two_observables_one_disposed_before_resolve() $s1 = $o1->subscribe($results1); - $this->scheduler->schedule(function () use ($s1) { + $this->scheduler->schedule(function () use ($s1): void { $s1->dispose(); }, 50); @@ -174,17 +174,17 @@ public function two_observables_one_disposed_before_resolve() /** * @test */ - public function observable_dispose_after_complete() + public function observable_dispose_after_complete(): void { $canceled = false; - $deferred = new Deferred(function () use (&$canceled) { + $deferred = new Deferred(function () use (&$canceled): void { $canceled = true; }); $o = Promise::toObservable($deferred->promise()); - $this->scheduler->schedule(function () use ($deferred) { + $this->scheduler->schedule(function () use ($deferred): void { $deferred->resolve(1); }, 200); @@ -192,7 +192,7 @@ public function observable_dispose_after_complete() $s = $o->subscribe($results); - $this->scheduler->schedule(function () use ($s) { + $this->scheduler->schedule(function () use ($s): void { $s->dispose(); }, 250); diff --git a/test/Rx/Functional/Scheduler/EventLoopSchedulerTest.php b/test/Rx/Functional/Scheduler/EventLoopSchedulerTest.php index 9bc10ff6..6c7778c7 100644 --- a/test/Rx/Functional/Scheduler/EventLoopSchedulerTest.php +++ b/test/Rx/Functional/Scheduler/EventLoopSchedulerTest.php @@ -12,7 +12,7 @@ class EventLoopSchedulerTest extends FunctionalTestCase { - public function testDisposeInsideFirstSchedulePeriodicAction() + public function testDisposeInsideFirstSchedulePeriodicAction(): void { $completed = false; $nextCount = 0; @@ -22,13 +22,13 @@ public function testDisposeInsideFirstSchedulePeriodicAction() Observable::interval(50, new EventLoopScheduler($loop)) ->take(1) ->subscribe(new CallbackObserver( - function ($x) use (&$nextCount) { + function ($x) use (&$nextCount): void { $nextCount++; }, - function ($err) { + function ($err): void { throw $err; }, - function () use (&$completed) { + function () use (&$completed): void { $completed = true; } )); diff --git a/test/Rx/Functional/Subject/AsyncSubjectTest.php b/test/Rx/Functional/Subject/AsyncSubjectTest.php index ebd706e2..370315c6 100644 --- a/test/Rx/Functional/Subject/AsyncSubjectTest.php +++ b/test/Rx/Functional/Subject/AsyncSubjectTest.php @@ -15,7 +15,7 @@ class AsyncSubjectTest extends FunctionalTestCase /** * @test */ - public function infinite() + public function infinite(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -42,43 +42,43 @@ public function infinite() $subscription2 = null; $subscription3 = null; - $this->scheduler->scheduleAbsolute(100, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(100, function () use (&$subject): void { $subject = new AsyncSubject(); }); - $this->scheduler->scheduleAbsolute(200, function () use ($xs, &$subscription, &$subject) { + $this->scheduler->scheduleAbsolute(200, function () use ($xs, &$subscription, &$subject): void { $subscription = $xs->subscribe($subject); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$results1, &$subscription1, &$subject) { + $this->scheduler->scheduleAbsolute(300, function () use (&$results1, &$subscription1, &$subject): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$results2, &$subscription2, &$subject) { + $this->scheduler->scheduleAbsolute(400, function () use (&$results2, &$subscription2, &$subject): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsolute(900, function () use (&$results3, &$subscription3, &$subject) { + $this->scheduler->scheduleAbsolute(900, function () use (&$results3, &$subscription3, &$subject): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsolute(600, function () use (&$subscription1) { + $this->scheduler->scheduleAbsolute(600, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsolute(700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsolute(700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$subscription1) { + $this->scheduler->scheduleAbsolute(800, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsolute(950, function () use (&$subscription3) { + $this->scheduler->scheduleAbsolute(950, function () use (&$subscription3): void { $subscription3->dispose(); }); @@ -92,7 +92,7 @@ public function infinite() /** * @test */ - public function finite() + public function finite(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -118,43 +118,43 @@ public function finite() $subscription2 = null; $subscription3 = null; - $this->scheduler->scheduleAbsolute(100, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(100, function () use (&$subject): void { $subject = new AsyncSubject(); }); - $this->scheduler->scheduleAbsolute(200, function () use ($xs, &$subscription, &$subject) { + $this->scheduler->scheduleAbsolute(200, function () use ($xs, &$subscription, &$subject): void { $subscription = $xs->subscribe($subject); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$results1, &$subscription1, &$subject) { + $this->scheduler->scheduleAbsolute(300, function () use (&$results1, &$subscription1, &$subject): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$results2, &$subscription2, &$subject) { + $this->scheduler->scheduleAbsolute(400, function () use (&$results2, &$subscription2, &$subject): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsolute(900, function () use (&$results3, &$subscription3, &$subject) { + $this->scheduler->scheduleAbsolute(900, function () use (&$results3, &$subscription3, &$subject): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsolute(600, function () use (&$subscription1) { + $this->scheduler->scheduleAbsolute(600, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsolute(700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsolute(700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$subscription1) { + $this->scheduler->scheduleAbsolute(800, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsolute(950, function () use (&$subscription3) { + $this->scheduler->scheduleAbsolute(950, function () use (&$subscription3): void { $subscription3->dispose(); }); @@ -169,7 +169,7 @@ public function finite() /** * @test */ - public function error() + public function error(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -195,43 +195,43 @@ public function error() $subscription2 = null; $subscription3 = null; - $this->scheduler->scheduleAbsolute(100, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(100, function () use (&$subject): void { $subject = new AsyncSubject(); }); - $this->scheduler->scheduleAbsolute(200, function () use ($xs, &$subscription, &$subject) { + $this->scheduler->scheduleAbsolute(200, function () use ($xs, &$subscription, &$subject): void { $subscription = $xs->subscribe($subject); }); - $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsolute(1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$results1, &$subscription1, &$subject) { + $this->scheduler->scheduleAbsolute(300, function () use (&$results1, &$subscription1, &$subject): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$results2, &$subscription2, &$subject) { + $this->scheduler->scheduleAbsolute(400, function () use (&$results2, &$subscription2, &$subject): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsolute(900, function () use (&$results3, &$subscription3, &$subject) { + $this->scheduler->scheduleAbsolute(900, function () use (&$results3, &$subscription3, &$subject): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsolute(600, function () use (&$subscription1) { + $this->scheduler->scheduleAbsolute(600, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsolute(700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsolute(700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$subscription1) { + $this->scheduler->scheduleAbsolute(800, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsolute(950, function () use (&$subscription3) { + $this->scheduler->scheduleAbsolute(950, function () use (&$subscription3): void { $subscription3->dispose(); }); @@ -247,7 +247,7 @@ public function error() /** * @test */ - public function dispose() + public function dispose(): void { @@ -260,88 +260,88 @@ public function dispose() $subscription2 = null; $subscription3 = null; - $this->scheduler->scheduleAbsolute(100, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(100, function () use (&$subject): void { $subject = new AsyncSubject(); }); - $this->scheduler->scheduleAbsolute(200, function () use (&$subscription1, &$subject, $results1) { + $this->scheduler->scheduleAbsolute(200, function () use (&$subscription1, &$subject, $results1): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsolute(300, function () use (&$subscription2, &$subject, $results2) { + $this->scheduler->scheduleAbsolute(300, function () use (&$subscription2, &$subject, $results2): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsolute(400, function () use (&$subscription3, &$subject, $results3) { + $this->scheduler->scheduleAbsolute(400, function () use (&$subscription3, &$subject, $results3): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsolute(500, function () use (&$subscription1) { + $this->scheduler->scheduleAbsolute(500, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsolute(600, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(600, function () use (&$subject): void { $subject->dispose(); }); - $this->scheduler->scheduleAbsolute(700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsolute(700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsolute(800, function () use (&$subscription3) { + $this->scheduler->scheduleAbsolute(800, function () use (&$subscription3): void { $subscription3->dispose(); }); - $this->scheduler->scheduleAbsolute(150, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(150, function () use (&$subject): void { $subject->onNext(1); }); - $this->scheduler->scheduleAbsolute(250, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(250, function () use (&$subject): void { $subject->onNext(2); }); - $this->scheduler->scheduleAbsolute(350, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(350, function () use (&$subject): void { $subject->onNext(3); }); - $this->scheduler->scheduleAbsolute(450, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(450, function () use (&$subject): void { $subject->onNext(4); }); - $this->scheduler->scheduleAbsolute(550, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(550, function () use (&$subject): void { $subject->onNext(5); }); - $this->scheduler->scheduleAbsolute(650, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(650, function () use (&$subject): void { - $this->assertException(function () use (&$subject) { + $this->assertException(function () use (&$subject): void { $subject->onNext(6); }); }); - $this->scheduler->scheduleAbsolute(750, function () use (&$subject) { - $this->assertException(function () use (&$subject) { + $this->scheduler->scheduleAbsolute(750, function () use (&$subject): void { + $this->assertException(function () use (&$subject): void { $subject->onCompleted(); }); }); - $this->scheduler->scheduleAbsolute(850, function () use (&$subject) { - $this->assertException(function () use (&$subject) { + $this->scheduler->scheduleAbsolute(850, function () use (&$subject): void { + $this->assertException(function () use (&$subject): void { $subject->onError(new \Exception()); }); }); - $this->scheduler->scheduleAbsolute(950, function () use (&$subject) { + $this->scheduler->scheduleAbsolute(950, function () use (&$subject): void { - $this->assertException(function () use (&$subject) { + $this->assertException(function () use (&$subject): void { $subject->subscribe(new CallbackObserver()); }); }); diff --git a/test/Rx/Functional/Subject/ReplaySubjectTest.php b/test/Rx/Functional/Subject/ReplaySubjectTest.php index c7c966d9..53256c92 100644 --- a/test/Rx/Functional/Subject/ReplaySubjectTest.php +++ b/test/Rx/Functional/Subject/ReplaySubjectTest.php @@ -12,7 +12,7 @@ class ReplaySubjectTest extends FunctionalTestCase { - public function testInfinite() + public function testInfinite(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -34,36 +34,36 @@ public function testInfinite() $results2 = $this->scheduler->createObserver(); $results3 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject): void { $subject = new ReplaySubject(3, 100, $this->scheduler); }); - $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subscription, &$xs, &$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subscription, &$xs, &$subject): void { $subscription = $xs->subscribe($subject); }); - $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subscription1, &$subject, &$results1) { + $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subscription1, &$subject, &$results1): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subscription2, &$subject, &$results2) { + $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subscription2, &$subject, &$results2): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subscription3, &$subject, &$results3) { + $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subscription3, &$subject, &$results3): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3) { + $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3): void { $subscription3->dispose(); }); @@ -99,7 +99,7 @@ public function testInfinite() ); } - public function testInfinite2() + public function testInfinite2(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -123,36 +123,36 @@ public function testInfinite2() $results2 = $this->scheduler->createObserver(); $results3 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject): void { $subject = new ReplaySubject(3, 100, $this->scheduler); }); - $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription, $xs) { + $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription, $xs): void { $subscription = $xs->subscribe($subject); }); - $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription1, &$results1) { + $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription1, &$results1): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription2, &$results2) { + $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription2, &$results2): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$subscription3, &$results3) { + $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$subscription3, &$results3): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3) { + $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3): void { $subscription3->dispose(); }); @@ -186,7 +186,7 @@ public function testInfinite2() } - public function testFinite() + public function testFinite(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -207,36 +207,36 @@ public function testFinite() $results2 = $this->scheduler->createObserver(); $results3 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject): void { $subject = new ReplaySubject(3, 100, $this->scheduler); }); - $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription, $xs) { + $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription, $xs): void { $subscription = $xs->subscribe($subject); }); - $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription1, &$results1) { + $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription1, &$results1): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription2, &$results2) { + $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription2, &$results2): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$subscription3, &$results3) { + $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$subscription3, &$results3): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3) { + $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3): void { $subscription3->dispose(); }); @@ -262,7 +262,7 @@ public function testFinite() } - public function testError() + public function testError(): void { $error = new \Exception(); @@ -284,36 +284,36 @@ public function testError() $results2 = $this->scheduler->createObserver(); $results3 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject): void { $subject = new ReplaySubject(3, 100, $this->scheduler); }); - $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription, $xs) { + $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription, $xs): void { $subscription = $xs->subscribe($subject); }); - $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription1, &$results1) { + $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription1, &$results1): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription2, &$results2) { + $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription2, &$results2): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$subscription3, &$results3) { + $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$subscription3, &$results3): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3) { + $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3): void { $subscription3->dispose(); }); @@ -339,7 +339,7 @@ public function testError() ], $results3->getMessages()); } - public function testCanceled() + public function testCanceled(): void { $xs = $this->createHotObservable([ onCompleted(630), @@ -352,36 +352,36 @@ public function testCanceled() $results2 = $this->scheduler->createObserver(); $results3 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject): void { $subject = new ReplaySubject(3, 100, $this->scheduler); }); - $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription, $xs) { + $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription, $xs): void { $subscription = $xs->subscribe($subject); }); - $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription) { + $this->scheduler->scheduleAbsoluteWithState(null, 1000, function () use (&$subscription): void { $subscription->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription1, &$results1) { + $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription1, &$results1): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription2, &$results2) { + $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription2, &$results2): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$subscription3, &$results3) { + $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$subscription3, &$results3): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3) { + $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subscription3): void { $subscription3->dispose(); }); @@ -399,69 +399,69 @@ public function testCanceled() } - public function testDisposed() + public function testDisposed(): void { $results1 = $this->scheduler->createObserver(); $results2 = $this->scheduler->createObserver(); $results3 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject): void { $subject = new ReplaySubject(null, null, $this->scheduler); }); - $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription1, &$results1) { + $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use (&$subject, &$subscription1, &$results1): void { $subscription1 = $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription2, &$results2) { + $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$subscription2, &$results2): void { $subscription2 = $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription3, &$results3) { + $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$subscription3, &$results3): void { $subscription3 = $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsoluteWithState(null, 500, function () use (&$subject, &$subscription1) { + $this->scheduler->scheduleAbsoluteWithState(null, 500, function () use (&$subject, &$subscription1): void { $subscription1->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subject): void { $subject->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2) { + $this->scheduler->scheduleAbsoluteWithState(null, 700, function () use (&$subscription2): void { $subscription2->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription3) { + $this->scheduler->scheduleAbsoluteWithState(null, 800, function () use (&$subscription3): void { $subscription3->dispose(); }); - $this->scheduler->scheduleAbsoluteWithState(null, 150, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 150, function () use (&$subject): void { $subject->onNext(1); }); - $this->scheduler->scheduleAbsoluteWithState(null, 250, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 250, function () use (&$subject): void { $subject->onNext(2); }); - $this->scheduler->scheduleAbsoluteWithState(null, 350, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 350, function () use (&$subject): void { $subject->onNext(3); }); - $this->scheduler->scheduleAbsoluteWithState(null, 450, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 450, function () use (&$subject): void { $subject->onNext(4); }); - $this->scheduler->scheduleAbsoluteWithState(null, 550, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 550, function () use (&$subject): void { $subject->onNext(5); }); - $this->scheduler->scheduleAbsoluteWithState(null, 650, function () use (&$subject) { - $this->assertException(function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 650, function () use (&$subject): void { + $this->assertException(function () use (&$subject): void { $subject->onNext(6); }); }); - $this->scheduler->scheduleAbsoluteWithState(null, 750, function () use (&$subject) { - $this->assertException(function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 750, function () use (&$subject): void { + $this->assertException(function () use (&$subject): void { $subject->onCompleted(); }); }); - $this->scheduler->scheduleAbsoluteWithState(null, 850, function () use (&$subject) { - $this->assertException(function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 850, function () use (&$subject): void { + $this->assertException(function () use (&$subject): void { $subject->onError(new \Exception()); }); }); - $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subject) { - $this->assertException(function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 950, function () use (&$subject): void { + $this->assertException(function () use (&$subject): void { $subject->subscribe(new CallbackObserver()); }); }); @@ -493,7 +493,7 @@ public function testDisposed() } - public function testDiesOut() + public function testDiesOut(): void { $xs = $this->createHotObservable([ onNext(70, 1), @@ -512,23 +512,23 @@ public function testDiesOut() $results3 = $this->scheduler->createObserver(); $results4 = $this->scheduler->createObserver(); - $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 100, function () use (&$subject): void { $subject = new ReplaySubject(9007199254740991, 100, $this->scheduler); }); - $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use ($xs, &$subject) { + $this->scheduler->scheduleAbsoluteWithState(null, 200, function () use ($xs, &$subject): void { $xs->subscribe($subject); }); - $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$results1) { + $this->scheduler->scheduleAbsoluteWithState(null, 300, function () use (&$subject, &$results1): void { $subject->subscribe($results1); }); - $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$results2) { + $this->scheduler->scheduleAbsoluteWithState(null, 400, function () use (&$subject, &$results2): void { $subject->subscribe($results2); }); - $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subject, &$results3) { + $this->scheduler->scheduleAbsoluteWithState(null, 600, function () use (&$subject, &$results3): void { $subject->subscribe($results3); }); - $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$results4) { + $this->scheduler->scheduleAbsoluteWithState(null, 900, function () use (&$subject, &$results4): void { $subject->subscribe($results4); }); @@ -565,7 +565,7 @@ public function testDiesOut() /** * @test */ - public function it_replays_with_immediate_scheduler() { + public function it_replays_with_immediate_scheduler(): void { $rs = new ReplaySubject(); $o = Observable::fromArray(range(1,5)); @@ -575,13 +575,13 @@ public function it_replays_with_immediate_scheduler() { $result = []; $completed = false; - $rs->subscribe(function ($x) use (&$result) { + $rs->subscribe(function ($x) use (&$result): void { $result[] = $x; }, - function ($e) { + function ($e): void { $this->fail('Should not have failed'); }, - function () use (&$result, &$completed) { + function () use (&$result, &$completed): void { $completed = true; $this->assertEquals($result, range(1,5)); } diff --git a/test/Rx/Observable/AnonymousObservableTest.php b/test/Rx/Observable/AnonymousObservableTest.php index e83c5f6d..a6aa1b06 100644 --- a/test/Rx/Observable/AnonymousObservableTest.php +++ b/test/Rx/Observable/AnonymousObservableTest.php @@ -14,12 +14,12 @@ class AnonymousObservableTest extends TestCase /** * @test */ - public function it_calls_the_subscribe_action_on_subscribe() + public function it_calls_the_subscribe_action_on_subscribe(): void { $called = 0; $observable = new AnonymousObservable(function() use (&$called) { $called++; return new EmptyDisposable(); }); - $observerMock = $this->createMock('Rx\ObserverInterface'); + $observerMock = $this->createMock(\Rx\ObserverInterface::class); $observable->subscribe($observerMock); $this->assertEquals(1, $called); @@ -28,17 +28,17 @@ public function it_calls_the_subscribe_action_on_subscribe() /** * @test */ - public function the_returned_disposable_disposes() + public function the_returned_disposable_disposes(): void { $disposed = false; $observable = new AnonymousObservable(function() use (&$disposed) { - return new CallbackDisposable(function() use (&$disposed) { + return new CallbackDisposable(function() use (&$disposed): void { $disposed = true; }); }); - $observerMock = $this->createMock('Rx\ObserverInterface'); + $observerMock = $this->createMock(\Rx\ObserverInterface::class); $disposable = $observable->subscribe($observerMock); $disposable->dispose(); @@ -49,10 +49,10 @@ public function the_returned_disposable_disposes() /** * @test */ - public function it_throws_when_args_invalid() + public function it_throws_when_args_invalid(): void { $this->expectException(\InvalidArgumentException::class); - $observable = new AnonymousObservable(function () { + $observable = new AnonymousObservable(function (): void { }); $observable->subscribe('invalid arg'); diff --git a/test/Rx/Observable/ArrayObservableTest.php b/test/Rx/Observable/ArrayObservableTest.php index cd9df38d..eb43f14b 100644 --- a/test/Rx/Observable/ArrayObservableTest.php +++ b/test/Rx/Observable/ArrayObservableTest.php @@ -13,7 +13,7 @@ class ArrayObservableTest extends TestCase /** * @test */ - public function it_starts_again_if_you_subscribe_again() + public function it_starts_again_if_you_subscribe_again(): void { $a = [1,2,3]; @@ -22,14 +22,14 @@ public function it_starts_again_if_you_subscribe_again() $goodCount = 0; $o->toArray()->subscribe(new CallbackObserver( - function ($x) use ($a, &$goodCount) { + function ($x) use ($a, &$goodCount): void { $goodCount++; $this->assertEquals($a, $x); } )); $o->toArray()->subscribe(new CallbackObserver( - function ($x) use ($a, &$goodCount) { + function ($x) use ($a, &$goodCount): void { $goodCount++; $this->assertEquals($a, $x); } @@ -38,24 +38,24 @@ function ($x) use ($a, &$goodCount) { $this->assertEquals(2, $goodCount); } - public function testRange() + public function testRange(): void { //todo: refactor $observable = new ArrayObservable(range(1, 10), Scheduler::getDefault()); - $record = array(); - $observable->subscribe(function($v) use (&$record) {$record[] = $v; }); + $record = []; + $observable->subscribe(function($v) use (&$record): void {$record[] = $v; }); $this->assertEquals(range(1, 10), $record); } - public function testOnCompleteIsCalled() + public function testOnCompleteIsCalled(): void { //todo: refactor - $observable = new ArrayObservable(array(), Scheduler::getDefault()); + $observable = new ArrayObservable([], Scheduler::getDefault()); $isCalled = false; - $observable->subscribe(null, null, function() use (&$isCalled) { $isCalled = true; }); + $observable->subscribe(null, null, function() use (&$isCalled): void { $isCalled = true; }); $this->assertTrue($isCalled, 'onComplete should be called.'); } diff --git a/test/Rx/Observable/ConnectableObservableTest.php b/test/Rx/Observable/ConnectableObservableTest.php index 62afe88b..ce3e7f48 100644 --- a/test/Rx/Observable/ConnectableObservableTest.php +++ b/test/Rx/Observable/ConnectableObservableTest.php @@ -16,13 +16,13 @@ class ConnectableObservableTest extends FunctionalTestCase /** * @test */ - public function connectable_observable_creation() + public function connectable_observable_creation(): void { $y = 0; $s2 = new Subject(); $co2 = new ConnectableObservable(Observable::of(1), $s2); - $co2->subscribe(new CallbackObserver(function ($x) use (&$y) { + $co2->subscribe(new CallbackObserver(function ($x) use (&$y): void { $y = $x; })); @@ -37,7 +37,7 @@ public function connectable_observable_creation() /** * @test */ - public function connectable_observable_connected() + public function connectable_observable_connected(): void { $xs = $this->createHotObservable( [ @@ -73,7 +73,7 @@ public function connectable_observable_connected() /** * @test */ - public function connectable_observable_disconnected() + public function connectable_observable_disconnected(): void { $xs = $this->createHotObservable( [ @@ -101,7 +101,7 @@ public function connectable_observable_disconnected() /** * @test */ - public function connectable_observable_disconnect_future() + public function connectable_observable_disconnect_future(): void { $xs = $this->createHotObservable( [ @@ -134,7 +134,7 @@ public function connectable_observable_disconnect_future() /** * @test */ - public function connectable_observable_multiple_non_overlapped_connections() + public function connectable_observable_multiple_non_overlapped_connections(): void { $xs = $this->createHotObservable( [ @@ -155,21 +155,21 @@ public function connectable_observable_multiple_non_overlapped_connections() $conn = $xs->multicast($subject); $c1 = null; - $this->scheduler->scheduleAbsolute(225, function () use(&$c1, $conn){ $c1 = $conn->connect(); }); - $this->scheduler->scheduleAbsolute(241, function () use(&$c1){ $c1->dispose(); }); - $this->scheduler->scheduleAbsolute(245, function () use(&$c1){ $c1->dispose(); }); // idempotency test - $this->scheduler->scheduleAbsolute(251, function () use(&$c1){ $c1->dispose(); }); // idempotency test - $this->scheduler->scheduleAbsolute(260, function () use(&$c1){ $c1->dispose(); }); // idempotency test + $this->scheduler->scheduleAbsolute(225, function () use(&$c1, $conn): void{ $c1 = $conn->connect(); }); + $this->scheduler->scheduleAbsolute(241, function () use(&$c1): void{ $c1->dispose(); }); + $this->scheduler->scheduleAbsolute(245, function () use(&$c1): void{ $c1->dispose(); }); // idempotency test + $this->scheduler->scheduleAbsolute(251, function () use(&$c1): void{ $c1->dispose(); }); // idempotency test + $this->scheduler->scheduleAbsolute(260, function () use(&$c1): void{ $c1->dispose(); }); // idempotency test $c2 = null; - $this->scheduler->scheduleAbsolute(249, function () use(&$c2, $conn){ $c2 = $conn->connect(); }); - $this->scheduler->scheduleAbsolute(255, function () use(&$c2){ $c2->dispose(); }); - $this->scheduler->scheduleAbsolute(265, function () use(&$c2){ $c2->dispose(); }); // idempotency test - $this->scheduler->scheduleAbsolute(280, function () use(&$c2){ $c2->dispose(); }); // idempotency test + $this->scheduler->scheduleAbsolute(249, function () use(&$c2, $conn): void{ $c2 = $conn->connect(); }); + $this->scheduler->scheduleAbsolute(255, function () use(&$c2): void{ $c2->dispose(); }); + $this->scheduler->scheduleAbsolute(265, function () use(&$c2): void{ $c2->dispose(); }); // idempotency test + $this->scheduler->scheduleAbsolute(280, function () use(&$c2): void{ $c2->dispose(); }); // idempotency test $c3 = null; - $this->scheduler->scheduleAbsolute(275, function () use(&$c3, $conn){ $c3 = $conn->connect(); }); - $this->scheduler->scheduleAbsolute(295, function () use(&$c3){ $c3->dispose(); }); + $this->scheduler->scheduleAbsolute(275, function () use(&$c3, $conn): void{ $c3 = $conn->connect(); }); + $this->scheduler->scheduleAbsolute(295, function () use(&$c3): void{ $c3->dispose(); }); $results = $this->scheduler->startWithCreate(function () use ($xs, $conn) { diff --git a/test/Rx/Observable/ErrorObservableTest.php b/test/Rx/Observable/ErrorObservableTest.php index d7732bc7..b16c5233 100644 --- a/test/Rx/Observable/ErrorObservableTest.php +++ b/test/Rx/Observable/ErrorObservableTest.php @@ -11,19 +11,19 @@ class ErrorObservableTest extends TestCase { /** @test */ - public function it_calls_observers_with_error() + public function it_calls_observers_with_error(): void { $ex = new RuntimeException('boom!'); $observable = new ErrorObservable($ex, Scheduler::getDefault()); $recordedException = null; $observable->subscribe( - function () { + function (): void { }, - function ($ex) use (&$recordedException) { + function ($ex) use (&$recordedException): void { $recordedException = $ex; }, - function () { + function (): void { } ); diff --git a/test/Rx/Observable/GroupedObservableTest.php b/test/Rx/Observable/GroupedObservableTest.php index 5722d83d..9a52389e 100644 --- a/test/Rx/Observable/GroupedObservableTest.php +++ b/test/Rx/Observable/GroupedObservableTest.php @@ -14,9 +14,9 @@ class GroupedObservableTest extends TestCase /** * @test */ - public function it_returns_the_disposable_of_the_underlying_disposable() + public function it_returns_the_disposable_of_the_underlying_disposable(): void { - $disposable = $this->createMock('Rx\DisposableInterface'); + $disposable = $this->createMock(\Rx\DisposableInterface::class); $disposable->expects($this->once()) ->method('dispose'); @@ -33,9 +33,9 @@ public function it_returns_the_disposable_of_the_underlying_disposable() /** * @test */ - public function it_exposes_its_key() + public function it_exposes_its_key(): void { - $observable = new AnonymousObservable(function(){}); + $observable = new AnonymousObservable(function(): void{}); $groupedObservable = new GroupedObservable('key', $observable); $this->assertEquals('key', $groupedObservable->getKey()); diff --git a/test/Rx/Observable/RefCountObservableTest.php b/test/Rx/Observable/RefCountObservableTest.php index 8586c384..e47d369b 100644 --- a/test/Rx/Observable/RefCountObservableTest.php +++ b/test/Rx/Observable/RefCountObservableTest.php @@ -11,7 +11,7 @@ class RefCountObservableTest extends TestCase { - public function testRefCountDisposableOnlyDisposesOnce() + public function testRefCountDisposableOnlyDisposesOnce(): void { $source = $this->createMock(ConnectableObservable::class); @@ -36,7 +36,7 @@ public function testRefCountDisposableOnlyDisposesOnce() } - public function testDisposesWhenRefcountReachesZero() + public function testDisposesWhenRefcountReachesZero(): void { $source = $this->createMock(ConnectableObservable::class); diff --git a/test/Rx/ObservableFactoryWrapperTest.php b/test/Rx/ObservableFactoryWrapperTest.php index 180c9dac..5f128519 100644 --- a/test/Rx/ObservableFactoryWrapperTest.php +++ b/test/Rx/ObservableFactoryWrapperTest.php @@ -9,33 +9,33 @@ class ObservableFactoryWrapperTest extends TestCase { - public function testPromiseIsConvertedToObservable() + public function testPromiseIsConvertedToObservable(): void { $afw = new ObservableFactoryWrapper(static function (): PromiseInterface { return resolve(true); }); $true = null; - $afw()->subscribe(function ($v) use (&$true) { + $afw()->subscribe(function ($v) use (&$true): void { $true = $v; }); self::assertTrue($true); } - public function testObservable() + public function testObservable(): void { $afw = new ObservableFactoryWrapper(static function (): Observable { return Observable::fromArray([true], Scheduler::getImmediate()); }); $true = null; - $afw()->subscribe(function ($v) use (&$true) { + $afw()->subscribe(function ($v) use (&$true): void { $true = $v; }); self::assertTrue($true); } - public function testNotAnObservableOrPromise() + public function testNotAnObservableOrPromise(): void { self::expectException(\Exception::class); self::expectExceptionMessageMatches('/You must return an Observable or Promise in/'); diff --git a/test/Rx/ObservableTest.php b/test/Rx/ObservableTest.php index a7713d95..b48ec9e1 100644 --- a/test/Rx/ObservableTest.php +++ b/test/Rx/ObservableTest.php @@ -14,7 +14,7 @@ class ObservableTest extends TestCase { - public function testJustIsAliasForOf() + public function testJustIsAliasForOf(): void { $o = new class extends Observable { private static $ofCalled = false; @@ -24,7 +24,7 @@ public static function ofWasCalled() return static::$ofCalled; } - public static function of($value, SchedulerInterface $scheduler = null): ReturnObservable + public static function of($value, ?SchedulerInterface $scheduler = null): ReturnObservable { static::$ofCalled = true; return new ReturnObservable(123, new ImmediateScheduler()); @@ -42,7 +42,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $this->assertTrue($o::ofWasCalled()); } - public function testEmptyObservableIsAliasForEmpty() + public function testEmptyObservableIsAliasForEmpty(): void { $o = new class extends Observable { private static $emptyCalled = false; @@ -52,7 +52,7 @@ public static function emptyWasCalled() return static::$emptyCalled; } - public static function empty(SchedulerInterface $scheduler = null): EmptyObservable + public static function empty(?SchedulerInterface $scheduler = null): EmptyObservable { static::$emptyCalled = true; return new EmptyObservable(new TestScheduler()); @@ -70,7 +70,7 @@ protected function _subscribe(ObserverInterface $observer): DisposableInterface $this->assertTrue($o::emptyWasCalled()); } - public function testShareCallsPublishRefCount() + public function testShareCallsPublishRefCount(): void { $o = $this->getMockBuilder(Observable::class) ->setMethods(['publish']) @@ -93,7 +93,7 @@ public function testShareCallsPublishRefCount() $o->share(); } - public function testShareValueCallsPublishValueRefCount() + public function testShareValueCallsPublishValueRefCount(): void { $o = $this->getMockBuilder(Observable::class) ->setMethods(['publishValue']) @@ -117,7 +117,7 @@ public function testShareValueCallsPublishValueRefCount() $o->shareValue(1); } - public function testShareReplayCallsReplayRefCount() + public function testShareReplayCallsReplayRefCount(): void { $o = $this->getMockBuilder(Observable::class) ->setMethods(['replay']) @@ -146,13 +146,13 @@ public function testShareReplayCallsReplayRefCount() $o->shareReplay(123, 456); } - public function testCatchErrorCallsCatch() + public function testCatchErrorCallsCatch(): void { $o = $this->getMockBuilder(Observable::class) ->setMethods(['catch']) ->getMockForAbstractClass(); - $callable = function () { + $callable = function (): void { }; @@ -167,7 +167,7 @@ public function testCatchErrorCallsCatch() $o->catchError($callable); } - public function testSwitchLatestCallsSwitch() + public function testSwitchLatestCallsSwitch(): void { $o = $this->getMockBuilder(Observable::class) ->setMethods(['switch']) @@ -184,9 +184,9 @@ public function testSwitchLatestCallsSwitch() /** * @test */ - public function it_sends_throwables_in_onnext_to_onerror() + public function it_sends_throwables_in_onnext_to_onerror(): void { - $onNext = function ($x) { + $onNext = function ($x): void { throw new TestException(); }; @@ -195,7 +195,7 @@ public function it_sends_throwables_in_onnext_to_onerror() Observable::of(0) ->subscribe( $onNext, - function (\Throwable $e) use (&$error) { + function (\Throwable $e) use (&$error): void { $error = $e; } ); diff --git a/test/Rx/Observer/AutoDetachObserverTest.php b/test/Rx/Observer/AutoDetachObserverTest.php index aa8e2244..4b06db09 100644 --- a/test/Rx/Observer/AutoDetachObserverTest.php +++ b/test/Rx/Observer/AutoDetachObserverTest.php @@ -13,10 +13,10 @@ class AutoDetachObserverTest extends TestCase /** * @test */ - public function it_calls_dispose_on_completed() + public function it_calls_dispose_on_completed(): void { $disposed = false; - $disposable = new CallbackDisposable(function() use (&$disposed){ $disposed = true; }); + $disposable = new CallbackDisposable(function() use (&$disposed): void{ $disposed = true; }); $observer = new AutoDetachObserver(new CallbackObserver()); $observer->setDisposable($disposable); @@ -28,12 +28,12 @@ public function it_calls_dispose_on_completed() /** * @test */ - public function it_calls_dispose_on_error() + public function it_calls_dispose_on_error(): void { $disposed = false; - $disposable = new CallbackDisposable(function() use (&$disposed){ $disposed = true; }); + $disposable = new CallbackDisposable(function() use (&$disposed): void{ $disposed = true; }); - $observer = new AutoDetachObserver(new CallbackObserver(null, function(){})); + $observer = new AutoDetachObserver(new CallbackObserver(null, function(): void{})); $observer->setDisposable($disposable); $observer->onError(new Exception()); @@ -43,14 +43,14 @@ public function it_calls_dispose_on_error() /** * @test */ - public function it_disposes_if_observer_on_completed_throws() + public function it_disposes_if_observer_on_completed_throws(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('fail'); $disposed = false; - $disposable = new CallbackDisposable(function() use (&$disposed){ $disposed = true; }); + $disposable = new CallbackDisposable(function() use (&$disposed): void{ $disposed = true; }); - $observer = new AutoDetachObserver(new CallbackObserver(null, null, function() { throw new Exception('fail'); })); + $observer = new AutoDetachObserver(new CallbackObserver(null, null, function(): void { throw new Exception('fail'); })); $observer->setDisposable($disposable); $observer->onCompleted(); @@ -60,14 +60,14 @@ public function it_disposes_if_observer_on_completed_throws() /** * @test */ - public function it_disposes_if_observer_on_error_throws() + public function it_disposes_if_observer_on_error_throws(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('fail'); $disposed = false; - $disposable = new CallbackDisposable(function() use (&$disposed){ $disposed = true; }); + $disposable = new CallbackDisposable(function() use (&$disposed): void{ $disposed = true; }); - $observer = new AutoDetachObserver(new CallbackObserver(null, function() { throw new Exception('fail'); })); + $observer = new AutoDetachObserver(new CallbackObserver(null, function(): void { throw new Exception('fail'); })); $observer->setDisposable($disposable); $observer->onError(new Exception()); @@ -77,14 +77,14 @@ public function it_disposes_if_observer_on_error_throws() /** * @test */ - public function it_disposes_if_observer_on_next_throws() + public function it_disposes_if_observer_on_next_throws(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('fail'); $disposed = false; - $disposable = new CallbackDisposable(function() use (&$disposed){ $disposed = true; }); + $disposable = new CallbackDisposable(function() use (&$disposed): void{ $disposed = true; }); - $observer = new AutoDetachObserver(new CallbackObserver(function() { throw new Exception('fail'); })); + $observer = new AutoDetachObserver(new CallbackObserver(function(): void { throw new Exception('fail'); })); $observer->setDisposable($disposable); $observer->onNext(42); diff --git a/test/Rx/Observer/CallbackObserverTest.php b/test/Rx/Observer/CallbackObserverTest.php index dcf67a10..e2196827 100644 --- a/test/Rx/Observer/CallbackObserverTest.php +++ b/test/Rx/Observer/CallbackObserverTest.php @@ -12,10 +12,10 @@ class CallbackObserverTest extends TestCase /** * @test */ - public function it_calls_the_given_callable_on_next() + public function it_calls_the_given_callable_on_next(): void { $called = false; - $observer = new CallbackObserver(function() use (&$called) { $called = true; }); + $observer = new CallbackObserver(function() use (&$called): void { $called = true; }); $observer->onNext(42); $this->assertTrue($called); @@ -24,10 +24,10 @@ public function it_calls_the_given_callable_on_next() /** * @test */ - public function it_calls_the_given_callable_on_error() + public function it_calls_the_given_callable_on_error(): void { $called = false; - $observer = new CallbackObserver(function(){}, function() use (&$called) { $called = true; }); + $observer = new CallbackObserver(function(): void{}, function() use (&$called): void { $called = true; }); $observer->onError(new Exception()); $this->assertTrue($called); @@ -36,10 +36,10 @@ public function it_calls_the_given_callable_on_error() /** * @test */ - public function it_calls_the_given_callable_on_complete() + public function it_calls_the_given_callable_on_complete(): void { $called = false; - $observer = new CallbackObserver(function(){}, function(){}, function() use (&$called) { $called = true; }); + $observer = new CallbackObserver(function(): void{}, function(): void{}, function() use (&$called): void { $called = true; }); $observer->onCompleted(); $this->assertTrue($called); @@ -48,7 +48,7 @@ public function it_calls_the_given_callable_on_complete() /** * @test */ - public function default_on_error_callable_rethrows_exception() + public function default_on_error_callable_rethrows_exception(): void { $this->expectException(\Rx\Observer\TestException::class); $observer = new CallbackObserver(); @@ -59,10 +59,10 @@ public function default_on_error_callable_rethrows_exception() /** * @test */ - public function it_calls_on_next_with_the_given_value() + public function it_calls_on_next_with_the_given_value(): void { $called = null; - $observer = new CallbackObserver(function($value) use (&$called) { $called = $value; }); + $observer = new CallbackObserver(function($value) use (&$called): void { $called = $value; }); $observer->onNext(42); @@ -72,12 +72,12 @@ public function it_calls_on_next_with_the_given_value() /** * @test */ - public function it_does_not_call_on_next_after_an_error() + public function it_does_not_call_on_next_after_an_error(): void { $called = false; - $record = function() use (&$called) { $called = true; }; + $record = function() use (&$called): void { $called = true; }; - $observer = new CallbackObserver($record, function(){}); + $observer = new CallbackObserver($record, function(): void{}); $observer->onError(new Exception()); $called = false; @@ -89,12 +89,12 @@ public function it_does_not_call_on_next_after_an_error() /** * @test */ - public function it_does_not_call_on_completed_after_an_error() + public function it_does_not_call_on_completed_after_an_error(): void { $called = false; - $record = function() use (&$called) { $called = true; }; + $record = function() use (&$called): void { $called = true; }; - $observer = new CallbackObserver(function(){}, function(){}, $record); + $observer = new CallbackObserver(function(): void{}, function(): void{}, $record); $observer->onError(new Exception()); $called = false; @@ -106,12 +106,12 @@ public function it_does_not_call_on_completed_after_an_error() /** * @test */ - public function it_does_not_call_on_error_after_an_error() + public function it_does_not_call_on_error_after_an_error(): void { $called = false; - $record = function() use (&$called) { $called = true; }; + $record = function() use (&$called): void { $called = true; }; - $observer = new CallbackObserver(function(){}, $record); + $observer = new CallbackObserver(function(): void{}, $record); $observer->onError(new Exception()); $called = false; @@ -123,12 +123,12 @@ public function it_does_not_call_on_error_after_an_error() /** * @test */ - public function it_does_not_call_on_next_after_completion() + public function it_does_not_call_on_next_after_completion(): void { $called = false; - $record = function() use (&$called) { $called = true; }; + $record = function() use (&$called): void { $called = true; }; - $observer = new CallbackObserver($record, function(){}); + $observer = new CallbackObserver($record, function(): void{}); $observer->onCompleted(); $called = false; @@ -140,12 +140,12 @@ public function it_does_not_call_on_next_after_completion() /** * @test */ - public function it_does_not_call_on_completed_after_completion() + public function it_does_not_call_on_completed_after_completion(): void { $called = false; - $record = function() use (&$called) { $called = true; }; + $record = function() use (&$called): void { $called = true; }; - $observer = new CallbackObserver(function(){}, function(){}, $record); + $observer = new CallbackObserver(function(): void{}, function(): void{}, $record); $observer->onCompleted(); $called = false; @@ -157,12 +157,12 @@ public function it_does_not_call_on_completed_after_completion() /** * @test */ - public function it_does_not_call_on_error_after_completion() + public function it_does_not_call_on_error_after_completion(): void { $called = false; - $record = function() use (&$called) { $called = true; }; + $record = function() use (&$called): void { $called = true; }; - $observer = new CallbackObserver(function(){}, $record); + $observer = new CallbackObserver(function(): void{}, $record); $observer->onCompleted(); $called = false; diff --git a/test/Rx/Observer/ScheduledObserverTest.php b/test/Rx/Observer/ScheduledObserverTest.php index aa529657..ca68f06a 100644 --- a/test/Rx/Observer/ScheduledObserverTest.php +++ b/test/Rx/Observer/ScheduledObserverTest.php @@ -13,11 +13,11 @@ class ScheduledObserverTest extends TestCase /** * @test */ - public function it_calls_the_given_callable_on_next() + public function it_calls_the_given_callable_on_next(): void { $called = false; $scheduler = new TestScheduler(); - $observer = new CallbackObserver(function () use (&$called) { + $observer = new CallbackObserver(function () use (&$called): void { $called = true; }); @@ -39,14 +39,14 @@ public function it_calls_the_given_callable_on_next() /** * @test */ - public function it_calls_the_given_callable_on_error() + public function it_calls_the_given_callable_on_error(): void { $called = false; $scheduler = new TestScheduler(); $observer = new CallbackObserver( - function () { + function (): void { }, - function () use (&$called) { + function () use (&$called): void { $called = true; }); @@ -68,16 +68,16 @@ function () use (&$called) { /** * @test */ - public function it_calls_the_given_callable_on_complete() + public function it_calls_the_given_callable_on_complete(): void { $called = false; $scheduler = new TestScheduler(); $observer = new CallbackObserver( - function () { + function (): void { }, - function () { + function (): void { }, - function () use (&$called) { + function () use (&$called): void { $called = true; }); @@ -100,15 +100,15 @@ function () use (&$called) { /** * @test */ - public function it_does_not_call_on_next_after_an_error() + public function it_does_not_call_on_next_after_an_error(): void { $called = false; $scheduler = new TestScheduler(); $observer = new CallbackObserver( - function () use (&$called) { + function () use (&$called): void { $called = true; }, - function () { + function (): void { } ); @@ -138,16 +138,16 @@ function () { /** * @test */ - public function it_does_not_call_on_completed_after_an_error() + public function it_does_not_call_on_completed_after_an_error(): void { $called = false; $scheduler = new TestScheduler(); $observer = new CallbackObserver( - function () { + function (): void { }, - function () { + function (): void { }, - function () use (&$called) { + function () use (&$called): void { $called = true; } ); @@ -178,17 +178,17 @@ function () use (&$called) { /** * @test */ - public function it_does_not_call_on_error_after_an_error() + public function it_does_not_call_on_error_after_an_error(): void { $called = false; $scheduler = new TestScheduler(); $observer = new CallbackObserver( - function () { + function (): void { }, - function () use (&$called) { + function () use (&$called): void { $called = true; }, - function () { + function (): void { } ); @@ -220,17 +220,17 @@ function () { /** * @test */ - public function it_does_not_call_on_next_after_completion() + public function it_does_not_call_on_next_after_completion(): void { $called = false; $scheduler = new TestScheduler(); $observer = new CallbackObserver( - function () use (&$called) { + function () use (&$called): void { $called = true; }, - function () { + function (): void { }, - function () { + function (): void { } ); @@ -262,16 +262,16 @@ function () { /** * @test */ - public function it_does_not_call_on_completed_after_completion() + public function it_does_not_call_on_completed_after_completion(): void { $called = false; $scheduler = new TestScheduler(); $observer = new CallbackObserver( - function () { + function (): void { }, - function () { + function (): void { }, - function () use (&$called) { + function () use (&$called): void { $called = true; } ); @@ -304,17 +304,17 @@ function () use (&$called) { /** * @test */ - public function it_does_not_call_on_error_after_completion() + public function it_does_not_call_on_error_after_completion(): void { $called = false; $scheduler = new TestScheduler(); $observer = new CallbackObserver( - function () { + function (): void { }, - function () use (&$called) { + function () use (&$called): void { $called = true; }, - function () { + function (): void { } ); @@ -346,7 +346,7 @@ function () { /** * @test */ - public function throw_inside_onnext_throws() + public function throw_inside_onnext_throws(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('onNext(0) exception'); @@ -355,7 +355,7 @@ public function throw_inside_onnext_throws() $scheduledObserver = new ScheduledObserver( $scheduler, new CallbackObserver( - function ($x) { + function ($x): void { throw new Exception("onNext($x) exception"); } ) diff --git a/test/Rx/Scheduler/EventLoopSchedulerTest.php b/test/Rx/Scheduler/EventLoopSchedulerTest.php index 2311ab2c..30f0e11c 100644 --- a/test/Rx/Scheduler/EventLoopSchedulerTest.php +++ b/test/Rx/Scheduler/EventLoopSchedulerTest.php @@ -14,7 +14,7 @@ class EventLoopSchedulerTest extends TestCase /** * @test */ - public function now_returns_time_since_epoch_in_ms() + public function now_returns_time_since_epoch_in_ms(): void { $scheduler = new EventLoopScheduler(function () { return new EmptyDisposable(); }); @@ -24,7 +24,7 @@ public function now_returns_time_since_epoch_in_ms() /** * @test */ - public function eventloop_schedule() + public function eventloop_schedule(): void { $loop = Factory::create(); @@ -38,10 +38,10 @@ public function eventloop_schedule() $disposable = $scheduler->schedule($action); - $this->assertInstanceOf('Rx\DisposableInterface', $disposable); + $this->assertInstanceOf(\Rx\DisposableInterface::class, $disposable); $this->assertFalse($actionCalled); - $loop->futureTick(function () use ($loop) { + $loop->futureTick(function () use ($loop): void { $loop->stop(); }); @@ -54,7 +54,7 @@ public function eventloop_schedule() /** * @test */ - public function eventloop_schedule_recursive() + public function eventloop_schedule_recursive(): void { $loop = Factory::create(); @@ -62,7 +62,7 @@ public function eventloop_schedule_recursive() $actionCalled = false; $count = 0; - $action = function ($reschedule) use (&$actionCalled, &$count, $loop) { + $action = function ($reschedule) use (&$actionCalled, &$count, $loop): void { $actionCalled = true; $count++; if ($count < 5) { @@ -74,7 +74,7 @@ public function eventloop_schedule_recursive() $disposable = $scheduler->scheduleRecursive($action); - $this->assertInstanceOf('Rx\DisposableInterface', $disposable); + $this->assertInstanceOf(\Rx\DisposableInterface::class, $disposable); $this->assertFalse($actionCalled); $this->assertEquals(0, $count); @@ -84,7 +84,7 @@ public function eventloop_schedule_recursive() $this->assertTrue($actionCalled); } - public function testDisposedEventDoesNotCauseSkip() + public function testDisposedEventDoesNotCauseSkip(): void { // create a scheduler - timing is not important for this test // so we can just use an empty callable @@ -96,15 +96,15 @@ public function testDisposedEventDoesNotCauseSkip() // the way that these are scheduled, if the scheduler runs (by calling start a few times), // calls should be [2] because 0 is disposed and 1 shouldn't be called for 10s - $disposable = $scheduler->schedule(function () use (&$calls) { + $disposable = $scheduler->schedule(function () use (&$calls): void { $calls[] = 0; }, 0); - $scheduler->schedule(function () use (&$calls) { + $scheduler->schedule(function () use (&$calls): void { $calls[] = 1; }, 10000); - $scheduler->schedule(function () use (&$calls) { + $scheduler->schedule(function () use (&$calls): void { $calls[] = 2; }, 0); @@ -117,7 +117,7 @@ public function testDisposedEventDoesNotCauseSkip() $this->assertEquals([2], $calls); } - public function testSchedulerWorkedWithScheduledEventOutsideItself() + public function testSchedulerWorkedWithScheduledEventOutsideItself(): void { $loop = Factory::create(); $scheduler = new EventLoopScheduler($loop); @@ -125,8 +125,8 @@ public function testSchedulerWorkedWithScheduledEventOutsideItself() $scheduler->start(); $called = null; - $loop->addTimer(0.100, function () use ($scheduler, &$called) { - $scheduler->schedule(function () use (&$called) { + $loop->addTimer(0.100, function () use ($scheduler, &$called): void { + $scheduler->schedule(function () use (&$called): void { $called = microtime(true); }, 100); }); @@ -136,28 +136,28 @@ public function testSchedulerWorkedWithScheduledEventOutsideItself() $this->assertNotNull($called); } - public function testScheduledItemsFromOutsideOfSchedulerDontCreateExtraTimers() + public function testScheduledItemsFromOutsideOfSchedulerDontCreateExtraTimers(): void { $timersCreated = 0; $timersExecuted = 0; $loop = Factory::create(); $scheduler = new EventLoopScheduler(function ($delay, $action) use ($loop, &$timersCreated, &$timersExecuted) { $timersCreated++; - $timer = $loop->addTimer($delay * 0.001, function () use ($action, &$timersExecuted) { + $timer = $loop->addTimer($delay * 0.001, function () use ($action, &$timersExecuted): void { $timersExecuted++; $action(); }); - return new CallbackDisposable(function () use ($loop, $timer) { + return new CallbackDisposable(function () use ($loop, $timer): void { $loop->cancelTimer($timer); }); }); - $scheduler->schedule(function () {}, 40); + $scheduler->schedule(function (): void {}, 40); - $scheduler->schedule(function () {}, 35)->dispose(); - $scheduler->schedule(function () {}, 34)->dispose(); + $scheduler->schedule(function (): void {}, 35)->dispose(); + $scheduler->schedule(function (): void {}, 34)->dispose(); - $scheduler->schedule(function () {}, 20); + $scheduler->schedule(function (): void {}, 20); $loop->run(); @@ -165,30 +165,30 @@ public function testScheduledItemsFromOutsideOfSchedulerDontCreateExtraTimers() $this->assertLessThanOrEqual(3, $timersExecuted); } - public function testMultipleSchedulesFromOutsideInSameTickDontCreateExtraTimers() + public function testMultipleSchedulesFromOutsideInSameTickDontCreateExtraTimers(): void { $timersCreated = 0; $timersExecuted = 0; $loop = Factory::create(); $scheduler = new EventLoopScheduler(function ($delay, $action) use ($loop, &$timersCreated, &$timersExecuted) { $timersCreated++; - $timer = $loop->addTimer($delay * 0.001, function () use ($action, &$timersExecuted) { + $timer = $loop->addTimer($delay * 0.001, function () use ($action, &$timersExecuted): void { $timersExecuted++; $action(); }); - return new CallbackDisposable(function () use ($loop, $timer) { + return new CallbackDisposable(function () use ($loop, $timer): void { $loop->cancelTimer($timer); }); }); - $scheduler->schedule(function () {}, 20); - $loop->addTimer(0.01, function () use ($scheduler) { - $scheduler->schedule(function () {}, 30); + $scheduler->schedule(function (): void {}, 20); + $loop->addTimer(0.01, function () use ($scheduler): void { + $scheduler->schedule(function (): void {}, 30); - $scheduler->schedule(function () {}, 25)->dispose(); - $scheduler->schedule(function () {}, 24)->dispose(); - $scheduler->schedule(function () {}, 23)->dispose(); - $scheduler->schedule(function () {}, 25)->dispose(); + $scheduler->schedule(function (): void {}, 25)->dispose(); + $scheduler->schedule(function (): void {}, 24)->dispose(); + $scheduler->schedule(function (): void {}, 23)->dispose(); + $scheduler->schedule(function (): void {}, 25)->dispose(); }); $loop->run(); @@ -197,23 +197,23 @@ public function testMultipleSchedulesFromOutsideInSameTickDontCreateExtraTimers( $this->assertEquals(3, $timersExecuted); } - public function testThatStuffScheduledWayInTheFutureDoesntKeepTheLoopRunningIfDisposed() + public function testThatStuffScheduledWayInTheFutureDoesntKeepTheLoopRunningIfDisposed(): void { $loop = Factory::create(); $scheduler = new EventLoopScheduler(function ($delay, $action) use ($loop, &$timersCreated, &$timersExecuted) { $timersCreated++; - $timer = $loop->addTimer($delay * 0.001, function () use ($action, &$timersExecuted) { + $timer = $loop->addTimer($delay * 0.001, function () use ($action, &$timersExecuted): void { $timersExecuted++; $action(); }); - return new CallbackDisposable(function () use ($loop, $timer) { + return new CallbackDisposable(function () use ($loop, $timer): void { $loop->cancelTimer($timer); }); }); - $disp = $scheduler->schedule(function () {}, 3000); - $loop->addTimer(0.01, function () use ($scheduler, $disp) { - $scheduler->schedule(function () use ($disp) { + $disp = $scheduler->schedule(function (): void {}, 3000); + $loop->addTimer(0.01, function () use ($scheduler, $disp): void { + $scheduler->schedule(function () use ($disp): void { $disp->dispose(); }); }); @@ -225,15 +225,15 @@ public function testThatStuffScheduledWayInTheFutureDoesntKeepTheLoopRunningIfDi $this->assertLessThan(2, $loopTime); } - public function testThatDisposalOfSingleScheduledItemOutsideOfInvokeCancelsTimer() + public function testThatDisposalOfSingleScheduledItemOutsideOfInvokeCancelsTimer(): void { $loop = Factory::create(); $scheduler = new EventLoopScheduler($loop); $startTime = microtime(true); - $disp = $scheduler->schedule(function () {}, 3000); - $loop->addTimer(0.01, function () use ($disp) { + $disp = $scheduler->schedule(function (): void {}, 3000); + $loop->addTimer(0.01, function () use ($disp): void { $disp->dispose(); }); @@ -243,16 +243,16 @@ public function testThatDisposalOfSingleScheduledItemOutsideOfInvokeCancelsTimer $this->assertLessThan(2, $endTime - $startTime); } - public function testScheduledItemPastNextScheduledItemKillsItOwnTimerIfItBecomesTheNextOneAndIsDisposed() + public function testScheduledItemPastNextScheduledItemKillsItOwnTimerIfItBecomesTheNextOneAndIsDisposed(): void { $loop = Factory::create(); $scheduler = new EventLoopScheduler($loop); $startTime = microtime(true); - $scheduler->schedule(function () {}, 30); - $disp = $scheduler->schedule(function () {}, 3000); - $loop->addTimer(0.050, function () use ($disp) { + $scheduler->schedule(function (): void {}, 30); + $disp = $scheduler->schedule(function (): void {}, 3000); + $loop->addTimer(0.050, function () use ($disp): void { $disp->dispose(); }); diff --git a/test/Rx/Scheduler/ImmediateSchedulerTest.php b/test/Rx/Scheduler/ImmediateSchedulerTest.php index fae210b5..6fa089e8 100644 --- a/test/Rx/Scheduler/ImmediateSchedulerTest.php +++ b/test/Rx/Scheduler/ImmediateSchedulerTest.php @@ -11,7 +11,7 @@ class ImmediateSchedulerTest extends TestCase /** * @test */ - public function now_returns_the_time() + public function now_returns_the_time(): void { $scheduler = new ImmediateScheduler(); @@ -21,12 +21,12 @@ public function now_returns_the_time() /** * @test */ - public function non_zero_delay_throws() + public function non_zero_delay_throws(): void { $this->expectException(\Exception::class); $scheduler = new ImmediateScheduler(); - $scheduler->schedule(function () { + $scheduler->schedule(function (): void { $this->fail("This should never get called"); }, 1); } @@ -34,13 +34,13 @@ public function non_zero_delay_throws() /** * @test */ - public function schedule_periodic_throws() + public function schedule_periodic_throws(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('ImmediateScheduler does not support a non-zero delay.'); $scheduler = new ImmediateScheduler(); - $scheduler->schedulePeriodic(function () { + $scheduler->schedulePeriodic(function (): void { $this->fail("This should never get called"); }, 1, 1); } diff --git a/test/Rx/Scheduler/PriorityQueueTest.php b/test/Rx/Scheduler/PriorityQueueTest.php index 7e9f800f..38290c1b 100644 --- a/test/Rx/Scheduler/PriorityQueueTest.php +++ b/test/Rx/Scheduler/PriorityQueueTest.php @@ -11,7 +11,7 @@ class PriorityQueueTest extends TestCase /** * @test */ - public function it_should_remove_a_scheduled_item() + public function it_should_remove_a_scheduled_item(): void { $queue = new PriorityQueue(); $scheduledItem = $this->createScheduledItem(1); @@ -38,7 +38,7 @@ private function createScheduledItem($dueTime) /** * @test */ - public function it_orders_the_items() + public function it_orders_the_items(): void { $queue = new PriorityQueue(); $scheduledItem = $this->createScheduledItem(3); @@ -57,7 +57,7 @@ public function it_orders_the_items() /** * @test */ - public function peek_returns_the_top_item() + public function peek_returns_the_top_item(): void { $queue = new PriorityQueue(); $scheduledItem = $this->createScheduledItem(3); @@ -74,7 +74,7 @@ public function peek_returns_the_top_item() /** * @test */ - public function dequeue_removes_the_top_item_from_the_queue() + public function dequeue_removes_the_top_item_from_the_queue(): void { $queue = new PriorityQueue(); $scheduledItem = $this->createScheduledItem(1); @@ -96,7 +96,7 @@ public function dequeue_removes_the_top_item_from_the_queue() /** * @test */ - public function first_scheduled_item_with_same_priority_comes_first() + public function first_scheduled_item_with_same_priority_comes_first(): void { $queue = new PriorityQueue(); $scheduledItem = $this->createScheduledItem(1); @@ -115,7 +115,7 @@ public function first_scheduled_item_with_same_priority_comes_first() /** * @test */ - public function can_remove_scheduled_items_out_of_order() + public function can_remove_scheduled_items_out_of_order(): void { $queue = new PriorityQueue(); $scheduledItem = $this->createScheduledItem(1); @@ -135,14 +135,14 @@ public function can_remove_scheduled_items_out_of_order() * @test * @doesNotPerformAssertions */ - public function should_not_remove_nonexistent_item() + public function should_not_remove_nonexistent_item(): void { $queue = new PriorityQueue(); $queue->remove( new ScheduledItem( $this->createMock(ScheduledItem::class), null, - function () { + function (): void { }, 0 ) diff --git a/test/Rx/SchedulerTest.php b/test/Rx/SchedulerTest.php index 27e5fcf0..2ae86189 100644 --- a/test/Rx/SchedulerTest.php +++ b/test/Rx/SchedulerTest.php @@ -28,7 +28,7 @@ public function setup() : void /** */ - public function testGetDefaultThrowsIfNotSet() + public function testGetDefaultThrowsIfNotSet(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Please set a default scheduler factory'); @@ -37,7 +37,7 @@ public function testGetDefaultThrowsIfNotSet() $this->assertInstanceOf(EventLoopScheduler::class, $scheduler); } - public function testSetDefault() + public function testSetDefault(): void { $scheduler = new TestScheduler(); @@ -48,7 +48,7 @@ public function testSetDefault() $this->assertSame($scheduler, Scheduler::getDefault()); } - public function testSetDefaultTwiceBeforeGet() + public function testSetDefaultTwiceBeforeGet(): void { $scheduler = new TestScheduler(); @@ -65,7 +65,7 @@ public function testSetDefaultTwiceBeforeGet() $this->assertSame($scheduler2, Scheduler::getDefault()); } - public function testSetAsync() + public function testSetAsync(): void { $scheduler = new TestScheduler(); @@ -76,7 +76,7 @@ public function testSetAsync() $this->assertSame($scheduler, Scheduler::getAsync()); } - public function testSetAsyncTwiceBeforeGet() + public function testSetAsyncTwiceBeforeGet(): void { $scheduler = new TestScheduler(); @@ -95,7 +95,7 @@ public function testSetAsyncTwiceBeforeGet() /** */ - public function testSetDefaultTwiceThrowsException() + public function testSetDefaultTwiceThrowsException(): void { $this->expectException(\Exception::class); $scheduler = new TestScheduler(); @@ -114,7 +114,7 @@ public function testSetDefaultTwiceThrowsException() /** */ - public function testSetAsyncTwiceThrowsException() + public function testSetAsyncTwiceThrowsException(): void { $this->expectException(\Exception::class); $scheduler = new TestScheduler(); @@ -132,7 +132,7 @@ public function testSetAsyncTwiceThrowsException() /** */ - public function testGetAsyncBeforeSet() + public function testGetAsyncBeforeSet(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Please set a default scheduler factory'); @@ -140,9 +140,9 @@ public function testGetAsyncBeforeSet() Scheduler::getAsync(); } - public function testGetAsyncAfterSettingDefaultToAsync() + public function testGetAsyncAfterSettingDefaultToAsync(): void { - $asyncScheduler = new EventLoopScheduler(function () { + $asyncScheduler = new EventLoopScheduler(function (): void { }); Scheduler::setDefaultFactory(function () use ($asyncScheduler) { @@ -154,7 +154,7 @@ public function testGetAsyncAfterSettingDefaultToAsync() /** */ - public function testAsyncSchedulerFactorReturnsNonAsyncScheduler() + public function testAsyncSchedulerFactorReturnsNonAsyncScheduler(): void { $this->expectException(\Throwable::class); if (phpversion() < '8.0.0') { @@ -172,7 +172,7 @@ public function testAsyncSchedulerFactorReturnsNonAsyncScheduler() /** */ - public function testDefaultSchedulerFactorReturnsNonScheduler() + public function testDefaultSchedulerFactorReturnsNonScheduler(): void { $this->expectException(\Throwable::class); if (phpversion() < '8.0.0') { @@ -189,7 +189,7 @@ public function testDefaultSchedulerFactorReturnsNonScheduler() /** */ - public function testAsyncSchedulerFactorThrowsNonAsyncDefaultScheduler() + public function testAsyncSchedulerFactorThrowsNonAsyncDefaultScheduler(): void { $this->expectException(\Throwable::class); $this->expectExceptionMessage('Please set an async scheduler factory'); diff --git a/test/Rx/Subject/BehaviorSubjectTest.php b/test/Rx/Subject/BehaviorSubjectTest.php index 923fbc17..b67b1c12 100644 --- a/test/Rx/Subject/BehaviorSubjectTest.php +++ b/test/Rx/Subject/BehaviorSubjectTest.php @@ -12,26 +12,26 @@ class BehaviorSubjectTest extends TestCase /** * @test */ - public function it_throws_when_subscribing_to_a_disposed_subject() + public function it_throws_when_subscribing_to_a_disposed_subject(): void { $this->expectException(\RuntimeException::class); $subject = new BehaviorSubject(); $subject->dispose(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $subject->subscribe($observer); } /** * @test */ - public function it_exposes_if_it_has_observers() + public function it_exposes_if_it_has_observers(): void { $subject = new BehaviorSubject(); $this->assertFalse($subject->hasObservers()); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $subject->subscribe($observer); $this->assertTrue($subject->hasObservers()); } @@ -39,7 +39,7 @@ public function it_exposes_if_it_has_observers() /** * @test */ - public function it_exposes_if_it_is_disposed() + public function it_exposes_if_it_is_disposed(): void { $subject = new BehaviorSubject(); @@ -52,11 +52,11 @@ public function it_exposes_if_it_is_disposed() /** * @test */ - public function it_has_no_observers_after_disposing() + public function it_has_no_observers_after_disposing(): void { $subject = new BehaviorSubject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $subject->subscribe($observer); $this->assertTrue($subject->hasObservers()); @@ -67,11 +67,11 @@ public function it_has_no_observers_after_disposing() /** * @test */ - public function it_returns_true_if_an_observer_is_removed() + public function it_returns_true_if_an_observer_is_removed(): void { $subject = new BehaviorSubject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $subject->subscribe($observer); $this->assertTrue($subject->hasObservers()); @@ -82,11 +82,11 @@ public function it_returns_true_if_an_observer_is_removed() /** * @test */ - public function it_returns_false_if_an_observer_is_not_subscribed() + public function it_returns_false_if_an_observer_is_not_subscribed(): void { $subject = new BehaviorSubject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $this->assertFalse($subject->removeObserver($observer)); $this->assertFalse($subject->hasObservers()); @@ -95,13 +95,13 @@ public function it_returns_false_if_an_observer_is_not_subscribed() /** * @test */ - public function it_passes_exception_on_subscribe_if_already_stopped() + public function it_passes_exception_on_subscribe_if_already_stopped(): void { $exception = new Exception('fail'); $subject = new BehaviorSubject(); $subject->onError($exception); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onError') ->with($this->equalTo($exception)); @@ -112,12 +112,12 @@ public function it_passes_exception_on_subscribe_if_already_stopped() /** * @test */ - public function it_passes_on_complete_on_subscribe_if_already_stopped() + public function it_passes_on_complete_on_subscribe_if_already_stopped(): void { $subject = new BehaviorSubject(); $subject->onCompleted(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onCompleted'); @@ -127,12 +127,12 @@ public function it_passes_on_complete_on_subscribe_if_already_stopped() /** * @test */ - public function it_passes_on_error_if_not_disposed() + public function it_passes_on_error_if_not_disposed(): void { $exception = new Exception('fail'); $subject = new BehaviorSubject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onError') ->with($this->equalTo($exception)); @@ -145,11 +145,11 @@ public function it_passes_on_error_if_not_disposed() /** * @test */ - public function it_passes_on_complete_if_not_disposed() + public function it_passes_on_complete_if_not_disposed(): void { $subject = new BehaviorSubject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onCompleted'); @@ -160,19 +160,19 @@ public function it_passes_on_complete_if_not_disposed() /** * @test */ - public function it_passes_on_next_if_not_disposed() + public function it_passes_on_next_if_not_disposed(): void { $subject = new BehaviorSubject(); $value = 42; - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->exactly(2)) ->method('onNext') - ->will($this->returnValueMap(array( - array(null), - array($value) - )) + ->will($this->returnValueMap([ + [null], + [$value] + ]) ); $subject->subscribe($observer); @@ -182,12 +182,12 @@ public function it_passes_on_next_if_not_disposed() /** * @test */ - public function it_passes_on_next_if_not_disposed_with_init() + public function it_passes_on_next_if_not_disposed_with_init(): void { $value = 42; $subject = new BehaviorSubject($value); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onNext') @@ -199,11 +199,11 @@ public function it_passes_on_next_if_not_disposed_with_init() /** * @test */ - public function it_does_not_pass_if_already_stopped() + public function it_does_not_pass_if_already_stopped(): void { $subject = new BehaviorSubject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onCompleted'); @@ -224,7 +224,7 @@ public function it_does_not_pass_if_already_stopped() /** * @test */ - public function it_throws_on_error_if_disposed() + public function it_throws_on_error_if_disposed(): void { $this->expectException(\RuntimeException::class); $subject = new BehaviorSubject(); @@ -236,7 +236,7 @@ public function it_throws_on_error_if_disposed() /** * @test */ - public function it_passes_on_complete_if_disposed() + public function it_passes_on_complete_if_disposed(): void { $this->expectException(\RuntimeException::class); $subject = new BehaviorSubject(); @@ -248,7 +248,7 @@ public function it_passes_on_complete_if_disposed() /** * @test */ - public function it_passes_on_next_if_disposed() + public function it_passes_on_next_if_disposed(): void { $this->expectException(\RuntimeException::class); $subject = new BehaviorSubject(); diff --git a/test/Rx/Subject/SubjectTest.php b/test/Rx/Subject/SubjectTest.php index 1e20470f..e958bd00 100644 --- a/test/Rx/Subject/SubjectTest.php +++ b/test/Rx/Subject/SubjectTest.php @@ -12,26 +12,26 @@ class SubjectTest extends TestCase /** * @test */ - public function it_throws_when_subscribing_to_a_disposed_subject() + public function it_throws_when_subscribing_to_a_disposed_subject(): void { $this->expectException(\RuntimeException::class); $subject = new Subject(); $subject->dispose(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $subject->subscribe($observer); } /** * @test */ - public function it_exposes_if_it_has_observers() + public function it_exposes_if_it_has_observers(): void { $subject = new Subject(); $this->assertFalse($subject->hasObservers()); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $subject->subscribe($observer); $this->assertTrue($subject->hasObservers()); } @@ -39,7 +39,7 @@ public function it_exposes_if_it_has_observers() /** * @test */ - public function it_exposes_if_it_is_disposed() + public function it_exposes_if_it_is_disposed(): void { $subject = new Subject(); @@ -52,11 +52,11 @@ public function it_exposes_if_it_is_disposed() /** * @test */ - public function it_has_no_observers_after_disposing() + public function it_has_no_observers_after_disposing(): void { $subject = new Subject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $subject->subscribe($observer); $this->assertTrue($subject->hasObservers()); @@ -67,11 +67,11 @@ public function it_has_no_observers_after_disposing() /** * @test */ - public function it_returns_true_if_an_observer_is_removed() + public function it_returns_true_if_an_observer_is_removed(): void { $subject = new Subject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $subject->subscribe($observer); $this->assertTrue($subject->hasObservers()); @@ -82,11 +82,11 @@ public function it_returns_true_if_an_observer_is_removed() /** * @test */ - public function it_returns_false_if_an_observer_is_not_subscribed() + public function it_returns_false_if_an_observer_is_not_subscribed(): void { $subject = new Subject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $this->assertFalse($subject->removeObserver($observer)); $this->assertFalse($subject->hasObservers()); @@ -95,13 +95,13 @@ public function it_returns_false_if_an_observer_is_not_subscribed() /** * @test */ - public function it_passes_exception_on_subscribe_if_already_stopped() + public function it_passes_exception_on_subscribe_if_already_stopped(): void { $exception = new Exception('fail'); $subject = new Subject(); $subject->onError($exception); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onError') ->with($this->equalTo($exception)); @@ -112,12 +112,12 @@ public function it_passes_exception_on_subscribe_if_already_stopped() /** * @test */ - public function it_passes_on_complete_on_subscribe_if_already_stopped() + public function it_passes_on_complete_on_subscribe_if_already_stopped(): void { $subject = new Subject(); $subject->onCompleted(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onCompleted'); @@ -127,12 +127,12 @@ public function it_passes_on_complete_on_subscribe_if_already_stopped() /** * @test */ - public function it_passes_on_error_if_not_disposed() + public function it_passes_on_error_if_not_disposed(): void { $exception = new Exception('fail'); $subject = new Subject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onError') ->with($this->equalTo($exception)); @@ -145,11 +145,11 @@ public function it_passes_on_error_if_not_disposed() /** * @test */ - public function it_passes_on_complete_if_not_disposed() + public function it_passes_on_complete_if_not_disposed(): void { $subject = new Subject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onCompleted'); @@ -160,12 +160,12 @@ public function it_passes_on_complete_if_not_disposed() /** * @test */ - public function it_passes_on_next_if_not_disposed() + public function it_passes_on_next_if_not_disposed(): void { $subject = new Subject(); $value = 42; - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onNext') ->with($this->equalTo($value)); @@ -177,11 +177,11 @@ public function it_passes_on_next_if_not_disposed() /** * @test */ - public function it_does_not_pass_if_already_stopped() + public function it_does_not_pass_if_already_stopped(): void { $subject = new Subject(); - $observer = $this->createMock('Rx\ObserverInterface'); + $observer = $this->createMock(\Rx\ObserverInterface::class); $observer->expects($this->once()) ->method('onCompleted'); @@ -202,7 +202,7 @@ public function it_does_not_pass_if_already_stopped() /** * @test */ - public function it_throws_on_error_if_disposed() + public function it_throws_on_error_if_disposed(): void { $this->expectException(\RuntimeException::class); $subject = new Subject(); @@ -214,7 +214,7 @@ public function it_throws_on_error_if_disposed() /** * @test */ - public function it_passes_on_complete_if_disposed() + public function it_passes_on_complete_if_disposed(): void { $this->expectException(\RuntimeException::class); $subject = new Subject(); @@ -226,7 +226,7 @@ public function it_passes_on_complete_if_disposed() /** * @test */ - public function it_passes_on_next_if_disposed() + public function it_passes_on_next_if_disposed(): void { $this->expectException(\RuntimeException::class); $subject = new Subject(); diff --git a/test/Rx/Testing/HotObservableTest.php b/test/Rx/Testing/HotObservableTest.php index 7e432a16..e2b190df 100644 --- a/test/Rx/Testing/HotObservableTest.php +++ b/test/Rx/Testing/HotObservableTest.php @@ -6,7 +6,7 @@ class HotObservableTest extends TestCase { - public function testRemovingObserverThatNeverSubscribed() + public function testRemovingObserverThatNeverSubscribed(): void { $scheduler = new TestScheduler(); diff --git a/test/Rx/Testing/RecordedTest.php b/test/Rx/Testing/RecordedTest.php index 10c88443..00f241a0 100644 --- a/test/Rx/Testing/RecordedTest.php +++ b/test/Rx/Testing/RecordedTest.php @@ -8,7 +8,7 @@ class RecordedTest extends TestCase { - public function testRecordedWillUseStrictCompareIfNoEqualsMethod() + public function testRecordedWillUseStrictCompareIfNoEqualsMethod(): void { $recorded1 = new Recorded(1, 5); $recorded2 = new Recorded(1, "5"); @@ -18,7 +18,7 @@ public function testRecordedWillUseStrictCompareIfNoEqualsMethod() $this->assertTrue($recorded1->equals($recorded3)); } - public function testRecordedToString() + public function testRecordedToString(): void { $recorded = new Recorded(1, 5); diff --git a/test/Rx/Testing/SubscriptionTest.php b/test/Rx/Testing/SubscriptionTest.php index 37dd8e5e..e6a39c54 100644 --- a/test/Rx/Testing/SubscriptionTest.php +++ b/test/Rx/Testing/SubscriptionTest.php @@ -8,7 +8,7 @@ class SubscriptionTest extends TestCase { - public function testSubscriptionGetters() + public function testSubscriptionGetters(): void { $sub = new Subscription(1, 2); @@ -16,7 +16,7 @@ public function testSubscriptionGetters() $this->assertEquals(2, $sub->getUnsubscribed()); } - public function testSubscriptionToString() + public function testSubscriptionToString(): void { $this->assertEquals(new Subscription(1, 2), "Subscription(1, 2)"); } diff --git a/test/Rx/TimestampedTest.php b/test/Rx/TimestampedTest.php index 03c342e4..0e0dec3a 100644 --- a/test/Rx/TimestampedTest.php +++ b/test/Rx/TimestampedTest.php @@ -6,7 +6,7 @@ class TimestampedTest extends TestCase { - public function testEqualWithScalar() + public function testEqualWithScalar(): void { $ts1 = new Timestamped(123, "Hello"); $ts2 = new Timestamped(123, "Hello"); @@ -14,7 +14,7 @@ public function testEqualWithScalar() $this->assertTrue($ts1->equals($ts2)); } - public function testNotEqualWithScalar() + public function testNotEqualWithScalar(): void { $ts1 = new Timestamped(123, "Hi"); $ts2 = new Timestamped(123, "Hello"); @@ -22,7 +22,7 @@ public function testNotEqualWithScalar() $this->assertTrue(!$ts1->equals($ts2)); } - public function testNotEqualInTime() + public function testNotEqualInTime(): void { $ts1 = new Timestamped(124, "Hello"); $ts2 = new Timestamped(123, "Hello"); @@ -30,21 +30,21 @@ public function testNotEqualInTime() $this->assertTrue(!$ts1->equals($ts2)); } - public function testEqualNotATimestamp() + public function testEqualNotATimestamp(): void { $ts1 = new Timestamped(123, "Hello"); $this->assertTrue(!$ts1->equals("Hello")); } - public function testEqualSameTimestamp() + public function testEqualSameTimestamp(): void { $ts1 = new Timestamped(123, "Hello"); $this->assertTrue($ts1->equals($ts1)); } - public function testEqualObjectSameInstance() + public function testEqualObjectSameInstance(): void { $o1 = new \stdClass(); $o1->x = "y"; @@ -56,7 +56,7 @@ public function testEqualObjectSameInstance() $this->assertTrue($ts1->equals($ts2)); } - public function testNotEqualObjectDiffentInstance() + public function testNotEqualObjectDiffentInstance(): void { $o1 = new \stdClass(); $o1->x = "y"; @@ -69,7 +69,7 @@ public function testNotEqualObjectDiffentInstance() $this->assertTrue(!$ts1->equals($ts2)); } - public function testGetValue() + public function testGetValue(): void { $ts1 = new Timestamped(123, "Hello"); diff --git a/test/helper-functions.php b/test/helper-functions.php index 81ae91b7..b8f120fb 100644 --- a/test/helper-functions.php +++ b/test/helper-functions.php @@ -8,15 +8,15 @@ use Rx\Notification\OnErrorNotification; use Rx\Notification\OnNextNotification; -function onError(int $dueTime, $error, callable $comparer = null) { +function onError(int $dueTime, $error, ?callable $comparer = null) { return new Recorded($dueTime, new OnErrorNotification($error), $comparer); } -function onNext(int $dueTime, $value, callable $comparer = null) { +function onNext(int $dueTime, $value, ?callable $comparer = null) { return new Recorded($dueTime, new OnNextNotification($value), $comparer); } -function onCompleted(int $dueTime, callable $comparer = null) { +function onCompleted(int $dueTime, ?callable $comparer = null) { return new Recorded($dueTime, new OnCompletedNotification(), $comparer); } diff --git a/test/loop-auto-start.php b/test/loop-auto-start.php index 1f1243fe..aee02435 100644 --- a/test/loop-auto-start.php +++ b/test/loop-auto-start.php @@ -11,6 +11,6 @@ return $scheduler; }); -register_shutdown_function(function () use ($loop) { +register_shutdown_function(function () use ($loop): void { $loop->run(); });