9
9
*/
10
10
namespace PHPUnit \TextUI \Command ;
11
11
12
+ use const E_ALL ;
12
13
use const PHP_EOL ;
13
14
use function extension_loaded ;
15
+ use function in_array ;
14
16
use function ini_get ;
15
17
use function max ;
16
18
use function sprintf ;
26
28
*/
27
29
final readonly class CheckPhpConfigurationCommand implements Command
28
30
{
29
- /**
30
- * @var non-empty-array<non-empty-string, array{expectedValue: non-empty-string, valueForConfiguration: non-empty-string, requiredExtensions: list<non-empty-string>}>
31
- */
32
- private const SETTINGS = [
33
- 'display_errors ' => [
34
- 'expectedValue ' => '1 ' ,
35
- 'valueForConfiguration ' => 'On ' ,
36
- 'requiredExtensions ' => [],
37
- ],
38
- 'display_startup_errors ' => [
39
- 'expectedValue ' => '1 ' ,
40
- 'valueForConfiguration ' => 'On ' ,
41
- 'requiredExtensions ' => [],
42
- ],
43
- 'error_reporting ' => [
44
- 'expectedValue ' => '-1 ' ,
45
- 'valueForConfiguration ' => '-1 ' ,
46
- 'requiredExtensions ' => [],
47
- ],
48
- 'xdebug.show_exception_trace ' => [
49
- 'expectedValue ' => '0 ' ,
50
- 'valueForConfiguration ' => '0 ' ,
51
- 'requiredExtensions ' => ['xdebug ' ],
52
- ],
53
- 'zend.assertions ' => [
54
- 'expectedValue ' => '1 ' ,
55
- 'valueForConfiguration ' => '1 ' ,
56
- 'requiredExtensions ' => [],
57
- ],
58
- 'assert.exception ' => [
59
- 'expectedValue ' => '1 ' ,
60
- 'valueForConfiguration ' => '1 ' ,
61
- 'requiredExtensions ' => [],
62
- ],
63
- 'memory_limit ' => [
64
- 'expectedValue ' => '-1 ' ,
65
- 'valueForConfiguration ' => '-1 ' ,
66
- 'requiredExtensions ' => [],
67
- ],
68
- ];
69
31
private bool $ colorize ;
70
32
71
33
public function __construct ()
@@ -78,7 +40,7 @@ public function execute(): Result
78
40
$ lines = [];
79
41
$ shellExitCode = 0 ;
80
42
81
- foreach (self :: SETTINGS as $ name => $ setting ) {
43
+ foreach ($ this -> settings () as $ name => $ setting ) {
82
44
foreach ($ setting ['requiredExtensions ' ] as $ extension ) {
83
45
if (!extension_loaded ($ extension )) {
84
46
// @codeCoverageIgnoreStart
@@ -89,7 +51,7 @@ public function execute(): Result
89
51
90
52
$ actualValue = ini_get ($ name );
91
53
92
- if ($ actualValue === $ setting ['expectedValue ' ] ) {
54
+ if (in_array ( $ actualValue, $ setting ['expectedValues ' ], true ) ) {
93
55
$ check = $ this ->ok ();
94
56
} else {
95
57
$ check = $ this ->notOk ($ actualValue );
@@ -157,4 +119,48 @@ private function notOk(string $actualValue): string
157
119
return Color::colorizeTextBox ('fg-red, bold ' , $ message );
158
120
// @codeCoverageIgnoreEnd
159
121
}
122
+
123
+ /**
124
+ * @return non-empty-array<non-empty-string, array{expectedValues: non-empty-list<non-empty-string>, valueForConfiguration: non-empty-string, requiredExtensions: list<non-empty-string>}>
125
+ */
126
+ private function settings (): array
127
+ {
128
+ return [
129
+ 'display_errors ' => [
130
+ 'expectedValues ' => ['1 ' ],
131
+ 'valueForConfiguration ' => 'On ' ,
132
+ 'requiredExtensions ' => [],
133
+ ],
134
+ 'display_startup_errors ' => [
135
+ 'expectedValues ' => ['1 ' ],
136
+ 'valueForConfiguration ' => 'On ' ,
137
+ 'requiredExtensions ' => [],
138
+ ],
139
+ 'error_reporting ' => [
140
+ 'expectedValues ' => ['-1 ' , (string ) E_ALL ],
141
+ 'valueForConfiguration ' => '-1 ' ,
142
+ 'requiredExtensions ' => [],
143
+ ],
144
+ 'xdebug.show_exception_trace ' => [
145
+ 'expectedValues ' => ['0 ' ],
146
+ 'valueForConfiguration ' => '0 ' ,
147
+ 'requiredExtensions ' => ['xdebug ' ],
148
+ ],
149
+ 'zend.assertions ' => [
150
+ 'expectedValues ' => ['1 ' ],
151
+ 'valueForConfiguration ' => '1 ' ,
152
+ 'requiredExtensions ' => [],
153
+ ],
154
+ 'assert.exception ' => [
155
+ 'expectedValues ' => ['1 ' ],
156
+ 'valueForConfiguration ' => '1 ' ,
157
+ 'requiredExtensions ' => [],
158
+ ],
159
+ 'memory_limit ' => [
160
+ 'expectedValues ' => ['-1 ' ],
161
+ 'valueForConfiguration ' => '-1 ' ,
162
+ 'requiredExtensions ' => [],
163
+ ],
164
+ ];
165
+ }
160
166
}
0 commit comments