@@ -31,156 +31,156 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class Supervisor |
| 33 | 33 | { |
| 34 | - /** |
|
| 35 | - * Get exception. |
|
| 36 | - * |
|
| 37 | - * @var \Throwable $exception |
|
| 38 | - */ |
|
| 39 | - protected $exception; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * The frame execute errors. |
|
| 43 | - * |
|
| 44 | - * @var string $frames |
|
| 45 | - */ |
|
| 46 | - protected $frames; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Constructor. The Supervisor class instance. |
|
| 50 | - * |
|
| 51 | - * @param \Throwable $exception |
|
| 52 | - * |
|
| 53 | - * @return string |
|
| 54 | - */ |
|
| 55 | - public function __construct($exception) |
|
| 56 | - { |
|
| 57 | - $this->exception = $exception; |
|
| 58 | - } |
|
| 34 | + /** |
|
| 35 | + * Get exception. |
|
| 36 | + * |
|
| 37 | + * @var \Throwable $exception |
|
| 38 | + */ |
|
| 39 | + protected $exception; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * The frame execute errors. |
|
| 43 | + * |
|
| 44 | + * @var string $frames |
|
| 45 | + */ |
|
| 46 | + protected $frames; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Constructor. The Supervisor class instance. |
|
| 50 | + * |
|
| 51 | + * @param \Throwable $exception |
|
| 52 | + * |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 55 | + public function __construct($exception) |
|
| 56 | + { |
|
| 57 | + $this->exception = $exception; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Returns an iterator for the inspected exception's frames. |
|
| 62 | - * |
|
| 63 | - * @param \Throwable $exception |
|
| 64 | - * |
|
| 65 | - * @return array |
|
| 66 | - */ |
|
| 67 | - public function getFrames() |
|
| 68 | - { |
|
| 69 | - if ($this->frames === null) { |
|
| 70 | - $frames = $this->getTrace($this->exception); |
|
| 71 | - |
|
| 72 | - // Fill empty line/file info for call_user_func_array usages |
|
| 73 | - foreach ($frames as $k => $frame) { |
|
| 74 | - if (empty($frame['file'])) { |
|
| 75 | - // Default values when file and line are missing |
|
| 76 | - $file = '[PHP internal Code]'; |
|
| 77 | - $line = 0; |
|
| 78 | - $next_frame = ! empty($frames[$k + 1]) ? $frames[$k + 1] : []; |
|
| 79 | - $frames[$k]['file'] = $file; |
|
| 80 | - $frames[$k]['line'] = $line; |
|
| 81 | - } |
|
| 82 | - } |
|
| 60 | + /** |
|
| 61 | + * Returns an iterator for the inspected exception's frames. |
|
| 62 | + * |
|
| 63 | + * @param \Throwable $exception |
|
| 64 | + * |
|
| 65 | + * @return array |
|
| 66 | + */ |
|
| 67 | + public function getFrames() |
|
| 68 | + { |
|
| 69 | + if ($this->frames === null) { |
|
| 70 | + $frames = $this->getTrace($this->exception); |
|
| 71 | + |
|
| 72 | + // Fill empty line/file info for call_user_func_array usages |
|
| 73 | + foreach ($frames as $k => $frame) { |
|
| 74 | + if (empty($frame['file'])) { |
|
| 75 | + // Default values when file and line are missing |
|
| 76 | + $file = '[PHP internal Code]'; |
|
| 77 | + $line = 0; |
|
| 78 | + $next_frame = ! empty($frames[$k + 1]) ? $frames[$k + 1] : []; |
|
| 79 | + $frames[$k]['file'] = $file; |
|
| 80 | + $frames[$k]['line'] = $line; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - // Find latest non-error handling frame index ($i) used to remove error handling frames |
|
| 85 | - $i = 0; |
|
| 86 | - |
|
| 87 | - foreach ($frames as $k => $frame) { |
|
| 88 | - if ($frame['file'] == $this->exception->getFile() && $frame['line'] == $this->exception->getLine()) { |
|
| 89 | - $i = $k; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - // Remove error handling frames |
|
| 93 | - if ($i > 0) { |
|
| 94 | - array_splice($frames, 0, $i); |
|
| 95 | - } |
|
| 84 | + // Find latest non-error handling frame index ($i) used to remove error handling frames |
|
| 85 | + $i = 0; |
|
| 86 | + |
|
| 87 | + foreach ($frames as $k => $frame) { |
|
| 88 | + if ($frame['file'] == $this->exception->getFile() && $frame['line'] == $this->exception->getLine()) { |
|
| 89 | + $i = $k; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + // Remove error handling frames |
|
| 93 | + if ($i > 0) { |
|
| 94 | + array_splice($frames, 0, $i); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - $firstFrame = $this->getFrameFromException($this->exception); |
|
| 98 | - array_unshift($frames, $firstFrame); |
|
| 99 | - |
|
| 100 | - $this->frames = new Collection($frames); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - return $this->frames; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Given an exception, generates an array in the format generated by Exception::getTrace(). |
|
| 108 | - * |
|
| 109 | - * @param \Throwable $exception |
|
| 110 | - * |
|
| 111 | - * @return array |
|
| 112 | - */ |
|
| 113 | - protected function getFrameFromException(Throwable $exception): array |
|
| 114 | - { |
|
| 115 | - return [ |
|
| 116 | - 'file' => $exception->getFile(), |
|
| 117 | - 'line' => $exception->getLine(), |
|
| 118 | - 'class' => getClass($exception), |
|
| 119 | - 'code' => $exception->getCode(), |
|
| 120 | - 'args' => [ |
|
| 121 | - $exception->getMessage(), |
|
| 122 | - ], |
|
| 123 | - ]; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Gets exception already specified. |
|
| 128 | - * |
|
| 129 | - * @return \Throwable |
|
| 130 | - */ |
|
| 131 | - public function getException() |
|
| 132 | - { |
|
| 133 | - return $this->exception; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Gets the message of exception. |
|
| 138 | - * |
|
| 139 | - * @return string |
|
| 140 | - */ |
|
| 141 | - public function getExceptionMessage(): string |
|
| 142 | - { |
|
| 143 | - return $this->exception->getMessage(); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Gets the class name of exception. |
|
| 148 | - * |
|
| 149 | - * @return mixed |
|
| 150 | - */ |
|
| 151 | - public function getExceptionName() |
|
| 152 | - { |
|
| 153 | - return getClass($this->exception, true); |
|
| 154 | - } |
|
| 97 | + $firstFrame = $this->getFrameFromException($this->exception); |
|
| 98 | + array_unshift($frames, $firstFrame); |
|
| 99 | + |
|
| 100 | + $this->frames = new Collection($frames); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + return $this->frames; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Given an exception, generates an array in the format generated by Exception::getTrace(). |
|
| 108 | + * |
|
| 109 | + * @param \Throwable $exception |
|
| 110 | + * |
|
| 111 | + * @return array |
|
| 112 | + */ |
|
| 113 | + protected function getFrameFromException(Throwable $exception): array |
|
| 114 | + { |
|
| 115 | + return [ |
|
| 116 | + 'file' => $exception->getFile(), |
|
| 117 | + 'line' => $exception->getLine(), |
|
| 118 | + 'class' => getClass($exception), |
|
| 119 | + 'code' => $exception->getCode(), |
|
| 120 | + 'args' => [ |
|
| 121 | + $exception->getMessage(), |
|
| 122 | + ], |
|
| 123 | + ]; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Gets exception already specified. |
|
| 128 | + * |
|
| 129 | + * @return \Throwable |
|
| 130 | + */ |
|
| 131 | + public function getException() |
|
| 132 | + { |
|
| 133 | + return $this->exception; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Gets the message of exception. |
|
| 138 | + * |
|
| 139 | + * @return string |
|
| 140 | + */ |
|
| 141 | + public function getExceptionMessage(): string |
|
| 142 | + { |
|
| 143 | + return $this->exception->getMessage(); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Gets the class name of exception. |
|
| 148 | + * |
|
| 149 | + * @return mixed |
|
| 150 | + */ |
|
| 151 | + public function getExceptionName() |
|
| 152 | + { |
|
| 153 | + return getClass($this->exception, true); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * Gets the backtrace from an exception. |
|
| 158 | - * |
|
| 159 | - * @param \Throwable $exception |
|
| 160 | - * |
|
| 161 | - * @return array |
|
| 162 | - */ |
|
| 163 | - protected function getTrace($exception): array |
|
| 164 | - { |
|
| 165 | - $traces = $exception->getTrace(); |
|
| 166 | - |
|
| 167 | - if ( ! $exception instanceof ErrorException) { |
|
| 168 | - return $traces; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - if ( ! Misc::isFatalError($exception->getSeverity())) { |
|
| 172 | - return $traces; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - if ( ! extension_loaded('xdebug') || ! function_exists('xdebug_is_enabled') || ! xdebug_is_enabled()) { |
|
| 176 | - return $traces; |
|
| 177 | - } |
|
| 156 | + /** |
|
| 157 | + * Gets the backtrace from an exception. |
|
| 158 | + * |
|
| 159 | + * @param \Throwable $exception |
|
| 160 | + * |
|
| 161 | + * @return array |
|
| 162 | + */ |
|
| 163 | + protected function getTrace($exception): array |
|
| 164 | + { |
|
| 165 | + $traces = $exception->getTrace(); |
|
| 166 | + |
|
| 167 | + if ( ! $exception instanceof ErrorException) { |
|
| 168 | + return $traces; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + if ( ! Misc::isFatalError($exception->getSeverity())) { |
|
| 172 | + return $traces; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + if ( ! extension_loaded('xdebug') || ! function_exists('xdebug_is_enabled') || ! xdebug_is_enabled()) { |
|
| 176 | + return $traces; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - // Use xdebug to get the full stack trace and remove the shutdown handler stack trace |
|
| 180 | - $stack = array_reverse(xdebug_get_function_stack()); |
|
| 181 | - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
| 182 | - $traces = array_diff_key($stack, $trace); |
|
| 179 | + // Use xdebug to get the full stack trace and remove the shutdown handler stack trace |
|
| 180 | + $stack = array_reverse(xdebug_get_function_stack()); |
|
| 181 | + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
| 182 | + $traces = array_diff_key($stack, $trace); |
|
| 183 | 183 | |
| 184 | - return $traces; |
|
| 185 | - } |
|
| 184 | + return $traces; |
|
| 185 | + } |
|
| 186 | 186 | } |
| 187 | 187 | \ No newline at end of file |
@@ -39,413 +39,413 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class GDebug implements DebugContract |
| 41 | 41 | { |
| 42 | - /** |
|
| 43 | - * Allow Handlers to force the script to quit. |
|
| 44 | - * |
|
| 45 | - * @var bool $allowQuit |
|
| 46 | - */ |
|
| 47 | - protected $allowQuit = true; |
|
| 42 | + /** |
|
| 43 | + * Allow Handlers to force the script to quit. |
|
| 44 | + * |
|
| 45 | + * @var bool $allowQuit |
|
| 46 | + */ |
|
| 47 | + protected $allowQuit = true; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Benchmark instance. |
|
| 51 | - * |
|
| 52 | - * @var string|object $benchmark |
|
| 53 | - */ |
|
| 54 | - protected $benchmark; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * The handler stack. |
|
| 58 | - * |
|
| 59 | - * @var array $handlerStack |
|
| 60 | - */ |
|
| 61 | - protected $handlerStack = []; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * The send Http code by default: 500 Internal Server Error. |
|
| 65 | - * |
|
| 66 | - * @var bool $sendHttpCode |
|
| 67 | - */ |
|
| 68 | - protected $sendHttpCode = 500; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * The send output. |
|
| 72 | - * |
|
| 73 | - * @var bool $sendOutput |
|
| 74 | - */ |
|
| 75 | - protected $sendOutput = true; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * The functions of system what control errors and exceptions. |
|
| 79 | - * |
|
| 80 | - * @var string|object $system |
|
| 81 | - */ |
|
| 82 | - protected $system; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * In certain scenarios, like in shutdown handler, we can not throw exceptions. |
|
| 86 | - * |
|
| 87 | - * @var bool $throwExceptions |
|
| 88 | - */ |
|
| 89 | - protected $throwExceptions = true; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Constructor. The Debug class instance. |
|
| 93 | - * |
|
| 94 | - * @param \Syscodes\Components\Debug\Util\System|null $system |
|
| 95 | - * |
|
| 96 | - * @return void |
|
| 97 | - */ |
|
| 98 | - public function __construct(System $system = null) |
|
| 99 | - { |
|
| 100 | - $this->system = $system ?: new System; |
|
| 101 | - $this->benchmark = new Benchmark; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Catches any uncaught errors and exceptions, including most Fatal errors. Will log the |
|
| 106 | - * error, display it if display_errors is on, and fire an event that allows custom actions |
|
| 107 | - * to be taken at this point. |
|
| 108 | - * |
|
| 109 | - * @param \Throwable $exception |
|
| 110 | - * |
|
| 111 | - * @return string |
|
| 112 | - */ |
|
| 113 | - public function handleException(Throwable $exception): string |
|
| 114 | - { |
|
| 115 | - // The start benchmark |
|
| 116 | - $this->benchmark->start('total_execution', LENEVOR_START); |
|
| 117 | - |
|
| 118 | - $supervisor = $this->getSupervisor($exception); |
|
| 119 | - |
|
| 120 | - // Start buffer |
|
| 121 | - $this->system->startOutputBuferring(); |
|
| 122 | - |
|
| 123 | - $handlerResponse = null; |
|
| 124 | - $handlerContentType = null; |
|
| 49 | + /** |
|
| 50 | + * Benchmark instance. |
|
| 51 | + * |
|
| 52 | + * @var string|object $benchmark |
|
| 53 | + */ |
|
| 54 | + protected $benchmark; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * The handler stack. |
|
| 58 | + * |
|
| 59 | + * @var array $handlerStack |
|
| 60 | + */ |
|
| 61 | + protected $handlerStack = []; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * The send Http code by default: 500 Internal Server Error. |
|
| 65 | + * |
|
| 66 | + * @var bool $sendHttpCode |
|
| 67 | + */ |
|
| 68 | + protected $sendHttpCode = 500; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * The send output. |
|
| 72 | + * |
|
| 73 | + * @var bool $sendOutput |
|
| 74 | + */ |
|
| 75 | + protected $sendOutput = true; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * The functions of system what control errors and exceptions. |
|
| 79 | + * |
|
| 80 | + * @var string|object $system |
|
| 81 | + */ |
|
| 82 | + protected $system; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * In certain scenarios, like in shutdown handler, we can not throw exceptions. |
|
| 86 | + * |
|
| 87 | + * @var bool $throwExceptions |
|
| 88 | + */ |
|
| 89 | + protected $throwExceptions = true; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Constructor. The Debug class instance. |
|
| 93 | + * |
|
| 94 | + * @param \Syscodes\Components\Debug\Util\System|null $system |
|
| 95 | + * |
|
| 96 | + * @return void |
|
| 97 | + */ |
|
| 98 | + public function __construct(System $system = null) |
|
| 99 | + { |
|
| 100 | + $this->system = $system ?: new System; |
|
| 101 | + $this->benchmark = new Benchmark; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Catches any uncaught errors and exceptions, including most Fatal errors. Will log the |
|
| 106 | + * error, display it if display_errors is on, and fire an event that allows custom actions |
|
| 107 | + * to be taken at this point. |
|
| 108 | + * |
|
| 109 | + * @param \Throwable $exception |
|
| 110 | + * |
|
| 111 | + * @return string |
|
| 112 | + */ |
|
| 113 | + public function handleException(Throwable $exception): string |
|
| 114 | + { |
|
| 115 | + // The start benchmark |
|
| 116 | + $this->benchmark->start('total_execution', LENEVOR_START); |
|
| 117 | + |
|
| 118 | + $supervisor = $this->getSupervisor($exception); |
|
| 119 | + |
|
| 120 | + // Start buffer |
|
| 121 | + $this->system->startOutputBuferring(); |
|
| 122 | + |
|
| 123 | + $handlerResponse = null; |
|
| 124 | + $handlerContentType = null; |
|
| 125 | 125 | |
| 126 | - try { |
|
| 127 | - foreach (array_reverse($this->handlerStack) as $handler) { |
|
| 128 | - $handler->setDebug($this); |
|
| 129 | - $handler->setException($exception); |
|
| 130 | - $handler->setSupervisor($supervisor); |
|
| 126 | + try { |
|
| 127 | + foreach (array_reverse($this->handlerStack) as $handler) { |
|
| 128 | + $handler->setDebug($this); |
|
| 129 | + $handler->setException($exception); |
|
| 130 | + $handler->setSupervisor($supervisor); |
|
| 131 | 131 | |
| 132 | - $handlerResponse = $handler->handle(); |
|
| 132 | + $handlerResponse = $handler->handle(); |
|
| 133 | 133 | |
| 134 | - // Collect the content type for possible sending in the headers |
|
| 135 | - $handlerContentType = method_exists($handler, 'contentType') ? $handler->contentType() : null; |
|
| 134 | + // Collect the content type for possible sending in the headers |
|
| 135 | + $handlerContentType = method_exists($handler, 'contentType') ? $handler->contentType() : null; |
|
| 136 | 136 | |
| 137 | - if (in_array($handlerResponse, [Handler::LAST_HANDLER, Handler::QUIT])) { |
|
| 138 | - break; |
|
| 139 | - } |
|
| 140 | - } |
|
| 137 | + if (in_array($handlerResponse, [Handler::LAST_HANDLER, Handler::QUIT])) { |
|
| 138 | + break; |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - $quit = $handlerResponse == Handler::QUIT && $this->allowQuit(); |
|
| 143 | - } finally { |
|
| 144 | - // Returns the contents of the output buffer |
|
| 145 | - $output = $this->system->CleanOutputBuffer(); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - // Returns the contents of the output buffer for loading time of page |
|
| 149 | - $totalTime = $this->benchmark->getElapsedTime('total_execution'); |
|
| 150 | - $output = str_replace('{{ elapsed_time }}', $totalTime, $output); |
|
| 151 | - |
|
| 152 | - if ($this->writeToOutput()) { |
|
| 153 | - if ($quit) { |
|
| 154 | - while ($this->system->getOutputBufferLevel() > 0) { |
|
| 155 | - // Cleanes the output buffer |
|
| 156 | - $this->system->endOutputBuffering(); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - if (Misc::sendHeaders() && $handlerContentType) { |
|
| 160 | - header("Content-Type: {$handlerContentType}"); |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - $this->writeToOutputBuffer($output); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - if ($quit) { |
|
| 168 | - $this->system->flushOutputBuffer(); |
|
| 169 | - $this->system->stopException($this->sendHttpCode()); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - return $output; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Allow Handlers to force the script to quit. |
|
| 177 | - * |
|
| 178 | - * @param bool|int|null $exit |
|
| 179 | - * |
|
| 180 | - * @return bool |
|
| 181 | - */ |
|
| 182 | - public function allowQuit($exit = null): bool |
|
| 183 | - { |
|
| 184 | - if (func_num_args() == 0) { |
|
| 185 | - return $this->allowQuit; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - return $this->allowQuit = (bool) $exit; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Lenevor Exception push output directly to the client it the data |
|
| 193 | - * if they are true, but if it is false, the output will be returned |
|
| 194 | - * by exception. |
|
| 195 | - * |
|
| 196 | - * @param bool|int|null $send |
|
| 197 | - * |
|
| 198 | - * @return bool |
|
| 199 | - */ |
|
| 200 | - public function writeToOutput($send = null): bool |
|
| 201 | - { |
|
| 202 | - if (func_num_args() == 0) { |
|
| 203 | - return $this->sendOutput; |
|
| 204 | - } |
|
| 142 | + $quit = $handlerResponse == Handler::QUIT && $this->allowQuit(); |
|
| 143 | + } finally { |
|
| 144 | + // Returns the contents of the output buffer |
|
| 145 | + $output = $this->system->CleanOutputBuffer(); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + // Returns the contents of the output buffer for loading time of page |
|
| 149 | + $totalTime = $this->benchmark->getElapsedTime('total_execution'); |
|
| 150 | + $output = str_replace('{{ elapsed_time }}', $totalTime, $output); |
|
| 151 | + |
|
| 152 | + if ($this->writeToOutput()) { |
|
| 153 | + if ($quit) { |
|
| 154 | + while ($this->system->getOutputBufferLevel() > 0) { |
|
| 155 | + // Cleanes the output buffer |
|
| 156 | + $this->system->endOutputBuffering(); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + if (Misc::sendHeaders() && $handlerContentType) { |
|
| 160 | + header("Content-Type: {$handlerContentType}"); |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + $this->writeToOutputBuffer($output); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + if ($quit) { |
|
| 168 | + $this->system->flushOutputBuffer(); |
|
| 169 | + $this->system->stopException($this->sendHttpCode()); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + return $output; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Allow Handlers to force the script to quit. |
|
| 177 | + * |
|
| 178 | + * @param bool|int|null $exit |
|
| 179 | + * |
|
| 180 | + * @return bool |
|
| 181 | + */ |
|
| 182 | + public function allowQuit($exit = null): bool |
|
| 183 | + { |
|
| 184 | + if (func_num_args() == 0) { |
|
| 185 | + return $this->allowQuit; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + return $this->allowQuit = (bool) $exit; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Lenevor Exception push output directly to the client it the data |
|
| 193 | + * if they are true, but if it is false, the output will be returned |
|
| 194 | + * by exception. |
|
| 195 | + * |
|
| 196 | + * @param bool|int|null $send |
|
| 197 | + * |
|
| 198 | + * @return bool |
|
| 199 | + */ |
|
| 200 | + public function writeToOutput($send = null): bool |
|
| 201 | + { |
|
| 202 | + if (func_num_args() == 0) { |
|
| 203 | + return $this->sendOutput; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - return $this->sendOutput = (bool) $send; |
|
| 207 | - } |
|
| 206 | + return $this->sendOutput = (bool) $send; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * Generate output to the browser. |
|
| 211 | - * |
|
| 212 | - * @param string $output |
|
| 213 | - * |
|
| 214 | - * @return static |
|
| 215 | - */ |
|
| 216 | - protected function writeToOutputBuffer($output): static |
|
| 217 | - { |
|
| 218 | - if ($this->sendHttpCode() && Misc::sendHeaders()) { |
|
| 219 | - $this->system->setHttpResponseCode($this->sendHttpCode()); |
|
| 220 | - } |
|
| 209 | + /** |
|
| 210 | + * Generate output to the browser. |
|
| 211 | + * |
|
| 212 | + * @param string $output |
|
| 213 | + * |
|
| 214 | + * @return static |
|
| 215 | + */ |
|
| 216 | + protected function writeToOutputBuffer($output): static |
|
| 217 | + { |
|
| 218 | + if ($this->sendHttpCode() && Misc::sendHeaders()) { |
|
| 219 | + $this->system->setHttpResponseCode($this->sendHttpCode()); |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - echo $output; |
|
| 222 | + echo $output; |
|
| 223 | 223 | |
| 224 | - return $this; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * Error handler |
|
| 229 | - * |
|
| 230 | - * This will catch the php native error and treat it as a exception which will |
|
| 231 | - * provide a full back trace on all errors. |
|
| 232 | - * |
|
| 233 | - * @param int $level |
|
| 234 | - * @param string $message |
|
| 235 | - * @param string|null $file |
|
| 236 | - * @param int|null $line |
|
| 237 | - * |
|
| 238 | - * @return bool |
|
| 239 | - * |
|
| 240 | - * @throws \ErrorException |
|
| 241 | - */ |
|
| 242 | - public function handleError( |
|
| 243 | - int $level, |
|
| 244 | - string $message, |
|
| 245 | - string $file = null, |
|
| 246 | - int $line = null |
|
| 247 | - ): bool { |
|
| 248 | - if ($level & $this->system->getErrorReportingLevel()) { |
|
| 249 | - $exception = new ErrorException($message, $level, $level, $file, $line); |
|
| 250 | - |
|
| 251 | - if ($this->throwExceptions) { |
|
| 252 | - throw $exception; |
|
| 253 | - } else { |
|
| 254 | - $this->handleException($exception); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - return true; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - return false; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * Appends a handler to the end of the stack. |
|
| 265 | - * |
|
| 266 | - * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 267 | - * |
|
| 268 | - * @return static |
|
| 269 | - */ |
|
| 270 | - public function appendHandler($handler): static |
|
| 271 | - { |
|
| 272 | - array_unshift($this->handlerStack, $this->resolveHandler($handler)); |
|
| 273 | - |
|
| 274 | - return $this; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * Prepends a handler to the start of the stack. |
|
| 279 | - * |
|
| 280 | - * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 281 | - * |
|
| 282 | - * @return static |
|
| 283 | - */ |
|
| 284 | - public function prependHandler($handler): static |
|
| 285 | - { |
|
| 286 | - return $this->pushHandler($handler); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Pushes a handler to the end of the stack. |
|
| 291 | - * |
|
| 292 | - * @param string|callable $handler |
|
| 293 | - * |
|
| 294 | - * @return static |
|
| 295 | - */ |
|
| 296 | - public function pushHandler($handler): static |
|
| 297 | - { |
|
| 298 | - $this->handlerStack[] = $this->resolveHandler($handler); |
|
| 299 | - |
|
| 300 | - return $this; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Create a CallbackHandler from callable and throw if handler is invalid. |
|
| 305 | - * |
|
| 306 | - * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 307 | - * |
|
| 308 | - * @return \Syscodes\Components\Contracts\Debug\Handler |
|
| 309 | - * |
|
| 310 | - * @throws \InvalidArgumentException If argument is not callable or instance of \Syscodes\Components\Contracts\Debug\Handler |
|
| 311 | - */ |
|
| 312 | - protected function resolveHandler($handler) |
|
| 313 | - { |
|
| 314 | - if (is_callable($handler)) { |
|
| 315 | - $handler = new CallbackHandler($handler); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - if ( ! $handler instanceof MainHandler) { |
|
| 319 | - throw new InvalidArgumentException( |
|
| 320 | - "Argument to " . __METHOD__ . " must be a callable, or instance of ". |
|
| 321 | - "Syscodes\Components\\Contracts\\Debug\\MainHandler" |
|
| 322 | - ); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - return $handler; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - /** |
|
| 329 | - * Returns an array with all handlers, in the order they were added to the stack. |
|
| 330 | - * |
|
| 331 | - * @return array |
|
| 332 | - */ |
|
| 333 | - public function getHandlers(): array |
|
| 334 | - { |
|
| 335 | - return $this->handlerStack; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * Clears all handlers in the handlerStack, including the default PleasingPage handler. |
|
| 340 | - * |
|
| 341 | - * @return static |
|
| 342 | - */ |
|
| 343 | - public function clearHandlers(): static |
|
| 344 | - { |
|
| 345 | - $this->handlerStack = []; |
|
| 346 | - |
|
| 347 | - return $this; |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * Removes the last handler in the stack and returns it. |
|
| 352 | - * |
|
| 353 | - * @return array|null |
|
| 354 | - */ |
|
| 355 | - public function popHandler() |
|
| 356 | - { |
|
| 357 | - return array_pop($this->handlerStack); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * Gets supervisor already specified. |
|
| 362 | - * |
|
| 363 | - * @param \Throwable $exception |
|
| 364 | - * |
|
| 365 | - * @return \Syscodes\Components\Debug\Engine\Supervisor |
|
| 366 | - */ |
|
| 367 | - protected function getSupervisor(Throwable $exception) |
|
| 368 | - { |
|
| 369 | - return new Supervisor($exception); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Unregisters all handlers registered by this Debug instance. |
|
| 374 | - * |
|
| 375 | - * @return void |
|
| 376 | - */ |
|
| 377 | - public function off(): void |
|
| 378 | - { |
|
| 379 | - $this->system->restoreExceptionHandler(); |
|
| 380 | - $this->system->restoreErrorHandler(); |
|
| 381 | - } |
|
| 224 | + return $this; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * Error handler |
|
| 229 | + * |
|
| 230 | + * This will catch the php native error and treat it as a exception which will |
|
| 231 | + * provide a full back trace on all errors. |
|
| 232 | + * |
|
| 233 | + * @param int $level |
|
| 234 | + * @param string $message |
|
| 235 | + * @param string|null $file |
|
| 236 | + * @param int|null $line |
|
| 237 | + * |
|
| 238 | + * @return bool |
|
| 239 | + * |
|
| 240 | + * @throws \ErrorException |
|
| 241 | + */ |
|
| 242 | + public function handleError( |
|
| 243 | + int $level, |
|
| 244 | + string $message, |
|
| 245 | + string $file = null, |
|
| 246 | + int $line = null |
|
| 247 | + ): bool { |
|
| 248 | + if ($level & $this->system->getErrorReportingLevel()) { |
|
| 249 | + $exception = new ErrorException($message, $level, $level, $file, $line); |
|
| 250 | + |
|
| 251 | + if ($this->throwExceptions) { |
|
| 252 | + throw $exception; |
|
| 253 | + } else { |
|
| 254 | + $this->handleException($exception); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + return true; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + return false; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * Appends a handler to the end of the stack. |
|
| 265 | + * |
|
| 266 | + * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 267 | + * |
|
| 268 | + * @return static |
|
| 269 | + */ |
|
| 270 | + public function appendHandler($handler): static |
|
| 271 | + { |
|
| 272 | + array_unshift($this->handlerStack, $this->resolveHandler($handler)); |
|
| 273 | + |
|
| 274 | + return $this; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * Prepends a handler to the start of the stack. |
|
| 279 | + * |
|
| 280 | + * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 281 | + * |
|
| 282 | + * @return static |
|
| 283 | + */ |
|
| 284 | + public function prependHandler($handler): static |
|
| 285 | + { |
|
| 286 | + return $this->pushHandler($handler); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Pushes a handler to the end of the stack. |
|
| 291 | + * |
|
| 292 | + * @param string|callable $handler |
|
| 293 | + * |
|
| 294 | + * @return static |
|
| 295 | + */ |
|
| 296 | + public function pushHandler($handler): static |
|
| 297 | + { |
|
| 298 | + $this->handlerStack[] = $this->resolveHandler($handler); |
|
| 299 | + |
|
| 300 | + return $this; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Create a CallbackHandler from callable and throw if handler is invalid. |
|
| 305 | + * |
|
| 306 | + * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 307 | + * |
|
| 308 | + * @return \Syscodes\Components\Contracts\Debug\Handler |
|
| 309 | + * |
|
| 310 | + * @throws \InvalidArgumentException If argument is not callable or instance of \Syscodes\Components\Contracts\Debug\Handler |
|
| 311 | + */ |
|
| 312 | + protected function resolveHandler($handler) |
|
| 313 | + { |
|
| 314 | + if (is_callable($handler)) { |
|
| 315 | + $handler = new CallbackHandler($handler); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + if ( ! $handler instanceof MainHandler) { |
|
| 319 | + throw new InvalidArgumentException( |
|
| 320 | + "Argument to " . __METHOD__ . " must be a callable, or instance of ". |
|
| 321 | + "Syscodes\Components\\Contracts\\Debug\\MainHandler" |
|
| 322 | + ); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + return $handler; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + /** |
|
| 329 | + * Returns an array with all handlers, in the order they were added to the stack. |
|
| 330 | + * |
|
| 331 | + * @return array |
|
| 332 | + */ |
|
| 333 | + public function getHandlers(): array |
|
| 334 | + { |
|
| 335 | + return $this->handlerStack; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * Clears all handlers in the handlerStack, including the default PleasingPage handler. |
|
| 340 | + * |
|
| 341 | + * @return static |
|
| 342 | + */ |
|
| 343 | + public function clearHandlers(): static |
|
| 344 | + { |
|
| 345 | + $this->handlerStack = []; |
|
| 346 | + |
|
| 347 | + return $this; |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * Removes the last handler in the stack and returns it. |
|
| 352 | + * |
|
| 353 | + * @return array|null |
|
| 354 | + */ |
|
| 355 | + public function popHandler() |
|
| 356 | + { |
|
| 357 | + return array_pop($this->handlerStack); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * Gets supervisor already specified. |
|
| 362 | + * |
|
| 363 | + * @param \Throwable $exception |
|
| 364 | + * |
|
| 365 | + * @return \Syscodes\Components\Debug\Engine\Supervisor |
|
| 366 | + */ |
|
| 367 | + protected function getSupervisor(Throwable $exception) |
|
| 368 | + { |
|
| 369 | + return new Supervisor($exception); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * Unregisters all handlers registered by this Debug instance. |
|
| 374 | + * |
|
| 375 | + * @return void |
|
| 376 | + */ |
|
| 377 | + public function off(): void |
|
| 378 | + { |
|
| 379 | + $this->system->restoreExceptionHandler(); |
|
| 380 | + $this->system->restoreErrorHandler(); |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - /** |
|
| 384 | - * Registers this instance as an error handler. |
|
| 385 | - * |
|
| 386 | - * @return void |
|
| 387 | - */ |
|
| 388 | - public function on() : void |
|
| 389 | - { |
|
| 390 | - // Set the exception handler |
|
| 391 | - $this->system->setExceptionHandler([$this, self::EXCEPTION_HANDLER]); |
|
| 392 | - // Set the error handler |
|
| 393 | - $this->system->setErrorHandler([$this, self::ERROR_HANDLER]); |
|
| 394 | - // Set the handler for shutdown to catch Parse errors |
|
| 395 | - $this->system->registerShutdownFunction([$this, self::SHUTDOWN_HANDLER]); |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * Lenevor Exception will by default send HTTP code 500, but you may wish |
|
| 400 | - * to use 502, 503, or another 5xx family code. |
|
| 401 | - * |
|
| 402 | - * @param bool|int $code |
|
| 403 | - * |
|
| 404 | - * @return int|false |
|
| 405 | - * |
|
| 406 | - * @throws \InvalidArgumentException |
|
| 407 | - */ |
|
| 408 | - public function sendHttpCode($code = null) |
|
| 409 | - { |
|
| 410 | - if (func_num_args() == 0) { |
|
| 411 | - return $this->sendHttpCode; |
|
| 412 | - } |
|
| 383 | + /** |
|
| 384 | + * Registers this instance as an error handler. |
|
| 385 | + * |
|
| 386 | + * @return void |
|
| 387 | + */ |
|
| 388 | + public function on() : void |
|
| 389 | + { |
|
| 390 | + // Set the exception handler |
|
| 391 | + $this->system->setExceptionHandler([$this, self::EXCEPTION_HANDLER]); |
|
| 392 | + // Set the error handler |
|
| 393 | + $this->system->setErrorHandler([$this, self::ERROR_HANDLER]); |
|
| 394 | + // Set the handler for shutdown to catch Parse errors |
|
| 395 | + $this->system->registerShutdownFunction([$this, self::SHUTDOWN_HANDLER]); |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * Lenevor Exception will by default send HTTP code 500, but you may wish |
|
| 400 | + * to use 502, 503, or another 5xx family code. |
|
| 401 | + * |
|
| 402 | + * @param bool|int $code |
|
| 403 | + * |
|
| 404 | + * @return int|false |
|
| 405 | + * |
|
| 406 | + * @throws \InvalidArgumentException |
|
| 407 | + */ |
|
| 408 | + public function sendHttpCode($code = null) |
|
| 409 | + { |
|
| 410 | + if (func_num_args() == 0) { |
|
| 411 | + return $this->sendHttpCode; |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - if ( ! $code) { |
|
| 415 | - return $this->sendHttpCode = false; |
|
| 416 | - } |
|
| 414 | + if ( ! $code) { |
|
| 415 | + return $this->sendHttpCode = false; |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - if ($code === true) { |
|
| 419 | - $code = 500; |
|
| 420 | - } |
|
| 418 | + if ($code === true) { |
|
| 419 | + $code = 500; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - if ($code < 400 || 600 <= $code) { |
|
| 423 | - throw new InvalidArgumentException("Invalid status code {$code}, must be 4xx or 5xx"); |
|
| 424 | - } |
|
| 422 | + if ($code < 400 || 600 <= $code) { |
|
| 423 | + throw new InvalidArgumentException("Invalid status code {$code}, must be 4xx or 5xx"); |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - return $this->sendHttpCode = $code; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * This will catch errors that are generated at the shutdown level of execution. |
|
| 431 | - * |
|
| 432 | - * @return void |
|
| 433 | - * |
|
| 434 | - * @throws \ErrorException |
|
| 435 | - */ |
|
| 436 | - public function handleShutdown() |
|
| 437 | - { |
|
| 438 | - $this->throwExceptions = false; |
|
| 439 | - |
|
| 440 | - $error = $this->system->getLastError(); |
|
| 441 | - |
|
| 442 | - // If we've got an error that hasn't been displayed, then convert |
|
| 443 | - // it to an Exception and use the Exception handler to display it |
|
| 444 | - // to the user |
|
| 445 | - if ($error && Misc::isFatalError($error['type'])) { |
|
| 446 | - $this->allowQuit = false; |
|
| 426 | + return $this->sendHttpCode = $code; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * This will catch errors that are generated at the shutdown level of execution. |
|
| 431 | + * |
|
| 432 | + * @return void |
|
| 433 | + * |
|
| 434 | + * @throws \ErrorException |
|
| 435 | + */ |
|
| 436 | + public function handleShutdown() |
|
| 437 | + { |
|
| 438 | + $this->throwExceptions = false; |
|
| 439 | + |
|
| 440 | + $error = $this->system->getLastError(); |
|
| 441 | + |
|
| 442 | + // If we've got an error that hasn't been displayed, then convert |
|
| 443 | + // it to an Exception and use the Exception handler to display it |
|
| 444 | + // to the user |
|
| 445 | + if ($error && Misc::isFatalError($error['type'])) { |
|
| 446 | + $this->allowQuit = false; |
|
| 447 | 447 | |
| 448 | - $this->handleError($error['type'], $error['message'], $error['file'], $error['line']); |
|
| 449 | - } |
|
| 450 | - } |
|
| 448 | + $this->handleError($error['type'], $error['message'], $error['file'], $error['line']); |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | 451 | } |
| 452 | 452 | \ No newline at end of file |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $this->system->endOutputBuffering(); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if (Misc::sendHeaders() && $handlerContentType) { |
|
| 159 | + if (Misc::sendHeaders() && $handlerContentType) { |
|
| 160 | 160 | header("Content-Type: {$handlerContentType}"); |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | if ( ! $handler instanceof MainHandler) { |
| 319 | 319 | throw new InvalidArgumentException( |
| 320 | - "Argument to " . __METHOD__ . " must be a callable, or instance of ". |
|
| 320 | + "Argument to ".__METHOD__." must be a callable, or instance of ". |
|
| 321 | 321 | "Syscodes\Components\\Contracts\\Debug\\MainHandler" |
| 322 | 322 | ); |
| 323 | 323 | } |
@@ -8,7 +8,8 @@ discard block |
||
| 8 | 8 | <div class="frame-info-class"> |
| 9 | 9 | <?php if ($frame->getClass() == '') : ?> |
| 10 | 10 | <span class="frame-function"><?= e($frame->getFunction()) ?></span> |
| 11 | - <?php else: ?> |
|
| 11 | + <?php else { |
|
| 12 | + : ?> |
|
| 12 | 13 | <span class="frame-class"><?= e($frame->getClass()) ?></span> |
| 13 | 14 | <?php if ($frame->getFunction() != '') : ?> |
| 14 | 15 | <span class="frame-function"><?= e($frame->getFunction()) ?></span> |
@@ -20,5 +21,7 @@ discard block |
||
| 20 | 21 | <span class="frame-line"><?= (int) $frame->getLine() ?></span> |
| 21 | 22 | </div> |
| 22 | 23 | </div> |
| 23 | -<?php endforeach; ?> |
|
| 24 | +<?php endforeach; |
|
| 25 | +} |
|
| 26 | +?> |
|
| 24 | 27 | </aside> |
| 25 | 28 | \ No newline at end of file |
@@ -4,9 +4,12 @@ |
||
| 4 | 4 | <?php foreach ($class as $i => $name) : ?> |
| 5 | 5 | <?php if ($i == count($class) - 1): ?> |
| 6 | 6 | <h2><?= $template->escape($name) ?></h2> |
| 7 | - <?php else: ?> |
|
| 7 | + <?php else { |
|
| 8 | + : ?> |
|
| 8 | 9 | <h2><?= $template->escape($name).' \\ ' ?></h2> |
| 9 | - <?php endif; ?> |
|
| 10 | + <?php endif; |
|
| 11 | +} |
|
| 12 | +?> |
|
| 10 | 13 | <?php endforeach; ?> |
| 11 | 14 | </div> |
| 12 | 15 | <?php if ($code): ?> |
@@ -95,8 +95,8 @@ |
||
| 95 | 95 | $info = "$logo\n"; |
| 96 | 96 | $info .= " {$application->getName()} Version ".$application->getVersion()."\n"; |
| 97 | 97 | $info .= " Core\n"; |
| 98 | - $info .= " Environment: ". env('APP_ENV')."\n"; |
|
| 99 | - $info .= " Debug: ". (env('APP_DEBUG') ? "True\n" : "False\n"); |
|
| 98 | + $info .= " Environment: ".env('APP_ENV')."\n"; |
|
| 99 | + $info .= " Debug: ".(env('APP_DEBUG') ? "True\n" : "False\n"); |
|
| 100 | 100 | $info .= " PHP Info\n"; |
| 101 | 101 | $info .= " Version: "."{$phpVersion}\n"; |
| 102 | 102 | $info .= " Architecture: "."{$architecture} bits\n"; |
@@ -152,7 +152,7 @@ |
||
| 152 | 152 | |
| 153 | 153 | /** @var \Syscodes\Components\Console\Command\Command $command */ |
| 154 | 154 | foreach ($commands as $name => $command) { |
| 155 | - if ( ! $command->getName() || (!$this->hidden && $command->isHidden())) { |
|
| 155 | + if ( ! $command->getName() || ( ! $this->hidden && $command->isHidden())) { |
|
| 156 | 156 | continue; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -67,14 +67,14 @@ |
||
| 67 | 67 | ), $options); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Describes an InputOption instance. |
|
| 72 | - * |
|
| 73 | - * @param \Syscodes\Components\Console\Input\InputOption $option The option implemented |
|
| 74 | - * @param array $options The options of the console |
|
| 75 | - * |
|
| 76 | - * @return void |
|
| 77 | - */ |
|
| 70 | + /** |
|
| 71 | + * Describes an InputOption instance. |
|
| 72 | + * |
|
| 73 | + * @param \Syscodes\Components\Console\Input\InputOption $option The option implemented |
|
| 74 | + * @param array $options The options of the console |
|
| 75 | + * |
|
| 76 | + * @return void |
|
| 77 | + */ |
|
| 78 | 78 | protected function describeOption(InputOption $option, array $options = []) |
| 79 | 79 | { |
| 80 | 80 | if ($option->isAcceptValue() && null !== $option->getDefault() && ( ! is_array($option->getDefault()) || count($option->getDefault()))) { |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | $text = ''; |
| 44 | 44 | |
| 45 | 45 | $options = array_merge([ |
| 46 | - 'leftChar' => '', // e.g ' ', ' * ' |
|
| 47 | - 'sepChar' => ' ', // e.g ' | ' OUT: key | value |
|
| 48 | - 'keyStyle' => '', // e.g 'info','comment' |
|
| 49 | - 'valStyle' => '', // e.g 'info','comment' |
|
| 46 | + 'leftChar' => '', // e.g ' ', ' * ' |
|
| 47 | + 'sepChar' => ' ', // e.g ' | ' OUT: key | value |
|
| 48 | + 'keyStyle' => '', // e.g 'info','comment' |
|
| 49 | + 'valStyle' => '', // e.g 'info','comment' |
|
| 50 | 50 | 'keyMinWidth' => 8, |
| 51 | 51 | 'keyMaxWidth' => 0, |
| 52 | 52 | 'keyPadPos' => 'right', |
| 53 | - 'ucFirst' => true, // upper first char for value |
|
| 53 | + 'ucFirst' => true, // upper first char for value |
|
| 54 | 54 | ], $options); |
| 55 | 55 | |
| 56 | 56 | $keyStyle = trim($options['keyStyle']); |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | $val = is_scalar($val) ? (string) $val : $val; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $temp .= ( ! is_numeric($k) ? "$k: " : '') . "$val, "; |
|
| 88 | + $temp .= ( ! is_numeric($k) ? "$k: " : '')."$val, "; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $value = rtrim($temp, ' ,') . ']'; |
|
| 91 | + $value = rtrim($temp, ' ,').']'; |
|
| 92 | 92 | } elseif (is_bool($value)) { |
| 93 | 93 | $value = $value ? '(True)' : '(False)'; |
| 94 | 94 | } else { |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | * |
| 91 | 91 | * @return string |
| 92 | 92 | */ |
| 93 | - public static function formatTime(int|float $seconds) |
|
| 93 | + public static function formatTime(int | float $seconds) |
|
| 94 | 94 | { |
| 95 | 95 | static $timeFormats = [ |
| 96 | 96 | [0, '< 1 sec'], |