@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | |
| 222 | 222 | // Will hold the properties we are sending back |
| 223 | - $properties = [ ]; |
|
| 223 | + $properties = []; |
|
| 224 | 224 | |
| 225 | 225 | // All of these are split on space |
| 226 | 226 | $items = explode(' ', $data); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @param string $data |
| 252 | 252 | * @param \GameQ\Result $result |
| 253 | 253 | */ |
| 254 | - protected function processDetails($data, Result &$result) |
|
| 254 | + protected function processDetails($data, Result & $result) |
|
| 255 | 255 | { |
| 256 | 256 | |
| 257 | 257 | // Offload the parsing for these values |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * @param string $data |
| 281 | 281 | * @param \GameQ\Result $result |
| 282 | 282 | */ |
| 283 | - protected function processChannels($data, Result &$result) |
|
| 283 | + protected function processChannels($data, Result & $result) |
|
| 284 | 284 | { |
| 285 | 285 | |
| 286 | 286 | // We need to split the data at the pipe |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @param string $data |
| 307 | 307 | * @param \GameQ\Result $result |
| 308 | 308 | */ |
| 309 | - protected function processPlayers($data, Result &$result) |
|
| 309 | + protected function processPlayers($data, Result & $result) |
|
| 310 | 310 | { |
| 311 | 311 | |
| 312 | 312 | // We need to split the data at the pipe |
@@ -97,7 +97,7 @@ |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Delete some unknown stuff |
| 100 | - $this->deleteResult($result, [ 's1', 's9', 's11', 's12', 's13', 's14' ]); |
|
| 100 | + $this->deleteResult($result, ['s1', 's9', 's11', 's12', 's13', 's14']); |
|
| 101 | 101 | |
| 102 | 102 | // Return the result |
| 103 | 103 | return $result; |
@@ -748,17 +748,17 @@ discard block |
||
| 748 | 748 | * @return string |
| 749 | 749 | * @throws \GameQ\Exception\Protocol |
| 750 | 750 | */ |
| 751 | - protected function decryptPackets(array $packets = [ ]) |
|
| 751 | + protected function decryptPackets(array $packets = []) |
|
| 752 | 752 | { |
| 753 | 753 | |
| 754 | 754 | // This will be returned |
| 755 | - $decrypted = [ ]; |
|
| 755 | + $decrypted = []; |
|
| 756 | 756 | |
| 757 | 757 | foreach ($packets as $packet) { |
| 758 | 758 | # Header : |
| 759 | 759 | $header = substr($packet, 0, 20); |
| 760 | 760 | |
| 761 | - $header_items = [ ]; |
|
| 761 | + $header_items = []; |
|
| 762 | 762 | |
| 763 | 763 | $header_key = unpack("n1", $header); |
| 764 | 764 | |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | * @param int $fieldCount |
| 839 | 839 | * @param \GameQ\Result $result |
| 840 | 840 | */ |
| 841 | - protected function processChannel($data, $fieldCount, Result &$result) |
|
| 841 | + protected function processChannel($data, $fieldCount, Result & $result) |
|
| 842 | 842 | { |
| 843 | 843 | |
| 844 | 844 | // Split the items on the comma |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | * @param int $fieldCount |
| 861 | 861 | * @param \GameQ\Result $result |
| 862 | 862 | */ |
| 863 | - protected function processPlayer($data, $fieldCount, Result &$result) |
|
| 863 | + protected function processPlayer($data, $fieldCount, Result & $result) |
|
| 864 | 864 | { |
| 865 | 865 | |
| 866 | 866 | // Split the items on the comma |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @var array |
| 34 | 34 | */ |
| 35 | - protected $result = [ ]; |
|
| 35 | + protected $result = []; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Adds variable to results |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | // Nothing of this type yet, set an empty array |
| 84 | 84 | if (!isset($this->result[$sub]) or !is_array($this->result[$sub])) { |
| 85 | - $this->result[$sub] = [ ]; |
|
| 85 | + $this->result[$sub] = []; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Find the first entry that doesn't have this variable |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $server_addr = explode(':', $ip_address); |
| 171 | 171 | |
| 172 | 172 | // Port is the last item in the array, remove it and save |
| 173 | - $this->port_client = (int)array_pop($server_addr); |
|
| 173 | + $this->port_client = (int) array_pop($server_addr); |
|
| 174 | 174 | |
| 175 | 175 | // The rest is the address, recombine |
| 176 | 176 | $this->ip = implode(':', $server_addr); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | // Now let's validate the IPv6 value sent, remove the square brackets ([]) first |
| 188 | - if (!filter_var(trim($this->ip, '[]'), FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV6,])) { |
|
| 188 | + if (!filter_var(trim($this->ip, '[]'), FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV6, ])) { |
|
| 189 | 189 | throw new Exception("The IPv6 address '{$this->ip}' is invalid."); |
| 190 | 190 | } |
| 191 | 191 | } else { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | list($this->ip, $this->port_client) = explode(':', $ip_address); |
| 195 | 195 | |
| 196 | 196 | // Type case the port |
| 197 | - $this->port_client = (int)$this->port_client; |
|
| 197 | + $this->port_client = (int) $this->port_client; |
|
| 198 | 198 | } else { |
| 199 | 199 | // No port, fail |
| 200 | 200 | throw new Exception( |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Validate the IPv4 value, if FALSE is not a valid IP, maybe a hostname. Try to resolve |
| 207 | - if (!filter_var($this->ip, FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV4,]) |
|
| 207 | + if (!filter_var($this->ip, FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV4, ]) |
|
| 208 | 208 | && $this->ip === gethostbyname($this->ip) |
| 209 | 209 | ) { |
| 210 | 210 | // When gethostbyname() fails it returns the original string |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | // Specific query port defined |
| 224 | 224 | if (array_key_exists(self::SERVER_OPTIONS_QUERY_PORT, $this->options)) { |
| 225 | - $this->port_query = (int)$this->options[self::SERVER_OPTIONS_QUERY_PORT]; |
|
| 225 | + $this->port_query = (int) $this->options[self::SERVER_OPTIONS_QUERY_PORT]; |
|
| 226 | 226 | } else { |
| 227 | 227 | // Do math based on the protocol class |
| 228 | 228 | $this->port_query = $this->protocol->findQueryPort($this->port_client); |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Multiply so we move the decimal point out of the way, if there is one |
| 93 | - $key = (int)(floatval($matches[2]) * 1000); |
|
| 93 | + $key = (int) (floatval($matches[2]) * 1000); |
|
| 94 | 94 | |
| 95 | 95 | // Add this packet to the processed |
| 96 | 96 | $processed[$key] = $matches[1]; |
@@ -108,7 +108,7 @@ |
||
| 108 | 108 | throw new Exception(__METHOD__ . " response type '" . bin2hex($header) . "' is not valid"); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return call_user_func_array([$this, $this->responses[ $header ]], [$buffer]); |
|
| 111 | + return call_user_func_array([$this, $this->responses[$header]], [$buffer]); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | protected function processStatus(Buffer $buffer) |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | if (isset($result['players']) && count($result['players']) > 0) { |
| 65 | 65 | // Iterate |
| 66 | 66 | foreach ($result['players'] as $key => $player) { |
| 67 | - $result['players'][ $key ] = array_merge($player, $this->check('player', $player)); |
|
| 67 | + $result['players'][$key] = array_merge($player, $this->check('player', $player)); |
|
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | 70 | $result['players'] = []; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | if (isset($result['teams']) && count($result['teams']) > 0) { |
| 75 | 75 | // Iterate |
| 76 | 76 | foreach ($result['teams'] as $key => $team) { |
| 77 | - $result['teams'][ $key ] = array_merge($team, $this->check('team', $team)); |
|
| 77 | + $result['teams'][$key] = array_merge($team, $this->check('team', $team)); |
|
| 78 | 78 | } |
| 79 | 79 | } else { |
| 80 | 80 | $result['teams'] = []; |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | // Normalized return array |
| 105 | 105 | $normalized = []; |
| 106 | 106 | |
| 107 | - if (isset($this->normalize[ $section ]) && !empty($this->normalize[ $section ])) { |
|
| 108 | - foreach ($this->normalize[ $section ] as $property => $raw) { |
|
| 107 | + if (isset($this->normalize[$section]) && !empty($this->normalize[$section])) { |
|
| 108 | + foreach ($this->normalize[$section] as $property => $raw) { |
|
| 109 | 109 | // Default the value for the new key as null |
| 110 | 110 | $value = null; |
| 111 | 111 | |
@@ -113,18 +113,18 @@ discard block |
||
| 113 | 113 | // Iterate over the raw property we want to use |
| 114 | 114 | foreach ($raw as $check) { |
| 115 | 115 | if (array_key_exists($check, $data)) { |
| 116 | - $value = $data[ $check ]; |
|
| 116 | + $value = $data[$check]; |
|
| 117 | 117 | break; |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | } else { |
| 121 | 121 | // String |
| 122 | 122 | if (array_key_exists($raw, $data)) { |
| 123 | - $value = $data[ $raw ]; |
|
| 123 | + $value = $data[$raw]; |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $normalized[ 'gq_' . $property ] = $value; |
|
| 127 | + $normalized['gq_' . $property] = $value; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | protected $options = [ |
| 84 | 84 | 'debug' => false, |
| 85 | 85 | 'timeout' => 3, // Seconds |
| 86 | - 'filters' => [ 'normalize' => [ ] ], |
|
| 86 | + 'filters' => ['normalize' => []], |
|
| 87 | 87 | // Advanced settings |
| 88 | 88 | 'stream_timeout' => 200000, // See http://www.php.net/manual/en/function.stream-select.php for more info |
| 89 | 89 | 'write_wait' => 500, |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @type array |
| 100 | 100 | */ |
| 101 | - protected $servers = [ ]; |
|
| 101 | + protected $servers = []; |
|
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * The query library to use. Default is Native |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | public function __get($option) |
| 125 | 125 | { |
| 126 | 126 | |
| 127 | - return isset($this->options[ $option ]) ? $this->options[ $option ] : null; |
|
| 127 | + return isset($this->options[$option]) ? $this->options[$option] : null; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | public function __set($option, $value) |
| 139 | 139 | { |
| 140 | 140 | |
| 141 | - $this->options[ $option ] = $value; |
|
| 141 | + $this->options[$option] = $value; |
|
| 142 | 142 | |
| 143 | 143 | return true; |
| 144 | 144 | } |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return $this |
| 169 | 169 | */ |
| 170 | - public function addServer(array $server_info = [ ]) |
|
| 170 | + public function addServer(array $server_info = []) |
|
| 171 | 171 | { |
| 172 | 172 | |
| 173 | 173 | // Add and validate the server |
| 174 | - $this->servers[ uniqid() ] = new Server($server_info); |
|
| 174 | + $this->servers[uniqid()] = new Server($server_info); |
|
| 175 | 175 | |
| 176 | 176 | return $this; // Make calls chainable |
| 177 | 177 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return $this |
| 185 | 185 | */ |
| 186 | - public function addServers(array $servers = [ ]) |
|
| 186 | + public function addServers(array $servers = []) |
|
| 187 | 187 | { |
| 188 | 188 | |
| 189 | 189 | // Loop through all the servers and add them |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | * @return $this |
| 205 | 205 | * @throws \Exception |
| 206 | 206 | */ |
| 207 | - public function addServersFromFiles($files = [ ]) |
|
| 207 | + public function addServersFromFiles($files = []) |
|
| 208 | 208 | { |
| 209 | 209 | |
| 210 | 210 | // Since we expect an array let us turn a string (i.e. single file) into an array |
| 211 | 211 | if (!is_array($files)) { |
| 212 | - $files = [ $files ]; |
|
| 212 | + $files = [$files]; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // Iterate over the file(s) and add them |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | { |
| 244 | 244 | |
| 245 | 245 | // Reset all the servers |
| 246 | - $this->servers = [ ]; |
|
| 246 | + $this->servers = []; |
|
| 247 | 247 | |
| 248 | 248 | return $this; // Make Chainable |
| 249 | 249 | } |
@@ -256,11 +256,11 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @return $this |
| 258 | 258 | */ |
| 259 | - public function addFilter($filterName, $options = [ ]) |
|
| 259 | + public function addFilter($filterName, $options = []) |
|
| 260 | 260 | { |
| 261 | 261 | |
| 262 | 262 | // Add the filter |
| 263 | - $this->options['filters'][ strtolower($filterName) ] = $options; |
|
| 263 | + $this->options['filters'][strtolower($filterName)] = $options; |
|
| 264 | 264 | |
| 265 | 265 | return $this; |
| 266 | 266 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | // Remove this filter if it has been defined |
| 282 | 282 | if (array_key_exists($filterName, $this->options['filters'])) { |
| 283 | - unset($this->options['filters'][ $filterName ]); |
|
| 283 | + unset($this->options['filters'][$filterName]); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | return $this; |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | unset($class); |
| 305 | 305 | |
| 306 | 306 | // Define the return |
| 307 | - $results = [ ]; |
|
| 307 | + $results = []; |
|
| 308 | 308 | |
| 309 | 309 | // @todo: Add break up into loop to split large arrays into smaller chunks |
| 310 | 310 | |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | ksort($result); |
| 329 | 329 | |
| 330 | 330 | // Add the result to the results array |
| 331 | - $results[ $server->id() ] = $result; |
|
| 331 | + $results[$server->id()] = $result; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | return $results; |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | { |
| 342 | 342 | |
| 343 | 343 | // Initialize the sockets for reading |
| 344 | - $sockets = [ ]; |
|
| 344 | + $sockets = []; |
|
| 345 | 345 | |
| 346 | 346 | // By default we don't have any challenges to process |
| 347 | 347 | $server_challenge = false; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | $socket->write($server->protocol()->getPacket(Protocol::PACKET_CHALLENGE)); |
| 372 | 372 | |
| 373 | 373 | // Add the socket information so we can reference it easily |
| 374 | - $sockets[ (int) $socket->get() ] = [ |
|
| 374 | + $sockets[(int) $socket->get()] = [ |
|
| 375 | 375 | 'server_id' => $server_id, |
| 376 | 376 | 'socket' => $socket, |
| 377 | 377 | ]; |
@@ -394,27 +394,27 @@ discard block |
||
| 394 | 394 | if ($server_challenge) { |
| 395 | 395 | // Now we need to listen for and grab challenge response(s) |
| 396 | 396 | $responses = call_user_func_array( |
| 397 | - [ $this->query, 'getResponses' ], |
|
| 398 | - [ $sockets, $this->timeout, $this->stream_timeout ] |
|
| 397 | + [$this->query, 'getResponses'], |
|
| 398 | + [$sockets, $this->timeout, $this->stream_timeout] |
|
| 399 | 399 | ); |
| 400 | 400 | |
| 401 | 401 | // Iterate over the challenge responses |
| 402 | 402 | foreach ($responses as $socket_id => $response) { |
| 403 | 403 | // Back out the server_id we need to update the challenge response for |
| 404 | - $server_id = $sockets[ $socket_id ]['server_id']; |
|
| 404 | + $server_id = $sockets[$socket_id]['server_id']; |
|
| 405 | 405 | |
| 406 | 406 | // Make this into a buffer so it is easier to manipulate |
| 407 | 407 | $challenge = new Buffer(implode('', $response)); |
| 408 | 408 | |
| 409 | 409 | // Grab the server instance |
| 410 | 410 | /* @var $server \GameQ\Server */ |
| 411 | - $server = $this->servers[ $server_id ]; |
|
| 411 | + $server = $this->servers[$server_id]; |
|
| 412 | 412 | |
| 413 | 413 | // Apply the challenge |
| 414 | 414 | $server->protocol()->challengeParseAndApply($challenge); |
| 415 | 415 | |
| 416 | 416 | // Add this socket to be reused, has to be reused in GameSpy3 for example |
| 417 | - $server->socketAdd($sockets[ $socket_id ]['socket']); |
|
| 417 | + $server->socketAdd($sockets[$socket_id]['socket']); |
|
| 418 | 418 | |
| 419 | 419 | // Clear |
| 420 | 420 | unset($server); |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | { |
| 430 | 430 | |
| 431 | 431 | // Initialize the array of sockets |
| 432 | - $sockets = [ ]; |
|
| 432 | + $sockets = []; |
|
| 433 | 433 | |
| 434 | 434 | // Iterate over the server list |
| 435 | 435 | foreach ($this->servers as $server_id => $server) { |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | unset($packets); |
| 480 | 480 | |
| 481 | 481 | // Add the socket information so we can reference it easily |
| 482 | - $sockets[ (int) $socket->get() ] = [ |
|
| 482 | + $sockets[(int) $socket->get()] = [ |
|
| 483 | 483 | 'server_id' => $server_id, |
| 484 | 484 | 'socket' => $socket, |
| 485 | 485 | ]; |
@@ -490,18 +490,18 @@ discard block |
||
| 490 | 490 | |
| 491 | 491 | // Now we need to listen for and grab response(s) |
| 492 | 492 | $responses = call_user_func_array( |
| 493 | - [ $this->query, 'getResponses' ], |
|
| 494 | - [ $sockets, $this->timeout, $this->stream_timeout ] |
|
| 493 | + [$this->query, 'getResponses'], |
|
| 494 | + [$sockets, $this->timeout, $this->stream_timeout] |
|
| 495 | 495 | ); |
| 496 | 496 | |
| 497 | 497 | // Iterate over the responses |
| 498 | 498 | foreach ($responses as $socket_id => $response) { |
| 499 | 499 | // Back out the server_id |
| 500 | - $server_id = $sockets[ $socket_id ]['server_id']; |
|
| 500 | + $server_id = $sockets[$socket_id]['server_id']; |
|
| 501 | 501 | |
| 502 | 502 | // Grab the server instance |
| 503 | 503 | /* @var $server \GameQ\Server */ |
| 504 | - $server = $this->servers[ $server_id ]; |
|
| 504 | + $server = $this->servers[$server_id]; |
|
| 505 | 505 | |
| 506 | 506 | // Save the response from this packet |
| 507 | 507 | $server->protocol()->packetResponse($response); |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | $class = new \ReflectionClass(sprintf('GameQ\\Filters\\%s', ucfirst($filterName))); |
| 599 | 599 | |
| 600 | 600 | // Create a new instance of the filter class specified |
| 601 | - $filter = $class->newInstanceArgs([ $filterOptions ]); |
|
| 601 | + $filter = $class->newInstanceArgs([$filterOptions]); |
|
| 602 | 602 | |
| 603 | 603 | // Apply the filter to the data |
| 604 | 604 | $results = $filter->apply($results, $server); |