Skip to content

Commit 951e2c3

Browse files
committed
Trim trailing whitespace
1 parent 8b16be3 commit 951e2c3

File tree

11 files changed

+306
-305
lines changed

11 files changed

+306
-305
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ root = true
66
charset = utf-8
77
indent_style = tab
88
insert_final_newline = true
9+
trim_trailing_whitespace = true
910

1011
[*.yaml]
1112
indent_style = space

Examples/Example.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<?php
22
declare(strict_types=1);
3-
3+
44
require __DIR__ . '/../vendor/autoload.php';
55

66
use xPaw\SourceQuery\SourceQuery;
7-
7+
88
// For the sake of this example
99
header( 'Content-Type: text/plain' );
1010
header( 'X-Content-Type-Options: nosniff' );
11-
11+
1212
// Edit this ->
1313
define( 'SQ_SERVER_ADDR', 'localhost' );
1414
define( 'SQ_SERVER_PORT', 27015 );
1515
define( 'SQ_TIMEOUT', 1 );
1616
define( 'SQ_ENGINE', SourceQuery::SOURCE );
1717
// Edit this <-
18-
18+
1919
$Query = new SourceQuery( );
20-
20+
2121
try
2222
{
2323
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
24-
24+
2525
print_r( $Query->GetInfo( ) );
2626
print_r( $Query->GetPlayers( ) );
2727
print_r( $Query->GetRules( ) );

Examples/RconExample.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
<?php
22
declare(strict_types=1);
3-
3+
44
require __DIR__ . '/../vendor/autoload.php';
55

66
use xPaw\SourceQuery\SourceQuery;
7-
7+
88
// For the sake of this example
99
header( 'Content-Type: text/plain' );
1010
header( 'X-Content-Type-Options: nosniff' );
11-
11+
1212
// Edit this ->
1313
define( 'SQ_SERVER_ADDR', 'localhost' );
1414
define( 'SQ_SERVER_PORT', 27015 );
1515
define( 'SQ_TIMEOUT', 1 );
1616
define( 'SQ_ENGINE', SourceQuery::SOURCE );
1717
// Edit this <-
18-
18+
1919
$Query = new SourceQuery( );
20-
20+
2121
try
2222
{
2323
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
24-
24+
2525
$Query->SetRconPassword( 'my_awesome_password' );
26-
26+
2727
var_dump( $Query->Rcon( 'say hello' ) );
2828
}
2929
catch( Exception $e )

Examples/View.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44
require __DIR__ . '/../vendor/autoload.php';
55

66
use xPaw\SourceQuery\SourceQuery;
7-
7+
88
// Edit this ->
99
define( 'SQ_SERVER_ADDR', 'localhost' );
1010
define( 'SQ_SERVER_PORT', 27015 );
1111
define( 'SQ_TIMEOUT', 3 );
1212
define( 'SQ_ENGINE', SourceQuery::SOURCE );
1313
// Edit this <-
14-
14+
1515
$Timer = microtime( true );
16-
16+
1717
$Query = new SourceQuery( );
18-
18+
1919
$Info = [];
2020
$Rules = [];
2121
$Players = [];
2222
$Exception = null;
23-
23+
2424
try
2525
{
2626
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
2727
//$Query->SetUseOldGetChallengeMethod( true ); // Use this when players/rules retrieval fails on games like Starbound
28-
28+
2929
$Info = $Query->GetInfo( );
3030
$Players = $Query->GetPlayers( );
3131
$Rules = $Query->GetRules( );
@@ -38,36 +38,36 @@
3838
{
3939
$Query->Disconnect( );
4040
}
41-
41+
4242
$Timer = number_format( microtime( true ) - $Timer, 4, '.', '' );
4343
?>
4444
<!DOCTYPE html>
4545
<html>
4646
<head>
4747
<meta charset="utf-8">
4848
<title>Source Query PHP Library</title>
49-
49+
5050
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
5151
<style type="text/css">
5252
.table {
5353
table-layout: fixed;
5454
border-top-color: #428BCA;
5555
}
56-
56+
5757
.table td {
5858
overflow-x: auto;
5959
}
60-
60+
6161
.table thead th {
6262
background-color: #428BCA;
6363
border-color: #428BCA !important;
6464
color: #FFF;
6565
}
66-
66+
6767
.info-column {
6868
width: 120px;
6969
}
70-
70+
7171
.frags-column {
7272
width: 80px;
7373
}
@@ -78,17 +78,17 @@
7878
<div class="jumbotron">
7979
<div class="container">
8080
<h1>Source Query PHP Library</h1>
81-
81+
8282
<p class="lead">This library was created to query game server which use the Source (Steamworks) query protocol.</p>
83-
83+
8484
<p>
8585
<a class="btn btn-large btn-primary" href="https://xpaw.me">Made by xPaw</a>
8686
<a class="btn btn-large btn-primary" href="https://github.com/xPaw/PHP-Source-Query">View on GitHub</a>
8787
<a class="btn btn-large btn-danger" href="https://github.com/xPaw/PHP-Source-Query/blob/master/LICENSE">LGPL v2.1</a>
8888
</p>
8989
</div>
9090
</div>
91-
91+
9292
<div class="container">
9393
<?php if( $Exception !== null ): ?>
9494
<div class="panel panel-error">

SourceQuery/BaseSocket.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
*
1212
* @internal
1313
*/
14-
14+
1515
namespace xPaw\SourceQuery;
16-
16+
1717
use xPaw\SourceQuery\Exception\InvalidPacketException;
1818
use xPaw\SourceQuery\Exception\SocketException;
1919

@@ -30,30 +30,30 @@ abstract class BaseSocket
3030
/** @var ?resource */
3131
public $Socket;
3232
public int $Engine;
33-
33+
3434
public string $Address;
3535
public int $Port;
3636
public int $Timeout;
37-
37+
3838
public function __destruct( )
3939
{
4040
$this->Close( );
4141
}
42-
42+
4343
abstract public function Close( ) : void;
4444
abstract public function Open( string $Address, int $Port, int $Timeout, int $Engine ) : void;
4545
abstract public function Write( int $Header, string $String = '' ) : bool;
4646
abstract public function Read( ) : Buffer;
47-
47+
4848
protected function ReadInternal( Buffer $Buffer, callable $SherlockFunction ) : Buffer
4949
{
5050
if( $Buffer->Remaining( ) === 0 )
5151
{
5252
throw new InvalidPacketException( 'Failed to read any data from socket', InvalidPacketException::BUFFER_EMPTY );
5353
}
54-
54+
5555
$Header = $Buffer->GetLong( );
56-
56+
5757
if( $Header === -1 ) // Single packet
5858
{
5959
// We don't have to do anything
@@ -64,54 +64,54 @@ protected function ReadInternal( Buffer $Buffer, callable $SherlockFunction ) :
6464
$IsCompressed = false;
6565
$ReadMore = false;
6666
$PacketChecksum = null;
67-
67+
6868
do
6969
{
7070
$RequestID = $Buffer->GetLong( );
71-
71+
7272
switch( $this->Engine )
7373
{
7474
case SourceQuery::GOLDSOURCE:
7575
{
7676
$PacketCountAndNumber = $Buffer->GetByte( );
7777
$PacketCount = $PacketCountAndNumber & 0xF;
7878
$PacketNumber = $PacketCountAndNumber >> 4;
79-
79+
8080
break;
8181
}
8282
case SourceQuery::SOURCE:
8383
{
8484
$IsCompressed = ( $RequestID & 0x80000000 ) !== 0;
8585
$PacketCount = $Buffer->GetByte( );
8686
$PacketNumber = $Buffer->GetByte( ) + 1;
87-
87+
8888
if( $IsCompressed )
8989
{
9090
$Buffer->GetLong( ); // Split size
91-
91+
9292
$PacketChecksum = $Buffer->GetUnsignedLong( );
9393
}
9494
else
9595
{
9696
$Buffer->GetShort( ); // Split size
9797
}
98-
98+
9999
break;
100100
}
101101
default:
102102
{
103103
throw new SocketException( 'Unknown engine.', SocketException::INVALID_ENGINE );
104104
}
105105
}
106-
106+
107107
$Packets[ $PacketNumber ] = $Buffer->Get( );
108-
108+
109109
$ReadMore = $PacketCount > sizeof( $Packets );
110110
}
111111
while( $ReadMore && $SherlockFunction( $Buffer ) );
112-
112+
113113
$Data = implode( $Packets );
114-
114+
115115
// TODO: Test this
116116
if( $IsCompressed )
117117
{
@@ -120,22 +120,22 @@ protected function ReadInternal( Buffer $Buffer, callable $SherlockFunction ) :
120120
{
121121
throw new \RuntimeException( 'Received compressed packet, PHP doesn\'t have Bzip2 library installed, can\'t decompress.' );
122122
}
123-
123+
124124
$Data = bzdecompress( $Data );
125-
125+
126126
if( !is_string( $Data ) || crc32( $Data ) !== $PacketChecksum )
127127
{
128128
throw new InvalidPacketException( 'CRC32 checksum mismatch of uncompressed packet data.', InvalidPacketException::CHECKSUM_MISMATCH );
129129
}
130130
}
131-
131+
132132
$Buffer->Set( substr( $Data, 4 ) );
133133
}
134134
else
135135
{
136136
throw new InvalidPacketException( 'Socket read: Raw packet header mismatch. (0x' . dechex( $Header ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );
137137
}
138-
138+
139139
return $Buffer;
140140
}
141141
}

0 commit comments

Comments
 (0)