Network: Improve typeinfo for PHPStan on bannedIps

This commit is contained in:
Dylan K. Taylor 2022-05-17 21:19:48 +01:00
parent 95ad3f16e1
commit cd016bedce
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -28,6 +28,7 @@ namespace pocketmine\network;
use pocketmine\event\server\NetworkInterfaceRegisterEvent; use pocketmine\event\server\NetworkInterfaceRegisterEvent;
use pocketmine\event\server\NetworkInterfaceUnregisterEvent; use pocketmine\event\server\NetworkInterfaceUnregisterEvent;
use pocketmine\utils\Utils;
use function base64_encode; use function base64_encode;
use function get_class; use function get_class;
use function preg_match; use function preg_match;
@ -45,7 +46,10 @@ class Network{
/** @var RawPacketHandler[] */ /** @var RawPacketHandler[] */
private $rawPacketHandlers = []; private $rawPacketHandlers = [];
/** @var int[] */ /**
* @var int[]
* @phpstan-var array<string, int>
*/
private $bannedIps = []; private $bannedIps = [];
/** @var BidirectionalBandwidthStatsTracker */ /** @var BidirectionalBandwidthStatsTracker */
@ -103,7 +107,7 @@ class Network{
if($interface instanceof AdvancedNetworkInterface){ if($interface instanceof AdvancedNetworkInterface){
$this->advancedInterfaces[$hash] = $interface; $this->advancedInterfaces[$hash] = $interface;
$interface->setNetwork($this); $interface->setNetwork($this);
foreach($this->bannedIps as $ip => $until){ foreach(Utils::stringifyKeys($this->bannedIps) as $ip => $until){
$interface->blockAddress($ip); $interface->blockAddress($ip);
} }
foreach($this->rawPacketHandlers as $handler){ foreach($this->rawPacketHandlers as $handler){