@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @param string[] ...$relation_names any list of relations to return |
60 | - * @return instance of Entity object |
|
60 | + * @return Entity of Entity object |
|
61 | 61 | */ |
62 | 62 | public function with(string ...$relation_names) |
63 | 63 | { |
@@ -129,6 +129,9 @@ |
||
129 | 129 | return $ret; |
130 | 130 | } |
131 | 131 | |
132 | + /** |
|
133 | + * @param integer $key |
|
134 | + */ |
|
132 | 135 | public static function top(array $outputs, ?string $key = null) : void |
133 | 136 | { |
134 | 137 | if (empty($outputs)) return; |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | case 'string' : $length = strlen($var); $var = '\'' . htmlentities($var) . '\''; break; |
110 | 110 | case 'NULL' : return '<span class="empty">NULL</span>'; break; |
111 | 111 | } |
112 | - $ret = '<span class="value ' . $type .'">' . $var . '</span> '; |
|
112 | + $ret = '<span class="value ' . $type .'">' . $var . '</span> '; |
|
113 | 113 | |
114 | - if ($type == 'string') { |
|
115 | - $ret .= '<span class="type">string[' . $length . ']</span>'; |
|
116 | - } else { |
|
117 | - $ret .= '<span class="type">' . $type . '</span>'; |
|
118 | - } |
|
114 | + if ($type == 'string') { |
|
115 | + $ret .= '<span class="type">string[' . $length . ']</span>'; |
|
116 | + } else { |
|
117 | + $ret .= '<span class="type">' . $type . '</span>'; |
|
118 | + } |
|
119 | 119 | return $ret; |
120 | 120 | } |
121 | 121 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | { |
124 | 124 | extract($location); |
125 | 125 | $ret = "line: <span>$line</span> ". |
126 | - "file: <span>$file</span> "; |
|
126 | + "file: <span>$file</span> "; |
|
127 | 127 | $ret .= isset($class) ? "class: <span>$class</span> " :''; |
128 | 128 | $ret .= isset($function) && $function != 'include' ? "function: <span>$function</span> " :''; |
129 | 129 | return $ret; |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | $debug->current_depth--; |
53 | 53 | return $ret . '<li><span class="empty"> -- Blacklisted Object Avoided -- </span></li></ul>'; |
54 | 54 | } |
55 | - if (isset($debug->object_references[$hash])) { |
|
55 | + if (isset($debug->object_references[$hash])) { |
|
56 | 56 | $debug->current_depth--; |
57 | 57 | return $ret . '<li><span class="empty"> -- Object Recursion Avoided -- </span></li></ul>'; |
58 | 58 | } |
59 | - if (in_array('object', $debug->options['avoid'])) { |
|
59 | + if (in_array('object', $debug->options['avoid'])) { |
|
60 | 60 | $debug->current_depth--; |
61 | 61 | return $ret . '<li><span class="empty"> -- Object Type Avoided -- </span></li></ul>'; |
62 | 62 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | $debug->current_depth--; |
78 | 78 | if ($props == '') return $ret .= '<li><span class="empty"> -- No properties -- </span></li></ul>'; |
79 | - else $ret .= $props; |
|
79 | + else $ret .= $props; |
|
80 | 80 | $ret .= '</ul>'; |
81 | 81 | return $ret; |
82 | 82 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | case 'string' : $length = strlen($var); $var = '\'' . htmlentities($var) . '\''; break; |
110 | 110 | case 'NULL' : return '<span class="empty">NULL</span>'; break; |
111 | 111 | } |
112 | - $ret = '<span class="value ' . $type .'">' . $var . '</span> '; |
|
112 | + $ret = '<span class="value ' . $type . '">' . $var . '</span> '; |
|
113 | 113 | |
114 | 114 | if ($type == 'string') { |
115 | 115 | $ret .= '<span class="type">string[' . $length . ']</span>'; |
@@ -122,14 +122,14 @@ discard block |
||
122 | 122 | public static function locationString(array $location) : string |
123 | 123 | { |
124 | 124 | extract($location); |
125 | - $ret = "line: <span>$line</span> ". |
|
125 | + $ret = "line: <span>$line</span> " . |
|
126 | 126 | "file: <span>$file</span> "; |
127 | - $ret .= isset($class) ? "class: <span>$class</span> " :''; |
|
128 | - $ret .= isset($function) && $function != 'include' ? "function: <span>$function</span> " :''; |
|
127 | + $ret .= isset($class) ? "class: <span>$class</span> " : ''; |
|
128 | + $ret .= isset($function) && $function != 'include' ? "function: <span>$function</span> " : ''; |
|
129 | 129 | return $ret; |
130 | 130 | } |
131 | 131 | |
132 | - public static function top(array $outputs, ?string $key = null) : void |
|
132 | + public static function top(array $outputs, ? string $key = null) : void |
|
133 | 133 | { |
134 | 134 | if (empty($outputs)) return; |
135 | 135 | echo '<div id="debugger">'; |
@@ -18,9 +18,10 @@ discard block |
||
18 | 18 | $ret .= '<ul class="array">'; |
19 | 19 | if (in_array('array', $debug->options['avoid'])) { |
20 | 20 | $ret .= '<li><span class="empty"> -- Array Type Avoided -- </span></li>'; |
21 | - } else |
|
22 | - foreach ($array as $key => $value) { |
|
21 | + } else { |
|
22 | + foreach ($array as $key => $value) { |
|
23 | 23 | $ret .= '<li>[ <span class="key">' . $key . '</span> ] => '; |
24 | + } |
|
24 | 25 | if (is_string($key) && in_array($key, $debug->options['blacklist']['key'])) { |
25 | 26 | $ret .= '<span class="empty"> -- Blacklisted Key Avoided -- </span></li>'; |
26 | 27 | continue; |
@@ -75,8 +76,11 @@ discard block |
||
75 | 76 | $props .= self::dump_properties($reflection, $obj, $type, $rule, $debug); |
76 | 77 | } |
77 | 78 | $debug->current_depth--; |
78 | - if ($props == '') return $ret .= '<li><span class="empty"> -- No properties -- </span></li></ul>'; |
|
79 | - else $ret .= $props; |
|
79 | + if ($props == '') { |
|
80 | + return $ret .= '<li><span class="empty"> -- No properties -- </span></li></ul>'; |
|
81 | + } else { |
|
82 | + $ret .= $props; |
|
83 | + } |
|
80 | 84 | $ret .= '</ul>'; |
81 | 85 | return $ret; |
82 | 86 | } |
@@ -92,10 +96,11 @@ discard block |
||
92 | 96 | $value = $refProp->getValue($obj); |
93 | 97 | $ret .= '<li>'; |
94 | 98 | $ret .= '<span class="access">' . $type . '</span> <span class="property">' . $property . '</span> '; |
95 | - if (in_array($property, $debug->options['blacklist']['property'])) |
|
96 | - $ret .= ' : <span class="empty"> -- Blacklisted Property Avoided -- </span>'; |
|
97 | - else |
|
98 | - $ret .= ' : ' . $debug->dump_it($value); |
|
99 | + if (in_array($property, $debug->options['blacklist']['property'])) { |
|
100 | + $ret .= ' : <span class="empty"> -- Blacklisted Property Avoided -- </span>'; |
|
101 | + } else { |
|
102 | + $ret .= ' : ' . $debug->dump_it($value); |
|
103 | + } |
|
99 | 104 | $ret .= '</li>'; |
100 | 105 | } |
101 | 106 | return $i ? $ret : ''; |
@@ -131,7 +136,9 @@ discard block |
||
131 | 136 | |
132 | 137 | public static function top(array $outputs, ?string $key = null) : void |
133 | 138 | { |
134 | - if (empty($outputs)) return; |
|
139 | + if (empty($outputs)) { |
|
140 | + return; |
|
141 | + } |
|
135 | 142 | echo '<div id="debugger">'; |
136 | 143 | if ($key !== null) { |
137 | 144 | if (!isset($outputs[$key])) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Get the singleton instance |
32 | 32 | * |
33 | - * @return alkemann\hl\debug\util\Debug |
|
33 | + * @return Debug |
|
34 | 34 | */ |
35 | 35 | public static function get_instance() : Debug |
36 | 36 | { |
@@ -112,6 +112,9 @@ discard block |
||
112 | 112 | $this->__out($key); |
113 | 113 | } |
114 | 114 | |
115 | + /** |
|
116 | + * @param integer $key |
|
117 | + */ |
|
115 | 118 | private function __out($key = null) : void |
116 | 119 | { |
117 | 120 | if ($key !== null) { |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | public $options; |
28 | 28 | public $output = array('<style type="text/css">@import url("/css/debug.css");</style>'); |
29 | 29 | |
30 | - /** |
|
31 | - * Get the singleton instance |
|
32 | - * |
|
33 | - * @return alkemann\hl\debug\util\Debug |
|
34 | - */ |
|
30 | + /** |
|
31 | + * Get the singleton instance |
|
32 | + * |
|
33 | + * @return alkemann\hl\debug\util\Debug |
|
34 | + */ |
|
35 | 35 | public static function get_instance() : Debug |
36 | 36 | { |
37 | 37 | if (!static::$__instance) { |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | return static::$__instance; |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Dump |
|
46 | - * |
|
47 | - * @param mixed $var |
|
48 | - * @param array $options |
|
49 | - */ |
|
44 | + /** |
|
45 | + * Dump |
|
46 | + * |
|
47 | + * @param mixed $var |
|
48 | + * @param array $options |
|
49 | + */ |
|
50 | 50 | public function dump($var, $options = array()) : void |
51 | 51 | { |
52 | 52 | $options += self::$defaults + array('split' => false, 'trace' => false); |
@@ -62,76 +62,76 @@ discard block |
||
62 | 62 | if ($options['split'] && is_array($var)) { |
63 | 63 | $this->current_depth = 0; |
64 | 64 | foreach ($var as $one) { |
65 | - $dump = array_merge($dump, array($this->dump_it($one), ' - ')); |
|
66 | - } |
|
67 | - $dump = array_slice($dump, 0, -1); |
|
65 | + $dump = array_merge($dump, array($this->dump_it($one), ' - ')); |
|
66 | + } |
|
67 | + $dump = array_slice($dump, 0, -1); |
|
68 | 68 | } else |
69 | 69 | $dump[] = $this->dump_it($var); |
70 | 70 | |
71 | 71 | switch ($mode) { |
72 | - default : |
|
73 | - $locString = \alkemann\h2l\internals\debug\adapters\Html::locationString($location); |
|
74 | - $this->output[] = '<div class="debug-dump"><div class="debug-location">' . $locString . '</div>'. |
|
75 | - '<div class="debug-content"> ' . implode("<br>\n", $dump) . '</div></div>'; |
|
76 | - break; |
|
77 | - } |
|
78 | - if ($options['echo']) { |
|
79 | - $this->__out(); |
|
80 | - } |
|
72 | + default : |
|
73 | + $locString = \alkemann\h2l\internals\debug\adapters\Html::locationString($location); |
|
74 | + $this->output[] = '<div class="debug-dump"><div class="debug-location">' . $locString . '</div>'. |
|
75 | + '<div class="debug-content"> ' . implode("<br>\n", $dump) . '</div></div>'; |
|
76 | + break; |
|
77 | + } |
|
78 | + if ($options['echo']) { |
|
79 | + $this->__out(); |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | |
83 | - /** |
|
84 | - * Return output dump as array |
|
85 | - * |
|
86 | - * @param string $key |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - public function array_out($key = null) : array |
|
83 | + /** |
|
84 | + * Return output dump as array |
|
85 | + * |
|
86 | + * @param string $key |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + public function array_out($key = null) : array |
|
90 | 90 | { |
91 | - if (count($this->output) < 2 || ($key && !isset($this->output[$key]))) { |
|
92 | - return []; |
|
93 | - } |
|
94 | - if ($key) { |
|
95 | - return $this->output[$key]; |
|
96 | - } |
|
97 | - array_shift($this->output); |
|
98 | - return $this->output; |
|
99 | - } |
|
91 | + if (count($this->output) < 2 || ($key && !isset($this->output[$key]))) { |
|
92 | + return []; |
|
93 | + } |
|
94 | + if ($key) { |
|
95 | + return $this->output[$key]; |
|
96 | + } |
|
97 | + array_shift($this->output); |
|
98 | + return $this->output; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Echo out stored debugging |
|
103 | - * |
|
104 | - * @param int $key |
|
105 | - */ |
|
106 | - public function out($key = null) : void |
|
101 | + /** |
|
102 | + * Echo out stored debugging |
|
103 | + * |
|
104 | + * @param int $key |
|
105 | + */ |
|
106 | + public function out($key = null) : void |
|
107 | 107 | { |
108 | - if ($this->options['mode'] == 'Html') { |
|
109 | - \alkemann\h2l\internals\debug\adapters\Html::top($this->output, $key); |
|
110 | - return; |
|
111 | - } |
|
112 | - $this->__out($key); |
|
113 | - } |
|
108 | + if ($this->options['mode'] == 'Html') { |
|
109 | + \alkemann\h2l\internals\debug\adapters\Html::top($this->output, $key); |
|
110 | + return; |
|
111 | + } |
|
112 | + $this->__out($key); |
|
113 | + } |
|
114 | 114 | |
115 | - private function __out($key = null) : void |
|
115 | + private function __out($key = null) : void |
|
116 | 116 | { |
117 | - if ($key !== null) { |
|
118 | - if (!isset($this->output[$key])) { |
|
119 | - throw new Exception('DEBUG: Not that many outputs in buffer'); |
|
120 | - } |
|
121 | - echo $this->output[$key]; |
|
122 | - return; |
|
123 | - } |
|
124 | - foreach ($this->output as $out) { |
|
125 | - echo $out; |
|
126 | - } |
|
127 | - $this->output = array(); |
|
128 | - } |
|
117 | + if ($key !== null) { |
|
118 | + if (!isset($this->output[$key])) { |
|
119 | + throw new Exception('DEBUG: Not that many outputs in buffer'); |
|
120 | + } |
|
121 | + echo $this->output[$key]; |
|
122 | + return; |
|
123 | + } |
|
124 | + foreach ($this->output as $out) { |
|
125 | + echo $out; |
|
126 | + } |
|
127 | + $this->output = array(); |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Grab global defines, will start at 'FIRST_APP_CONSTANT', if defined |
|
132 | - * |
|
133 | - * @return array |
|
134 | - */ |
|
130 | + /** |
|
131 | + * Grab global defines, will start at 'FIRST_APP_CONSTANT', if defined |
|
132 | + * |
|
133 | + * @return array |
|
134 | + */ |
|
135 | 135 | public function defines() : array |
136 | 136 | { |
137 | 137 | $defines = get_defined_constants(); |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | return $ret; |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * Send a variable to the adapter and return it's formated output |
|
150 | - * |
|
151 | - * @param mixed $var |
|
152 | - * @return string |
|
153 | - */ |
|
148 | + /** |
|
149 | + * Send a variable to the adapter and return it's formated output |
|
150 | + * |
|
151 | + * @param mixed $var |
|
152 | + * @return string |
|
153 | + */ |
|
154 | 154 | public function dump_it($var) : string |
155 | 155 | { |
156 | - $adapter = '\alkemann\h2l\internals\debug\adapters\\'. $this->options['mode']; |
|
156 | + $adapter = '\alkemann\h2l\internals\debug\adapters\\'. $this->options['mode']; |
|
157 | 157 | if (is_array($var)) |
158 | 158 | return $adapter::dump_array($var, $this); |
159 | 159 | elseif (is_object($var)) |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | return $adapter::dump_other($var); |
163 | 163 | } |
164 | 164 | |
165 | - /** |
|
166 | - * Create an array that describes the location of the debug call |
|
167 | - * |
|
168 | - * @param string $trace |
|
169 | - * @return array |
|
170 | - */ |
|
165 | + /** |
|
166 | + * Create an array that describes the location of the debug call |
|
167 | + * |
|
168 | + * @param string $trace |
|
169 | + * @return array |
|
170 | + */ |
|
171 | 171 | public function location($trace) : array |
172 | 172 | { |
173 | 173 | $root = substr($_SERVER['DOCUMENT_ROOT'], 0 , strlen(static::$defaults['docroot']) * -1); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | switch ($mode) { |
72 | 72 | default : |
73 | 73 | $locString = \alkemann\h2l\internals\debug\adapters\Html::locationString($location); |
74 | - $this->output[] = '<div class="debug-dump"><div class="debug-location">' . $locString . '</div>'. |
|
74 | + $this->output[] = '<div class="debug-dump"><div class="debug-location">' . $locString . '</div>' . |
|
75 | 75 | '<div class="debug-content"> ' . implode("<br>\n", $dump) . '</div></div>'; |
76 | 76 | break; |
77 | 77 | } |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | while ($def = array_slice($defines, $offset--, 1)) { |
140 | 140 | $key = key($def); |
141 | 141 | $value = current($def); |
142 | - if ($key == 'FIRST_APP_CONSTANT') break; |
|
143 | - $ret[$key ] = $value; |
|
142 | + if ($key == 'FIRST_APP_CONSTANT') break; |
|
143 | + $ret[$key] = $value; |
|
144 | 144 | } |
145 | 145 | return $ret; |
146 | 146 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function dump_it($var) : string |
155 | 155 | { |
156 | - $adapter = '\alkemann\h2l\internals\debug\adapters\\'. $this->options['mode']; |
|
156 | + $adapter = '\alkemann\h2l\internals\debug\adapters\\' . $this->options['mode']; |
|
157 | 157 | if (is_array($var)) |
158 | 158 | return $adapter::dump_array($var, $this); |
159 | 159 | elseif (is_object($var)) |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function location($trace) : array |
172 | 172 | { |
173 | - $root = substr($_SERVER['DOCUMENT_ROOT'], 0 , strlen(static::$defaults['docroot']) * -1); |
|
173 | + $root = substr($_SERVER['DOCUMENT_ROOT'], 0, strlen(static::$defaults['docroot']) * -1); |
|
174 | 174 | $file = implode('/', array_diff(explode('/', $trace[0]['file']), explode('/', $root))); |
175 | 175 | $ret = array( |
176 | 176 | 'file' => $file, |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | public function trace() : array |
185 | 185 | { |
186 | - $root = substr($_SERVER['DOCUMENT_ROOT'], 0 , strlen(static::$defaults['docroot']) * -1); |
|
186 | + $root = substr($_SERVER['DOCUMENT_ROOT'], 0, strlen(static::$defaults['docroot']) * -1); |
|
187 | 187 | $trace = debug_backtrace(); |
188 | 188 | array_unshift($trace, array()); |
189 | 189 | $arr = array(); |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | $arr[$k]['file'] = $file; |
195 | 195 | } |
196 | 196 | if (isset($one['line'])) $arr[$k]['line'] = $one['line']; |
197 | - if (isset($one['class'])) $arr[$k-1]['class'] = $one['class']; |
|
198 | - if (isset($one['function'])) $arr[$k-1]['function'] = $one['function']; |
|
197 | + if (isset($one['class'])) $arr[$k - 1]['class'] = $one['class']; |
|
198 | + if (isset($one['function'])) $arr[$k - 1]['function'] = $one['function']; |
|
199 | 199 | } |
200 | 200 | array_shift($arr); |
201 | 201 | array_shift($arr); |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | $obj = $var; |
210 | 210 | } else { |
211 | 211 | if (!class_exists($var)) { |
212 | - throw new \Exception('Class ['.$var.'] doesn\'t exist'); |
|
212 | + throw new \Exception('Class [' . $var . '] doesn\'t exist'); |
|
213 | 213 | } |
214 | 214 | $class = $var; |
215 | 215 | try { |
216 | 216 | $obj = new $class(); |
217 | 217 | } catch (\Exception $e) { |
218 | - throw new \Exception('Debug::api could not instantiate ['.$var.'], send it an object.'); |
|
218 | + throw new \Exception('Debug::api could not instantiate [' . $var . '], send it an object.'); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | $reflection = new \ReflectionObject($obj); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | if (is_object($value)) { |
235 | 235 | $value = get_class($value); |
236 | 236 | } elseif (is_array($value)) { |
237 | - $value = 'array['.count($value).']'; |
|
237 | + $value = 'array[' . count($value) . ']'; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | $properties[$access][$property] = compact('value', 'type'); |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | }*/ |
264 | 264 | $method_name = $refMethod->getName(); |
265 | 265 | |
266 | - $string = $access .' function '.$method_name.'('; |
|
266 | + $string = $access . ' function ' . $method_name . '('; |
|
267 | 267 | $paramString = ''; |
268 | 268 | foreach ($params as $p) { |
269 | - $paramString .= '$'.$p.', '; |
|
269 | + $paramString .= '$' . $p . ', '; |
|
270 | 270 | } |
271 | - $paramString = substr($paramString,0,-2); |
|
271 | + $paramString = substr($paramString, 0, -2); |
|
272 | 272 | $string .= $paramString; |
273 | 273 | $string .= ')'; |
274 | 274 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $info = implode(' ', $paramArr); |
289 | 289 | $tags['param'][$name] = compact('type', 'info'); |
290 | 290 | } else { |
291 | - $tags[$tagArr[0]] = isset($tagArr[1])?$tagArr[1]:''; |
|
291 | + $tags[$tagArr[0]] = isset($tagArr[1]) ? $tagArr[1] : ''; |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - return compact('properties', 'constants' ,'methods'); |
|
300 | + return compact('properties', 'constants', 'methods'); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | } |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | $this->current_depth = 0; |
55 | 55 | $this->object_references = array(); |
56 | 56 | |
57 | - if (!$options['trace']) $options['trace'] = debug_backtrace(); |
|
57 | + if (!$options['trace']) { |
|
58 | + $options['trace'] = debug_backtrace(); |
|
59 | + } |
|
58 | 60 | extract($options); |
59 | 61 | $location = $this->location($trace); |
60 | 62 | |
@@ -65,8 +67,9 @@ discard block |
||
65 | 67 | $dump = array_merge($dump, array($this->dump_it($one), ' - ')); |
66 | 68 | } |
67 | 69 | $dump = array_slice($dump, 0, -1); |
68 | - } else |
|
69 | - $dump[] = $this->dump_it($var); |
|
70 | + } else { |
|
71 | + $dump[] = $this->dump_it($var); |
|
72 | + } |
|
70 | 73 | |
71 | 74 | switch ($mode) { |
72 | 75 | default : |
@@ -139,7 +142,9 @@ discard block |
||
139 | 142 | while ($def = array_slice($defines, $offset--, 1)) { |
140 | 143 | $key = key($def); |
141 | 144 | $value = current($def); |
142 | - if ($key == 'FIRST_APP_CONSTANT') break; |
|
145 | + if ($key == 'FIRST_APP_CONSTANT') { |
|
146 | + break; |
|
147 | + } |
|
143 | 148 | $ret[$key ] = $value; |
144 | 149 | } |
145 | 150 | return $ret; |
@@ -154,12 +159,13 @@ discard block |
||
154 | 159 | public function dump_it($var) : string |
155 | 160 | { |
156 | 161 | $adapter = '\alkemann\h2l\internals\debug\adapters\\'. $this->options['mode']; |
157 | - if (is_array($var)) |
|
158 | - return $adapter::dump_array($var, $this); |
|
159 | - elseif (is_object($var)) |
|
160 | - return $adapter::dump_object($var, $this); |
|
161 | - else |
|
162 | - return $adapter::dump_other($var); |
|
162 | + if (is_array($var)) { |
|
163 | + return $adapter::dump_array($var, $this); |
|
164 | + } elseif (is_object($var)) { |
|
165 | + return $adapter::dump_object($var, $this); |
|
166 | + } else { |
|
167 | + return $adapter::dump_other($var); |
|
168 | + } |
|
163 | 169 | } |
164 | 170 | |
165 | 171 | /** |
@@ -176,8 +182,12 @@ discard block |
||
176 | 182 | 'file' => $file, |
177 | 183 | 'line' => $trace[0]['line'] |
178 | 184 | ); |
179 | - if (isset($trace[1]['function'])) $ret['function'] = $trace[1]['function']; |
|
180 | - if (isset($trace[1]['class'])) $ret['class'] = $trace[1]['class']; |
|
185 | + if (isset($trace[1]['function'])) { |
|
186 | + $ret['function'] = $trace[1]['function']; |
|
187 | + } |
|
188 | + if (isset($trace[1]['class'])) { |
|
189 | + $ret['class'] = $trace[1]['class']; |
|
190 | + } |
|
181 | 191 | return $ret; |
182 | 192 | } |
183 | 193 | |
@@ -193,9 +203,15 @@ discard block |
||
193 | 203 | $file = implode('/', array_diff(explode('/', $one['file']), explode('/', $root))); |
194 | 204 | $arr[$k]['file'] = $file; |
195 | 205 | } |
196 | - if (isset($one['line'])) $arr[$k]['line'] = $one['line']; |
|
197 | - if (isset($one['class'])) $arr[$k-1]['class'] = $one['class']; |
|
198 | - if (isset($one['function'])) $arr[$k-1]['function'] = $one['function']; |
|
206 | + if (isset($one['line'])) { |
|
207 | + $arr[$k]['line'] = $one['line']; |
|
208 | + } |
|
209 | + if (isset($one['class'])) { |
|
210 | + $arr[$k-1]['class'] = $one['class']; |
|
211 | + } |
|
212 | + if (isset($one['function'])) { |
|
213 | + $arr[$k-1]['function'] = $one['function']; |
|
214 | + } |
|
199 | 215 | } |
200 | 216 | array_shift($arr); |
201 | 217 | array_shift($arr); |
@@ -283,7 +299,9 @@ discard block |
||
283 | 299 | if ($tagArr[0] == 'param') { |
284 | 300 | $paramArr = preg_split("/[\s\t]+/", $tagArr[1]); |
285 | 301 | $type = array_shift($paramArr); |
286 | - if (empty($type)) $type = array_shift($paramArr); |
|
302 | + if (empty($type)) { |
|
303 | + $type = array_shift($paramArr); |
|
304 | + } |
|
287 | 305 | $name = array_shift($paramArr); |
288 | 306 | $info = implode(' ', $paramArr); |
289 | 307 | $tags['param'][$name] = compact('type', 'info'); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | /** |
139 | 139 | * Extra short way of adding a blacklisted object property |
140 | 140 | * |
141 | - * @param mixed $value Name of object property to blacklist, or array of |
|
141 | + * @param string $value Name of object property to blacklist, or array of |
|
142 | 142 | */ |
143 | 143 | function dbp($value) |
144 | 144 | { |
@@ -161,7 +161,6 @@ discard block |
||
161 | 161 | * Convenient wrapper for other \util\Debug methods |
162 | 162 | * |
163 | 163 | * @param string $method Name of method to call on the Debug obect |
164 | - * @param boolean $echo True will echo, false will return result |
|
165 | 164 | */ |
166 | 165 | function dw($method) |
167 | 166 | { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Global convenience methods |
|
4 | - */ |
|
3 | + * Global convenience methods |
|
4 | + */ |
|
5 | 5 | |
6 | 6 | use alkemann\h2l\internals\debug\Debug; |
7 | 7 | |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | $split = false; |
59 | 59 | $args = $args[0]; |
60 | 60 | } |
61 | - $echo = true; |
|
61 | + $echo = true; |
|
62 | 62 | @ob_end_clean(); |
63 | 63 | $debug->dump($args, compact('trace', 'split', 'echo')); |
64 | - if (!empty($debug->output)) { |
|
65 | - dout(); |
|
66 | - } |
|
64 | + if (!empty($debug->output)) { |
|
65 | + dout(); |
|
66 | + } |
|
67 | 67 | die('<div style="margin-top: 25px;font-size: 10px;color: #500;">-Debug die-</div>'); |
68 | 68 | } |
69 | 69 | |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | function dout($key = null, $incStyle = true) |
186 | 186 | { |
187 | 187 | $debug = Debug::get_instance(); |
188 | - if ($key && $incStyle) { |
|
189 | - $debug->out(0); |
|
190 | - } |
|
191 | - $debug->out($key); |
|
188 | + if ($key && $incStyle) { |
|
189 | + $debug->out(0); |
|
190 | + } |
|
191 | + $debug->out($key); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -202,5 +202,5 @@ discard block |
||
202 | 202 | function daout($key = null) |
203 | 203 | { |
204 | 204 | $debug = Debug::get_instance(); |
205 | - return $debug->array_out($key); |
|
205 | + return $debug->array_out($key); |
|
206 | 206 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | @ob_end_clean(); |
42 | 42 | $debug_trace = $debug->trace(); |
43 | 43 | foreach ($debug_trace as $t) { |
44 | - @$traced[] = (empty($t['class'])?$t['file']:$t['class']).'::'.$t['function'].'::'.$t['line']; |
|
44 | + @$traced[] = (empty($t['class']) ? $t['file'] : $t['class']) . '::' . $t['function'] . '::' . $t['line']; |
|
45 | 45 | } |
46 | 46 | $args[] = $traced; |
47 | 47 | $debug->dump($args, compact('trace', 'split')); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | @ob_end_clean(); |
78 | 78 | $debug_trace = $debug->trace(); |
79 | 79 | foreach ($debug_trace as $t) { |
80 | - @$traced[] = (empty($t['class'])?$t['file']:$t['class']).'::'.$t['function'].'::'.$t['line']; |
|
80 | + @$traced[] = (empty($t['class']) ? $t['file'] : $t['class']) . '::' . $t['function'] . '::' . $t['line']; |
|
81 | 81 | } |
82 | 82 | $args[] = $traced; |
83 | 83 | $debug->dump($args, compact('trace', 'split', 'echo')); |
@@ -157,6 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @throws InvalidUrl |
160 | + * @param string $view |
|
160 | 161 | */ |
161 | 162 | public function view($view): string |
162 | 163 | { |
@@ -203,6 +204,9 @@ discard block |
||
203 | 204 | $this->template = "{$template}.{$this->type}"; |
204 | 205 | } |
205 | 206 | |
207 | + /** |
|
208 | + * @param string $url |
|
209 | + */ |
|
206 | 210 | private function templateFromUrl(?string $url = null): string |
207 | 211 | { |
208 | 212 | $parts = \explode('/', $url); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | try { |
95 | 95 | $headfile = $this->getLayoutFile('head'); |
96 | 96 | if (file_exists($headfile)) { |
97 | - (function ($sldkfjlksejflskjflskdjflskdfj) { |
|
97 | + (function($sldkfjlksejflskjflskdjflskdfj) { |
|
98 | 98 | extract($this->data); |
99 | 99 | include $sldkfjlksejflskjflskdjflskdfj; |
100 | 100 | })($headfile); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | $neckfile = $this->getLayoutFile('neck'); |
104 | 104 | if (file_exists($neckfile)) { |
105 | - (function ($lidsinqjhsdfytqkwjkasjdksadsdg) { |
|
105 | + (function($lidsinqjhsdfytqkwjkasjdksadsdg) { |
|
106 | 106 | extract($this->data); |
107 | 107 | include $lidsinqjhsdfytqkwjkasjdksadsdg; |
108 | 108 | })($neckfile); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | ob_start(); |
144 | 144 | try { |
145 | - (function ($ldkfoskdfosjicyvutwehkshfskjdf) { |
|
145 | + (function($ldkfoskdfosjicyvutwehkshfskjdf) { |
|
146 | 146 | extract($this->data); |
147 | 147 | include $ldkfoskdfosjicyvutwehkshfskjdf; |
148 | 148 | })($footfile); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | ob_start(); |
168 | 168 | try { |
169 | 169 | // or another way to hide the file variable? |
170 | - (function ($dsfjskdfjsdlkfjsdkfjsdkfjsdlkfjsd) { |
|
170 | + (function($dsfjskdfjsdlkfjsdkfjsdkfjsdlkfjsd) { |
|
171 | 171 | extract($this->data); |
172 | 172 | include $dsfjskdfjsdlkfjsdkfjsdkfjsdlkfjsd; |
173 | 173 | })($file); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $this->template = "{$template}.{$this->type}"; |
204 | 204 | } |
205 | 205 | |
206 | - private function templateFromUrl(?string $url = null): string |
|
206 | + private function templateFromUrl(? string $url = null) : string |
|
207 | 207 | { |
208 | 208 | $parts = \explode('/', $url); |
209 | 209 | $last = \array_slice($parts, -1, 1, true); |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @param Closure|null $cb |
33 | 33 | * @param array $parameters |
34 | 34 | */ |
35 | - public function __construct(string $url, ?Closure $cb = null, array $parameters = []) |
|
35 | + public function __construct(string $url, ? Closure $cb = null, array $parameters = []) |
|
36 | 36 | { |
37 | 37 | $this->url = $url; |
38 | 38 | $this->callback = $cb; |
@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | public function query($query, array $params = []); |
10 | 10 | |
11 | - public function one(string $table, array $conditions, array $options = []):?array; |
|
11 | + public function one(string $table, array $conditions, array $options = []): ? array; |
|
12 | 12 | |
13 | 13 | public function find(string $table, array $conditions, array $options = []); |
14 | 14 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | throw new \Exception("Query method is not implemented for MongDB"); |
79 | 79 | } |
80 | 80 | |
81 | - public function one(string $collection_name, array $conditions, array $options = []): ?array |
|
81 | + public function one(string $collection_name, array $conditions, array $options = []): ? array |
|
82 | 82 | { |
83 | 83 | $collection = $this->collection($collection_name); |
84 | 84 | $conditions = $this->idReplaceConditions($conditions); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | return $result->getModifiedCount(); |
130 | 130 | } |
131 | 131 | |
132 | - public function insert(string $collection, array $data, array $options = []): ?ObjectID |
|
132 | + public function insert(string $collection, array $data, array $options = []): ? ObjectID |
|
133 | 133 | { |
134 | 134 | $collection = $this->collection($collection); |
135 | 135 | $result = $collection->insertOne($data, $options); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | return $result->fetchAll(PDO::FETCH_ASSOC); |
62 | 62 | } |
63 | 63 | |
64 | - public function one(string $table, array $conditions, array $options = []): ?array |
|
64 | + public function one(string $table, array $conditions, array $options = []): ? array |
|
65 | 65 | { |
66 | 66 | $result = $this->find($table, $conditions, $options); |
67 | 67 | $result = iterator_to_array($result); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | if (empty($conditions)) { |
124 | 124 | return ""; |
125 | 125 | } |
126 | - $fun = function ($o, $v) { |
|
126 | + $fun = function($o, $v) { |
|
127 | 127 | return "{$o}{$v} = :c_{$v}"; |
128 | 128 | }; |
129 | 129 | $where = array_reduce(array_keys($conditions), $fun, ""); |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | |
171 | 171 | private function data(array $data): string |
172 | 172 | { |
173 | - $fun = function ($o, $v) { |
|
173 | + $fun = function($o, $v) { |
|
174 | 174 | return "{$o}{$v} = :d_{$v}"; |
175 | 175 | }; |
176 | 176 | return array_reduce(array_keys($data), $fun, ""); |
177 | 177 | } |
178 | 178 | |
179 | - public function insert(string $table, array $data, array $options = []): ?int |
|
179 | + public function insert(string $table, array $data, array $options = []): ? int |
|
180 | 180 | { |
181 | 181 | $keys = implode(', ', array_keys($data)); |
182 | 182 | $data_phs = ':d_' . implode(', :d_', array_keys($data)); |