Skip to content

Commit

Permalink
cs: Update CS (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Apr 22, 2024
1 parent 37f0349 commit 9bbed12
Show file tree
Hide file tree
Showing 22 changed files with 169 additions and 187 deletions.
2 changes: 1 addition & 1 deletion src/Input/DecoratesInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function hasParameterOption(array|string $values, bool $onlyParams = fals

public function getParameterOption(
array|string $values,
null|array|bool|float|int|string $default = false,
array|bool|float|int|string|null $default = false,
bool $onlyParams = false
): mixed {
return $this->input->getParameterOption(...func_get_args());
Expand Down
2 changes: 1 addition & 1 deletion src/Input/IO.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use function class_alias;
use function sprintf;

$alias = \Fidry\Console\Input\IO::class;
$alias = IO::class;
$newClass = \Fidry\Console\IO::class;

Deprecation::trigger(
Expand Down
18 changes: 9 additions & 9 deletions src/Input/TypedInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class TypedInput
* @psalm-suppress RedundantCondition
*/
private function __construct(
private readonly null|array|bool|string $value,
private readonly array|bool|string|null $value,
private readonly string $label,
) {
Assert::stringNotEmpty($label);
Expand Down Expand Up @@ -198,7 +198,7 @@ public function asNullableBackedEnum(
/**
* @return null|bool|string|list<string>
*/
public function asRaw(?string $errorMessage = null): null|array|bool|string
public function asRaw(?string $errorMessage = null): array|bool|string|null
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\RawType::class,
Expand Down Expand Up @@ -241,7 +241,7 @@ public function asBoolean(?string $errorMessage = null): bool
public function asNullableBoolean(?string $errorMessage = null): ?bool
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\BooleanType::class,
]);

Expand Down Expand Up @@ -336,7 +336,7 @@ public function asNatural(?string $errorMessage = null): int
public function asNullableNatural(?string $errorMessage = null): ?int
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\NaturalType::class,
]);

Expand Down Expand Up @@ -431,7 +431,7 @@ public function asPositiveInteger(?string $errorMessage = null): int
public function asNullablePositiveInteger(?string $errorMessage = null): ?int
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\PositiveIntegerType::class,
]);

Expand Down Expand Up @@ -520,7 +520,7 @@ public function asFloat(?string $errorMessage = null): float
public function asNullableFloat(?string $errorMessage = null): ?float
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\FloatType::class,
]);

Expand Down Expand Up @@ -609,7 +609,7 @@ public function asString(?string $errorMessage = null): string
public function asNullableString(?string $errorMessage = null): ?string
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\StringType::class,
]);

Expand Down Expand Up @@ -704,7 +704,7 @@ public function asNonEmptyString(?string $errorMessage = null): string
public function asNullableNonEmptyString(?string $errorMessage = null): ?string
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\NonEmptyStringType::class,
]);

Expand Down Expand Up @@ -793,7 +793,7 @@ public function asUntrimmedString(?string $errorMessage = null): string
public function asNullableUntrimmedString(?string $errorMessage = null): ?string
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\UntrimmedStringType::class,
]);

Expand Down
12 changes: 6 additions & 6 deletions src/Internal/InputAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function assertIsValidOptionType(mixed $option, string $name): voi
*
* @psalm-assert scalar|null $value
*/
public static function assertIsScalar(null|array|bool|string $value, string $label): void
public static function assertIsScalar(array|bool|string|null $value, string $label): void
{
self::castThrowException(
static function () use ($value): void {
Expand All @@ -115,7 +115,7 @@ static function () use ($value): void {
*
* @psalm-assert list<string> $value
*/
public static function assertIsList(null|array|bool|string $value, string $label): void
public static function assertIsList(array|bool|string|null $value, string $label): void
{
self::castThrowException(
static function () use ($value): void {
Expand Down Expand Up @@ -145,7 +145,7 @@ static function () use ($value): void {
*
* @psalm-assert numeric $value
*/
public static function numericString(null|array|bool|string $value, string $label): void
public static function numericString(array|bool|string|null $value, string $label): void
{
self::castThrowException(
static function () use ($value, $label): void {
Expand Down Expand Up @@ -175,7 +175,7 @@ static function () use ($value, $label): void {
*
* @psalm-assert string $value
*/
public static function integerString(null|array|bool|string $value, string $label): void
public static function integerString(array|bool|string|null $value, string $label): void
{
self::castThrowException(
static function () use ($value, $label): void {
Expand Down Expand Up @@ -205,7 +205,7 @@ static function () use ($value, $label): void {
*
* @psalm-assert string $value
*/
public static function string(null|array|bool|string $value, string $label): void
public static function string(array|bool|string|null $value, string $label): void
{
self::castThrowException(
static function () use ($value, $label): void {
Expand Down Expand Up @@ -238,7 +238,7 @@ public static function castThrowException(callable $callable, string $label): vo
/**
* @param ArgumentInput|OptionInput $value
*/
public static function castType(null|array|bool|string $value): string
public static function castType(array|bool|string|null $value): string
{
return var_export($value, true);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/Type/BackedEnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
) {
}

public function coerceValue(null|array|bool|string $value, string $label): BackedEnum
public function coerceValue(array|bool|string|null $value, string $label): BackedEnum
{
InputAssert::assertIsScalar($value, $label);

Expand Down Expand Up @@ -70,7 +70,7 @@ public function getPhpTypeDeclaration(): ?string
/**
* @return T
*/
private function coerce(null|bool|string $value): BackedEnum
private function coerce(bool|string|null $value): BackedEnum
{
try {
return $this->backedEnumClassName::from((int) $value);
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/BooleanType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
final class BooleanType implements ScalarType
{
public function coerceValue(null|array|bool|string $value, string $label): bool
public function coerceValue(array|bool|string|null $value, string $label): bool
{
InputAssert::assertIsScalar($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/FloatType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
final class FloatType implements ScalarType
{
public function coerceValue(null|array|bool|string $value, string $label): float
public function coerceValue(array|bool|string|null $value, string $label): float
{
InputAssert::numericString($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/InputType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface InputType
*
* @return TypedValue
*/
public function coerceValue(null|array|bool|string $value, string $label): mixed;
public function coerceValue(array|bool|string|null $value, string $label): mixed;

/**
* @return non-empty-list<class-string<InputType>>
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/ListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(InputType $innerType)
$this->innerType = $innerType;
}

public function coerceValue(null|array|bool|string $value, string $label): array
public function coerceValue(array|bool|string|null $value, string $label): array
{
InputAssert::assertIsList($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/NaturalRangeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(int $min, int $max)
}
}

public function coerceValue(null|array|bool|string $value, string $label): int
public function coerceValue(array|bool|string|null $value, string $label): int
{
$intValue = (new NaturalType())->coerceValue($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/NaturalType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
final class NaturalType implements ScalarType
{
public function coerceValue(null|array|bool|string $value, string $label): int
public function coerceValue(array|bool|string|null $value, string $label): int
{
InputAssert::integerString($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/NonEmptyListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(InputType $innerType)
$this->innerType = $innerType;
}

public function coerceValue(null|array|bool|string $value, string $label): array
public function coerceValue(array|bool|string|null $value, string $label): array
{
$list = (new ListType($this->innerType))->coerceValue($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/NonEmptyStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
final class NonEmptyStringType implements ScalarType
{
public function coerceValue(null|array|bool|string $value, string $label): string
public function coerceValue(array|bool|string|null $value, string $label): string
{
InputAssert::string($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/NullOrNonEmptyStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
final class NullOrNonEmptyStringType implements ScalarType
{
public function coerceValue(null|array|bool|string $value, string $label): ?string
public function coerceValue(array|bool|string|null $value, string $label): ?string
{
$trimmedValue = (new StringType())->coerceValue($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/NullableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(InputType $innerType)
$this->innerType = $innerType;
}

public function coerceValue(null|array|bool|string $value, string $label): mixed
public function coerceValue(array|bool|string|null $value, string $label): mixed
{
return null === $value
? $value
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/PositiveIntegerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
final class PositiveIntegerType implements ScalarType
{
public function coerceValue(null|array|bool|string $value, string $label): int
public function coerceValue(array|bool|string|null $value, string $label): int
{
$intValue = (new NaturalType())->coerceValue($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/RawType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
final class RawType implements InputType
{
public function coerceValue(null|array|bool|string $value, string $label): mixed
public function coerceValue(array|bool|string|null $value, string $label): mixed
{
/** @psalm-suppress NullableReturnStatement */
return $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/StringChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(array $choices)
$this->choices = $choices;
}

public function coerceValue(null|array|bool|string $value, string $label): string
public function coerceValue(array|bool|string|null $value, string $label): string
{
$value = (new StringType())->coerceValue($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/StringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
final class StringType implements ScalarType
{
public function coerceValue(null|array|bool|string $value, string $label): string
public function coerceValue(array|bool|string|null $value, string $label): string
{
InputAssert::string($value, $label);

Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Type/UntrimmedStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
final class UntrimmedStringType implements ScalarType
{
public function coerceValue(null|array|bool|string $value, string $label): string
public function coerceValue(array|bool|string|null $value, string $label): string
{
InputAssert::string($value, $label);

Expand Down
16 changes: 8 additions & 8 deletions tests/IO/TypedInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ final class TypedInput
*/
public function __construct(
public readonly bool|TypeException $boolean,
public readonly null|bool|TypeException $nullableBoolean,
public readonly bool|TypeException|null $nullableBoolean,
public readonly string|TypeException $string,
public readonly null|string|TypeException $nullableString,
public readonly string|TypeException|null $nullableString,
public readonly array|TypeException $stringArray,
public readonly int|TypeException $integer,
public readonly null|int|TypeException $nullableInteger,
public readonly int|TypeException|null $nullableInteger,
public readonly array|TypeException $integerArray,
public readonly float|TypeException $float,
public readonly null|float|TypeException $nullableFloat,
public readonly float|TypeException|null $nullableFloat,
public readonly array|TypeException $floatArray,
) {
}

public static function createForScalar(
TypeException $arrayToScalarTypeException,
bool|TypeException $boolean,
null|bool|TypeException $nullableBoolean,
bool|TypeException|null $nullableBoolean,
string|TypeException $string,
null|string|TypeException $nullableString,
string|TypeException|null $nullableString,
int|TypeException $integer,
null|int|TypeException $nullableInteger,
int|TypeException|null $nullableInteger,
float|TypeException $float,
null|float|TypeException $nullableFloat,
float|TypeException|null $nullableFloat,
): self {
return new self(
$boolean,
Expand Down
Loading

0 comments on commit 9bbed12

Please sign in to comment.