Use autoloading.

pull/150/head
Anthony Birkett 4 years ago
parent b5d355514b
commit a2f7834ef5

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
require __DIR__ . '/../SourceQuery/bootstrap.php'; require __DIR__ . '/../vendor/autoload.php';
use xPaw\SourceQuery\SourceQuery; use xPaw\SourceQuery\SourceQuery;

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
require __DIR__ . '/../SourceQuery/bootstrap.php'; require __DIR__ . '/../vendor/autoload.php';
use xPaw\SourceQuery\SourceQuery; use xPaw\SourceQuery\SourceQuery;

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
require __DIR__ . '/../SourceQuery/bootstrap.php'; require __DIR__ . '/../vendor/autoload.php';
use xPaw\SourceQuery\SourceQuery; use xPaw\SourceQuery\SourceQuery;
@ -115,6 +115,8 @@ $Timer = number_format(microtime(true) - $Timer, 4, '.', '');
echo 'true'; echo 'true';
} elseif ($InfoValue === false) { } elseif ($InfoValue === false) {
echo 'false'; echo 'false';
} elseif (is_int($InfoValue)) {
echo $InfoValue;
} else { } else {
echo htmlspecialchars($InfoValue); echo htmlspecialchars($InfoValue);
} }

@ -29,7 +29,7 @@ use xPaw\SourceQuery\Exception\SocketException;
abstract class BaseSocket abstract class BaseSocket
{ {
/** /**
* @var resource * @var resource|null
*/ */
public $Socket; public $Socket;

@ -33,10 +33,10 @@ final class Socket extends BaseSocket
*/ */
public function Close(): void public function Close(): void
{ {
if ($this->Socket !== null) { if ($this->Socket !== null && $this->Socket !== 0) {
fclose($this->Socket); fclose($this->Socket);
$this->Socket = 0; $this->Socket = null;
} }
} }
@ -94,7 +94,13 @@ final class Socket extends BaseSocket
public function Read(int $Length = 1400): Buffer public function Read(int $Length = 1400): Buffer
{ {
$Buffer = new Buffer(); $Buffer = new Buffer();
$Buffer->Set(fread($this->Socket, $Length)); $data = fread($this->Socket, $Length);
if (!$data) {
throw new SocketException('Failed to open socket.');
}
$Buffer->Set($data);
$this->ReadInternal($Buffer, $Length, [ $this, 'Sherlock' ]); $this->ReadInternal($Buffer, $Length, [ $this, 'Sherlock' ]);

@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
/**
* Library to query servers that implement Source Engine Query protocol.
*
* Special thanks to koraktor for his awesome Steam Condenser class,
* I used it as a reference at some points.
*
* @author Pavel Djundik
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*/
require_once __DIR__ . '/Exception/SourceQueryException.php';
require_once __DIR__ . '/Exception/AuthenticationException.php';
require_once __DIR__ . '/Exception/InvalidArgumentException.php';
require_once __DIR__ . '/Exception/SocketException.php';
require_once __DIR__ . '/Exception/InvalidPacketException.php';
require_once __DIR__ . '/Buffer.php';
require_once __DIR__ . '/BaseSocket.php';
require_once __DIR__ . '/Socket.php';
require_once __DIR__ . '/SourceRcon.php';
require_once __DIR__ . '/GoldSourceRcon.php';
require_once __DIR__ . '/SourceQuery.php';

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" <phpunit colors="true" verbose="true">
bootstrap="../SourceQuery/bootstrap.php"
verbose="true">
<testsuites> <testsuites>
<testsuite name="Tests"> <testsuite name="Tests">
<file>./Tests.php</file> <file>./Tests.php</file>

@ -19,9 +19,9 @@
"require": "require":
{ {
"php": ">=7.4", "php": ">=7.4",
"ext-bz2": ">7.*", "ext-bz2": ">=7.4",
"ext-gmp": ">7.*", "ext-gmp": ">=7.4",
"ext-json": ">7.*" "ext-json": ">=7.4"
}, },
"require-dev": "require-dev":
{ {

Loading…
Cancel
Save