Skip to content

Commit fc96faa

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 aa79596 commit fc96faa

41 files changed

Lines changed: 506 additions & 88 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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 DocsLinterCommand($differ, new CompositeLinter(
3132
new ValidatorIndexLinter(),
33+
new ValidatorHeaderLinter(),
3234
)));
3335
$application->addCommand(new UpdateDomainSuffixesCommand());
3436
$application->addCommand(new UpdateDomainToplevelCommand());

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@
7272
}
7373
},
7474
"scripts": {
75+
"docs:validators:headers": "bin/console docs:validators:headers",
7576
"docs:validators:index": "bin/console docs:validators:index",
7677
"docheader": "vendor/bin/docheader check library/ tests/",
7778
"phpcs": "vendor/bin/phpcs",
7879
"phpstan": "vendor/bin/phpstan analyze",
7980
"phpunit": "vendor/bin/phpunit --testsuite=unit",
8081
"pest": "vendor/bin/pest --testsuite=feature --compact",
8182
"docs": [
83+
"@docs:validators:headers",
8284
"@docs:validators:index"
8385
],
8486
"qa": [

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

0 commit comments

Comments
 (0)