Skip to content

Commit 7636944

Browse files
committed
Register v as a class alias to Validator
This is a pattern that we already use everywhere, so it makes sense to simply turn `v` into a class alias to `Validator`, which will allow people to use all the examples in the documentation without needing to import the namespace. We already do that when we run tests, so I just changed it to be a global setting.
1 parent 94ddfcd commit 7636944

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed
File renamed without changes.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@
5959
"autoload": {
6060
"psr-4": {
6161
"Respect\\Validation\\": "library/"
62-
}
62+
},
63+
"files": ["aliases.php"]
6364
},
6465
"autoload-dev": {
6566
"psr-4": {
6667
"Respect\\Validation\\": "tests/unit/",
6768
"Respect\\Validation\\Test\\": "tests/library/"
68-
},
69-
"files": ["tests/aliases.php"]
69+
}
7070
},
7171
"scripts": {
7272
"docheader": "vendor/bin/docheader check library/ tests/",

docs/02-feature-guide.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Feature Guide
22

3-
We'll use `v` as an alias for `Respect\Validation\Validator` to keep things simple:
3+
The `Validator` class is the core of Respect\Validation, offering a fluent interface for building validation rules.
4+
5+
For convenience, the `Validator` class is aliased as `v`. This means you can write `v::intType()` instead of `\Respect\Validation\Validator::intType()`.
46

5-
```php
6-
use Respect\Validation\Validator as v;
7-
```
87

98
## Validating using booleans
109

0 commit comments

Comments
 (0)