Skip to content

Commit

Permalink
Use strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Aug 22, 2016
1 parent def6a6b commit 52f7ec6
Show file tree
Hide file tree
Showing 69 changed files with 81 additions and 79 deletions.
2 changes: 1 addition & 1 deletion lib/Body.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
8 changes: 5 additions & 3 deletions lib/BodyParser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down Expand Up @@ -133,7 +133,7 @@ private function end($data) {
$metadata[$name][count($fields[$name]) - 1]["mime"] = $headers["content-type"];
}
}

return new ParsedBody($fields, $metadata);

} else {
Expand Down Expand Up @@ -216,7 +216,9 @@ public function stream(string $name, int $size = 0): FieldBody {
return new FieldBody($body->getObservable(), $metadata->getAwaitable());
}
} elseif (empty($this->bodies[$name])) {
return new FieldBody(new Success, new Success([]));
$postponed = new Postponed;
$postponed->resolve();
return new FieldBody($postponed->getObservable(), new Success([]));
}

$key = key($this->bodies[$name]);
Expand Down
2 changes: 1 addition & 1 deletion lib/Bootable.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Bootstrapper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
4 changes: 2 additions & 2 deletions lib/Client.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand All @@ -22,7 +22,7 @@ class Client {
public $readWatcher;
public $writeWatcher;

public $writeBuffer;
public $writeBuffer = "";
public $bufferSize = 0;
public $bufferDeferred;
public $onWriteDrain;
Expand Down
2 changes: 1 addition & 1 deletion lib/ClientException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/ClientSizeException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/CommandClient.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Console.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/ConsoleLogger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/DebugProcess.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/FieldBody.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/FilterException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
4 changes: 2 additions & 2 deletions lib/Host.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down Expand Up @@ -140,7 +140,7 @@ public function encrypt(string $certificate, string $key = null, array $options
* The following example redirects all unencrypted requests to the equivalent
* encrypted resource:
*
* <?php
* <?php declare(strict_types = 1);
* // Redirect http://mysite.com to https://mysite.com
* $host = new Aerys\Host;
* $host->setName("mysite.com");
Expand Down
4 changes: 2 additions & 2 deletions lib/Http1Driver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down Expand Up @@ -256,7 +256,7 @@ public function parser(Client $client): \Generator {
}

$protocol = \strtok(" ");
if (stripos($protocol, "HTTP/") !== 0) {
if (!is_string($protocol) || stripos($protocol, "HTTP/") !== 0) {
$error = "Bad Request: invalid request line";
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Http2Driver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/HttpDriver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/InternalRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/IpcLogger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Logger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Middleware.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Monitor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/NullBody.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Options.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/ParsedBody.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Process.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Request.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Response.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Root.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Router.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Server.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/ServerObserver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/StandardRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/StandardResponse.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
4 changes: 2 additions & 2 deletions lib/Ticker.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down Expand Up @@ -59,7 +59,7 @@ public function updateTime() {
// Date string generation is (relatively) expensive. Since we only need HTTP
// dates at a granularity of one second we're better off to generate this
// information once per second and cache it.
$now = (int) round(microtime(1));
$now = (int) round(microtime(true));
$this->currentTime = $now;
$this->currentHttpDate = gmdate("D, d M Y H:i:s", $now) . " GMT";
foreach ($this->useCallbacks as $useCallback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Vhost.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
4 changes: 2 additions & 2 deletions lib/VhostContainer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down Expand Up @@ -164,7 +164,7 @@ private function selectHostByAuthority(InternalRequest $ireq) {
$ipComparison = $ireq->uriHost;

if (!@inet_pton($ipComparison)) {
$ipComparison = substr($ipComparison, 1, -1); // IPv6 braces
$ipComparison = (string) substr($ipComparison, 1, -1); // IPv6 braces
if (!@inet_pton($ipComparison)) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/WatcherProcess.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Websocket.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/Websocket/Code.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys\Websocket;

Expand Down
2 changes: 1 addition & 1 deletion lib/Websocket/Endpoint.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys\Websocket;

Expand Down
2 changes: 1 addition & 1 deletion lib/Websocket/Handshake.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys\Websocket;

Expand Down
2 changes: 1 addition & 1 deletion lib/Websocket/Message.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys\Websocket;

Expand Down
2 changes: 1 addition & 1 deletion lib/Websocket/Rfc6455Client.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys\Websocket;

Expand Down
4 changes: 2 additions & 2 deletions lib/Websocket/Rfc6455Endpoint.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys\Websocket;

Expand Down Expand Up @@ -622,7 +622,7 @@ public function send(/* int|array|null */ $clientId, string $data, bool $binary
if (\strlen($data) > 1.5 * $this->autoFrameSize) {
$len = \strlen($data);
$slices = ceil($len / $this->autoFrameSize);
$frames = str_split($data, ceil($len / $slices));
$frames = str_split($data, (int) ceil($len / $slices));
$data = array_pop($frames);
foreach ($frames as $frame) {
$this->compile($client, $frame, $opcode, false);
Expand Down
2 changes: 1 addition & 1 deletion lib/Websocket/Rfc6455EndpointProxy.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys\Websocket;

Expand Down
2 changes: 1 addition & 1 deletion lib/WorkerProcess.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/constants.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
2 changes: 1 addition & 1 deletion lib/functions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys;

Expand Down
6 changes: 3 additions & 3 deletions test/BodyParsingTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys\Test;

Expand Down Expand Up @@ -61,7 +61,7 @@ function testImmediateWatch($header, $data, $fields, $metadata) {
});
yield $body;

$this->assertEquals(count($fieldlist), count($fieldlist, true));
$this->assertEquals(count($fieldlist), count($fieldlist, \COUNT_RECURSIVE));
$this->assertEquals($fields, $result["fields"]);
$this->assertEquals($metadata, $result["metadata"]);
});
Expand Down Expand Up @@ -97,7 +97,7 @@ function testIncrementalWatch($header, $data, $fields, $metadata) {
});
yield $body;

$this->assertEquals(count($fieldlist), count($fieldlist, true));
$this->assertEquals(count($fieldlist), count($fieldlist, \COUNT_RECURSIVE));
$this->assertEquals($fields, $result["fields"]);
$this->assertEquals($metadata, $result["metadata"]);
});
Expand Down
2 changes: 1 addition & 1 deletion test/BodyTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Aerys\Test;

Expand Down
Loading

0 comments on commit 52f7ec6

Please sign in to comment.