@@ -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; |
@@ -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) { |
@@ -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 | { |
@@ -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); |