These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | 7 | { |
|
27 | /** |
||
28 | 7 | * automate run |
|
29 | 7 | * |
|
30 | 7 | * @since 3.1.0 |
|
31 | 7 | */ |
|
32 | 7 | ||
33 | 7 | protected function _autorun() |
|
34 | 7 | { |
|
35 | $this->_setServer(); |
||
36 | $this->_setClient(); |
||
37 | $this->_setDriver(); |
||
38 | $this->_setModule(); |
||
39 | $this->_setPhp(); |
||
40 | $this->_setOpcache(); |
||
41 | } |
||
42 | 7 | ||
43 | /** |
||
44 | 7 | * set the server |
|
45 | 7 | * |
|
46 | 7 | * @since 3.1.0 |
|
47 | 7 | */ |
|
48 | |||
49 | protected function _setServer() |
||
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 | 7 | ||
56 | /* set the registry */ |
||
57 | |||
58 | $this->_registry->set('file', $file->getOutput()); |
||
59 | $this->_registry->set('root', $root->getOutput()); |
||
60 | $this->_registry->set('host', $host->getOutput()); |
||
61 | $this->_registry->set('token', $token->getOutput()); |
||
62 | } |
||
63 | 7 | ||
64 | /** |
||
65 | 7 | * set the client |
|
66 | 7 | * |
|
67 | 7 | * @since 3.1.0 |
|
68 | 7 | */ |
|
69 | 7 | ||
70 | 7 | protected function _setClient() |
|
71 | { |
||
72 | $browser = new Client\Browser($this->_request); |
||
73 | $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 | 7 | ||
79 | 7 | /* set the registry */ |
|
80 | 7 | ||
81 | $this->_registry->set('myBrowser', $browser->getOutput()); |
||
82 | $this->_registry->set('myBrowserVersion', $version->getOutput()); |
||
83 | $this->_registry->set('myEngine', $engine->getOutput()); |
||
84 | $this->_registry->set('myMobile', $mobile->getOutput()); |
||
85 | $this->_registry->set('myTablet', $tablet->getOutput()); |
||
86 | $this->_registry->set('myDesktop', $desktop->getOutput()); |
||
87 | } |
||
88 | 7 | ||
89 | /** |
||
90 | 7 | * set the driver |
|
91 | * |
||
92 | * @since 3.1.0 |
||
93 | */ |
||
94 | 7 | ||
95 | protected function _setDriver() |
||
96 | 7 | { |
|
97 | 7 | $driverArray = []; |
|
98 | |||
99 | 7 | /* process driver */ |
|
100 | |||
101 | foreach (PDO::getAvailableDrivers() as $driver) |
||
102 | 7 | { |
|
103 | 7 | $driver = $driver === 'sqlsrv' ? 'mssql' : $driver; |
|
104 | if (is_dir('database' . DIRECTORY_SEPARATOR . $driver)) |
||
105 | { |
||
106 | $driverArray[$driver] = $driver; |
||
107 | } |
||
108 | } |
||
109 | $this->_registry->set('driverArray', $driverArray); |
||
110 | } |
||
111 | 7 | ||
112 | /** |
||
113 | 7 | * set the module |
|
114 | * |
||
115 | * @since 3.1.0 |
||
116 | 7 | */ |
|
117 | |||
118 | protected function _setModule() |
||
119 | { |
||
120 | $moduleArray = function_exists('apache_get_modules') ? apache_get_modules() : []; |
||
121 | $fallbackArray = |
||
122 | [ |
||
123 | 7 | 'mod_deflate', |
|
124 | 'mod_headers', |
||
125 | 7 | 'mod_rewrite' |
|
126 | ]; |
||
127 | 7 | ||
128 | /* process fallback */ |
||
129 | 7 | ||
130 | if (!$moduleArray) |
||
131 | { |
||
132 | foreach ($fallbackArray as $value) |
||
133 | 7 | { |
|
134 | 7 | if (getenv('REDIRECT_' . $value) === 'on') |
|
135 | { |
||
136 | $moduleArray[$value] = true; |
||
137 | } |
||
138 | } |
||
139 | } |
||
140 | $this->_registry->set('moduleArray', $moduleArray); |
||
141 | } |
||
142 | 7 | ||
143 | /** |
||
144 | 7 | * set the php |
|
145 | 7 | * |
|
146 | 7 | * @since 3.2.3 |
|
147 | */ |
||
148 | 7 | ||
149 | protected function _setPhp() |
||
150 | { |
||
151 | $phpOs = strtolower(PHP_OS); |
||
152 | $phpVersion = PHP_VERSION; |
||
153 | if (strpos($phpOs, 'linux') === 0) |
||
154 | 7 | { |
|
155 | 7 | $this->_registry->set('phpOs', 'linux'); |
|
156 | 7 | } |
|
157 | else if (strpos($phpOs, 'win') === 0) |
||
158 | { |
||
159 | $this->_registry->set('phpOs', 'windows'); |
||
160 | } |
||
161 | $this->_registry->set('phpVersion', $phpVersion); |
||
162 | $this->_registry->set('phpStatus', version_compare($phpVersion, '7.2', '>=')); |
||
0 ignored issues
–
show
|
|||
163 | } |
||
164 | 7 | ||
165 | /** |
||
166 | 7 | * set the opcache |
|
167 | 7 | * |
|
168 | 7 | * @since 4.0.0 |
|
169 | */ |
||
170 | |||
171 | protected function _setOpcache() |
||
172 | { |
||
173 | $opcacheArray = function_exists('opcache_get_status') ? opcache_get_status(false) : []; |
||
174 | $this->_registry->set('opcacheArray', $opcacheArray); |
||
175 | } |
||
176 | } |
||
177 |
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: