Replace disallowed operators in src/command/

This commit is contained in:
Dylan K. Taylor
2022-01-20 16:49:58 +00:00
parent 22bc3bc3f9
commit 2f32bd877a
9 changed files with 19 additions and 19 deletions

View File

@@ -71,7 +71,7 @@ class FormattedCommandAlias extends Command{
$index = strpos($formatString, '$');
while($index !== false){
$start = $index;
if($index > 0 and $formatString[$start - 1] === "\\"){
if($index > 0 && $formatString[$start - 1] === "\\"){
$formatString = substr($formatString, 0, $start - 1) . substr($formatString, $start);
$index = strpos($formatString, '$', $index);
continue;
@@ -88,7 +88,7 @@ class FormattedCommandAlias extends Command{
$argStart = $index;
while($index < strlen($formatString) and self::inRange(ord($formatString[$index]) - 48, 0, 9)){
while($index < strlen($formatString) && self::inRange(ord($formatString[$index]) - 48, 0, 9)){
++$index;
}
@@ -106,19 +106,19 @@ class FormattedCommandAlias extends Command{
$rest = false;
if($index < strlen($formatString) and $formatString[$index] === "-"){
if($index < strlen($formatString) && $formatString[$index] === "-"){
$rest = true;
++$index;
}
$end = $index;
if($required and $position >= count($args)){
if($required && $position >= count($args)){
throw new \InvalidArgumentException("Missing required argument " . ($position + 1));
}
$replacement = "";
if($rest and $position < count($args)){
if($rest && $position < count($args)){
for($i = $position, $c = count($args); $i < $c; ++$i){
if($i !== $position){
$replacement .= " ";
@@ -141,6 +141,6 @@ class FormattedCommandAlias extends Command{
}
private static function inRange(int $i, int $j, int $k) : bool{
return $i >= $j and $i <= $k;
return $i >= $j && $i <= $k;
}
}