diff --git a/README.md b/README.md index a17cf38..2282014 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,12 @@ This extension specifies types of values passed to: * `Assert::minLength` * `Assert::maxLength` * `Assert::lengthBetween` +* `Assert::uuid` +* `Assert::ip` +* `Assert::ipv4` +* `Assert::ipv6` +* `Assert::email` +* `Assert::notWhitespaceOnly` * `nullOr*` and `all*` variants of the above methods diff --git a/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php b/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php index a2ff1ce..9ebcfb9 100644 --- a/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php +++ b/src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php @@ -713,6 +713,10 @@ private static function getExpressionResolvers(): array ); }, ]; + + foreach (['uuid', 'ip', 'ipv4', 'ipv6', 'email', 'notWhitespaceOnly'] as $key) { + self::$resolvers[$key] = self::$resolvers['stringNotEmpty']; + } } return self::$resolvers; diff --git a/tests/Type/WebMozartAssert/data/bug-85.php b/tests/Type/WebMozartAssert/data/bug-85.php index 8a0a60f..3a50f4b 100644 --- a/tests/Type/WebMozartAssert/data/bug-85.php +++ b/tests/Type/WebMozartAssert/data/bug-85.php @@ -28,7 +28,7 @@ function bar($url): void public function baz(string $s): void { Assert::stringNotEmpty($s); - Assert::uuid($s); + Assert::digits($s); } } diff --git a/tests/Type/WebMozartAssert/data/string.php b/tests/Type/WebMozartAssert/data/string.php index dc9f86a..cb5178b 100644 --- a/tests/Type/WebMozartAssert/data/string.php +++ b/tests/Type/WebMozartAssert/data/string.php @@ -73,4 +73,39 @@ public function lengthBetween(string $a, string $b, string $c, string $d, string \PHPStan\Testing\assertType('non-empty-string|null', $f); } + public function uuid(string $a): void + { + Assert::uuid($a); + \PHPStan\Testing\assertType('non-empty-string', $a); + } + + public function ip(string $a): void + { + Assert::ip($a); + \PHPStan\Testing\assertType('non-empty-string', $a); + } + + public function ipv4(string $a): void + { + Assert::ipv4($a); + \PHPStan\Testing\assertType('non-empty-string', $a); + } + + public function ipv6(string $a): void + { + Assert::ipv6($a); + \PHPStan\Testing\assertType('non-empty-string', $a); + } + + public function email(string $a): void + { + Assert::email($a); + \PHPStan\Testing\assertType('non-empty-string', $a); + } + + public function notWhitespaceOnly(string $a): void + { + Assert::notWhitespaceOnly($a); + \PHPStan\Testing\assertType('non-empty-string', $a); + } }