mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-25 04:44:03 +00:00
Fixed PHPStan errors
This commit is contained in:
parent
b875b68fc7
commit
5cc0d92eff
@ -249,7 +249,7 @@ class SimpleCommandMap implements CommandMap{
|
|||||||
|
|
||||||
foreach($commandStrings as $commandString){
|
foreach($commandStrings as $commandString){
|
||||||
$args = CommandStringHelper::parseQuoteAware($commandString);
|
$args = CommandStringHelper::parseQuoteAware($commandString);
|
||||||
$commandName = array_shift($args);
|
$commandName = array_shift($args) ?? "";
|
||||||
$command = $this->getCommand($commandName);
|
$command = $this->getCommand($commandName);
|
||||||
|
|
||||||
if($command === null){
|
if($command === null){
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\command\utils;
|
namespace pocketmine\command\utils;
|
||||||
|
|
||||||
|
use pocketmine\utils\AssumptionFailedError;
|
||||||
use function preg_match_all;
|
use function preg_match_all;
|
||||||
use function preg_replace;
|
use function preg_replace;
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ final class CommandStringHelper{
|
|||||||
* - `say "This is a \"string containing quotes\""` -> ['say', 'This is a "string containing quotes"']
|
* - `say "This is a \"string containing quotes\""` -> ['say', 'This is a "string containing quotes"']
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
* @phpstan-return non-empty-list<string>
|
* @phpstan-return list<string>
|
||||||
*/
|
*/
|
||||||
public static function parseQuoteAware(string $commandLine) : array{
|
public static function parseQuoteAware(string $commandLine) : array{
|
||||||
$args = [];
|
$args = [];
|
||||||
@ -49,7 +50,9 @@ final class CommandStringHelper{
|
|||||||
foreach($matches[0] as $k => $_){
|
foreach($matches[0] as $k => $_){
|
||||||
for($i = 1; $i <= 2; ++$i){
|
for($i = 1; $i <= 2; ++$i){
|
||||||
if($matches[$i][$k] !== ""){
|
if($matches[$i][$k] !== ""){
|
||||||
$args[(int) $k] = preg_replace('/\\\\([\\\\"])/u', '$1', $matches[$i][$k]);
|
/** @var string $match */ //phpstan can't understand preg_match and friends by itself :(
|
||||||
|
$match = $matches[$i][$k];
|
||||||
|
$args[(int) $k] = preg_replace('/\\\\([\\\\"])/u', '$1', $match) ?? throw new AssumptionFailedError(preg_last_error_msg());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user