@@ -54,6 +54,9 @@ public static function merge(mixed $value, mixed $base): mixed
5454 }
5555
5656
57+ /**
58+ * Returns the type of a property or parameter as a string, or null if not determinable.
59+ */
5760 public static function getPropertyType (\ReflectionProperty |\ReflectionParameter $ prop ): ?string
5861 {
5962 if ($ type = Nette \Utils \Type::fromReflection ($ prop )) {
@@ -89,6 +92,9 @@ public static function parseAnnotation(\ReflectionClass|\ReflectionProperty $ref
8992 }
9093
9194
95+ /**
96+ * Formats a value for use in error messages (e.g., 'hello', true, object stdClass).
97+ */
9298 public static function formatValue (mixed $ value ): string
9399 {
94100 if ($ value instanceof DynamicParameter) {
@@ -105,6 +111,9 @@ public static function formatValue(mixed $value): string
105111 }
106112
107113
114+ /**
115+ * Adds a TypeMismatch error to the context if the value does not match the expected type.
116+ */
108117 public static function validateType (mixed $ value , string $ expected , Context $ context ): void
109118 {
110119 if (!Nette \Utils \Validators::is ($ value , $ expected )) {
@@ -119,7 +128,10 @@ public static function validateType(mixed $value, string $expected, Context $con
119128 }
120129
121130
122- /** @param array{?float, ?float} $range */
131+ /**
132+ * Adds a range error to the context if the value (or its length for strings/arrays) is outside the given range.
133+ * @param array{?float, ?float} $range
134+ */
123135 public static function validateRange (mixed $ value , array $ range , Context $ context , string $ types = '' ): void
124136 {
125137 if (is_array ($ value ) || is_string ($ value )) {
@@ -146,14 +158,20 @@ public static function validateRange(mixed $value, array $range, Context $contex
146158 }
147159
148160
149- /** @param array{?float, ?float} $range */
161+ /**
162+ * Checks whether a value falls within the given [min, max] range (null means no bound).
163+ * @param array{?float, ?float} $range
164+ */
150165 public static function isInRange (mixed $ value , array $ range ): bool
151166 {
152167 return ($ range [0 ] === null || $ value >= $ range [0 ])
153168 && ($ range [1 ] === null || $ value <= $ range [1 ]);
154169 }
155170
156171
172+ /**
173+ * Adds a PatternMismatch error to the context if the value does not match the pattern.
174+ */
157175 public static function validatePattern (string $ value , string $ pattern , Context $ context ): void
158176 {
159177 if (!preg_match ("\x01^(?: $ pattern)$ \x01Du " , $ value )) {
@@ -166,7 +184,10 @@ public static function validatePattern(string $value, string $pattern, Context $
166184 }
167185
168186
169- /** @return \Closure(mixed): mixed */
187+ /**
188+ * Returns a closure that casts a value to the given type (built-in, class with constructor, or plain class).
189+ * @return \Closure(mixed): mixed
190+ */
170191 public static function getCastStrategy (string $ type ): \Closure
171192 {
172193 if (Nette \Utils \Validators::isBuiltinType ($ type )) {
0 commit comments