-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathDataProviders.php
79 lines (72 loc) · 2.42 KB
/
DataProviders.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Test;
use Test\Utils\Classes\ClassWithToString;
use TRegx\CleanRegex\Internal\Definition;
class DataProviders
{
public static function invalidPregPatterns(): array
{
return [
['/{2,1}/'],
['/)unopened.group/'],
['/*starting.quantifier/'],
[' /\/'],
['/\\/'],
['/(/'],
['/{1}/'],
];
}
public static function invalidStandardPatterns(): array
{
return [
['{2,1}'],
[')unopened.group'],
['*starting.quantifier'],
['\\'],
['('],
['{1}'],
];
}
public function invalidUtf8Sequences(): array
{
return \TRegx\DataProvider\DataProviders::each([
'Invalid 2 Octet Sequence' => "\xc3\x28",
'Invalid Sequence Identifier' => "\xa0\xa1",
'Invalid 3 Octet Sequence (in 2nd Octet)' => "\xe2\x28\xa1",
'Invalid 3 Octet Sequence (in 3rd Octet)' => "\xe2\x82\x28",
'Invalid 4 Octet Sequence (in 2nd Octet)' => "\xf0\x28\x8c\xbc",
'Invalid 4 Octet Sequence (in 3rd Octet)' => "\xf0\x90\x28\xbc",
'Invalid 4 Octet Sequence (in 4th Octet)' => "\xf0\x28\x8c\x28",
]);
}
public static function allPhpTypes(string ...$except): array
{
return array_diff_key(self::typesMap(), array_flip($except));
}
private static function typesMap(): array
{
return [
'null' => [null, 'null'],
'true' => [true, 'boolean (true)'],
'false' => [false, 'boolean (false)'],
'int' => [2, 'integer (2)'],
'float' => [2.23, 'double (2.23)'],
'string' => ["She's sexy", "string ('She\'s sexy')"],
'array' => [[1, new \stdClass(), 3], 'array (3)'],
'resource' => [self::getResource(), 'resource'],
'stdClass' => [new \stdClass(), 'stdClass'],
'__toString' => [new ClassWithToString('string'), 'Test\Utils\Classes\ClassWithToString'],
'class' => [new Definition('//'), Definition::class],
'function' => [function () {
}, 'Closure']
];
}
/**
* @return resource
*/
private static function getResource()
{
$resources = get_resources();
return reset($resources);
}
}