1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Bootstrap; |
3
|
|
|
|
4
|
|
|
use PDO; |
5
|
|
|
use Redaxscript\Client; |
6
|
|
|
use Redaxscript\Server; |
7
|
|
|
use function function_exists; |
8
|
|
|
use function getenv; |
9
|
|
|
use function is_dir; |
10
|
|
|
use function opcache_get_status; |
11
|
|
|
use function strpos; |
12
|
|
|
use function strtolower; |
13
|
|
|
use function version_compare; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* children class to boot the common |
17
|
|
|
* |
18
|
|
|
* @since 3.1.0 |
19
|
|
|
* |
20
|
|
|
* @package Redaxscript |
21
|
|
|
* @category Bootstrap |
22
|
|
|
* @author Henry Ruhs |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
class Common extends BootstrapAbstract |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* automate run |
29
|
|
|
* |
30
|
|
|
* @since 3.1.0 |
31
|
|
|
*/ |
32
|
|
|
|
33
|
7 |
|
public function autorun() : void |
34
|
|
|
{ |
35
|
7 |
|
$this->_setServer(); |
36
|
7 |
|
$this->_setClient(); |
37
|
7 |
|
$this->_setDriver(); |
38
|
7 |
|
$this->_setModule(); |
39
|
7 |
|
$this->_setPhp(); |
40
|
7 |
|
$this->_setOpcache(); |
41
|
7 |
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* set the server |
45
|
|
|
* |
46
|
|
|
* @since 3.1.0 |
47
|
|
|
*/ |
48
|
|
|
|
49
|
7 |
|
protected function _setServer() : void |
50
|
|
|
{ |
51
|
7 |
|
$file = new Server\File($this->_request); |
52
|
7 |
|
$root = new Server\Root($this->_request); |
53
|
7 |
|
$host = new Server\Host($this->_request); |
54
|
7 |
|
$token = new Server\Token($this->_request); |
55
|
|
|
|
56
|
|
|
/* set the registry */ |
57
|
|
|
|
58
|
7 |
|
$this->_registry->set('file', $file->getOutput()); |
59
|
7 |
|
$this->_registry->set('root', $root->getOutput()); |
60
|
7 |
|
$this->_registry->set('host', $host->getOutput()); |
61
|
7 |
|
$this->_registry->set('token', $token->getOutput()); |
62
|
7 |
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* set the client |
66
|
|
|
* |
67
|
|
|
* @since 3.1.0 |
68
|
|
|
*/ |
69
|
|
|
|
70
|
7 |
|
protected function _setClient() : void |
71
|
|
|
{ |
72
|
7 |
|
$browser = new Client\Browser($this->_request); |
73
|
7 |
|
$version = new Client\Version($this->_request); |
74
|
7 |
|
$engine = new Client\Engine($this->_request); |
75
|
7 |
|
$mobile = new Client\Mobile($this->_request); |
76
|
7 |
|
$tablet = new Client\Tablet($this->_request); |
77
|
7 |
|
$desktop = new Client\Desktop($this->_request); |
78
|
|
|
|
79
|
|
|
/* set the registry */ |
80
|
|
|
|
81
|
7 |
|
$this->_registry->set('myBrowser', $browser->getOutput()); |
82
|
7 |
|
$this->_registry->set('myBrowserVersion', $version->getOutput()); |
83
|
7 |
|
$this->_registry->set('myEngine', $engine->getOutput()); |
84
|
7 |
|
$this->_registry->set('myMobile', $mobile->getOutput()); |
85
|
7 |
|
$this->_registry->set('myTablet', $tablet->getOutput()); |
86
|
7 |
|
$this->_registry->set('myDesktop', $desktop->getOutput()); |
87
|
7 |
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* set the driver |
91
|
|
|
* |
92
|
|
|
* @since 3.1.0 |
93
|
|
|
*/ |
94
|
|
|
|
95
|
7 |
|
protected function _setDriver() : void |
96
|
|
|
{ |
97
|
7 |
|
$driverArray = []; |
98
|
|
|
|
99
|
|
|
/* process driver */ |
100
|
|
|
|
101
|
7 |
|
foreach (PDO::getAvailableDrivers() as $driver) |
102
|
|
|
{ |
103
|
7 |
|
$driver = $driver === 'sqlsrv' ? 'mssql' : $driver; |
104
|
7 |
|
if (is_dir('database' . DIRECTORY_SEPARATOR . $driver)) |
105
|
|
|
{ |
106
|
7 |
|
$driverArray[$driver] = $driver; |
107
|
|
|
} |
108
|
|
|
} |
109
|
7 |
|
$this->_registry->set('driverArray', $driverArray); |
110
|
7 |
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* set the module |
114
|
|
|
* |
115
|
|
|
* @since 3.1.0 |
116
|
|
|
*/ |
117
|
|
|
|
118
|
7 |
|
protected function _setModule() : void |
119
|
|
|
{ |
120
|
7 |
|
$moduleArray = function_exists('apache_get_modules') ? apache_get_modules() : []; |
121
|
|
|
$fallbackArray = |
122
|
|
|
[ |
123
|
7 |
|
'mod_brotli', |
124
|
|
|
'mod_deflate', |
125
|
|
|
'mod_headers', |
126
|
|
|
'mod_rewrite' |
127
|
|
|
]; |
128
|
|
|
|
129
|
|
|
/* process fallback */ |
130
|
|
|
|
131
|
7 |
|
if (!$moduleArray) |
132
|
|
|
{ |
133
|
7 |
|
foreach ($fallbackArray as $value) |
134
|
|
|
{ |
135
|
7 |
|
if (getenv('REDIRECT_' . $value) === 'on') |
136
|
|
|
{ |
137
|
1 |
|
$moduleArray[$value] = true; |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
} |
141
|
7 |
|
$this->_registry->set('moduleArray', $moduleArray); |
142
|
7 |
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* set the php |
146
|
|
|
* |
147
|
|
|
* @since 3.2.3 |
148
|
|
|
*/ |
149
|
|
|
|
150
|
7 |
|
protected function _setPhp() : void |
151
|
|
|
{ |
152
|
7 |
|
$phpOs = strtolower(PHP_OS); |
153
|
7 |
|
$phpVersion = PHP_VERSION; |
154
|
7 |
|
if (strpos($phpOs, 'linux') === 0) |
155
|
|
|
{ |
156
|
7 |
|
$this->_registry->set('phpOs', 'linux'); |
157
|
|
|
} |
158
|
|
|
else if (strpos($phpOs, 'win') === 0) |
159
|
|
|
{ |
160
|
|
|
$this->_registry->set('phpOs', 'windows'); |
161
|
|
|
} |
162
|
7 |
|
$this->_registry->set('phpVersion', $phpVersion); |
163
|
7 |
|
$this->_registry->set('phpStatus', version_compare($phpVersion, '7.2', '>=')); |
|
|
|
|
164
|
7 |
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* set the opcache |
168
|
|
|
* |
169
|
|
|
* @since 4.0.0 |
170
|
|
|
*/ |
171
|
|
|
|
172
|
7 |
|
protected function _setOpcache() : void |
173
|
|
|
{ |
174
|
7 |
|
$opcacheArray = function_exists('opcache_get_status') ? opcache_get_status(false) : []; |
175
|
7 |
|
$this->_registry->set('opcacheArray', $opcacheArray); |
176
|
7 |
|
} |
177
|
|
|
} |
178
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: