|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace Genesis\Commands\Test; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use Genesis\Commands\Command; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @author Adam Bisek <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class Php extends Command |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
/** @var string[] */ |
|
16
|
|
|
private $errors; |
|
17
|
|
|
|
|
18
|
|
|
private $settings; |
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @return array |
|
23
|
|
|
*/ |
|
24
|
|
|
public function getSettings() |
|
25
|
|
|
{ |
|
26
|
|
|
return $this->settings; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param array $settings |
|
32
|
|
|
*/ |
|
33
|
1 |
|
public function setSettings($settings) |
|
34
|
|
|
{ |
|
35
|
1 |
|
$this->settings = $settings; |
|
36
|
1 |
|
} |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
1 |
|
public function execute() |
|
40
|
|
|
{ |
|
41
|
1 |
|
$this->errors = []; |
|
42
|
|
|
|
|
43
|
1 |
|
if (isset($this->settings['settings'])) { |
|
44
|
1 |
|
$this->testSettings($this->settings['settings']); |
|
45
|
1 |
|
} |
|
46
|
1 |
|
if (isset($this->settings['extensions'])) { |
|
47
|
1 |
|
$this->testExtensions($this->settings['extensions']); |
|
48
|
1 |
|
} |
|
49
|
|
|
|
|
50
|
1 |
|
if (!empty($this->errors)) { |
|
51
|
|
|
$this->error(implode(PHP_EOL, $this->errors)); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
1 |
|
$this->log('PHP settings correct.'); |
|
55
|
1 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
1 |
|
private function testSettings(array $settings) |
|
59
|
|
|
{ |
|
60
|
1 |
|
foreach ($settings as $option => $requiredValue) { |
|
61
|
1 |
|
$setValue = ini_get($option); |
|
62
|
1 |
|
if ($requiredValue === '0') { |
|
63
|
|
|
if ($setValue !== '' && $setValue && $setValue != $requiredValue) { // intentionally != |
|
64
|
|
|
$this->errors[] = 'PHP option ' . $option . ' is not set to required value "' . $requiredValue . '".'; |
|
65
|
|
|
} |
|
66
|
|
|
} else { |
|
67
|
1 |
|
if ($setValue != $requiredValue) { // intentionally |
|
68
|
|
|
$this->errors[] = 'PHP option ' . $option . ' is not set to required value "' . $requiredValue . '".'; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
1 |
|
} |
|
72
|
1 |
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
1 |
|
private function testExtensions(array $extensions) |
|
76
|
|
|
{ |
|
77
|
1 |
|
foreach ($extensions as $extension) { |
|
78
|
1 |
|
if (!extension_loaded($extension)) { |
|
79
|
|
|
$this->errors[] = 'Required PHP extension "' . $extension . '" is not loaded.'; |
|
80
|
|
|
} |
|
81
|
1 |
|
} |
|
82
|
1 |
|
} |
|
83
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
|