CommandEnum: specify enumValues type

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.
This commit is contained in:
Dylan K. Taylor 2020-06-10 10:33:35 +01:00
parent 42613618a5
commit fcc9e62c65
2 changed files with 6 additions and 2 deletions

View File

@ -172,6 +172,7 @@ use pocketmine\utils\TextFormat;
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;
@ -742,7 +743,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
$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;

View File

@ -26,7 +26,10 @@ namespace pocketmine\network\mcpe\protocol\types;
class CommandEnum{
/** @var string */
public $enumName;
/** @var string[] */
/**
* @var string[]
* @phpstan-var list<string>
*/
public $enumValues = [];
}