Skip to content

Commit

Permalink
Adding support for php8.4 (Implicitly nullable parameter declarations…
Browse files Browse the repository at this point in the history
… deprecated)
  • Loading branch information
rayanlevert committed Aug 17, 2024
1 parent 9f94a31 commit 46138bd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Inspired by Sebastian Bergmann's phpunit action workflow https://github.com/sebastianbergmann/phpunit/blob/main/.github/workflows/ci.yml
# Inspired by Sebastian Bergmann's phpunit action workflow https://github.com/sebastianbergmann/phpunit/blob/main/.github/workflows/ci.yaml

name: "CI"

Expand Down
2 changes: 1 addition & 1 deletion src/Arguments/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function verifiesType(mixed $value): bool
};
}

/** Returns the php property for the Arguments\Argument class */
/** Returns the PHP property for the Arguments\Argument class */
public function getPhpProperty(): string
{
return match ($this) {
Expand Down
4 changes: 2 additions & 2 deletions src/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ public function getCurrent(): int
private function printTime(): void
{
// Time color by its total time
$time = Style::stylize($this->getFormattedTime($this->totalTime), fg: match (true) {
$time = Style::stylize(self::getFormattedTime($this->totalTime), fg: match (true) {
$this->totalTime <= 500 => Foreground::GREEN,
$this->totalTime <= 2000 => Foreground::YELLOW,
default => Foreground::RED
});

// Allocated memory by its usage
$memoryUsage = memory_get_usage(true);
$memory = Style::stylize($this->getFormattedMemory($memoryUsage), fg: match (true) {
$memory = Style::stylize(self::getFormattedMemory($memoryUsage), fg: match (true) {
$memoryUsage <= 268435456 => Foreground::LIGHT_GREEN, // 256MB
$memoryUsage <= 536870912 => Foreground::YELLOW, // 512MB
default => Foreground::RED
Expand Down
20 changes: 11 additions & 9 deletions src/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use function sprintf;
use function get_class;
use function preg_match_all;
use function substr;
use function trigger_error;
use function get_called_class;
use function str_replace;

Expand All @@ -24,9 +26,9 @@ class Style
*/
public static function inline(
string $string,
Style\Background $bg = null,
Style\Foreground $fg = null,
Style\Attribute $at = null
?Style\Background $bg = null,
?Style\Foreground $fg = null,
?Style\Attribute $at = null
): void {
print self::stylize($string, $bg, $fg, $at);
}
Expand All @@ -36,9 +38,9 @@ public static function inline(
*/
public static function outline(
string $string,
Style\Background $bg = null,
Style\Foreground $fg = null,
Style\Attribute $at = null
?Style\Background $bg = null,
?Style\Foreground $fg = null,
?Style\Attribute $at = null
): void {
print self::stylize($string, $bg, $fg, $at) . PHP_EOL;
}
Expand Down Expand Up @@ -202,9 +204,9 @@ public static function tag(string $tag): void
*/
public static function stylize(
string $string,
Style\Background $bg = null,
Style\Foreground $fg = null,
Style\Attribute $at = null
?Style\Background $bg = null,
?Style\Foreground $fg = null,
?Style\Attribute $at = null
): string {
if (!$bg && !$fg && !$at) {
return $string;
Expand Down

0 comments on commit 46138bd

Please sign in to comment.