Skip to content

Commit 8642c8b

Browse files
committed
Add GitHub action 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. This commit will create a console command that will automatically update the headers of each validator documentation file, so it matches the constructor of the validator itself. With this change, we avoid having a disparity between the documentation and the code.
1 parent 92677b9 commit 8642c8b

39 files changed

Lines changed: 316 additions & 40 deletions

.github/workflows/continuous-integration-docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ jobs:
3131

3232
- name: Validators' index
3333
run: bin/console docs:validators:index
34+
35+
- name: Validator headers
36+
run: bin/console docs:validators:headers

bin/console

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ declare(strict_types=1);
1111
require __DIR__ . '/../vendor/autoload.php';
1212

1313
use Respect\Dev\Commands\CreateMixinCommand;
14+
use Respect\Dev\Commands\DocsValidatorsHeadersCommand;
1415
use Respect\Dev\Commands\DocsValidatorsListCommand;
1516
use Respect\Dev\Commands\UpdateDomainSuffixesCommand;
1617
use Respect\Dev\Commands\UpdateDomainToplevelCommand;
@@ -25,6 +26,7 @@ return (static function () {
2526

2627
$application = new Application('Respect/Validation', '3.0');
2728
$application->addCommand(new CreateMixinCommand());
29+
$application->addCommand(new DocsValidatorsHeadersCommand($differ));
2830
$application->addCommand(new DocsValidatorsListCommand($differ));
2931
$application->addCommand(new UpdateDomainSuffixesCommand());
3032
$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

0 commit comments

Comments
 (0)