Skip to content

Commit f88d70b

Browse files
committed
chore: reorganize tests, improve tooling and documentation
Tests: - Restructure tests/ into Unit/Integration/Regression hierarchy - Consolidate 7 duplicate tests across 4 test files - 502 tests, 924 assertions, 0 failures Tooling: - Configure PHPStan level max, resolve initial PHPDoc issues - Update benchmark results (PHP 8.5.1 + OPcache) Documentation: - Update README with new performance metrics - Generate comprehensive PHPDoc annotations
1 parent 7e6a38d commit f88d70b

File tree

70 files changed

+1212
-1035
lines changed

Some content is hidden

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

70 files changed

+1212
-1035
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [1.0.4] - 2026-01-05
8+
## [1.0.5] - 2026-01-06
9+
### Tests
10+
- Restructured test suite into Unit/Integration/Regression hierarchy
11+
- Consolidated 7 duplicate tests across 4 test files
12+
- 502 tests, 924 assertions, 0 failures
13+
14+
### Tooling
15+
- Configured PHPStan level max, resolved initial PHPDoc issues
16+
- Updated benchmark results (PHP 8.5.1 + OPcache)
917

18+
### Documentation
19+
- Updated README with new performance metrics
20+
- Generated comprehensive PHPDoc annotations
21+
22+
## [1.0.4] - 2026-01-05
1023
### Performance
1124
- **Static Translator Cache** - Eliminates repeated file I/O across validation instances
1225
- TranslationManager now uses process-wide cached translator instance

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
.PHONY: test stan mutation benchmark p99 docs docs-serve
22

33
test:
4-
bash tests.sh --full
4+
@vendor/bin/phpunit --colors --display-warnings --testdox
55

66
stan:
7-
@vendor/bin/phpstan analyse src tests
7+
@vendor/bin/phpstan analyse -l max src
88

99
mutation:
1010
@vendor/bin/infection --threads=4
1111

1212
benchmark:
13-
@vendor/bin/phpbench run --report=default --iterations=10 --revs=1000 --warmup=2 --output=csv > benchmarks/bench_results.csv
13+
@vendor/bin/phpbench run --report=default --warmup=2 --output=csv > benchmarks/bench_results.csv
1414

1515
p99:
1616
@cd benchmarks && php analyze_bench.php

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ $dv->addTranslations([
221221
-**Fast** - ~9μs simple validation, ~4.9MB memory ([benchmarks](docs/BENCHMARK.md))
222222
-**i18n ready** - Built-in translation support (EN, FR)
223223
-**Framework agnostic** - Works with WordPress, Laravel, Symfony, vanilla PHP
224-
-**Production tested** - 482 tests, 75% mutation score
224+
-**Production tested** - 500+ tests, 83% mutation score
225225

226226
## Documentation
227227

@@ -244,10 +244,10 @@ $dv->addTranslations([
244244

245245
DataVerify is designed for production with predictable sub-millisecond performance:
246246
```
247-
Simple validation: ~8.8μs (99% < 9μs)
248-
Complex nested: ~17.1μs (99% < 18μs)
249-
Batch mode (100 fields): 1.15ms
250-
Fail-fast (100 fields): 0.23ms (2.3x faster)
247+
Simple validation: ~8.7μs (99% < 9μs)
248+
Complex nested: ~16.4μs (99% < 18μs)
249+
Batch mode (100 fields): ~0.53ms
250+
Fail-fast (100 fields): ~0.23ms (2.3x faster)
251251
Memory usage: ~4.9MB (stable)
252252
```
253253

benchmarks/bench_results.csv

Lines changed: 205 additions & 350 deletions
Large diffs are not rendered by default.

docs/BENCHMARK.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ make benchmark-stats # With P50/P95/P99 percentiles
1111
### Results (PHP 8.5.1 + OPcache)
1212

1313
**Core Operations** (P99):
14-
- Simple validation: **8.8μs** (99% < 9μs)
15-
- Complex nested: **17.1μs** (99% < 18μs)
16-
- Custom strategy: **11.4μs** (99% < 12μs)
14+
- Simple validation: **8.7μs** (99% < 9μs)
15+
- Complex nested: **16.4μs** (99% < 17μs)
16+
- Custom strategy: **11.2μs** (99% < 12μs)
1717

1818
**Batch Processing:**
19-
- Batch mode (100 fields): **1.15ms**
20-
- Fail-fast mode (100 fields): **0.23ms****5x faster**
19+
- Batch mode (100 fields): **~0.53ms**
20+
- Fail-fast mode (100 fields): **~0.23ms****2.3x faster**
2121

2222
**Conditional Validations** (P99):
23-
- Triggered: **8.9μs**
23+
- Triggered: **8.5μs**
2424
- Not triggered: **5.7μs** ← Faster (validation skipped)
25-
- Failed + errors: **14.5μs** ← Most expensive (error rendering)
25+
- Failed + errors: **13μs** ← Most expensive (error rendering)
2626
- Complex AND/OR: **~6.1μs**
2727

2828
**Translation Overhead:**
2929
- With translation: **14.6μs**
3030
- Without translation: **14.3μs**
31-
- **Overhead: ~2%** (negligible)
31+
- **Overhead: ~2-3%** (negligible)
3232

3333
**Memory:** ~4.9MB (stable, no leaks)
3434

3535
**Key Insights:**
36-
-**99% of validations complete in <18μs** (sub-millisecond)
37-
-**Very stable** - P99 within 5% of mean (low variance)
38-
-**Fail-fast mode 5x faster** when you need speed
36+
-**99% of validations complete in <17μs** (sub-millisecond)
37+
-**Very low variance** - P99 tightly clustered around the mean
38+
-**Fail-fast mode 2.3x faster** when you need speed
3939
-**Conditional skip is fast** - unused validations add minimal overhead
4040
-**Static translator cache** eliminates file I/O overhead
4141

docs/VALIDATIONS.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ $verifier->field("test")->maxLength(20)
225225
</details>
226226

227227
<details>
228-
<summary><code>disposableEmail</code> - Validates that an email is not from a disposable domain</summary>
228+
<summary><code>disposableEmail</code> - Validates that an email is not from a disposable domain, can be overri...</summary>
229+
230+
**Description:**
231+
232+
Validates that an email is not from a disposable domain, can be overriden ["@yourDisposableDomain", ...]
229233

230234
**Parameters:**
231235

@@ -237,7 +241,11 @@ $verifier->field("test")->maxLength(20)
237241
**Usage:**
238242

239243
```php
240-
$verifier->field("test")->disposableEmail([])
244+
$verifier->field("email")->disposableEmail
245+
```
246+
247+
```php
248+
$verifier->field("email")->disposableEmail(["@yourDisposableDomain", ...])
241249
```
242250

243251
</details>

docs/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
"disposableEmail": {
127127
"type": "object",
128128
"title": "DisposableEmail",
129-
"description": "Validates that an email is not from a disposable domain\n\n**Usage:**\n```php\n$verifier->field(\"test\")->disposableEmail([])\n```\n\n**Parameters:**\n- `disposables`: []",
129+
"description": "Validates that an email is not from a disposable domain, can be overriden [\"@yourDisposableDomain\", ...]\n\n**Usage:**\n```php\n$verifier->field(\"email\")->disposableEmail\n```\n```php\n$verifier->field(\"email\")->disposableEmail([\"@yourDisposableDomain\", ...])\n```\n\n**Parameters:**\n- `disposables`: []",
130130
"x-category": "String",
131131
"properties": {
132132
"disposables": {

docs/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"disposableEmail": {
123123
"type": "object",
124124
"title": "DisposableEmail",
125-
"description": "Validates that an email is not from a disposable domain\n\n**Usage:**\n```php\n$verifier->field(\"test\")->disposableEmail([])\n```\n\n**Parameters:**\n- `disposables`: []",
125+
"description": "Validates that an email is not from a disposable domain, can be overriden [\"@yourDisposableDomain\", ...]\n\n**Usage:**\n```php\n$verifier->field(\"email\")->disposableEmail\n```\n```php\n$verifier->field(\"email\")->disposableEmail([\"@yourDisposableDomain\", ...])\n```\n\n**Parameters:**\n- `disposables`: []",
126126
"x-category": "String",
127127
"properties": {
128128
"disposables": {

docs/validations.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@
126126
},
127127
"disposableEmail": {
128128
"name": "disposableEmail",
129-
"description": "Validates that an email is not from a disposable domain",
129+
"description": "Validates that an email is not from a disposable domain, can be overriden [\"@yourDisposableDomain\", ...]",
130130
"category": "String",
131131
"examples": [
132-
"$verifier->field(\"test\")->disposableEmail([])"
132+
"$verifier->field(\"email\")->disposableEmail",
133+
"$verifier->field(\"email\")->disposableEmail([\"@yourDisposableDomain\", ...])"
133134
],
134135
"parameters": [
135136
{

infection.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"source": {
3+
"directories": ["src"],
4+
"excludes": ["Documentation"]
5+
},
6+
"logs": {
7+
"text": "infection.log"
8+
},
9+
"mutators": {
10+
"@default": true,
11+
"ProtectedVisibility": {
12+
"ignore": ["*"]
13+
},
14+
"PublicVisibility": {
15+
"ignore": ["*"]
16+
}
17+
},
18+
"phpUnit": {
19+
"customPath": "vendor/bin/phpunit",
20+
"configDir": "."
21+
}
22+
}

0 commit comments

Comments
 (0)