Skip to content

Commit

Permalink
CommandEnum: specify enumValues type
Browse files Browse the repository at this point in the history
phpstan 0.12.26 starts reporting errors about the result of array_search() being given to some constructor or another because of the lack of key type specification.
  • Loading branch information
dktapps committed Jun 10, 2020
1 parent 4261361 commit fcc9e62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
use pocketmine\utils\UUID;
use function abs;
use function array_merge;
use function array_values;
use function assert;
use function base64_decode;
use function ceil;
Expand Down Expand Up @@ -742,7 +743,7 @@ public function sendCommandData(){
}
$data->aliases = new CommandEnum();
$data->aliases->enumName = ucfirst($command->getName()) . "Aliases";
$data->aliases->enumValues = $aliases;
$data->aliases->enumValues = array_values($aliases);
}

$pk->commandData[$command->getName()] = $data;
Expand Down
5 changes: 4 additions & 1 deletion src/pocketmine/network/mcpe/protocol/types/CommandEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
class CommandEnum{
/** @var string */
public $enumName;
/** @var string[] */
/**
* @var string[]
* @phpstan-var list<string>
*/
public $enumValues = [];

}

0 comments on commit fcc9e62

Please sign in to comment.