Skip to content

Commit

Permalink
use psr factory and cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Mar 4, 2024
1 parent 3faec66 commit 7d2a7fa
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 25 deletions.
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<testsuites>
<testsuite name="Socket Client Test Suite">
<directory>tests/</directory>
<exclude>tests/SocketClientFeatureTest.php</exclude>
</testsuite>
</testsuites>
<php>
Expand Down
11 changes: 4 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ public function __construct($config1 = [], $config2 = null, array $config = [])
$this->config = $this->configure($config2 ?: $config);
}

/**
* {@inheritdoc}
*/
public function sendRequest(RequestInterface $request): ResponseInterface
{
$remote = $this->config['remote_socket'];
Expand Down Expand Up @@ -100,9 +97,9 @@ public function sendRequest(RequestInterface $request): ResponseInterface
* @param string $remote Entrypoint for the connection
* @param bool $useSsl Whether to use ssl or not
*
* @throws ConnectionException|SSLConnectionException When the connection fail
*
* @return resource Socket resource
*
* @throws ConnectionException|SSLConnectionException When the connection fail
*/
protected function createSocket(RequestInterface $request, string $remote, bool $useSsl)
{
Expand Down Expand Up @@ -174,9 +171,9 @@ protected function configure(array $config = [])
/**
* Return remote socket from the request.
*
* @throws InvalidRequestException When no remote can be determined from the request
*
* @return string
*
* @throws InvalidRequestException When no remote can be determined from the request
*/
private function determineRemoteFromRequest(RequestInterface $request)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/NetworkException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NetworkException extends \RuntimeException implements NetworkExceptionInte
*/
private $request;

public function __construct(string $message, RequestInterface $request, \Exception $previous = null)
public function __construct(string $message, RequestInterface $request, ?\Exception $previous = null)
{
$this->request = $request;

Expand Down
1 change: 1 addition & 0 deletions src/RequestWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private function fwrite($stream, string $bytes)
// The write worked or failed explicitly. This value is fine to return.
return $result;
}

// We performed a 0-length write, were told that the stream was writable, and
// then immediately performed another 0-length write. Conclude that the pipe
// is broken and return `false`.
Expand Down
4 changes: 2 additions & 2 deletions src/ResponseReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Http\Client\Socket\Exception\BrokenPipeException;
use Http\Client\Socket\Exception\TimeoutException;
use Http\Message\ResponseFactory;
use Nyholm\Psr7\Response;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;

/**
Expand All @@ -19,7 +19,7 @@
trait ResponseReader
{
/**
* @var ResponseFactory For creating response
* @var ResponseFactoryInterface For creating response
*/
protected $responseFactory;

Expand Down
4 changes: 0 additions & 4 deletions src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public function detach()
}

/**
* {@inheritdoc}
*
* @return int<0, max>|null
*/
public function getSize(): ?int
Expand Down Expand Up @@ -153,8 +151,6 @@ public function isReadable(): bool
}

/**
* {@inheritdoc}
*
* @param int<0, max> $length
*/
public function read($length): string
Expand Down
3 changes: 0 additions & 3 deletions tests/SocketHttpAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

class SocketHttpAdapterTest extends HttpClientTest
{
/**
* {@inheritdoc}
*/
protected function createHttpAdapter(): ClientInterface
{
return new SocketHttpClient();
Expand Down
4 changes: 2 additions & 2 deletions tests/SocketHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace Http\Client\Socket\Tests;

use GuzzleHttp\Psr7\HttpFactory;
use Http\Client\Common\HttpMethodsClient;
use Http\Client\Socket\Client as SocketHttpClient;
use Http\Client\Socket\Exception\NetworkException;
use Http\Client\Socket\Exception\TimeoutException;
use Http\Message\MessageFactory\GuzzleMessageFactory;

class SocketHttpClientTest extends BaseTestCase
{
public function createClient($options = [])
{
$messageFactory = new GuzzleMessageFactory();
$messageFactory = new HttpFactory();

return new HttpMethodsClient(new SocketHttpClient($options), $messageFactory);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/server/tcp-bugous-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
$client = stream_socket_accept($socketServer);

fclose($client);
\Http\Client\Socket\Tests\Semaphore::release();
Http\Client\Socket\Tests\Semaphore::release();
2 changes: 1 addition & 1 deletion tests/server/tcp-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
while (!@feof($client)) {
@fread($client, 1000);
}
\Http\Client\Socket\Tests\Semaphore::release();
Http\Client\Socket\Tests\Semaphore::release();
2 changes: 1 addition & 1 deletion tests/server/tcp-ssl-server-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
while (!@feof($client)) {
@fread($client, 1000);
}
\Http\Client\Socket\Tests\Semaphore::release();
Http\Client\Socket\Tests\Semaphore::release();
2 changes: 1 addition & 1 deletion tests/server/tcp-ssl-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
@fread($client, 1000);
}

\Http\Client\Socket\Tests\Semaphore::release();
Http\Client\Socket\Tests\Semaphore::release();
2 changes: 1 addition & 1 deletion tests/server/unix-domain-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
}

unlink(__DIR__.'/server.sock');
\Http\Client\Socket\Tests\Semaphore::release();
Http\Client\Socket\Tests\Semaphore::release();

0 comments on commit 7d2a7fa

Please sign in to comment.