Code cleanup, no functional changes

This commit is contained in:
2023-06-27 19:39:11 +12:00
parent b70a36003a
commit ad36da0bb1
64 changed files with 466 additions and 438 deletions

View File

@@ -77,7 +77,7 @@ class Font
$escape = FALSE;
foreach (str_split(strtolower($this->text)) as $c) {
if ($c == "\x1b") {
if (ord($c) === 0x1b) {
$escape = TRUE;
continue;
@@ -112,7 +112,7 @@ class Font
$ansi = FALSE;
foreach (str_split(strtolower($this->text)) as $c) {
if (ord($c) == 0x1b) {
if (ord($c) === 0x1b) {
$escape = TRUE;
} elseif ($escape && $c) {
@@ -120,7 +120,7 @@ class Font
$escape = FALSE;
$ansi = TRUE;
} elseif (($c == ' ') || (! $font_chars=$chars->get($c))) {
} elseif (($c === ' ') || (! $font_chars=$chars->get($c))) {
$result .= $c;
} else {
@@ -245,7 +245,7 @@ class Font
// Work out the characters we need
foreach (array_unique(str_split($text)) as $c) {
if (($c == ' ') || (! $x=Arr::get(static::FONT,$c))) {
if (($c === ' ') || (! $x=Arr::get(static::FONT,$c))) {
continue;
}
@@ -265,7 +265,7 @@ class Font
if (self::DEBUG) dump(sprintf('current position %d of %d',$current_pos,strlen($text)));
for ($line=0;$line<$font_height;$line++) {
if ($line == 0) {
if ($line === 0) {
$line_icon_width = $icon_width
->skip(intdiv($result_height,$step)*$step)
->take($step)
@@ -324,9 +324,10 @@ class Font
}
$next_next_space_width = $current_line_width+$next_space_chars+$next_next_space_chars;
};
}
if (self::DEBUG) dump(sprintf(' - our next space is: [%s] (%x) at %d in %d chars, taking %d chars (taking our width to %d)',$c,ord($c),$find_space_pos,$find_space_pos-$line_pos,$next_space_chars,$current_line_width+$next_space_chars));
if (self::DEBUG)
dump(sprintf(' - our next space is: [%s] (%x) at %d in %d chars, taking %d chars (taking our width to %d)',$c,ord($c),$find_space_pos,$find_space_pos-$line_pos,$next_space_chars,$current_line_width+$next_space_chars));
// We are only spaces, so we can return to the next line
if ($current_line_width+$next_space_chars > $line_width) {
@@ -338,7 +339,7 @@ class Font
}
$c = substr($text,$line_pos,1);
if (($c == ' ') || (! $font_chars=$chars->get($c))) {
if (($c === ' ') || (! $font_chars=$chars->get($c))) {
// Ignore this space if we are at the beginning of the line
if ($current_line_width && ($next_next_space_width < $line_width)) {
$line_result .= $c;
@@ -357,7 +358,7 @@ class Font
$line_pos++;
if (self::DEBUG) dump(sprintf(' = line width [%d of %d] and we are on char [%d] our space is [%d]',$current_line_width,$line_width,$line_pos,$find_space_pos));
if ($line_pos == strlen($text)) {
if ($line_pos === strlen($text)) {
if (self::DEBUG) dump(sprintf(' = we are finished, as we are on char %d on line %d',$line_pos,$line));
break;
}