Skip to content

Commit 9496370

Browse files
committed
Fix PHPStan errors
1 parent 7ae7926 commit 9496370

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/generic/ReceiveReliabilityLayer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ private function handleEncapsulatedPacket(EncapsulatedPacket $packet) : void{
176176
}
177177

178178
if(PacketReliability::isSequenced($packet->reliability)){
179+
assert($packet->orderChannel !== null, 'This should have been set during decode');
179180
if($packet->sequenceIndex < $this->receiveSequencedHighestIndex[$packet->orderChannel] or $packet->orderIndex < $this->receiveOrderedIndex[$packet->orderChannel]){
180181
//too old sequenced packet, discard it
181182
return;
@@ -184,6 +185,7 @@ private function handleEncapsulatedPacket(EncapsulatedPacket $packet) : void{
184185
$this->receiveSequencedHighestIndex[$packet->orderChannel] = $packet->sequenceIndex + 1;
185186
$this->handleEncapsulatedPacketRoute($packet);
186187
}elseif(PacketReliability::isOrdered($packet->reliability)){
188+
assert($packet->orderChannel !== null, 'This should have been set during decode');
187189
if($packet->orderIndex === $this->receiveOrderedIndex[$packet->orderChannel]){
188190
//this is the packet we expected to get next
189191
//Any ordered packet resets the sequence index to zero, so that sequenced packets older than this ordered

src/generic/SendReliabilityLayer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,14 @@ public function addEncapsulatedToQueue(EncapsulatedPacket $packet, bool $immedia
169169
}
170170

171171
if(PacketReliability::isOrdered($packet->reliability)){
172+
if($packet->orderChannel === null){
173+
throw new \InvalidArgumentException("Order channel must be set for an ordered packet");
174+
}
172175
$packet->orderIndex = $this->sendOrderedIndex[$packet->orderChannel]++;
173176
}elseif(PacketReliability::isSequenced($packet->reliability)){
177+
if($packet->orderChannel === null){
178+
throw new \InvalidArgumentException("Order channel must be set for a sequenced packet");
179+
}
174180
$packet->orderIndex = $this->sendOrderedIndex[$packet->orderChannel]; //sequenced packets don't increment the ordered channel index
175181
$packet->sequenceIndex = $this->sendSequencedIndex[$packet->orderChannel]++;
176182
}

tools/proxy.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
$bindAddr = "0.0.0.0";
3939
$bindPort = 19132;
4040

41+
$argv ??= [];
4142
if(count($argv) === 3){
4243
$serverAddress = $argv[1];
4344
$serverPort = (int) $argv[2];

tools/scan.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
require dirname(__DIR__) . '/vendor/autoload.php';
1414

15-
if(count($argv) === 3){
15+
if(isset($argv) && count($argv) === 3){
1616
$broadcastAddress = $argv[1];
1717
$port = (int) $argv[2];
1818
}else{

0 commit comments

Comments
 (0)