1
0
mirror of https://github.com/xPaw/PHP-Source-Query.git synced 2026-06-11 01:33:15 +02:00

Psalm fixes around resource handling.

This commit is contained in:
Anthony Birkett
2021-05-31 13:05:53 +01:00
parent efa37503bf
commit 48b89017c4
3 changed files with 27 additions and 19 deletions
+5 -3
View File
@@ -31,6 +31,8 @@ final class SourceRcon extends AbstractRcon
/**
* @var ?resource
*
* @psalm-var null|resource|closed-resource
*/
private $rconSocket;
@@ -76,7 +78,7 @@ final class SourceRcon extends AbstractRcon
*/
public function close(): void
{
if ($this->rconSocket) {
if (is_resource($this->rconSocket)) {
fclose($this->rconSocket);
$this->rconSocket = null;
@@ -173,7 +175,7 @@ final class SourceRcon extends AbstractRcon
*/
protected function read(): Buffer
{
if (!$this->rconSocket) {
if (!is_resource($this->rconSocket)) {
throw new InvalidPacketException('Rcon socket not open.');
}
@@ -236,7 +238,7 @@ final class SourceRcon extends AbstractRcon
*/
protected function write(?int $header, string $string = ''): bool
{
if (!$this->rconSocket) {
if (!is_resource($this->rconSocket)) {
throw new InvalidPacketException('Rcon socket not open.');
}