Skip to content

Commit d38736d

Browse files
committed
Add doc linter to check validator constructors
When we make changes to the code, renaming variables, or adding parameters to a validator, it's easy to forget to update the documentation. With this change, we avoid having a disparity between the documentation and the code.
1 parent 098c973 commit d38736d

39 files changed

Lines changed: 250 additions & 88 deletions

bin/console

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use Respect\Dev\Commands\UpdateDomainToplevelCommand;
1717
use Respect\Dev\Commands\UpdatePostalCodesCommand;
1818
use Respect\Dev\Markdown\CompositeLinter;
1919
use Respect\Dev\Markdown\Differ as MarkdownDiffer;
20+
use Respect\Dev\Markdown\Linters\ValidatorHeaderLinter;
2021
use Respect\Dev\Markdown\Linters\ValidatorIndexLinter;
2122
use SebastianBergmann\Diff\Differ;
2223
use SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder;
@@ -29,6 +30,7 @@ return (static function () {
2930
$application->addCommand(new CreateMixinCommand());
3031
$application->addCommand(new DocsLintCommand($differ, new CompositeLinter(
3132
new ValidatorIndexLinter(),
33+
new ValidatorHeaderLinter(),
3234
)));
3335
$application->addCommand(new UpdateDomainSuffixesCommand());
3436
$application->addCommand(new UpdateDomainToplevelCommand());

docs/validators/AllOf.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# AllOf
22

3-
- `AllOf(Validator $validator1, Validator $validator2, Validator ...$validator)`
3+
- `AllOf(Validator $validator1, Validator $validator2)`
4+
- `AllOf(Validator $validator1, Validator $validator2, Validator ...$validators)`
45

56
Will validate if all inner validators validates.
67

docs/validators/AnyOf.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# AnyOf
22

3-
- `AnyOf(Validator $validator1, Validator $validator2, Validator ...$validator)`
3+
- `AnyOf(Validator $validator1, Validator $validator2)`
4+
- `AnyOf(Validator $validator1, Validator $validator2, Validator ...$validators)`
45

56
This is a group validator that acts as an OR operator.
67

docs/validators/Base.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Base
22

3-
- `Base(string $base)`
3+
- `Base(int $base)`
4+
- `Base(int $base, string $chars)`
45

56
Validate numbers in any base, even with non regular bases.
67

docs/validators/Between.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Between
22

3-
- `Between(mixed $minimum, mixed $maximum)`
3+
- `Between(mixed $minValue, mixed $maxValue)`
44

55
Validates whether the input is between two other values.
66

docs/validators/Callback.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Callback
22

33
- `Callback(callable $callback)`
4+
- `Callback(callable $callback, mixed ...$arguments)`
45

56
Validates the input using the return of a given callable.
67

docs/validators/Charset.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Charset
22

3-
- `Charset(string ...$charset)`
3+
- `Charset(string $charset)`
4+
- `Charset(string $charset, string ...$charsets)`
45

56
Validates if a string is in a specific charset.
67

docs/validators/Circuit.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Circuit
22

3-
- `Circuit(Validator $validator1, Validator $validator2, Validator ...$validator)`
3+
- `Circuit(Validator $validator1, Validator $validator2)`
4+
- `Circuit(Validator $validator1, Validator $validator2, Validator ...$validators)`
45

56
Validates the input against a series of validators until the first fails.
67

docs/validators/Contains.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Contains
22

3-
- `Contains(mixed $expectedValue)`
4-
- `Contains(mixed $expectedValue, bool $identical)`
3+
- `Contains(mixed $containsValue)`
4+
- `Contains(mixed $containsValue, bool $identical)`
55

66
Validates if the input contains some value.
77

docs/validators/ContainsAny.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ContainsAny
22

3-
- `ContainsAny(array $needles)`
4-
- `ContainsAny(array $needles, bool $identical)`
3+
- `ContainsAny(non-empty-array<mixed> $needles)`
4+
- `ContainsAny(non-empty-array<mixed> $needles, bool $identical)`
55

66
Validates if the input contains at least one of defined values
77

0 commit comments

Comments
 (0)