@@ -18,7 +18,6 @@ |
||
| 18 | 18 | |
| 19 | 19 | namespace GameQ\Protocols; |
| 20 | 20 | |
| 21 | -use GameQ\Buffer; |
|
| 22 | 21 | use GameQ\Result; |
| 23 | 22 | |
| 24 | 23 | /** |
@@ -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; |
@@ -33,14 +33,14 @@ |
||
| 33 | 33 | * |
| 34 | 34 | * @type array |
| 35 | 35 | */ |
| 36 | - protected $options = [ ]; |
|
| 36 | + protected $options = []; |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Construct |
| 40 | 40 | * |
| 41 | 41 | * @param array $options |
| 42 | 42 | */ |
| 43 | - public function __construct($options = [ ]) |
|
| 43 | + public function __construct($options = []) |
|
| 44 | 44 | { |
| 45 | 45 | |
| 46 | 46 | $this->options = $options; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @type array |
| 35 | 35 | */ |
| 36 | - protected $normalize = [ ]; |
|
| 36 | + protected $normalize = []; |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Apply this filter |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $result['players'][$key] = array_merge($player, $this->check('player', $player)); |
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | - $result['players'] = [ ]; |
|
| 70 | + $result['players'] = []; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Do team information |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $result['teams'][$key] = array_merge($team, $this->check('team', $team)); |
| 78 | 78 | } |
| 79 | 79 | } else { |
| 80 | - $result['teams'] = [ ]; |
|
| 80 | + $result['teams'] = []; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | //$data['filtered'][$server->id()] = $result; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | |
| 104 | 104 | // Normalized return array |
| 105 | - $normalized = [ ]; |
|
| 105 | + $normalized = []; |
|
| 106 | 106 | |
| 107 | 107 | if (isset($this->normalize[$section]) && !empty($this->normalize[$section])) { |
| 108 | 108 | foreach ($this->normalize[$section] as $property => $raw) { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | protected $options = [ |
| 83 | 83 | 'debug' => false, |
| 84 | 84 | 'timeout' => 3, // Seconds |
| 85 | - 'filters' => [ 'normalize' => [ ] ], |
|
| 85 | + 'filters' => ['normalize' => []], |
|
| 86 | 86 | // Advanced settings |
| 87 | 87 | 'stream_timeout' => 200000, // See http://www.php.net/manual/en/function.stream-select.php for more info |
| 88 | 88 | 'write_wait' => 500, |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @type array |
| 99 | 99 | */ |
| 100 | - protected $servers = [ ]; |
|
| 100 | + protected $servers = []; |
|
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * The query library to use. Default is Native |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return $this |
| 168 | 168 | */ |
| 169 | - public function addServer(array $server_info = [ ]) |
|
| 169 | + public function addServer(array $server_info = []) |
|
| 170 | 170 | { |
| 171 | 171 | |
| 172 | 172 | // Add and validate the server |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * |
| 183 | 183 | * @return $this |
| 184 | 184 | */ |
| 185 | - public function addServers(array $servers = [ ]) |
|
| 185 | + public function addServers(array $servers = []) |
|
| 186 | 186 | { |
| 187 | 187 | |
| 188 | 188 | // Loop through all the servers and add them |
@@ -203,12 +203,12 @@ discard block |
||
| 203 | 203 | * @return $this |
| 204 | 204 | * @throws \Exception |
| 205 | 205 | */ |
| 206 | - public function addServersFromFiles($files = [ ]) |
|
| 206 | + public function addServersFromFiles($files = []) |
|
| 207 | 207 | { |
| 208 | 208 | |
| 209 | 209 | // Since we expect an array let us turn a string (i.e. single file) into an array |
| 210 | 210 | if (!is_array($files)) { |
| 211 | - $files = [ $files ]; |
|
| 211 | + $files = [$files]; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // Iterate over the file(s) and add them |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | { |
| 243 | 243 | |
| 244 | 244 | // Reset all the servers |
| 245 | - $this->servers = [ ]; |
|
| 245 | + $this->servers = []; |
|
| 246 | 246 | |
| 247 | 247 | return $this; // Make Chainable |
| 248 | 248 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @return $this |
| 257 | 257 | */ |
| 258 | - public function addFilter($filterName, $options = [ ]) |
|
| 258 | + public function addFilter($filterName, $options = []) |
|
| 259 | 259 | { |
| 260 | 260 | |
| 261 | 261 | // Add the filter |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | unset($class); |
| 304 | 304 | |
| 305 | 305 | // Define the return |
| 306 | - $results = [ ]; |
|
| 306 | + $results = []; |
|
| 307 | 307 | |
| 308 | 308 | // @todo: Add break up into loop to split large arrays into smaller chunks |
| 309 | 309 | |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | { |
| 341 | 341 | |
| 342 | 342 | // Initialize the sockets for reading |
| 343 | - $sockets = [ ]; |
|
| 343 | + $sockets = []; |
|
| 344 | 344 | |
| 345 | 345 | // By default we don't have any challenges to process |
| 346 | 346 | $server_challenge = false; |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | if ($server_challenge) { |
| 386 | 386 | // Now we need to listen for and grab challenge response(s) |
| 387 | 387 | $responses = call_user_func_array( |
| 388 | - [ $this->query, 'getResponses' ], |
|
| 389 | - [ $sockets, $this->timeout, $this->stream_timeout ] |
|
| 388 | + [$this->query, 'getResponses'], |
|
| 389 | + [$sockets, $this->timeout, $this->stream_timeout] |
|
| 390 | 390 | ); |
| 391 | 391 | |
| 392 | 392 | // Iterate over the challenge responses |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | { |
| 421 | 421 | |
| 422 | 422 | // Initialize the array of sockets |
| 423 | - $sockets = [ ]; |
|
| 423 | + $sockets = []; |
|
| 424 | 424 | |
| 425 | 425 | // Iterate over the server list |
| 426 | 426 | foreach ($this->servers as $server_id => $server) { |
@@ -474,8 +474,8 @@ discard block |
||
| 474 | 474 | |
| 475 | 475 | // Now we need to listen for and grab response(s) |
| 476 | 476 | $responses = call_user_func_array( |
| 477 | - [ $this->query, 'getResponses' ], |
|
| 478 | - [ $sockets, $this->timeout, $this->stream_timeout ] |
|
| 477 | + [$this->query, 'getResponses'], |
|
| 478 | + [$sockets, $this->timeout, $this->stream_timeout] |
|
| 479 | 479 | ); |
| 480 | 480 | |
| 481 | 481 | // Iterate over the responses |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | $class = new \ReflectionClass(sprintf('GameQ\\Filters\\%s', ucfirst($filterName))); |
| 583 | 583 | |
| 584 | 584 | // Create a new instance of the filter class specified |
| 585 | - $filter = $class->newInstanceArgs([ $filterOptions ]); |
|
| 585 | + $filter = $class->newInstanceArgs([$filterOptions]); |
|
| 586 | 586 | |
| 587 | 587 | // Apply the filter to the data |
| 588 | 588 | $results = $filter->apply($results, $server); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param \GameQ\Buffer $buffer |
| 149 | 149 | * @param \GameQ\Result $result |
| 150 | 150 | */ |
| 151 | - protected function processKeyValuePairs(Buffer &$buffer, Result &$result) |
|
| 151 | + protected function processKeyValuePairs(Buffer & $buffer, Result & $result) |
|
| 152 | 152 | { |
| 153 | 153 | |
| 154 | 154 | // Key / value pairs |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @param \GameQ\Buffer $buffer |
| 177 | 177 | * @param \GameQ\Result $result |
| 178 | 178 | */ |
| 179 | - protected function processPlayersAndTeams(Buffer &$buffer, Result &$result) |
|
| 179 | + protected function processPlayersAndTeams(Buffer & $buffer, Result & $result) |
|
| 180 | 180 | { |
| 181 | 181 | |
| 182 | 182 | // Players and team info |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | |
| 137 | 137 | // Holds the results sent back |
| 138 | - $results = [ ]; |
|
| 138 | + $results = []; |
|
| 139 | 139 | |
| 140 | 140 | // Holds the processed packets after having been reassembled |
| 141 | - $processed = [ ]; |
|
| 141 | + $processed = []; |
|
| 142 | 142 | |
| 143 | 143 | // Start up the index for the processed |
| 144 | 144 | $sequence_id_last = 0; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | // Now we need to call the proper method |
| 183 | 183 | $results = array_merge( |
| 184 | 184 | $results, |
| 185 | - call_user_func_array([ $this, $this->responses[$sequence_id] ], [ $buffer ]) |
|
| 185 | + call_user_func_array([$this, $this->responses[$sequence_id]], [$buffer]) |
|
| 186 | 186 | ); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | protected function decode(Buffer $buffer) |
| 204 | 204 | { |
| 205 | 205 | |
| 206 | - $items = [ ]; |
|
| 206 | + $items = []; |
|
| 207 | 207 | |
| 208 | 208 | // Get the number of words in this buffer |
| 209 | 209 | $itemCount = $buffer->readInt32(); |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | * @return string |
| 52 | 52 | * @throws \GameQ\Exception\Protocol |
| 53 | 53 | */ |
| 54 | - protected function processPackets($packet_id, array $packets = [ ]) |
|
| 54 | + protected function processPackets($packet_id, array $packets = []) |
|
| 55 | 55 | { |
| 56 | 56 | |
| 57 | 57 | // The response is gold source if the packets are split |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | |
| 109 | 109 | // Holds the processed packets |
| 110 | - $processed = [ ]; |
|
| 110 | + $processed = []; |
|
| 111 | 111 | |
| 112 | 112 | // Iterate over the packets |
| 113 | 113 | foreach ($this->packets_response as $response) { |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * |
| 170 | 170 | * @return array |
| 171 | 171 | */ |
| 172 | - protected function cleanPackets(array $packets = [ ]) |
|
| 172 | + protected function cleanPackets(array $packets = []) |
|
| 173 | 173 | { |
| 174 | 174 | |
| 175 | 175 | // Get the number of packets |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * @param \GameQ\Buffer $buffer |
| 223 | 223 | * @param \GameQ\Result $result |
| 224 | 224 | */ |
| 225 | - protected function processDetails(Buffer &$buffer, Result &$result) |
|
| 225 | + protected function processDetails(Buffer & $buffer, Result & $result) |
|
| 226 | 226 | { |
| 227 | 227 | |
| 228 | 228 | // We go until we hit an empty key |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param \GameQ\Buffer $buffer |
| 242 | 242 | * @param \GameQ\Result $result |
| 243 | 243 | */ |
| 244 | - protected function processPlayersAndTeams(Buffer &$buffer, Result &$result) |
|
| 244 | + protected function processPlayersAndTeams(Buffer & $buffer, Result & $result) |
|
| 245 | 245 | { |
| 246 | 246 | |
| 247 | 247 | /* |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | // Set the item group |
| 290 | 290 | $item_group = 'teams'; |
| 291 | 291 | // Set the item type, rip off any trailing stuff and bad chars |
| 292 | - $item_type = rtrim(str_replace([ "\x00", "\x02" ], '', $item), '_t'); |
|
| 292 | + $item_type = rtrim(str_replace(["\x00", "\x02"], '', $item), '_t'); |
|
| 293 | 293 | } else { |
| 294 | 294 | // We can assume it is data belonging to a previously defined item |
| 295 | 295 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | // Let's iterate over the response items, there are a lot |
| 136 | 136 | foreach ($data as $key => $value) { |
| 137 | 137 | // Ignore root for now, that is where all of the channel/player info is housed |
| 138 | - if (in_array($key, [ 'root' ])) { |
|
| 138 | + if (in_array($key, ['root'])) { |
|
| 139 | 139 | continue; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | * @param array $data |
| 165 | 165 | * @param \GameQ\Result $result |
| 166 | 166 | */ |
| 167 | - protected function processChannelsAndUsers(array $data, Result &$result) |
|
| 167 | + protected function processChannelsAndUsers(array $data, Result & $result) |
|
| 168 | 168 | { |
| 169 | 169 | |
| 170 | 170 | // Let's add all of the channel information |
| 171 | 171 | foreach ($data as $key => $value) { |
| 172 | 172 | // We will handle these later |
| 173 | - if (in_array($key, [ 'channels', 'users' ])) { |
|
| 173 | + if (in_array($key, ['channels', 'users'])) { |
|
| 174 | 174 | // skip |
| 175 | 175 | continue; |
| 176 | 176 | } |