Skip to content

Commit

Permalink
Extended lowest PHP version support from 7.1 -> 7.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Sep 28, 2019
1 parent 2e5e6f6 commit 7f3cb86
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
notifications:
email: false

sudo: false

language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
}
],
"require": {
"php": "^7.1",
"php": "^7",
"amphp/amp": "^2"
},
"require-dev": {
"phpunit/phpunit": "^7.5"
"phpunit/phpunit": "^6.5"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 6 additions & 6 deletions src/Throttle.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Throttle
/**
* Milliseconds to wait when the watch frequency crosses the threshold.
*/
private const RETRY_DELAY = 100;
/*private*/ const RETRY_DELAY = 100;

/**
* List of promises we're throttling.
Expand Down Expand Up @@ -79,13 +79,13 @@ public function finish(): Promise
});
}

private function watch(Promise $promise): void
private function watch(Promise $promise)/*: void*/
{
$this->startTime === null && $this->startTime = self::getTime();

$this->watching[$hash = spl_object_hash($promise)] = $promise;

$promise->onResolve(function () use ($hash): void {
$promise->onResolve(function () use ($hash)/*: void*/ {
unset($this->watching[$hash]);

$this->tryFulfilPromises();
Expand Down Expand Up @@ -123,7 +123,7 @@ private function tryFulfilPromises(): bool
if (!$this->isBelowChronoThreshold()) {
Loop::delay(
self::RETRY_DELAY,
function (): void {
function ()/*: void*/ {
$this->tryFulfilPromises();
}
);
Expand All @@ -147,7 +147,7 @@ public function getMaxConcurrency(): int
return $this->maxConcurrency;
}

public function setMaxConcurrency(int $maxConcurrency): void
public function setMaxConcurrency(int $maxConcurrency)/*: void*/
{
$this->maxConcurrency = $maxConcurrency;
}
Expand All @@ -157,7 +157,7 @@ public function getMaxPerSecond(): int
return $this->maxPerSecond;
}

public function setMaxPerSecond(int $maxPerSecond): void
public function setMaxPerSecond(int $maxPerSecond)/*: void*/
{
$this->maxPerSecond = $maxPerSecond;
}
Expand Down
6 changes: 3 additions & 3 deletions test/ThrottleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function setUp()
/**
* Tests that a single promise is resolved almost instantly.
*/
public function testPromiseResolved(): void
public function testPromiseResolved()/*: void*/
{
Loop::run(function (): \Generator {
$promise = new Delayed(0);
Expand All @@ -36,7 +36,7 @@ public function testPromiseResolved(): void
yield $this->throttle->finish();
self::assertLessThanOrEqual(.01, microtime(true) - $start);

$promise->onResolve(static function () use (&$resolved): void {
$promise->onResolve(static function () use (&$resolved)/*: void*/ {
$resolved = true;
});
self::assertTrue($resolved);
Expand All @@ -46,7 +46,7 @@ public function testPromiseResolved(): void
/**
* Tests that a hundred promises that resolve almost immediately are not throttled despite low concurrency limit.
*/
public function testThroughput(): void
public function testThroughput()/*: void*/
{
Loop::run(function (): \Generator {
$this->throttle->setMaxConcurrency(1);
Expand Down

0 comments on commit 7f3cb86

Please sign in to comment.