From e4754b5260bcc60bc093e413fdc80bd641d9de06 Mon Sep 17 00:00:00 2001 From: cdosoftei Date: Thu, 31 Mar 2022 19:05:41 -0400 Subject: [PATCH 1/2] :zap: Add InboundClient::getAddress() +minor tweaks --- composer.json | 8 ++++---- etc/psalm.xml | 1 - src/InboundClient.php | 12 +++++++++++- src/OutboundServer.php | 2 +- tests/InboundClientTest.php | 8 ++++++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 8036091..e82a39a 100644 --- a/composer.json +++ b/composer.json @@ -31,10 +31,10 @@ }, "require-dev": { "clue/block-react": "^1.5", - "clue/stdio-react": "^2.5", - "phpstan/phpstan": "^1.4", + "clue/stdio-react": "^2.6", + "phpstan/phpstan": "^1.5", "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^4.20" + "vimeo/psalm": "^4.22" }, "autoload": { "psr-4": { @@ -48,7 +48,7 @@ }, "scripts": { "phpstan": "php -d memory_limit=-1 ./vendor/bin/phpstan analyse -c ./etc/phpstan.neon -n -vvv --ansi --level=max src", - "psalm": "php -d memory_limit=-1 ./vendor/bin/psalm --config=./etc/psalm.xml --show-info=true", + "psalm": "php -d memory_limit=-1 ./vendor/bin/psalm --config=./etc/psalm.xml --show-info=true --shepherd", "phpunit": "php -d memory_limit=-1 ./vendor/bin/phpunit --debug -c ./etc/phpunit.xml.dist", "coverage": "php -d memory_limit=-1 ./vendor/bin/phpunit --debug -c ./etc/phpunit.xml.dist --coverage-text --coverage-html=reports/coverage" } diff --git a/etc/psalm.xml b/etc/psalm.xml index 56f559b..84bf951 100644 --- a/etc/psalm.xml +++ b/etc/psalm.xml @@ -1,6 +1,5 @@ esl->getAddress(); + } + /** * Closes the TCP connection */ diff --git a/src/OutboundServer.php b/src/OutboundServer.php index bfad5e4..b2b1998 100644 --- a/src/OutboundServer.php +++ b/src/OutboundServer.php @@ -116,7 +116,7 @@ protected function connectionHandler(DuplexStreamInterface $stream): void 'error', [new ReactESLException( 'Unexpected reply received (ENOMSG) ' . $contentType, - defined('SOCKET_ENOMSG') ? SOCKET_ENOMSG : 42 + defined('SOCKET_ENOMSG') ? (int)SOCKET_ENOMSG : 42 )] ); } else { diff --git a/tests/InboundClientTest.php b/tests/InboundClientTest.php index d56a4d2..9538930 100644 --- a/tests/InboundClientTest.php +++ b/tests/InboundClientTest.php @@ -394,6 +394,14 @@ public function testPreAuthHandlerOnUnexpectedResponse(): void }); } + public function testGetAddress(): void + { + $context = $this->prepareClientAndConnectors(); + + $context->esl->expects($this->once())->method('getAddress'); + $context->client->getAddress(); + } + public function testClose(): void { $context = $this->prepareClientAndConnectors(); From 04c26f95971fabf922ef3f080d8f70008e2468cc Mon Sep 17 00:00:00 2001 From: cdosoftei Date: Thu, 31 Mar 2022 19:14:29 -0400 Subject: [PATCH 2/2] :green_heart: Remove redundant type cast --- src/InboundClient.php | 2 +- src/OutboundServer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/InboundClient.php b/src/InboundClient.php index 80f7c26..4c6ea17 100644 --- a/src/InboundClient.php +++ b/src/InboundClient.php @@ -158,7 +158,7 @@ protected function dataHandler(string $chunk): void 'error', [new ReactESLException( 'Unexpected reply received (ENOMSG) ' . $contentType, - defined('SOCKET_ENOMSG') ? (int)SOCKET_ENOMSG : 42 + defined('SOCKET_ENOMSG') ? SOCKET_ENOMSG : 42 )] ); } else { diff --git a/src/OutboundServer.php b/src/OutboundServer.php index b2b1998..bfad5e4 100644 --- a/src/OutboundServer.php +++ b/src/OutboundServer.php @@ -116,7 +116,7 @@ protected function connectionHandler(DuplexStreamInterface $stream): void 'error', [new ReactESLException( 'Unexpected reply received (ENOMSG) ' . $contentType, - defined('SOCKET_ENOMSG') ? (int)SOCKET_ENOMSG : 42 + defined('SOCKET_ENOMSG') ? SOCKET_ENOMSG : 42 )] ); } else {