We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2f751f1 commit ac90a28Copy full SHA for ac90a28
2 files changed
src/Utils/Validators.php
@@ -37,6 +37,7 @@ class Validators
37
'callable' => [__CLASS__, 'isCallable'],
38
'iterable' => 'is_iterable',
39
'list' => [Arrays::class, 'isList'],
40
+ 'mixed' => [__CLASS__, 'isMixed'],
41
'none' => [__CLASS__, 'isNone'],
42
'number' => [__CLASS__, 'isNumber'],
43
'numeric' => [__CLASS__, 'isNumeric'],
@@ -60,6 +61,10 @@ class Validators
60
61
'url' => [__CLASS__, 'isUrl'],
62
63
// environment validation
64
+ 'class' => 'class_exists',
65
+ 'interface' => 'interface_exists',
66
+ 'directory' => 'is_dir',
67
+ 'file' => 'is_file',
68
'type' => [__CLASS__, 'isType'],
69
];
70
@@ -236,6 +241,13 @@ public static function isNone($value): bool
236
241
}
237
242
238
243
244
+ /** @internal */
245
+ public static function isMixed(): bool
246
+ {
247
+ return true;
248
+ }
249
+
250
239
251
/**
240
252
* Finds whether a variable is a zero-based integer indexed array.
253
*/
tests/Utils/Validators.is().phpt
@@ -170,6 +170,12 @@ test(function () {
170
});
171
172
173
+test(function () {
174
+ Assert::true(Validators::is([], 'mixed'));
175
+ Assert::true(Validators::is(null, 'mixed'));
176
+});
177
178
179
test(function () {
180
Assert::false(Validators::is('', 'email'));
181
Assert::false(Validators::is(false, 'email'));
@@ -321,6 +327,32 @@ test(function () {
321
327
322
328
323
329
330
331
+ Assert::true(Validators::is('rimmer', 'class'));
332
+ Assert::false(Validators::is('kryton', 'class'));
333
+ Assert::false(Validators::is('1', 'class'));
334
335
336
337
338
+ Assert::false(Validators::is('rimmer', 'interface'));
339
+ Assert::true(Validators::is('kryton', 'interface'));
340
+ Assert::false(Validators::is('1', 'interface'));
341
342
343
344
345
+ Assert::true(Validators::is(__FILE__, 'file'));
346
+ Assert::false(Validators::is(__FILE__ . 'xx', 'class'));
347
348
349
350
351
+ Assert::true(Validators::is(__DIR__, 'directory'));
352
+ Assert::false(Validators::is(__DIR__ . 'xx', 'directory'));
353
354
355
324
356
325
357
Assert::true(Validators::is('Item', 'identifier'));
326
358
Assert::false(Validators::is('0Item', 'identifier'));
0 commit comments