@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * |
| 34 | 34 | * @return string The human representation for a given value |
| 35 | 35 | */ |
| 36 | - public static function readableForValue(string|int $value): string; |
|
| 36 | + public static function readableForValue(string | int $value): string; |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Gets the human representation for a given name. |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * @param class-string<FlagEnumInterface>|FlagEnumInterface $enumOrType |
| 58 | 58 | */ |
| 59 | - public static function from(string|FlagEnumInterface $enumOrType, FlagEnumInterface ...$flags): static |
|
| 59 | + public static function from(string | FlagEnumInterface $enumOrType, FlagEnumInterface ...$flags): static |
|
| 60 | 60 | { |
| 61 | 61 | if ($enumOrType instanceof FlagEnumInterface) { |
| 62 | 62 | $type = $enumOrType::class; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $type = $enumOrType; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return new static($type, static::encodeBits(array_map(static fn (FlagEnumInterface $flag) => $flag->value, $flags))); |
|
| 72 | + return new static($type, static::encodeBits(array_map(static fn(FlagEnumInterface $flag) => $flag->value, $flags))); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public static function accepts(string $enumType, int $value): bool |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return array_values( |
| 95 | 95 | array_filter( |
| 96 | 96 | array_map( |
| 97 | - static fn ($k, $v) => $v === '1' ? (1 << $k) : null, |
|
| 97 | + static fn($k, $v) => $v === '1' ? (1 << $k) : null, |
|
| 98 | 98 | array_keys($bits), |
| 99 | 99 | array_values($bits), |
| 100 | 100 | ) |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function getFlags(): array |
| 155 | 155 | { |
| 156 | - return array_map(fn (int $bit) => $this->type::from($bit), $this->bits); |
|
| 156 | + return array_map(fn(int $bit) => $this->type::from($bit), $this->bits); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function hasFlags(FlagEnumInterface ...$flags): bool |
| 175 | 175 | { |
| 176 | - $bits = static::encodeBits(array_map(static fn (FlagEnumInterface $flag) => $flag->value, $flags)); |
|
| 176 | + $bits = static::encodeBits(array_map(static fn(FlagEnumInterface $flag) => $flag->value, $flags)); |
|
| 177 | 177 | |
| 178 | 178 | if ($flags >= 1) { |
| 179 | 179 | return $bits === ($bits & self::encodeBits($this->bits)); |
@@ -224,6 +224,6 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | private function flagsToBits(FlagEnumInterface ...$flags): array |
| 226 | 226 | { |
| 227 | - return array_map(static fn (FlagEnumInterface $flag) => $flag->value, $flags); |
|
| 227 | + return array_map(static fn(FlagEnumInterface $flag) => $flag->value, $flags); |
|
| 228 | 228 | } |
| 229 | 229 | } |
@@ -121,9 +121,4 @@ |
||
| 121 | 121 | |
| 122 | 122 | protected function onNullFromPhp() |
| 123 | 123 | { |
| 124 | - return {$defaultOnNullCode}; |
|
| 125 | - } |
|
| 126 | - PHP; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | -} |
|
| 124 | + return {$defaultOnNullCode} |
|
| 130 | 125 | \ No newline at end of file |
@@ -121,9 +121,4 @@ |
||
| 121 | 121 | |
| 122 | 122 | protected function onNullFromPhp() |
| 123 | 123 | { |
| 124 | - return {$defaultOnNullCode}; |
|
| 125 | - } |
|
| 126 | - PHP; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | -} |
|
| 124 | + return {$defaultOnNullCode} |
|
| 130 | 125 | \ No newline at end of file |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | string $classname, |
| 68 | 68 | string $enumClass, |
| 69 | 69 | string $name, |
| 70 | - int|string|null $defaultOnNull = null |
|
| 70 | + int | string | null $defaultOnNull = null |
|
| 71 | 71 | ): string { |
| 72 | 72 | $code = <<<PHP |
| 73 | 73 | protected function getEnumClass(): string |
@@ -121,9 +121,4 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | protected function onNullFromPhp() |
| 123 | 123 | { |
| 124 | - return {$defaultOnNullCode}; |
|
| 125 | - } |
|
| 126 | - PHP; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | -} |
|
| 124 | + return {$defaultOnNullCode} |
|
| 130 | 125 | \ No newline at end of file |
@@ -121,9 +121,4 @@ |
||
| 121 | 121 | |
| 122 | 122 | protected function onNullFromPhp() |
| 123 | 123 | { |
| 124 | - return {$defaultOnNullCode}; |
|
| 125 | - } |
|
| 126 | - PHP; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | -} |
|
| 124 | + return {$defaultOnNullCode} |
|
| 130 | 125 | \ No newline at end of file |
@@ -121,9 +121,4 @@ |
||
| 121 | 121 | |
| 122 | 122 | protected function onNullFromPhp() |
| 123 | 123 | { |
| 124 | - return {$defaultOnNullCode}; |
|
| 125 | - } |
|
| 126 | - PHP; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | -} |
|
| 124 | + return {$defaultOnNullCode} |
|
| 130 | 125 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * {@inheritdoc} |
| 23 | 23 | */ |
| 24 | - public static function readableForValue(string|int $value): string |
|
| 24 | + public static function readableForValue(string | int $value): string |
|
| 25 | 25 | { |
| 26 | 26 | /** @var ReadableEnumInterface $case */ |
| 27 | 27 | $case = static::from($value); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | static $map; |
| 39 | 39 | |
| 40 | 40 | if (null === $map) { |
| 41 | - $map = array_combine(array_map(static fn (\UnitEnum $e) => $e->name, static::cases()), static::cases()); |
|
| 41 | + $map = array_combine(array_map(static fn(\UnitEnum $e) => $e->name, static::cases()), static::cases()); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | if (!isset($map[$name])) { |