Skip to content

Commit 4bad328

Browse files
committed
fixed tests
1 parent 587c00b commit 4bad328

File tree

11 files changed

+42
-40
lines changed

11 files changed

+42
-40
lines changed

src/Driver/Userland/Connection/StreamSocketConnectionPool.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class StreamSocketConnectionPool implements ConnectionPoolInterface
3737
*/
3838
public function __construct($socket)
3939
{
40-
stream_set_blocking($socket, 0);
40+
stream_set_blocking($socket, false);
4141

4242
$this->serverSocket = $socket;
4343
$this->clientSockets = [];
@@ -152,7 +152,7 @@ private function acceptConnection(): void
152152
$clientSocket = @stream_socket_accept($this->serverSocket);
153153

154154
if (false !== $clientSocket) {
155-
stream_set_blocking($clientSocket, 0);
155+
stream_set_blocking($clientSocket, false);
156156

157157
$connection = new StreamSocketConnection($clientSocket);
158158

src/Driver/Userland/ConnectionHandler/ConnectionHandler.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function ready(): array
9090
while (!empty($record = $this->readRecord())) {
9191
$statusCode = $this->processRecord($record);
9292

93-
if (null != $statusCode) {
93+
if (null !== $statusCode) {
9494
$statusCodes[] = $statusCode;
9595
}
9696
}
@@ -180,11 +180,11 @@ private function readRecord(): array
180180
*
181181
* @param array $record The record that has been read
182182
*
183-
* @return int Number of dispatched requests
183+
* @return null|int Number of dispatched requests
184184
*
185185
* @throws ProtocolException If the client sends an unexpected record.
186186
*/
187-
private function processRecord(array $record): int
187+
private function processRecord(array $record): ?int
188188
{
189189
$requestId = $record['requestId'];
190190

@@ -195,7 +195,7 @@ private function processRecord(array $record): int
195195
} elseif (!isset($this->requests[$requestId])) {
196196
throw new ProtocolException('Invalid request id for record of type: '.$record['type']);
197197
} elseif (DaemonInterface::FCGI_PARAMS === $record['type']) {
198-
while (strlen($content) > 0) {
198+
while (null !== $content && strlen($content) > 0) {
199199
$this->readNameValuePair($requestId, $content);
200200
}
201201
} elseif (DaemonInterface::FCGI_STDIN === $record['type']) {
@@ -218,11 +218,11 @@ private function processRecord(array $record): int
218218
* Process a FCGI_BEGIN_REQUEST record.
219219
*
220220
* @param int $requestId The request id sending the record
221-
* @param string $contentData The content of the record
221+
* @param null|string $contentData The content of the record
222222
*
223223
* @throws ProtocolException If the FCGI_BEGIN_REQUEST record is unexpected
224224
*/
225-
private function processBeginRequestRecord(int $requestId, string $contentData): void
225+
private function processBeginRequestRecord(int $requestId, ?string $contentData): void
226226
{
227227
if (isset($this->requests[$requestId])) {
228228
throw new ProtocolException('Unexpected FCGI_BEGIN_REQUEST record');
@@ -257,9 +257,9 @@ private function processBeginRequestRecord(int $requestId, string $contentData):
257257
* Read a FastCGI name-value pair from a buffer and add it to the request params.
258258
*
259259
* @param int $requestId The request id that sent the name-value pair
260-
* @param string $buffer The buffer to read the pair from (pass by reference)
260+
* @param null|string $buffer The buffer to read the pair from (pass by reference)
261261
*/
262-
private function readNameValuePair(int $requestId, string &$buffer): void
262+
private function readNameValuePair(int $requestId, ?string &$buffer): void
263263
{
264264
$nameLength = $this->readFieldLength($buffer);
265265
$valueLength = $this->readFieldLength($buffer);

test/CallbackKernelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CallbackKernelTest extends TestCase
1818
*/
1919
public function testInvalidArgumentException()
2020
{
21-
$this->expectException(\InvalidArgumentException::class);
21+
$this->expectException(\TypeError::class);
2222
new CallbackKernel('not a callable function');
2323
}
2424

test/Helper/Mocker/Driver/Connection/MockConnection.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ class MockConnection implements ConnectionInterface
99
{
1010
use MockerTrait;
1111

12-
public function read($length)
12+
public function read(int $length): string
1313
{
14-
return $this->delegateCall('read', func_get_args());
14+
$this->delegateCall('read', func_get_args());
1515
}
1616

17-
public function write($buffer)
17+
public function write(string $buffer): void
1818
{
19-
return $this->delegateCall('write', func_get_args());
19+
$this->delegateCall('write', func_get_args());
2020
}
2121

22-
public function isClosed()
22+
public function isClosed(): bool
2323
{
2424
return $this->delegateCall('isClosed', func_get_args());
2525
}
2626

27-
public function close()
27+
public function close(): void
2828
{
29-
return $this->delegateCall('close', func_get_args());
29+
$this->delegateCall('close', func_get_args());
3030
}
3131
}

test/Helper/Mocker/Driver/Connection/MockConnectionPool.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ class MockConnectionPool implements ConnectionPoolInterface
99
{
1010
use MockerTrait;
1111

12-
public function getReadableConnections($timeout)
12+
public function getReadableConnections(int $timeout): array
1313
{
1414
return $this->delegateCall('getReadableConnections', func_get_args());
1515
}
1616

17-
public function count()
17+
public function count(): int
1818
{
1919
return $this->delegateCall('count', func_get_args());
2020
}
2121

22-
public function shutdown()
22+
public function shutdown(): void
2323
{
24-
return $this->delegateCall('shutdown', func_get_args());
24+
$this->delegateCall('shutdown', func_get_args());
2525
}
2626

27-
public function close()
27+
public function close(): void
2828
{
29-
return $this->delegateCall('close', func_get_args());
29+
$this->delegateCall('close', func_get_args());
3030
}
3131
}

test/Helper/Mocker/Driver/ConnectionHandler/MockConnectionHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ class MockConnectionHandler implements ConnectionHandlerInterface
99
{
1010
use MockerTrait;
1111

12-
public function ready()
12+
public function ready(): array
1313
{
1414
return $this->delegateCall('ready', func_get_args());
1515
}
1616

17-
public function shutdown()
17+
public function shutdown(): void
1818
{
19-
return $this->delegateCall('shutdown', func_get_args());
19+
$this->delegateCall('shutdown', func_get_args());
2020
}
2121

22-
public function close()
22+
public function close(): void
2323
{
24-
return $this->delegateCall('close', func_get_args());
24+
$this->delegateCall('close', func_get_args());
2525
}
2626

27-
public function isClosed()
27+
public function isClosed(): bool
2828
{
2929
return $this->delegateCall('isClosed', func_get_args());
3030
}

test/Helper/Mocker/Driver/ConnectionHandler/MockConnectionHandlerFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPFastCGI\Test\FastCGIDaemon\Helper\Mocker\Driver\ConnectionHandler;
44

5+
use PHPFastCGI\FastCGIDaemon\Driver\Userland\ConnectionHandler\ConnectionHandlerInterface;
56
use PHPFastCGI\FastCGIDaemon\KernelInterface;
67
use PHPFastCGI\FastCGIDaemon\Driver\Userland\Connection\ConnectionInterface;
78
use PHPFastCGI\FastCGIDaemon\Driver\Userland\ConnectionHandler\ConnectionHandlerFactoryInterface;
@@ -11,7 +12,7 @@ class MockConnectionHandlerFactory implements ConnectionHandlerFactoryInterface
1112
{
1213
use MockerTrait;
1314

14-
public function createConnectionHandler(KernelInterface $kernel, ConnectionInterface $connection)
15+
public function createConnectionHandler(KernelInterface $kernel, ConnectionInterface $connection): ConnectionHandlerInterface
1516
{
1617
return $this->delegateCall('createConnectionHandler', func_get_args());
1718
}

test/Helper/Mocker/Driver/MockDriverContainer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace PHPFastCGI\Test\FastCGIDaemon\Helper\Mocker\Driver;
44

5+
use PHPFastCGI\FastCGIDaemon\DaemonFactoryInterface;
56
use PHPFastCGI\FastCGIDaemon\Driver\DriverContainerInterface;
67
use PHPFastCGI\Test\FastCGIDaemon\Helper\Mocker\MockerTrait;
78

89
class MockDriverContainer implements DriverContainerInterface
910
{
1011
use MockerTrait;
1112

12-
public function getFactory($driver)
13+
public function getFactory(string $driver): DaemonFactoryInterface
1314
{
1415
return $this->delegateCall('getFactory', func_get_args());
1516
}

test/Helper/Mocker/MockDaemon.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ class MockDaemon implements DaemonInterface
88
{
99
use MockerTrait;
1010

11-
public function run()
11+
public function run(): void
1212
{
13-
return $this->delegateCall('run', func_get_args());
13+
$this->delegateCall('run', func_get_args());
1414
}
1515

16-
public function flagShutdown($message = null)
16+
public function flagShutdown(string $message = null): void
1717
{
18-
return $this->delegateCall('flagShutdown', func_get_args());
18+
$this->delegateCall('flagShutdown', func_get_args());
1919
}
2020
}

test/Helper/Mocker/MockDaemonFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ class MockDaemonFactory implements DaemonFactoryInterface
1111
{
1212
use MockerTrait;
1313

14-
public function createDaemon(KernelInterface $kernel, DaemonOptions $options, $fd = DaemonInterface::FCGI_LISTENSOCK_FILENO)
14+
public function createDaemon(KernelInterface $kernel, DaemonOptions $options, int $fd = DaemonInterface::FCGI_LISTENSOCK_FILENO): DaemonInterface
1515
{
1616
return $this->delegateCall('createDaemon', func_get_args());
1717
}
1818

19-
public function createTcpDaemon(KernelInterface $kernel, DaemonOptions $options, $port, $host = 'localhost')
19+
public function createTcpDaemon(KernelInterface $kernel, DaemonOptions $options, string $host = 'localhost', int $port): DaemonInterface
2020
{
2121
return $this->delegateCall('createTcpDaemon', func_get_args());
2222
}

0 commit comments

Comments
 (0)