@@ -25,13 +25,7 @@ public static function asyncifyProvider(): array
25
25
function (...$ args ) {
26
26
return \file_get_contents (...$ args );
27
27
} :
28
- <<<EOF
29
- (
30
- function (... \$args) {
31
- return file_get_contents(... \$args);
32
- }
33
- )
34
- EOF
28
+ '(function (...$args) { return file_get_contents(...$args); }) '
35
29
),
36
30
['foo.txt ' ]
37
31
],
@@ -43,20 +37,57 @@ function (...\$args) {
43
37
],
44
38
[
45
39
[
46
- <<<EOF
47
- (
48
- function ( \$cmd) {
49
- return exec( \$cmd);
50
- }
51
- )
52
- EOF ,
40
+ '(function ($cmd) { return exec($cmd); }) ' ,
53
41
['echo "foo" ' ],
54
42
],
55
43
(
56
44
PHP_THREADABLE ?
57
45
'/(Call to undefined function)/i ' :
58
46
'/^(foo)$/ '
59
47
)
48
+ ],
49
+ [
50
+ [
51
+ (
52
+ PHP_THREADABLE ?
53
+ function (string $ value ) {
54
+ return ['foo ' => $ value ];
55
+ } :
56
+ '(function (string $value) { return ["foo" => $value]; }) '
57
+ ),
58
+ ['foo ' ]
59
+ ],
60
+ ['foo ' => 'foo ' ],
61
+ ],
62
+ [
63
+ [
64
+ (
65
+ PHP_THREADABLE ?
66
+ function (int $ value ) {
67
+ return (object ) ['foo ' => $ value ];
68
+ } :
69
+ '(function (int $value) { return (object) ["foo" => $value]; }) '
70
+ ),
71
+ [12 ]
72
+ ],
73
+ (object ) ['foo ' => 12 ]
74
+ ],
75
+ [
76
+ [
77
+ (
78
+ PHP_THREADABLE ?
79
+ function (int $ next ) {
80
+ if ($ next < 3 ) {
81
+ throw new \Exception ('Invalid argument ' );
82
+ }
83
+
84
+ return $ next + 2 ;
85
+ } :
86
+ '(function (int $next) { if ($next < 3) { throw new Exception("Invalid argument"); } return $next + 2; }) '
87
+ ),
88
+ [2 ]
89
+ ],
90
+ '/(Invalid argument)/i '
60
91
]
61
92
];
62
93
}
@@ -75,10 +106,17 @@ function (\Throwable $err) {
75
106
}
76
107
)(...$ args );
77
108
78
- $ this ->assertMatchesRegularExpression (
79
- $ result ,
80
- $ exec
81
- );
109
+ if (\is_string ($ result )) {
110
+ $ this ->assertMatchesRegularExpression (
111
+ $ result ,
112
+ $ exec
113
+ );
114
+ } else {
115
+ $ this ->assertEquals (
116
+ $ result ,
117
+ $ exec
118
+ );
119
+ }
82
120
}
83
121
84
122
/**
@@ -96,9 +134,16 @@ function (\Throwable $err) {
96
134
}
97
135
)(...$ args );
98
136
99
- $ this ->assertMatchesRegularExpression (
100
- $ result ,
101
- $ exec
102
- );
137
+ if (\is_string ($ result )) {
138
+ $ this ->assertMatchesRegularExpression (
139
+ $ result ,
140
+ $ exec
141
+ );
142
+ } else {
143
+ $ this ->assertEquals (
144
+ $ result ,
145
+ $ exec
146
+ );
147
+ }
103
148
}
104
149
}
0 commit comments