@@ -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]; |
@@ -200,12 +200,12 @@ |
||
| 200 | 200 | // Check to see if the response is empty, if so we are done with this server |
| 201 | 201 | if (strlen($response) == 0) { |
| 202 | 202 | // Remove this server from any future read loops |
| 203 | - unset($sockets_tmp[(int)$socket]); |
|
| 203 | + unset($sockets_tmp[(int) $socket]); |
|
| 204 | 204 | continue; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // Add the response we got back |
| 208 | - $responses[(int)$socket][] = $response; |
|
| 208 | + $responses[(int) $socket][] = $response; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // Because stream_select modifies read we need to reset it each time to the original array of sockets |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | // These are the same no matter what mode the server is in |
| 243 | 243 | $result->add('hostname', $items[1]); |
| 244 | - $result->add('num_players', (int)$items[2]); |
|
| 245 | - $result->add('max_players', (int)$items[3]); |
|
| 244 | + $result->add('num_players', (int) $items[2]); |
|
| 245 | + $result->add('max_players', (int) $items[3]); |
|
| 246 | 246 | $result->add('gametype', $items[4]); |
| 247 | 247 | $result->add('map', $items[5]); |
| 248 | - $result->add('roundsplayed', (int)$items[6]); |
|
| 249 | - $result->add('roundstotal', (int)$items[7]); |
|
| 250 | - $result->add('num_teams', (int)$items[8]); |
|
| 248 | + $result->add('roundsplayed', (int) $items[6]); |
|
| 249 | + $result->add('roundstotal', (int) $items[7]); |
|
| 250 | + $result->add('num_teams', (int) $items[8]); |
|
| 251 | 251 | |
| 252 | 252 | // Set the current index |
| 253 | 253 | $index_current = 9; |
@@ -264,22 +264,22 @@ discard block |
||
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | // Get and set the rest of the data points. |
| 267 | - $result->add('targetscore', (int)$items[$index_current]); |
|
| 267 | + $result->add('targetscore', (int) $items[$index_current]); |
|
| 268 | 268 | $result->add('online', 1); // Forced true, it seems $words[$index_current + 1] is always empty |
| 269 | - $result->add('ranked', (int)$items[$index_current + 2]); |
|
| 270 | - $result->add('punkbuster', (int)$items[$index_current + 3]); |
|
| 271 | - $result->add('password', (int)$items[$index_current + 4]); |
|
| 272 | - $result->add('uptime', (int)$items[$index_current + 5]); |
|
| 273 | - $result->add('roundtime', (int)$items[$index_current + 6]); |
|
| 269 | + $result->add('ranked', (int) $items[$index_current + 2]); |
|
| 270 | + $result->add('punkbuster', (int) $items[$index_current + 3]); |
|
| 271 | + $result->add('password', (int) $items[$index_current + 4]); |
|
| 272 | + $result->add('uptime', (int) $items[$index_current + 5]); |
|
| 273 | + $result->add('roundtime', (int) $items[$index_current + 6]); |
|
| 274 | 274 | // Added in R9 |
| 275 | 275 | $result->add('ip_port', $items[$index_current + 7]); |
| 276 | 276 | $result->add('punkbuster_version', $items[$index_current + 8]); |
| 277 | - $result->add('join_queue', (int)$items[$index_current + 9]); |
|
| 277 | + $result->add('join_queue', (int) $items[$index_current + 9]); |
|
| 278 | 278 | $result->add('region', $items[$index_current + 10]); |
| 279 | 279 | $result->add('pingsite', $items[$index_current + 11]); |
| 280 | 280 | $result->add('country', $items[$index_current + 12]); |
| 281 | 281 | // Added in R29, No docs as of yet |
| 282 | - $result->add('quickmatch', (int)$items[$index_current + 13]); // Guessed from research |
|
| 282 | + $result->add('quickmatch', (int) $items[$index_current + 13]); // Guessed from research |
|
| 283 | 283 | |
| 284 | 284 | unset($items, $index_current, $teamCount, $buffer); |
| 285 | 285 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $result->add('serverversion', $json->serverversion); |
| 121 | 121 | $result->add('world', $json->world); |
| 122 | 122 | $result->add('uptime', $json->uptime); |
| 123 | - $result->add('password', (int)$json->serverpassword); |
|
| 123 | + $result->add('password', (int) $json->serverpassword); |
|
| 124 | 124 | $result->add('numplayers', $json->playercount); |
| 125 | 125 | $result->add('maxplayers', $json->maxplayers); |
| 126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $result->addPlayer('nickname', $player->nickname); |
| 130 | 130 | $result->addPlayer('username', $player->username); |
| 131 | 131 | $result->addPlayer('group', $player->group); |
| 132 | - $result->addPlayer('active', (int)$player->active); |
|
| 132 | + $result->addPlayer('active', (int) $player->active); |
|
| 133 | 133 | $result->addPlayer('state', $player->state); |
| 134 | 134 | $result->addPlayer('team', $player->team); |
| 135 | 135 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | // Parse rules |
| 141 | 141 | foreach ($json->rules as $rule => $value) { |
| 142 | 142 | // Add rule but convert boolean into int (0|1) |
| 143 | - $rules[$rule] = (is_bool($value)) ? (int)$value : $value; |
|
| 143 | + $rules[$rule] = (is_bool($value)) ? (int) $value : $value; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Add rules |
@@ -224,13 +224,13 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | // These are the same no matter what mode the server is in |
| 226 | 226 | $result->add('hostname', $items[1]); |
| 227 | - $result->add('num_players', (int)$items[2]); |
|
| 228 | - $result->add('max_players', (int)$items[3]); |
|
| 227 | + $result->add('num_players', (int) $items[2]); |
|
| 228 | + $result->add('max_players', (int) $items[3]); |
|
| 229 | 229 | $result->add('gametype', $items[4]); |
| 230 | 230 | $result->add('map', $items[5]); |
| 231 | - $result->add('roundsplayed', (int)$items[6]); |
|
| 232 | - $result->add('roundstotal', (int)$items[7]); |
|
| 233 | - $result->add('num_teams', (int)$items[8]); |
|
| 231 | + $result->add('roundsplayed', (int) $items[6]); |
|
| 232 | + $result->add('roundstotal', (int) $items[7]); |
|
| 233 | + $result->add('num_teams', (int) $items[8]); |
|
| 234 | 234 | |
| 235 | 235 | // Set the current index |
| 236 | 236 | $index_current = 9; |
@@ -247,13 +247,13 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // Get and set the rest of the data points. |
| 250 | - $result->add('targetscore', (int)$items[$index_current]); |
|
| 250 | + $result->add('targetscore', (int) $items[$index_current]); |
|
| 251 | 251 | $result->add('online', 1); // Forced true, shows accepting players |
| 252 | 252 | $result->add('ranked', (($items[$index_current + 2] == 'true') ? 1 : 0)); |
| 253 | 253 | $result->add('punkbuster', (($items[$index_current + 3] == 'true') ? 1 : 0)); |
| 254 | 254 | $result->add('password', (($items[$index_current + 4] == 'true') ? 1 : 0)); |
| 255 | - $result->add('uptime', (int)$items[$index_current + 5]); |
|
| 256 | - $result->add('roundtime', (int)$items[$index_current + 6]); |
|
| 255 | + $result->add('uptime', (int) $items[$index_current + 5]); |
|
| 256 | + $result->add('roundtime', (int) $items[$index_current + 6]); |
|
| 257 | 257 | $result->add('mod', $items[$index_current + 7]); |
| 258 | 258 | |
| 259 | 259 | $result->add('ip_port', $items[$index_current + 9]); |
@@ -74,6 +74,6 @@ |
||
| 74 | 74 | */ |
| 75 | 75 | public function findQueryPort($clientPort) |
| 76 | 76 | { |
| 77 | - return $clientPort+97; |
|
| 77 | + return $clientPort + 97; |
|
| 78 | 78 | } |
| 79 | 79 | } |
@@ -154,7 +154,7 @@ |
||
| 154 | 154 | $result->add('serverversion', $json->ServerVersion); |
| 155 | 155 | $result->add('map', ((!empty($json->Map)) ? $json->Map : 'Los Santos/Blaine Country')); |
| 156 | 156 | $result->add('mod', $json->Gamemode); |
| 157 | - $result->add('password', (int)$json->Passworded); |
|
| 157 | + $result->add('password', (int) $json->Passworded); |
|
| 158 | 158 | $result->add('numplayers', $json->CurrentPlayers); |
| 159 | 159 | $result->add('maxplayers', $json->MaxPlayers); |
| 160 | 160 | |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | $socket->write($server->protocol()->getPacket(Protocol::PACKET_CHALLENGE)); |
| 405 | 405 | |
| 406 | 406 | // Add the socket information so we can reference it easily |
| 407 | - $sockets[(int)$socket->get()] = [ |
|
| 407 | + $sockets[(int) $socket->get()] = [ |
|
| 408 | 408 | 'server_id' => $server_id, |
| 409 | 409 | 'socket' => $socket, |
| 410 | 410 | ]; |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | unset($packets); |
| 506 | 506 | |
| 507 | 507 | // Add the socket information so we can reference it easily |
| 508 | - $sockets[(int)$socket->get()] = [ |
|
| 508 | + $sockets[(int) $socket->get()] = [ |
|
| 509 | 509 | 'server_id' => $server_id, |
| 510 | 510 | 'socket' => $socket, |
| 511 | 511 | ]; |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | $results['gq_port_client'] = $server->portClient(); |
| 602 | 602 | $results['gq_port_query'] = (isset($results['gq_port_query'])) ? $results['gq_port_query'] : $server->portQuery(); |
| 603 | 603 | $results['gq_protocol'] = $server->protocol()->getProtocol(); |
| 604 | - $results['gq_type'] = (string)$server->protocol(); |
|
| 604 | + $results['gq_type'] = (string) $server->protocol(); |
|
| 605 | 605 | $results['gq_name'] = $server->protocol()->nameLong(); |
| 606 | 606 | $results['gq_transport'] = $server->protocol()->transport(); |
| 607 | 607 | |