@@ -147,16 +147,16 @@ |
||
| 147 | 147 | |
| 148 | 148 | $result->add('edition', $info[0]); |
| 149 | 149 | $result->add('motd_line_1', $info[1]); |
| 150 | - $result->add('protocol_version', (int)$info[2]); |
|
| 150 | + $result->add('protocol_version', (int) $info[2]); |
|
| 151 | 151 | $result->add('version', $info[3]); |
| 152 | - $result->add('num_players', (int)$info[4]); |
|
| 153 | - $result->add('max_players', (int)$info[5]); |
|
| 152 | + $result->add('num_players', (int) $info[4]); |
|
| 153 | + $result->add('max_players', (int) $info[5]); |
|
| 154 | 154 | $result->add('server_uid', $info[6]); |
| 155 | 155 | $result->add('motd_line_2', $info[7]); |
| 156 | 156 | $result->add('gamemode', $info[8]); |
| 157 | - $result->add('gamemode_numeric', (int)$info[9]); |
|
| 158 | - $result->add('port_ipv4', (isset($info[10])) ? (int)$info[10] : null); |
|
| 159 | - $result->add('port_ipv6', (isset($info[11])) ? (int)$info[11] : null); |
|
| 157 | + $result->add('gamemode_numeric', (int) $info[9]); |
|
| 158 | + $result->add('port_ipv4', (isset($info[10])) ? (int) $info[10] : null); |
|
| 159 | + $result->add('port_ipv6', (isset($info[11])) ? (int) $info[11] : null); |
|
| 160 | 160 | $result->add('dedicated', 1); |
| 161 | 161 | |
| 162 | 162 | unset($header, $serverGUID, $magicCheck, $info); |
@@ -193,12 +193,12 @@ |
||
| 193 | 193 | $serverFlags = $buffer->readInt8(); |
| 194 | 194 | |
| 195 | 195 | // Read server flags |
| 196 | - $result->add('password', (int)$this->readFlag($serverFlags, 0)); |
|
| 197 | - $result->add('registered_only', (int)$this->readFlag($serverFlags, 1)); |
|
| 198 | - $result->add('fog_of_war', (int)$this->readFlag($serverFlags, 2)); |
|
| 199 | - $result->add('friendly_fire', (int)$this->readFlag($serverFlags, 3)); |
|
| 200 | - $result->add('bots_enabled', (int)$this->readFlag($serverFlags, 5)); |
|
| 201 | - $result->add('lua_scripts', (int)$this->readFlag($serverFlags, 6)); |
|
| 196 | + $result->add('password', (int) $this->readFlag($serverFlags, 0)); |
|
| 197 | + $result->add('registered_only', (int) $this->readFlag($serverFlags, 1)); |
|
| 198 | + $result->add('fog_of_war', (int) $this->readFlag($serverFlags, 2)); |
|
| 199 | + $result->add('friendly_fire', (int) $this->readFlag($serverFlags, 3)); |
|
| 200 | + $result->add('bots_enabled', (int) $this->readFlag($serverFlags, 5)); |
|
| 201 | + $result->add('lua_scripts', (int) $this->readFlag($serverFlags, 6)); |
|
| 202 | 202 | |
| 203 | 203 | // Read the rest of the buffer data |
| 204 | 204 | $result->add('servername', Str::isoToUtf8($buffer->readPascalString(0))); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @return void |
| 101 | 101 | * @throws \GameQ\Exception\Protocol |
| 102 | 102 | */ |
| 103 | - protected function processDetails(Buffer &$buffer, Result &$result) |
|
| 103 | + protected function processDetails(Buffer & $buffer, Result & $result) |
|
| 104 | 104 | { |
| 105 | 105 | parent::processDetails($buffer, $result); |
| 106 | 106 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @see Gamespy3::processPlayersAndTeams() |
| 121 | 121 | */ |
| 122 | - protected function processPlayersAndTeams(Buffer &$buffer, Result &$result) |
|
| 122 | + protected function processPlayersAndTeams(Buffer & $buffer, Result & $result) |
|
| 123 | 123 | { |
| 124 | 124 | // Loop until we run out of data |
| 125 | 125 | while ($buffer->getLength()) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @return void |
| 191 | 191 | * @throws \GameQ\Exception\Protocol |
| 192 | 192 | */ |
| 193 | - protected function parsePlayers(Buffer &$buffer, Result &$result) |
|
| 193 | + protected function parsePlayers(Buffer & $buffer, Result & $result) |
|
| 194 | 194 | { |
| 195 | 195 | // By default there are 0 players |
| 196 | 196 | $players = 0; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @return void |
| 222 | 222 | * @throws \GameQ\Exception\Protocol |
| 223 | 223 | */ |
| 224 | - protected function parsePlayersExtra(Buffer &$buffer, Result &$result) |
|
| 224 | + protected function parsePlayersExtra(Buffer & $buffer, Result & $result) |
|
| 225 | 225 | { |
| 226 | 226 | // Iterate over the extra player info |
| 227 | 227 | while (($id = $buffer->readInt8()) != 32) { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $server_addr = explode(':', $ip_address); |
| 162 | 162 | |
| 163 | 163 | // Port is the last item in the array, remove it and save |
| 164 | - $this->port_client = (int)array_pop($server_addr); |
|
| 164 | + $this->port_client = (int) array_pop($server_addr); |
|
| 165 | 165 | |
| 166 | 166 | // The rest is the address, recombine |
| 167 | 167 | $this->ip = implode(':', $server_addr); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // Now let's validate the IPv6 value sent, remove the square brackets ([]) first |
| 179 | - if (!filter_var(trim($this->ip, '[]'), FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV6,])) { |
|
| 179 | + if (!filter_var(trim($this->ip, '[]'), FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV6, ])) { |
|
| 180 | 180 | throw new Exception("The IPv6 address '{$this->ip}' is invalid."); |
| 181 | 181 | } |
| 182 | 182 | } else { |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | list($this->ip, $this->port_client) = explode(':', $ip_address); |
| 186 | 186 | |
| 187 | 187 | // Type case the port |
| 188 | - $this->port_client = (int)$this->port_client; |
|
| 188 | + $this->port_client = (int) $this->port_client; |
|
| 189 | 189 | } else { |
| 190 | 190 | // No port, fail |
| 191 | 191 | throw new Exception( |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // Validate the IPv4 value, if FALSE is not a valid IP, maybe a hostname. |
| 198 | - if (! filter_var($this->ip, FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV4,])) { |
|
| 198 | + if (!filter_var($this->ip, FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV4, ])) { |
|
| 199 | 199 | // Try to resolve the hostname to IPv4 |
| 200 | 200 | $resolved = gethostbyname($this->ip); |
| 201 | 201 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | // Specific query port defined |
| 219 | 219 | if (array_key_exists(self::SERVER_OPTIONS_QUERY_PORT, $this->options)) { |
| 220 | - $this->port_query = (int)$this->options[self::SERVER_OPTIONS_QUERY_PORT]; |
|
| 220 | + $this->port_query = (int) $this->options[self::SERVER_OPTIONS_QUERY_PORT]; |
|
| 221 | 221 | } else { |
| 222 | 222 | // Do math based on the protocol class |
| 223 | 223 | $this->port_query = $this->protocol->findQueryPort($this->port_client); |
@@ -160,7 +160,7 @@ |
||
| 160 | 160 | * @param array $data |
| 161 | 161 | * @param \GameQ\Result $result |
| 162 | 162 | */ |
| 163 | - protected function processChannelsAndUsers(array $data, Result &$result) |
|
| 163 | + protected function processChannelsAndUsers(array $data, Result & $result) |
|
| 164 | 164 | { |
| 165 | 165 | // Let's add all of the channel information |
| 166 | 166 | foreach ($data as $key => $value) { |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | * @param \GameQ\Result $result |
| 834 | 834 | * @return void |
| 835 | 835 | */ |
| 836 | - protected function processChannel($data, $fieldCount, Result &$result) |
|
| 836 | + protected function processChannel($data, $fieldCount, Result & $result) |
|
| 837 | 837 | { |
| 838 | 838 | // Split the items on the comma |
| 839 | 839 | $items = explode(",", $data, $fieldCount); |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | * @param \GameQ\Result $result |
| 856 | 856 | * @return void |
| 857 | 857 | */ |
| 858 | - protected function processPlayer($data, $fieldCount, Result &$result) |
|
| 858 | + protected function processPlayer($data, $fieldCount, Result & $result) |
|
| 859 | 859 | { |
| 860 | 860 | // Split the items on the comma |
| 861 | 861 | $items = explode(",", $data, $fieldCount); |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | $result->add('num_grfs', $num_grfs); |
| 133 | 133 | //$buffer->skip ($num_grfs * 20); #skip grfs id and md5 hash |
| 134 | 134 | |
| 135 | - for ($i=0; $i<$num_grfs; $i++) { |
|
| 136 | - $result->add('grfs_'.$i.'_ID', strtoupper(bin2hex($buffer->read(4)))); |
|
| 137 | - $result->add('grfs_'.$i.'_MD5', strtoupper(bin2hex($buffer->read(16)))); |
|
| 135 | + for ($i = 0; $i < $num_grfs; $i++) { |
|
| 136 | + $result->add('grfs_' . $i . '_ID', strtoupper(bin2hex($buffer->read(4)))); |
|
| 137 | + $result->add('grfs_' . $i . '_MD5', strtoupper(bin2hex($buffer->read(16)))); |
|
| 138 | 138 | } |
| 139 | 139 | // no break, cascades all the down even if case is meet |
| 140 | 140 | case 3: |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | $language = $buffer->readInt8(); |
| 156 | 156 | $result->add('language', $language); |
| 157 | - $result->add('language_icon', '//media.openttd.org/images/server/'.$language.'_lang.gif'); |
|
| 157 | + $result->add('language_icon', '//media.openttd.org/images/server/' . $language . '_lang.gif'); |
|
| 158 | 158 | |
| 159 | 159 | $result->add('password', $buffer->readInt8()); |
| 160 | 160 | $result->add('max_clients', $buffer->readInt8()); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @return void |
| 198 | 198 | * @throws \GameQ\Exception\Protocol |
| 199 | 199 | */ |
| 200 | - protected function processDetails($data, Result &$result) |
|
| 200 | + protected function processDetails($data, Result & $result) |
|
| 201 | 201 | { |
| 202 | 202 | // Create a buffer |
| 203 | 203 | $buffer = new Buffer($data); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @return void |
| 229 | 229 | * @throws \GameQ\Exception\Protocol |
| 230 | 230 | */ |
| 231 | - protected function processChannels($data, Result &$result) |
|
| 231 | + protected function processChannels($data, Result & $result) |
|
| 232 | 232 | { |
| 233 | 233 | // Create a buffer |
| 234 | 234 | $buffer = new Buffer($data); |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @return void |
| 262 | 262 | * @throws \GameQ\Exception\Protocol |
| 263 | 263 | */ |
| 264 | - protected function processPlayers($data, Result &$result) |
|
| 264 | + protected function processPlayers($data, Result & $result) |
|
| 265 | 265 | { |
| 266 | 266 | // Create a buffer |
| 267 | 267 | $buffer = new Buffer($data); |