Skip to content

Commit e014ee2

Browse files
committed
Use arg names from rule constants in definitions
1 parent e9631c9 commit e014ee2

28 files changed

+36
-44
lines changed

src/Rules/ArrayEnumRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
final class ArrayEnumRule implements Rule
2525
{
2626

27-
private const
27+
public const
2828
Cases = 'cases',
2929
UseKeys = 'useKeys',
3030
AllowUnknown = 'allowUnknown';

src/Rules/ArrayEnumValue.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function getType(): string
4040
public function getArgs(): array
4141
{
4242
return [
43-
'cases' => $this->cases,
44-
'useKeys' => $this->useKeys,
45-
'allowUnknown' => $this->allowUnknown,
43+
ArrayEnumRule::Cases => $this->cases,
44+
ArrayEnumRule::UseKeys => $this->useKeys,
45+
ArrayEnumRule::AllowUnknown => $this->allowUnknown,
4646
];
4747
}
4848

src/Rules/ArrayOf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getType(): string
3838
public function getArgs(): array
3939
{
4040
$args = parent::getArgs();
41-
$args['key'] = $this->key;
41+
$args[ArrayOfRule::KeyRule] = $this->key;
4242

4343
return $args;
4444
}

src/Rules/ArrayOfRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
final class ArrayOfRule extends MultiValueRule
2727
{
2828

29-
/** @internal */
3029
public const KeyRule = 'key';
3130

3231
public function resolveArgs(array $args, ArgsFieldContext $context): ArrayOfArgs

src/Rules/ArrayShape.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getType(): string
3535
public function getArgs(): array
3636
{
3737
return [
38-
'fields' => $this->fields,
38+
ArrayShapeRule::Fields => $this->fields,
3939
];
4040
}
4141

src/Rules/ArrayShapeRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
final class ArrayShapeRule implements Rule
2727
{
2828

29-
/** @internal */
3029
public const Fields = 'fields';
3130

3231
public function resolveArgs(array $args, ArgsFieldContext $context): ArrayShapeArgs

src/Rules/BackedEnumRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
final class BackedEnumRule implements Rule
2525
{
2626

27-
private const
27+
public const
2828
ClassName = 'class',
2929
AllowUnknown = 'allowUnknown';
3030

src/Rules/BackedEnumValue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function getType(): string
3131
public function getArgs(): array
3232
{
3333
return [
34-
'class' => $this->class,
35-
'allowUnknown' => $this->allowUnknown,
34+
BackedEnumRule::ClassName => $this->class,
35+
BackedEnumRule::AllowUnknown => $this->allowUnknown,
3636
];
3737
}
3838

src/Rules/BoolRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
final class BoolRule implements Rule
2222
{
2323

24-
private const CastBoolLike = 'castBoolLike';
24+
public const CastBoolLike = 'castBoolLike';
2525

2626
private const CastMap = [
2727
'true' => true,

src/Rules/BoolValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function getType(): string
3030
public function getArgs(): array
3131
{
3232
return [
33-
'castBoolLike' => $this->castBoolLike,
33+
BoolRule::CastBoolLike => $this->castBoolLike,
3434
];
3535
}
3636

src/Rules/CompoundDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private function definitionsToRules(array $definitions): array
3535
public function getArgs(): array
3636
{
3737
return [
38-
'rules' => $this->rules,
38+
CompoundRule::Rules => $this->rules,
3939
];
4040
}
4141

src/Rules/CompoundRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
abstract class CompoundRule implements Rule
1919
{
2020

21-
/** @internal */
2221
public const Rules = 'rules';
2322

2423
public function resolveArgs(array $args, ArgsFieldContext $context): CompoundArgs

src/Rules/DateTimeRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
final class DateTimeRule implements Rule
3434
{
3535

36-
/** @internal */
3736
public const
3837
Format = 'format',
3938
ClassName = 'class';

src/Rules/DateTimeValue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function getType(): string
4242
public function getArgs(): array
4343
{
4444
return [
45-
'class' => $this->class,
46-
'format' => $this->format,
45+
DateTimeRule::ClassName => $this->class,
46+
DateTimeRule::Format => $this->format,
4747
];
4848
}
4949

src/Rules/FloatRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
final class FloatRule implements Rule
2424
{
2525

26-
/** @internal */
2726
public const
2827
Min = 'min',
2928
Max = 'max',

src/Rules/FloatValue.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public function getType(): string
4444
public function getArgs(): array
4545
{
4646
return [
47-
'min' => $this->min,
48-
'max' => $this->max,
49-
'unsigned' => $this->unsigned,
50-
'castNumericString' => $this->castNumericString,
47+
FloatRule::Min => $this->min,
48+
FloatRule::Max => $this->max,
49+
FloatRule::Unsigned => $this->unsigned,
50+
FloatRule::CastNumericString => $this->castNumericString,
5151
];
5252
}
5353

src/Rules/InstanceOfRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
final class InstanceOfRule implements Rule
2222
{
2323

24-
private const Type = 'type';
24+
public const Type = 'type';
2525

2626
public function resolveArgs(array $args, ArgsFieldContext $context): InstanceOfArgs
2727
{

src/Rules/InstanceOfValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getType(): string
3434
public function getArgs(): array
3535
{
3636
return [
37-
'type' => $this->type,
37+
InstanceOfRule::Type => $this->type,
3838
];
3939
}
4040

src/Rules/IntRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
final class IntRule implements Rule
2323
{
2424

25-
/** @internal */
2625
public const
2726
Min = 'min',
2827
Max = 'max',

src/Rules/IntValue.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public function getType(): string
4444
public function getArgs(): array
4545
{
4646
return [
47-
'min' => $this->min,
48-
'max' => $this->max,
49-
'unsigned' => $this->unsigned,
50-
'castNumericString' => $this->castNumericString,
47+
IntRule::Min => $this->min,
48+
IntRule::Max => $this->max,
49+
IntRule::Unsigned => $this->unsigned,
50+
IntRule::CastNumericString => $this->castNumericString,
5151
];
5252
}
5353

src/Rules/MappedObjectRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
final class MappedObjectRule implements Rule
2626
{
2727

28-
private const ClassName = 'class';
28+
public const ClassName = 'class';
2929

3030
/** @var array<string, null> */
3131
private array $alreadyResolved = [];

src/Rules/MappedObjectValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getType(): string
3535
public function getArgs(): array
3636
{
3737
return [
38-
'class' => $this->class,
38+
MappedObjectRule::ClassName => $this->class,
3939
];
4040
}
4141

src/Rules/MultiValueDefinition.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public function __construct(
3131
public function getArgs(): array
3232
{
3333
return [
34-
'item' => $this->item,
35-
'minItems' => $this->minItems,
36-
'maxItems' => $this->maxItems,
37-
'mergeDefaults' => $this->mergeDefaults,
34+
MultiValueRule::ItemRule => $this->item,
35+
MultiValueRule::MinItems => $this->minItems,
36+
MultiValueRule::MaxItems => $this->maxItems,
37+
MultiValueRule::MergeDefaults => $this->mergeDefaults,
3838
];
3939
}
4040

src/Rules/MultiValueRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
abstract class MultiValueRule implements Rule
1010
{
1111

12-
/** @internal */
1312
public const
1413
ItemRule = 'item',
1514
MinItems = 'minItems',

src/Rules/NullRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
final class NullRule implements Rule
2020
{
2121

22-
private const CastEmptyString = 'castEmptyString';
22+
public const CastEmptyString = 'castEmptyString';
2323

2424
public function resolveArgs(array $args, ArgsFieldContext $context): NullArgs
2525
{

src/Rules/NullValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function getType(): string
3030
public function getArgs(): array
3131
{
3232
return [
33-
'castEmptyString' => $this->castEmptyString,
33+
NullRule::CastEmptyString => $this->castEmptyString,
3434
];
3535
}
3636

src/Rules/StringRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
final class StringRule implements Rule
2121
{
2222

23-
/** @internal */
2423
public const
2524
Pattern = 'pattern',
2625
MinLength = 'minLength',

src/Rules/StringValue.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public function getType(): string
4444
public function getArgs(): array
4545
{
4646
return [
47-
'pattern' => $this->pattern,
48-
'minLength' => $this->minLength,
49-
'maxLength' => $this->maxLength,
50-
'notEmpty' => $this->notEmpty,
47+
StringRule::Pattern => $this->pattern,
48+
StringRule::MinLength => $this->minLength,
49+
StringRule::MaxLength => $this->maxLength,
50+
StringRule::NotEmpty => $this->notEmpty,
5151
];
5252
}
5353

0 commit comments

Comments
 (0)