Skip to content

Commit

Permalink
Merge branch 'release/v0.10.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Aug 21, 2024
2 parents 4a7af66 + d43db04 commit 6d7fa9b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 40 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v0.10.5 (2024-08-21)
* Converted consts to protected PascalCase
* Updated Veneer dependency and Stub
* Removed unneeded LazyLoad binding attribute
* Updated dependency versions

## v0.10.4 (2024-07-17)
* Updated Veneer dependency

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"require": {
"php": "^8.1",

"decodelabs/archetype": "^0.2|^0.3",
"decodelabs/archetype": "^0.3",
"decodelabs/coercion": "^0.2",
"decodelabs/deliverance": "^0.2",
"decodelabs/exceptional": "^0.4",
"decodelabs/glitch-support": "^0.4",
"decodelabs/tightrope": "^0.1.1",
"decodelabs/veneer": "^0.11.1",
"decodelabs/veneer": "^0.11.6",

"psr/log": "^3"
},
Expand Down
1 change: 0 additions & 1 deletion src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
/**
* @mixin Session
*/
#[LazyLoad]
class Context
{
#[Plugin(Command::class)]
Expand Down
40 changes: 20 additions & 20 deletions src/Io/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class Style
{
public const FG_COLORS = [
protected const FgColors = [
'black' => 30,
'red' => 31,
'green' => 32,
Expand All @@ -35,7 +35,7 @@ class Style
'brightWhite' => 97
];

public const BG_COLORS = [
protected const BgColors = [
'black' => 40,
'red' => 41,
'green' => 42,
Expand All @@ -56,7 +56,7 @@ class Style
'brightWhite' => 107
];

public const OPTIONS = [
protected const Options = [
'bold' => [1, 22],
'dim' => [2, 22],
'italic' => [3, 23],
Expand Down Expand Up @@ -91,8 +91,8 @@ public static function isKeyword(
string $string
): bool {
return
isset(self::FG_COLORS[$string]) ||
isset(self::OPTIONS[$string]);
isset(self::FgColors[$string]) ||
isset(self::Options[$string]);
}

/**
Expand Down Expand Up @@ -120,13 +120,13 @@ public static function parse(
$testPart = '_select';
}

if (isset(self::FG_COLORS[$testPart])) {
if (isset(self::FgColors[$testPart])) {
if (!$fg) {
$fg = $part;
} elseif (!$bg) {
$bg = $part;
}
} elseif (isset(self::OPTIONS[$testPart])) {
} elseif (isset(self::Options[$testPart])) {
$options[] = $part;
} elseif (!empty($part)) {
throw Exceptional::InvalidArgument(
Expand Down Expand Up @@ -203,7 +203,7 @@ public function setForeground(
$bits = 24;
$foreground = $this->hexToRgb($colorMatches[3]);
}
} elseif (!isset(self::FG_COLORS[$foreground])) {
} elseif (!isset(self::FgColors[$foreground])) {
throw Exceptional::InvalidArgument(
'Invalid foreground color: ' . $foreground
);
Expand Down Expand Up @@ -253,7 +253,7 @@ public function setBackground(
$bits = 24;
$background = $this->hexToRgb($colorMatches[3]);
}
} elseif (!isset(self::FG_COLORS[$background])) {
} elseif (!isset(self::FgColors[$background])) {
throw Exceptional::InvalidArgument(
'Invalid background color: ' . $background
);
Expand Down Expand Up @@ -326,7 +326,7 @@ public function setOptions(
continue;
}

if (!isset(self::OPTIONS[$option])) {
if (!isset(self::Options[$option])) {
throw Exceptional::InvalidArgument(
'Invalid option: ' . $option
);
Expand Down Expand Up @@ -511,42 +511,42 @@ protected function format(
if ($this->foreground !== null) {
switch ($this->foregroundBits) {
case 4:
$setCodes[] = static::FG_COLORS[$this->foreground];
$setCodes[] = static::FgColors[$this->foreground];
break;

case 8:
$setCodes[] = static::FG_COLORS['_select'] . ';5;' . $this->foreground;
$setCodes[] = static::FgColors['_select'] . ';5;' . $this->foreground;
break;

case 24:
$setCodes[] = static::FG_COLORS['_select'] . ';2;' . str_replace(',', ';', $this->foreground);
$setCodes[] = static::FgColors['_select'] . ';2;' . str_replace(',', ';', $this->foreground);
break;
}

$unsetCodes[] = static::FG_COLORS['reset'];
$unsetCodes[] = static::FgColors['reset'];
}

if ($this->background !== null) {
switch ($this->backgroundBits) {
case 4:
$setCodes[] = static::BG_COLORS[$this->background];
$setCodes[] = static::BgColors[$this->background];
break;

case 8:
$setCodes[] = static::BG_COLORS['_select'] . ';5;' . $this->background;
$setCodes[] = static::BgColors['_select'] . ';5;' . $this->background;
break;

case 24:
$setCodes[] = static::BG_COLORS['_select'] . ';2;' . str_replace(',', ';', $this->background);
$setCodes[] = static::BgColors['_select'] . ';2;' . str_replace(',', ';', $this->background);
break;
}

$unsetCodes[] = static::BG_COLORS['reset'];
$unsetCodes[] = static::BgColors['reset'];
}

foreach ($this->options as $option) {
$setCodes[] = static::OPTIONS[$option][0];
$unsetCodes[] = static::OPTIONS[$option][1];
$setCodes[] = static::Options[$option][0];
$unsetCodes[] = static::Options[$option][1];
}

return sprintf("\e[%sm%s\e[%sm", implode(';', $setCodes), $message, implode(';', $unsetCodes));
Expand Down
10 changes: 5 additions & 5 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ public static function stringToBoolean(



public const LOG_STYLES = [
protected const LogStyles = [
'debug' => ['β ', '#996300'], // @ignore-non-ascii
'info' => ['', 'cyan'], // @ignore-non-ascii
'notice' => ['', 'cyan|bold'], // @ignore-non-ascii
Expand Down Expand Up @@ -1347,12 +1347,12 @@ public function log(
): void {
$message = $this->interpolate((string)$message, $context);

if (!isset(self::LOG_STYLES[$level])) {
if (!isset(self::LogStyles[$level])) {
$this->writeLine($message);
return;
}

[$prefix, $style] = self::LOG_STYLES[$level];
[$prefix, $style] = self::LogStyles[$level];

$message = $prefix . $message;
$this->style('.' . $style, $message);
Expand All @@ -1368,12 +1368,12 @@ public function inlineLog(
): void {
$message = $this->interpolate((string)$message, $context);

if (!isset(self::LOG_STYLES[$level])) {
if (!isset(self::LogStyles[$level])) {
$this->writeLine($message);
return;
}

[$prefix, $style] = self::LOG_STYLES[$level];
[$prefix, $style] = self::LogStyles[$level];

$message = $prefix . $message;
$this->style($style, $message);
Expand Down
10 changes: 5 additions & 5 deletions src/Widget/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

class ProgressBar
{
public const EMPTY = ''; // @ignore-non-ascii
public const FULL = ''; // @ignore-non-ascii
protected const Empty = ''; // @ignore-non-ascii
protected const Full = ''; // @ignore-non-ascii

protected float $min = 0;
protected float $max = 100;
Expand Down Expand Up @@ -279,8 +279,8 @@ public function advance(
$this->session->style('brightWhite', $maxVal . ' ');
}

$this->session->style($color, str_repeat(self::FULL, (int)$chars));
$this->session->style('dim', str_repeat(self::EMPTY, (int)($barSize - $chars)));
$this->session->style($color, str_repeat(self::Full, (int)$chars));
$this->session->style('dim', str_repeat(self::Empty, (int)($barSize - $chars)));

if ($this->showPercent) {
$this->session->style('white|bold', str_pad(ceil($percent * 100) . '%', 5, ' ', STR_PAD_LEFT));
Expand All @@ -292,7 +292,7 @@ public function advance(
}

while ($chars > $this->written) {
$this->session->write(self::FULL);
$this->session->write(self::Full);
$this->written++;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Widget/Spinner.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

class Spinner
{
public const TICK = 0.08;
public const CHARS = ['-', '\\', '|', '/'];
protected const Tick = 0.08;
protected const Chars = ['-', '\\', '|', '/'];

protected ?string $style = null;
protected Session $session;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function advance(): static
{
$time = microtime(true);

if ($this->lastTime + self::TICK > $time) {
if ($this->lastTime + self::Tick > $time) {
return $this;
}

Expand All @@ -74,10 +74,10 @@ public function advance(): static
$this->session->backspace();
}

$char = self::CHARS[$this->char];
$char = self::Chars[$this->char];
$this->char++;

if (!isset(self::CHARS[$this->char])) {
if (!isset(self::Chars[$this->char])) {
$this->char = 0;
}

Expand Down
4 changes: 2 additions & 2 deletions stubs/DecodeLabs/Terminus.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Terminus implements Proxy
{
use ProxyTrait;

const VENEER = 'DecodeLabs\\Terminus';
const VENEER_TARGET = Inst::class;
const Veneer = 'DecodeLabs\\Terminus';
const VeneerTarget = Inst::class;

public static Inst $instance;
/** @var CommandPlugin|PluginWrapper<CommandPlugin> $command */
Expand Down

0 comments on commit 6d7fa9b

Please sign in to comment.