diff --git a/rules/Php81/NodeFactory/ClassFromEnumFactory.php b/rules/Php81/NodeFactory/ClassFromEnumFactory.php index ac95ac96c05..295d7cbe729 100644 --- a/rules/Php81/NodeFactory/ClassFromEnumFactory.php +++ b/rules/Php81/NodeFactory/ClassFromEnumFactory.php @@ -26,15 +26,16 @@ final class ClassFromEnumFactory public function createFromEnum(Enum_ $enum) : Class_ { $shortClassName = $this->nodeNameResolver->getShortName($enum); - $classConsts = []; + $classStmts = []; foreach ($enum->stmts as $stmt) { if (!$stmt instanceof EnumCase) { + $classStmts[] = $stmt; continue; } $constValue = $this->createConstValue($stmt); - $classConsts[] = new ClassConst([new Const_($stmt->name, $constValue)], Visibility::PUBLIC); + $classStmts[] = new ClassConst([new Const_($stmt->name, $constValue)], Visibility::PUBLIC); } - $class = new Class_($shortClassName, ['stmts' => $classConsts]); + $class = new Class_($shortClassName, ['stmts' => $classStmts]); $class->namespacedName = $enum->namespacedName; return $class; } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 895934010c8..049b9a40624 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -17,12 +17,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '4e15a691a006b0ee95df856ac18f8a2b399ccfad'; + public const PACKAGE_VERSION = 'd2064068055fb25da2c245515a6c6260fbe6a597'; /** * @api * @var string */ - public const RELEASE_DATE = '2022-12-01 18:56:43'; + public const RELEASE_DATE = '2022-12-01 19:02:13'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 3f48edad77f..1eea635ac63 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitd8e1eb79b4b61cc3ae04fef368f8f991::getLoader(); +return ComposerAutoloaderInitf22ad65e12742e0fc5781b13aafc2fbf::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 6be388a7bdd..5910e3df557 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitd8e1eb79b4b61cc3ae04fef368f8f991 +class ComposerAutoloaderInitf22ad65e12742e0fc5781b13aafc2fbf { private static $loader; @@ -22,19 +22,19 @@ class ComposerAutoloaderInitd8e1eb79b4b61cc3ae04fef368f8f991 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitd8e1eb79b4b61cc3ae04fef368f8f991', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitf22ad65e12742e0fc5781b13aafc2fbf', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitd8e1eb79b4b61cc3ae04fef368f8f991', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitf22ad65e12742e0fc5781b13aafc2fbf', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitd8e1eb79b4b61cc3ae04fef368f8f991::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitf22ad65e12742e0fc5781b13aafc2fbf::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $includeFiles = \Composer\Autoload\ComposerStaticInitd8e1eb79b4b61cc3ae04fef368f8f991::$files; + $includeFiles = \Composer\Autoload\ComposerStaticInitf22ad65e12742e0fc5781b13aafc2fbf::$files; foreach ($includeFiles as $fileIdentifier => $file) { - composerRequired8e1eb79b4b61cc3ae04fef368f8f991($fileIdentifier, $file); + composerRequiref22ad65e12742e0fc5781b13aafc2fbf($fileIdentifier, $file); } return $loader; @@ -46,7 +46,7 @@ class ComposerAutoloaderInitd8e1eb79b4b61cc3ae04fef368f8f991 * @param string $file * @return void */ -function composerRequired8e1eb79b4b61cc3ae04fef368f8f991($fileIdentifier, $file) +function composerRequiref22ad65e12742e0fc5781b13aafc2fbf($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 3ed149471a1..f8f78c8ca9e 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitd8e1eb79b4b61cc3ae04fef368f8f991 +class ComposerStaticInitf22ad65e12742e0fc5781b13aafc2fbf { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3046,9 +3046,9 @@ class ComposerStaticInitd8e1eb79b4b61cc3ae04fef368f8f991 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitd8e1eb79b4b61cc3ae04fef368f8f991::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitd8e1eb79b4b61cc3ae04fef368f8f991::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitd8e1eb79b4b61cc3ae04fef368f8f991::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitf22ad65e12742e0fc5781b13aafc2fbf::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitf22ad65e12742e0fc5781b13aafc2fbf::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitf22ad65e12742e0fc5781b13aafc2fbf::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/symfony/console/Output/AnsiColorMode.php b/vendor/symfony/console/Output/AnsiColorMode.php index 13e890fe934..423a71cce10 100644 --- a/vendor/symfony/console/Output/AnsiColorMode.php +++ b/vendor/symfony/console/Output/AnsiColorMode.php @@ -16,4 +16,75 @@ class AnsiColorMode public const Ansi4 = 'ansi4'; public const Ansi8 = 'ansi8'; public const Ansi24 = 'ansi24'; + /** + * Converts an RGB hexadecimal color to the corresponding Ansi code. + */ + public function convertFromHexToAnsiColorCode(string $hexColor) : string + { + $hexColor = \str_replace('#', '', $hexColor); + if (3 === \strlen($hexColor)) { + $hexColor = $hexColor[0] . $hexColor[0] . $hexColor[1] . $hexColor[1] . $hexColor[2] . $hexColor[2]; + } + if (6 !== \strlen($hexColor)) { + throw new InvalidArgumentException(\sprintf('Invalid "#%s" color.', $hexColor)); + } + $color = \hexdec($hexColor); + $r = $color >> 16 & 255; + $g = $color >> 8 & 255; + $b = $color & 255; + switch ($this) { + case self::Ansi4: + return (string) $this->convertFromRGB($r, $g, $b); + case self::Ansi8: + return '8;5;' . (string) $this->convertFromRGB($r, $g, $b); + case self::Ansi24: + return \sprintf('8;2;%d;%d;%d', $r, $g, $b); + } + } + private function convertFromRGB(int $r, int $g, int $b) : int + { + switch ($this) { + case self::Ansi4: + return $this->degradeHexColorToAnsi4($r, $g, $b); + case self::Ansi8: + return $this->degradeHexColorToAnsi8($r, $g, $b); + default: + throw new InvalidArgumentException("RGB cannot be converted to {$this->name}."); + } + } + private function degradeHexColorToAnsi4(int $r, int $g, int $b) : int + { + if (0 === \round($this->getSaturation($r, $g, $b) / 50)) { + return 0; + } + return (int) (\round($b / 255) << 2 | \round($g / 255) << 1 | \round($r / 255)); + } + private function getSaturation(int $r, int $g, int $b) : int + { + $r = $r / 255; + $g = $g / 255; + $b = $b / 255; + $v = \max($r, $g, $b); + if (0 === ($diff = $v - \min($r, $g, $b))) { + return 0; + } + return (int) ((int) $diff * 100 / $v); + } + /** + * Inspired from https://github.com/ajalt/colormath/blob/e464e0da1b014976736cf97250063248fc77b8e7/colormath/src/commonMain/kotlin/com/github/ajalt/colormath/model/Ansi256.kt code (MIT license). + */ + private function degradeHexColorToAnsi8(int $r, int $g, int $b) : int + { + if ($r === $g && $g === $b) { + if ($r < 8) { + return 16; + } + if ($r > 248) { + return 231; + } + return (int) \round(($r - 8) / 247 * 24) + 232; + } else { + return 16 + 36 * (int) \round($r / 255 * 5) + 6 * (int) \round($g / 255 * 5) + (int) \round($b / 255 * 5); + } + } }