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\Modules\Debugger; |
||
3 | |||
4 | use Redaxscript\Db; |
||
5 | use Redaxscript\Head; |
||
6 | use Redaxscript\Module; |
||
7 | use function array_filter; |
||
8 | use function file_get_contents; |
||
9 | use function is_array; |
||
10 | use function json_encode; |
||
11 | |||
12 | /** |
||
13 | * debugger |
||
14 | * |
||
15 | * @since 4.0.0 |
||
16 | * |
||
17 | * @package Redaxscript |
||
18 | * @category Modules |
||
19 | * @author Henry Ruhs |
||
20 | */ |
||
21 | |||
22 | class Debugger extends Module\Module |
||
23 | { |
||
24 | /** |
||
25 | * array of the module |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | |||
30 | protected static $_moduleArray = |
||
31 | [ |
||
32 | 'name' => 'Debugger', |
||
33 | 'alias' => 'Debugger', |
||
34 | 'author' => 'Redaxmedia', |
||
35 | 'description' => 'Debugger', |
||
36 | 'version' => '4.0.0', |
||
37 | 'access' => '[1]' |
||
38 | ]; |
||
39 | |||
40 | /** |
||
41 | * renderStart |
||
42 | * |
||
43 | * @since 3.0.0 |
||
44 | */ |
||
45 | |||
46 | public function renderStart() : void |
||
47 | { |
||
48 | /* script */ |
||
49 | |||
50 | $script = Head\Script::getInstance(); |
||
51 | $script |
||
52 | ->init('foot') |
||
53 | ->appendFile('modules/Debugger/assets/scripts/init.js'); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * renderEnd |
||
58 | * |
||
59 | * @since 4.0.0 |
||
60 | */ |
||
61 | |||
62 | public function renderEnd() : void |
||
63 | { |
||
64 | $debuggerArray = $this->_getArray(); |
||
65 | $inline = file_get_contents('modules/Debugger/assets/scripts/debugger.js'); |
||
66 | |||
67 | /* script */ |
||
68 | |||
69 | $script = Head\Script::getInstance(); |
||
70 | echo $script |
||
71 | ->init() |
||
72 | ->transportVar('rs.modules.Debugger.data', $debuggerArray) |
||
73 | ->appendInline($inline); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * getArray |
||
78 | * |
||
79 | * @since 3.3.0 |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | |||
84 | protected function _getArray() : array |
||
85 | { |
||
86 | return array_filter( |
||
87 | [ |
||
88 | 'database' => $this->_flattenArray(Db::getQueryLog()), |
||
89 | 'registry' => $this->_flattenArray($this->_registry->getArray()), |
||
90 | 'server' => $this->_flattenArray($this->_request->get('server')), |
||
0 ignored issues
–
show
|
|||
91 | 'get' => $this->_flattenArray($this->_request->get('get')), |
||
0 ignored issues
–
show
It seems like
$this->_request->get('get') targeting Redaxscript\Request::get() can also be of type null or string ; however, Redaxscript\Modules\Debu...bugger::_flattenArray() does only seem to accept array , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
92 | 'post' => $this->_flattenArray($this->_request->get('post')), |
||
0 ignored issues
–
show
It seems like
$this->_request->get('post') targeting Redaxscript\Request::get() can also be of type null or string ; however, Redaxscript\Modules\Debu...bugger::_flattenArray() does only seem to accept array , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
93 | 'files' => $this->_flattenArray($this->_request->get('files')), |
||
0 ignored issues
–
show
It seems like
$this->_request->get('files') targeting Redaxscript\Request::get() can also be of type null or string ; however, Redaxscript\Modules\Debu...bugger::_flattenArray() does only seem to accept array , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
94 | 'session' => $this->_flattenArray($this->_request->get('session')), |
||
0 ignored issues
–
show
It seems like
$this->_request->get('session') targeting Redaxscript\Request::get() can also be of type null or string ; however, Redaxscript\Modules\Debu...bugger::_flattenArray() does only seem to accept array , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
95 | 'cookie' => $this->_flattenArray($this->_request->get('cookie')) |
||
0 ignored issues
–
show
It seems like
$this->_request->get('cookie') targeting Redaxscript\Request::get() can also be of type null or string ; however, Redaxscript\Modules\Debu...bugger::_flattenArray() does only seem to accept array , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
96 | ]); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * flattenArray |
||
101 | * |
||
102 | * @since 4.0.0 |
||
103 | * |
||
104 | * @param array $dirtyArray |
||
105 | * |
||
106 | * @return array |
||
107 | */ |
||
108 | |||
109 | protected function _flattenArray(array $dirtyArray = []) : array |
||
110 | { |
||
111 | $flatArray = []; |
||
112 | |||
113 | /* process dirty */ |
||
114 | |||
115 | foreach ($dirtyArray as $key => $value) |
||
116 | { |
||
117 | $flatArray[$key] = is_array($value) ? json_encode($value) : $value; |
||
118 | } |
||
119 | return $flatArray; |
||
120 | } |
||
121 | } |
||
122 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.