@@ -33,35 +33,35 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class PostTooLargeHttpException extends HttpException |
| 35 | 35 | { |
| 36 | - /** |
|
| 37 | - * Get the HTTP status code. |
|
| 38 | - * |
|
| 39 | - * @var int $code |
|
| 40 | - */ |
|
| 41 | - protected $code = 413; |
|
| 36 | + /** |
|
| 37 | + * Get the HTTP status code. |
|
| 38 | + * |
|
| 39 | + * @var int $code |
|
| 40 | + */ |
|
| 41 | + protected $code = 413; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Initialize constructor. |
|
| 45 | - * |
|
| 46 | - * @param string|null $message |
|
| 47 | - * @param \Throwable|null $previous |
|
| 48 | - * @param int $code |
|
| 49 | - * @param array $headers |
|
| 50 | - * |
|
| 51 | - * @return void |
|
| 52 | - */ |
|
| 53 | - public function __construct( |
|
| 54 | - string $message = null, |
|
| 55 | - Throwable $previous = null, |
|
| 56 | - int $code = 0, |
|
| 57 | - array $headers = [] |
|
| 58 | - ) { |
|
| 43 | + /** |
|
| 44 | + * Initialize constructor. |
|
| 45 | + * |
|
| 46 | + * @param string|null $message |
|
| 47 | + * @param \Throwable|null $previous |
|
| 48 | + * @param int $code |
|
| 49 | + * @param array $headers |
|
| 50 | + * |
|
| 51 | + * @return void |
|
| 52 | + */ |
|
| 53 | + public function __construct( |
|
| 54 | + string $message = null, |
|
| 55 | + Throwable $previous = null, |
|
| 56 | + int $code = 0, |
|
| 57 | + array $headers = [] |
|
| 58 | + ) { |
|
| 59 | 59 | parent::__construct( |
| 60 | - $this->code, |
|
| 61 | - $message, |
|
| 62 | - $previous, |
|
| 63 | - $headers, |
|
| 64 | - $code |
|
| 65 | - ); |
|
| 66 | - } |
|
| 60 | + $this->code, |
|
| 61 | + $message, |
|
| 62 | + $previous, |
|
| 63 | + $headers, |
|
| 64 | + $code |
|
| 65 | + ); |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | 68 | \ No newline at end of file |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | return $this->createClassListener($listener, $wildcard); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - return function ($event, $payload) use ($listener, $wildcard) { |
|
| 135 | + return function($event, $payload) use ($listener, $wildcard) { |
|
| 136 | 136 | if ($wildcard) { |
| 137 | 137 | return $listener($event, $payload); |
| 138 | 138 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function createClassListener($listener, $wildcard = false): Closure |
| 153 | 153 | { |
| 154 | - return function ($event, $payload) use ($listener, $wildcard) { |
|
| 154 | + return function($event, $payload) use ($listener, $wildcard) { |
|
| 155 | 155 | if ($wildcard) { |
| 156 | 156 | return call_user_func($this->createClassClosure($listener), $event, $payload); |
| 157 | 157 | } |
@@ -28,115 +28,115 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | interface Routable |
| 30 | 30 | { |
| 31 | - /** |
|
| 32 | - * Add a route for all posible methods. |
|
| 33 | - * |
|
| 34 | - * @param string $route |
|
| 35 | - * @param \Closure|array|string $action |
|
| 36 | - * |
|
| 37 | - * @return void |
|
| 38 | - */ |
|
| 39 | - public function any($route, $action); |
|
| 31 | + /** |
|
| 32 | + * Add a route for all posible methods. |
|
| 33 | + * |
|
| 34 | + * @param string $route |
|
| 35 | + * @param \Closure|array|string $action |
|
| 36 | + * |
|
| 37 | + * @return void |
|
| 38 | + */ |
|
| 39 | + public function any($route, $action); |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Add a route with delete method. |
|
| 43 | - * |
|
| 44 | - * @param string $route |
|
| 45 | - * @param \Closure|array|string $action |
|
| 46 | - * |
|
| 47 | - * @return void |
|
| 48 | - */ |
|
| 49 | - public function delete($route, $action); |
|
| 41 | + /** |
|
| 42 | + * Add a route with delete method. |
|
| 43 | + * |
|
| 44 | + * @param string $route |
|
| 45 | + * @param \Closure|array|string $action |
|
| 46 | + * |
|
| 47 | + * @return void |
|
| 48 | + */ |
|
| 49 | + public function delete($route, $action); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Add a route with get method. |
|
| 53 | - * |
|
| 54 | - * @param string $route |
|
| 55 | - * @param \Closure|array|string $action |
|
| 56 | - * |
|
| 57 | - * @return void |
|
| 58 | - */ |
|
| 59 | - public function get($route, $action); |
|
| 51 | + /** |
|
| 52 | + * Add a route with get method. |
|
| 53 | + * |
|
| 54 | + * @param string $route |
|
| 55 | + * @param \Closure|array|string $action |
|
| 56 | + * |
|
| 57 | + * @return void |
|
| 58 | + */ |
|
| 59 | + public function get($route, $action); |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Add a route with head method. |
|
| 63 | - * |
|
| 64 | - * @param string $route |
|
| 65 | - * @param \Closure|array|string $action |
|
| 66 | - * |
|
| 67 | - * @return void |
|
| 68 | - */ |
|
| 69 | - public function head($route, $action); |
|
| 61 | + /** |
|
| 62 | + * Add a route with head method. |
|
| 63 | + * |
|
| 64 | + * @param string $route |
|
| 65 | + * @param \Closure|array|string $action |
|
| 66 | + * |
|
| 67 | + * @return void |
|
| 68 | + */ |
|
| 69 | + public function head($route, $action); |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Register a new route with the given methods. |
|
| 73 | - * |
|
| 74 | - * @param array|string $methods |
|
| 75 | - * @param string $route |
|
| 76 | - * @param string|callable|null $action |
|
| 77 | - * |
|
| 78 | - * @return void |
|
| 79 | - */ |
|
| 80 | - public function match($methods, $route, $action = null); |
|
| 71 | + /** |
|
| 72 | + * Register a new route with the given methods. |
|
| 73 | + * |
|
| 74 | + * @param array|string $methods |
|
| 75 | + * @param string $route |
|
| 76 | + * @param string|callable|null $action |
|
| 77 | + * |
|
| 78 | + * @return void |
|
| 79 | + */ |
|
| 80 | + public function match($methods, $route, $action = null); |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Add a route with options method |
|
| 84 | - * |
|
| 85 | - * @param string $route |
|
| 86 | - * @param \Closure|array|string $action |
|
| 87 | - * |
|
| 88 | - * @return void |
|
| 89 | - */ |
|
| 90 | - public function options($route, $action); |
|
| 82 | + /** |
|
| 83 | + * Add a route with options method |
|
| 84 | + * |
|
| 85 | + * @param string $route |
|
| 86 | + * @param \Closure|array|string $action |
|
| 87 | + * |
|
| 88 | + * @return void |
|
| 89 | + */ |
|
| 90 | + public function options($route, $action); |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Add a route with patch method. |
|
| 94 | - * |
|
| 95 | - * @param string $route |
|
| 96 | - * @param \Closure|array|string $action |
|
| 97 | - * |
|
| 98 | - * @return void |
|
| 99 | - */ |
|
| 100 | - public function patch($route, $action); |
|
| 92 | + /** |
|
| 93 | + * Add a route with patch method. |
|
| 94 | + * |
|
| 95 | + * @param string $route |
|
| 96 | + * @param \Closure|array|string $action |
|
| 97 | + * |
|
| 98 | + * @return void |
|
| 99 | + */ |
|
| 100 | + public function patch($route, $action); |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Add a route with post method. |
|
| 104 | - * |
|
| 105 | - * @param string $route |
|
| 106 | - * @param \Closure|array|string $action |
|
| 107 | - * |
|
| 108 | - * @return void |
|
| 109 | - */ |
|
| 110 | - public function post($route, $action); |
|
| 102 | + /** |
|
| 103 | + * Add a route with post method. |
|
| 104 | + * |
|
| 105 | + * @param string $route |
|
| 106 | + * @param \Closure|array|string $action |
|
| 107 | + * |
|
| 108 | + * @return void |
|
| 109 | + */ |
|
| 110 | + public function post($route, $action); |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * Add a route with put method. |
|
| 114 | - * |
|
| 115 | - * @param string $route |
|
| 116 | - * @param \Closure|array|string $action |
|
| 117 | - * |
|
| 118 | - * @return void |
|
| 119 | - */ |
|
| 120 | - public function put($route, $action); |
|
| 112 | + /** |
|
| 113 | + * Add a route with put method. |
|
| 114 | + * |
|
| 115 | + * @param string $route |
|
| 116 | + * @param \Closure|array|string $action |
|
| 117 | + * |
|
| 118 | + * @return void |
|
| 119 | + */ |
|
| 120 | + public function put($route, $action); |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Group a series of routes under a single URL segment. This is handy |
|
| 124 | - * for grouping items into an admin area, like: |
|
| 125 | - * |
|
| 126 | - * Example: |
|
| 127 | - * // Creates route: /admin show the word 'User' |
|
| 128 | - * Route::group(['prefix' => 'admin'], function() { |
|
| 129 | - * |
|
| 130 | - * Route::get('/user', function() { |
|
| 131 | - * echo 'Hello world..!'; |
|
| 132 | - * }); |
|
| 133 | - * |
|
| 134 | - * }); /admin/user |
|
| 135 | - * |
|
| 136 | - * @param array $attributes |
|
| 137 | - * @param \Closure|array|string $callback |
|
| 138 | - * |
|
| 139 | - * @return void |
|
| 140 | - */ |
|
| 141 | - public function group(array $attributes, $routes): void; |
|
| 122 | + /** |
|
| 123 | + * Group a series of routes under a single URL segment. This is handy |
|
| 124 | + * for grouping items into an admin area, like: |
|
| 125 | + * |
|
| 126 | + * Example: |
|
| 127 | + * // Creates route: /admin show the word 'User' |
|
| 128 | + * Route::group(['prefix' => 'admin'], function() { |
|
| 129 | + * |
|
| 130 | + * Route::get('/user', function() { |
|
| 131 | + * echo 'Hello world..!'; |
|
| 132 | + * }); |
|
| 133 | + * |
|
| 134 | + * }); /admin/user |
|
| 135 | + * |
|
| 136 | + * @param array $attributes |
|
| 137 | + * @param \Closure|array|string $callback |
|
| 138 | + * |
|
| 139 | + * @return void |
|
| 140 | + */ |
|
| 141 | + public function group(array $attributes, $routes): void; |
|
| 142 | 142 | } |
| 143 | 143 | \ No newline at end of file |
@@ -29,143 +29,143 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | interface Handler |
| 31 | 31 | { |
| 32 | - const ERROR_HANDLER = "HandleError"; |
|
| 33 | - const EXCEPTION_HANDLER = "handleException"; |
|
| 34 | - const SHUTDOWN_HANDLER = "handleShutdown"; |
|
| 32 | + const ERROR_HANDLER = "HandleError"; |
|
| 33 | + const EXCEPTION_HANDLER = "handleException"; |
|
| 34 | + const SHUTDOWN_HANDLER = "handleShutdown"; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Catches any uncaught errors and exceptions, including most Fatal errors. Will log the |
|
| 38 | - * error, display it if display_errors is on, and fire an event that allows custom actions |
|
| 39 | - * to be taken at this point. |
|
| 40 | - * |
|
| 41 | - * @param \Throwable $exception |
|
| 42 | - * |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 45 | - public function handleException(Throwable $exception): string; |
|
| 36 | + /** |
|
| 37 | + * Catches any uncaught errors and exceptions, including most Fatal errors. Will log the |
|
| 38 | + * error, display it if display_errors is on, and fire an event that allows custom actions |
|
| 39 | + * to be taken at this point. |
|
| 40 | + * |
|
| 41 | + * @param \Throwable $exception |
|
| 42 | + * |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | + public function handleException(Throwable $exception): string; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Pushes a handler to the end of the stack. |
|
| 49 | - * |
|
| 50 | - * @param string|callable $handler |
|
| 51 | - * |
|
| 52 | - * @return \Syscodes\Components\Contracts\Debug\Handler |
|
| 53 | - */ |
|
| 54 | - public function pushHandler($handler); |
|
| 47 | + /** |
|
| 48 | + * Pushes a handler to the end of the stack. |
|
| 49 | + * |
|
| 50 | + * @param string|callable $handler |
|
| 51 | + * |
|
| 52 | + * @return \Syscodes\Components\Contracts\Debug\Handler |
|
| 53 | + */ |
|
| 54 | + public function pushHandler($handler); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Appends a handler to the end of the stack. |
|
| 58 | - * |
|
| 59 | - * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 60 | - * |
|
| 61 | - * @return self |
|
| 62 | - */ |
|
| 63 | - public function appendHandler($handler): self; |
|
| 56 | + /** |
|
| 57 | + * Appends a handler to the end of the stack. |
|
| 58 | + * |
|
| 59 | + * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 60 | + * |
|
| 61 | + * @return self |
|
| 62 | + */ |
|
| 63 | + public function appendHandler($handler): self; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Prepends a handler to the start of the stack. |
|
| 67 | - * |
|
| 68 | - * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 69 | - * |
|
| 70 | - * @return self |
|
| 71 | - */ |
|
| 72 | - public function prependHandler($handler): self; |
|
| 65 | + /** |
|
| 66 | + * Prepends a handler to the start of the stack. |
|
| 67 | + * |
|
| 68 | + * @param \Callable|\Syscodes\Components\Contracts\Debug\Handler $handler |
|
| 69 | + * |
|
| 70 | + * @return self |
|
| 71 | + */ |
|
| 72 | + public function prependHandler($handler): self; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Unregisters all handlers registered by this Debug instance. |
|
| 76 | - * |
|
| 77 | - * @return void |
|
| 78 | - */ |
|
| 79 | - public function off(): void; |
|
| 74 | + /** |
|
| 75 | + * Unregisters all handlers registered by this Debug instance. |
|
| 76 | + * |
|
| 77 | + * @return void |
|
| 78 | + */ |
|
| 79 | + public function off(): void; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Registers this instance as an error handler. |
|
| 83 | - * |
|
| 84 | - * @return void |
|
| 85 | - */ |
|
| 86 | - public function on(): void; |
|
| 81 | + /** |
|
| 82 | + * Registers this instance as an error handler. |
|
| 83 | + * |
|
| 84 | + * @return void |
|
| 85 | + */ |
|
| 86 | + public function on(): void; |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Allow Handlers to force the script to quit. |
|
| 90 | - * |
|
| 91 | - * @param bool|int|null $exit |
|
| 92 | - * |
|
| 93 | - * @return bool |
|
| 94 | - */ |
|
| 95 | - public function allowQuit($exit = null); |
|
| 88 | + /** |
|
| 89 | + * Allow Handlers to force the script to quit. |
|
| 90 | + * |
|
| 91 | + * @param bool|int|null $exit |
|
| 92 | + * |
|
| 93 | + * @return bool |
|
| 94 | + */ |
|
| 95 | + public function allowQuit($exit = null); |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Lenevor Exception push output directly to the client it the data |
|
| 99 | - * if they are true, but if it is false, the output will be returned |
|
| 100 | - * by exception. |
|
| 101 | - * |
|
| 102 | - * @param bool|int|null $send |
|
| 103 | - * |
|
| 104 | - * @return bool |
|
| 105 | - */ |
|
| 106 | - public function writeToOutput($send = null); |
|
| 97 | + /** |
|
| 98 | + * Lenevor Exception push output directly to the client it the data |
|
| 99 | + * if they are true, but if it is false, the output will be returned |
|
| 100 | + * by exception. |
|
| 101 | + * |
|
| 102 | + * @param bool|int|null $send |
|
| 103 | + * |
|
| 104 | + * @return bool |
|
| 105 | + */ |
|
| 106 | + public function writeToOutput($send = null); |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Returns an array with all handlers, in the order they were added to the stack. |
|
| 110 | - * |
|
| 111 | - * @return array |
|
| 112 | - */ |
|
| 113 | - public function getHandlers(): array; |
|
| 108 | + /** |
|
| 109 | + * Returns an array with all handlers, in the order they were added to the stack. |
|
| 110 | + * |
|
| 111 | + * @return array |
|
| 112 | + */ |
|
| 113 | + public function getHandlers(): array; |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Clears all handlers in the handlerStack, including the default PleasingPage handler. |
|
| 117 | - * |
|
| 118 | - * @return self |
|
| 119 | - */ |
|
| 120 | - public function clearHandlers(): self; |
|
| 115 | + /** |
|
| 116 | + * Clears all handlers in the handlerStack, including the default PleasingPage handler. |
|
| 117 | + * |
|
| 118 | + * @return self |
|
| 119 | + */ |
|
| 120 | + public function clearHandlers(): self; |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Removes the last handler in the stack and returns it. |
|
| 124 | - * |
|
| 125 | - * @return array|null |
|
| 126 | - */ |
|
| 127 | - public function popHandler(); |
|
| 122 | + /** |
|
| 123 | + * Removes the last handler in the stack and returns it. |
|
| 124 | + * |
|
| 125 | + * @return array|null |
|
| 126 | + */ |
|
| 127 | + public function popHandler(); |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Error handler |
|
| 131 | - * |
|
| 132 | - * This will catch the php native error and treat it as a exception which will |
|
| 133 | - * provide a full back trace on all errors. |
|
| 134 | - * |
|
| 135 | - * @param int $level |
|
| 136 | - * @param string $message |
|
| 137 | - * @param string|null $file |
|
| 138 | - * @param int|null $line |
|
| 139 | - * |
|
| 140 | - * @return bool |
|
| 141 | - * |
|
| 142 | - * @throws \ErrorException |
|
| 143 | - */ |
|
| 144 | - public function handleError( |
|
| 145 | - int $level, |
|
| 146 | - string $message, |
|
| 147 | - string $file = null, |
|
| 148 | - int $line = null |
|
| 149 | - ); |
|
| 129 | + /** |
|
| 130 | + * Error handler |
|
| 131 | + * |
|
| 132 | + * This will catch the php native error and treat it as a exception which will |
|
| 133 | + * provide a full back trace on all errors. |
|
| 134 | + * |
|
| 135 | + * @param int $level |
|
| 136 | + * @param string $message |
|
| 137 | + * @param string|null $file |
|
| 138 | + * @param int|null $line |
|
| 139 | + * |
|
| 140 | + * @return bool |
|
| 141 | + * |
|
| 142 | + * @throws \ErrorException |
|
| 143 | + */ |
|
| 144 | + public function handleError( |
|
| 145 | + int $level, |
|
| 146 | + string $message, |
|
| 147 | + string $file = null, |
|
| 148 | + int $line = null |
|
| 149 | + ); |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * Lenevor Exception will by default send HTTP code 500, but you may wish |
|
| 153 | - * to use 502, 503, or another 5xx family code. |
|
| 154 | - * |
|
| 155 | - * @param bool|int $code |
|
| 156 | - * |
|
| 157 | - * @return int|false |
|
| 158 | - * |
|
| 159 | - * @throws \InvalidArgumentException |
|
| 160 | - */ |
|
| 161 | - public function sendHttpCode($code = null); |
|
| 151 | + /** |
|
| 152 | + * Lenevor Exception will by default send HTTP code 500, but you may wish |
|
| 153 | + * to use 502, 503, or another 5xx family code. |
|
| 154 | + * |
|
| 155 | + * @param bool|int $code |
|
| 156 | + * |
|
| 157 | + * @return int|false |
|
| 158 | + * |
|
| 159 | + * @throws \InvalidArgumentException |
|
| 160 | + */ |
|
| 161 | + public function sendHttpCode($code = null); |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * This will catch errors that are generated at the shutdown level of execution. |
|
| 165 | - * |
|
| 166 | - * @return void |
|
| 167 | - * |
|
| 168 | - * @throws \ErrorException |
|
| 169 | - */ |
|
| 170 | - public function handleShutdown(); |
|
| 163 | + /** |
|
| 164 | + * This will catch errors that are generated at the shutdown level of execution. |
|
| 165 | + * |
|
| 166 | + * @return void |
|
| 167 | + * |
|
| 168 | + * @throws \ErrorException |
|
| 169 | + */ |
|
| 170 | + public function handleShutdown(); |
|
| 171 | 171 | } |
| 172 | 172 | \ No newline at end of file |
@@ -30,103 +30,103 @@ |
||
| 30 | 30 | interface Factory |
| 31 | 31 | { |
| 32 | 32 | /** |
| 33 | - * Check existance view file. |
|
| 34 | - * |
|
| 35 | - * @param string $view |
|
| 36 | - * |
|
| 37 | - * @return bool |
|
| 38 | - */ |
|
| 33 | + * Check existance view file. |
|
| 34 | + * |
|
| 35 | + * @param string $view |
|
| 36 | + * |
|
| 37 | + * @return bool |
|
| 38 | + */ |
|
| 39 | 39 | public function viewExists($view): bool; |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Global and local data are merged and extracted to create local variables within the view file. |
| 43 | - * Renders the view object to a string. |
|
| 44 | - * |
|
| 45 | - * @example $output = $view->make(); |
|
| 46 | - * |
|
| 47 | - * @param string $view View filename |
|
| 48 | - * @param array $data Array of values |
|
| 49 | - * |
|
| 50 | - * @return \Syscodes\Components\Contracts\View\View |
|
| 43 | + * Renders the view object to a string. |
|
| 44 | + * |
|
| 45 | + * @example $output = $view->make(); |
|
| 46 | + * |
|
| 47 | + * @param string $view View filename |
|
| 48 | + * @param array $data Array of values |
|
| 49 | + * |
|
| 50 | + * @return \Syscodes\Components\Contracts\View\View |
|
| 51 | 51 | */ |
| 52 | 52 | public function make($view, $data = []); |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * Call the creator for a given view. |
|
| 56 | - * |
|
| 57 | - * @param \Syscodes\View\View $view |
|
| 58 | - * |
|
| 59 | - * @return void |
|
| 60 | - */ |
|
| 61 | - public function callCreator(View $view): void; |
|
| 55 | + * Call the creator for a given view. |
|
| 56 | + * |
|
| 57 | + * @param \Syscodes\View\View $view |
|
| 58 | + * |
|
| 59 | + * @return void |
|
| 60 | + */ |
|
| 61 | + public function callCreator(View $view): void; |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | - * Get the extension to engine bindings. |
|
| 65 | - * |
|
| 66 | - * @return array |
|
| 67 | - */ |
|
| 68 | - public function getExtensions(): array; |
|
| 64 | + * Get the extension to engine bindings. |
|
| 65 | + * |
|
| 66 | + * @return array |
|
| 67 | + */ |
|
| 68 | + public function getExtensions(): array; |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * Add a piece of shared data to the environment. |
|
| 73 | - * |
|
| 74 | - * @param array|string $key |
|
| 75 | - * @param mixed|null $value |
|
| 76 | - * |
|
| 77 | - * @return mixed |
|
| 78 | - */ |
|
| 79 | - public function share($key, $value = null); |
|
| 72 | + * Add a piece of shared data to the environment. |
|
| 73 | + * |
|
| 74 | + * @param array|string $key |
|
| 75 | + * @param mixed|null $value |
|
| 76 | + * |
|
| 77 | + * @return mixed |
|
| 78 | + */ |
|
| 79 | + public function share($key, $value = null); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | - * Replace the namespace hints for the given namespace. |
|
| 83 | - * |
|
| 84 | - * @param string $namespace |
|
| 85 | - * @param string|array $hints |
|
| 86 | - * |
|
| 87 | - * @return self |
|
| 88 | - */ |
|
| 89 | - public function replaceNamespace($namespace, $hints): self; |
|
| 82 | + * Replace the namespace hints for the given namespace. |
|
| 83 | + * |
|
| 84 | + * @param string $namespace |
|
| 85 | + * @param string|array $hints |
|
| 86 | + * |
|
| 87 | + * @return self |
|
| 88 | + */ |
|
| 89 | + public function replaceNamespace($namespace, $hints): self; |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | - * Increment the rendering counter. |
|
| 93 | - * |
|
| 94 | - * @return int |
|
| 95 | - */ |
|
| 96 | - public function increment(): int; |
|
| 92 | + * Increment the rendering counter. |
|
| 93 | + * |
|
| 94 | + * @return int |
|
| 95 | + */ |
|
| 96 | + public function increment(): int; |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | - * Decrement the rendering counter. |
|
| 100 | - * |
|
| 101 | - * @return int |
|
| 102 | - */ |
|
| 103 | - public function decrement(): int; |
|
| 99 | + * Decrement the rendering counter. |
|
| 100 | + * |
|
| 101 | + * @return int |
|
| 102 | + */ |
|
| 103 | + public function decrement(): int; |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * Check if there are no active render operations. |
|
| 107 | - * |
|
| 108 | - * @return bool |
|
| 109 | - */ |
|
| 110 | - public function doneRendering(): bool; |
|
| 106 | + * Check if there are no active render operations. |
|
| 107 | + * |
|
| 108 | + * @return bool |
|
| 109 | + */ |
|
| 110 | + public function doneRendering(): bool; |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | - * Flush all of the parser state like sections. |
|
| 114 | - * |
|
| 115 | - * @return void |
|
| 116 | - */ |
|
| 117 | - public function flushState(): void; |
|
| 113 | + * Flush all of the parser state like sections. |
|
| 114 | + * |
|
| 115 | + * @return void |
|
| 116 | + */ |
|
| 117 | + public function flushState(): void; |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | - * Flush all of the section contents if done rendering. |
|
| 121 | - * |
|
| 122 | - * @return void |
|
| 123 | - */ |
|
| 124 | - public function flushStateIfDoneRendering(): void; |
|
| 120 | + * Flush all of the section contents if done rendering. |
|
| 121 | + * |
|
| 122 | + * @return void |
|
| 123 | + */ |
|
| 124 | + public function flushStateIfDoneRendering(): void; |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | - * Get all of the shared data for the environment. |
|
| 128 | - * |
|
| 129 | - * @return array |
|
| 130 | - */ |
|
| 131 | - public function getShared(): array; |
|
| 127 | + * Get all of the shared data for the environment. |
|
| 128 | + * |
|
| 129 | + * @return array |
|
| 130 | + */ |
|
| 131 | + public function getShared(): array; |
|
| 132 | 132 | } |
| 133 | 133 | \ No newline at end of file |
@@ -28,13 +28,13 @@ |
||
| 28 | 28 | interface OutputStyle |
| 29 | 29 | { |
| 30 | 30 | /** |
| 31 | - * Enter a number of empty lines. |
|
| 32 | - * |
|
| 33 | - * @param int $num Number of lines to output |
|
| 34 | - * |
|
| 35 | - * @return string |
|
| 36 | - */ |
|
| 37 | - public function newline(int $num = 1); |
|
| 31 | + * Enter a number of empty lines. |
|
| 32 | + * |
|
| 33 | + * @param int $num Number of lines to output |
|
| 34 | + * |
|
| 35 | + * @return string |
|
| 36 | + */ |
|
| 37 | + public function newline(int $num = 1); |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Writes a string formatting for comment output. |
@@ -339,7 +339,7 @@ |
||
| 339 | 339 | */ |
| 340 | 340 | protected function getNestedResourceUri(array $segments): string |
| 341 | 341 | { |
| 342 | - return implode('/', array_map(function ($segment) { |
|
| 342 | + return implode('/', array_map(function($segment) { |
|
| 343 | 343 | return $segment.'/{'.$this->getResourceWilcard($segment).'}'; |
| 344 | 344 | }, $segments)); |
| 345 | 345 | } |
@@ -108,7 +108,7 @@ |
||
| 108 | 108 | */ |
| 109 | 109 | protected function getInParameters($class, array $parameters): bool |
| 110 | 110 | { |
| 111 | - return ! is_null(Arr::first($parameters, function ($value) use ($class) { |
|
| 111 | + return ! is_null(Arr::first($parameters, function($value) use ($class) { |
|
| 112 | 112 | return $value instanceof $class; |
| 113 | 113 | })); |
| 114 | 114 | } |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | if ($bytes < 1024) { |
| 106 | 106 | return $bytes.'B'; |
| 107 | 107 | } else if ($bytes < 1048576) { |
| 108 | - return round($bytes/1024, 2).'KB'; |
|
| 108 | + return round($bytes / 1024, 2).'KB'; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return round($bytes/1048576, 2).'MB'; |
|
| 111 | + return round($bytes / 1048576, 2).'MB'; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $origin = str_replace(["\r\n", "\r"], "\n", $origin); |
| 182 | - $origin = explode("\n", highlight_string($origin , true)); |
|
| 182 | + $origin = explode("\n", highlight_string($origin, true)); |
|
| 183 | 183 | $origin = str_replace('<br />', "\n", $origin [1]); |
| 184 | 184 | |
| 185 | 185 | $origin = explode("\n", str_replace("\r\n", "\n", $origin)); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $start = $start < 0 ? 0 : $start; |
| 190 | 190 | |
| 191 | 191 | // Get just the lines we need to display, while keeping line numbers... |
| 192 | - $origin = array_splice($origin, $start, $lines, true); |
|
| 192 | + $origin = array_splice($origin, $start, $lines, true); |
|
| 193 | 193 | |
| 194 | 194 | // Used to format the line number in the source |
| 195 | 195 | $format = '% '.strlen($start + $lines).'d'; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $spans += substr_count($row, '<span') - substr_count($row, '</span'); |
| 206 | 206 | $row = str_replace(["\r", "\n"], ['', ''], $row); |
| 207 | 207 | |
| 208 | - if (($n+$start+1) == $lineNumber) { |
|
| 208 | + if (($n + $start + 1) == $lineNumber) { |
|
| 209 | 209 | preg_match_all('#<[^>]+>#', $row, $tags); |
| 210 | 210 | $out .= sprintf("<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s", |
| 211 | 211 | $n + $start + 1, |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | implode('', $tags[0]) |
| 214 | 214 | ); |
| 215 | 215 | } else { |
| 216 | - $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start + 1, $row) ."\n"; |
|
| 216 | + $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start + 1, $row)."\n"; |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | public function slug($original): string |
| 246 | 246 | { |
| 247 | 247 | $slug = str_replace(" ", "-", $original); |
| 248 | - $slug = preg_replace('/[^\w\d\-\_]/i',' ', $slug); |
|
| 248 | + $slug = preg_replace('/[^\w\d\-\_]/i', ' ', $slug); |
|
| 249 | 249 | |
| 250 | 250 | return strtolower($slug); |
| 251 | 251 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // Instantiate the error view and prepare the vars |
| 271 | - call_user_func(function () { |
|
| 271 | + call_user_func(function() { |
|
| 272 | 272 | extract(func_get_arg(1)); |
| 273 | 273 | include func_get_arg(0); |
| 274 | 274 | }, $template, $vars); |
@@ -30,247 +30,247 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class TemplateHandler |
| 32 | 32 | { |
| 33 | - /** |
|
| 34 | - * Benchmark instance. |
|
| 35 | - * |
|
| 36 | - * @var string $benchmark |
|
| 37 | - */ |
|
| 38 | - protected $benchmark; |
|
| 33 | + /** |
|
| 34 | + * Benchmark instance. |
|
| 35 | + * |
|
| 36 | + * @var string $benchmark |
|
| 37 | + */ |
|
| 38 | + protected $benchmark; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Nesting level of the output buffering mechanism. |
|
| 42 | - * |
|
| 43 | - * @var string $obLevel |
|
| 44 | - */ |
|
| 45 | - public $obLevel; |
|
| 40 | + /** |
|
| 41 | + * Nesting level of the output buffering mechanism. |
|
| 42 | + * |
|
| 43 | + * @var string $obLevel |
|
| 44 | + */ |
|
| 45 | + public $obLevel; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The functions of system what control errors and exceptions. |
|
| 49 | - * |
|
| 50 | - * @var string|object $system |
|
| 51 | - */ |
|
| 52 | - protected $system; |
|
| 47 | + /** |
|
| 48 | + * The functions of system what control errors and exceptions. |
|
| 49 | + * |
|
| 50 | + * @var string|object $system |
|
| 51 | + */ |
|
| 52 | + protected $system; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * An array of variables to be passed to all templates. |
|
| 56 | - * |
|
| 57 | - * @var array $variables |
|
| 58 | - */ |
|
| 59 | - protected $variables = []; |
|
| 54 | + /** |
|
| 55 | + * An array of variables to be passed to all templates. |
|
| 56 | + * |
|
| 57 | + * @var array $variables |
|
| 58 | + */ |
|
| 59 | + protected $variables = []; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Constructor. The TemplateHandler class instance. |
|
| 63 | - * |
|
| 64 | - * @return void |
|
| 65 | - */ |
|
| 66 | - public function __construct() |
|
| 67 | - { |
|
| 68 | - $this->system = new System; |
|
| 69 | - $this->benchmark = new Benchmark; |
|
| 70 | - $this->obLevel = $this->system->getOutputBufferLevel(); |
|
| 71 | - } |
|
| 61 | + /** |
|
| 62 | + * Constructor. The TemplateHandler class instance. |
|
| 63 | + * |
|
| 64 | + * @return void |
|
| 65 | + */ |
|
| 66 | + public function __construct() |
|
| 67 | + { |
|
| 68 | + $this->system = new System; |
|
| 69 | + $this->benchmark = new Benchmark; |
|
| 70 | + $this->obLevel = $this->system->getOutputBufferLevel(); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Clean Path: This makes nicer looking paths for the error output. |
|
| 75 | - * |
|
| 76 | - * @param string $file |
|
| 77 | - * |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - public function cleanPath($file): string |
|
| 81 | - { |
|
| 82 | - if (strpos($file, appPath().DIRECTORY_SEPARATOR) === 0) { |
|
| 83 | - $file = appPath().DIRECTORY_SEPARATOR.substr($file, strlen(appPath().DIRECTORY_SEPARATOR)); |
|
| 84 | - } elseif (strpos($file, basePath().DIRECTORY_SEPARATOR) === 0) { |
|
| 85 | - $file = basePath().DIRECTORY_SEPARATOR.substr($file, strlen(basePath().DIRECTORY_SEPARATOR)); |
|
| 86 | - } elseif (strpos($file, configPath().DIRECTORY_SEPARATOR) === 0) { |
|
| 87 | - $file = configPath().DIRECTORY_SEPARATOR.substr($file, strlen(configPath().DIRECTORY_SEPARATOR)); |
|
| 88 | - } elseif (strpos($file, resourcePath().DIRECTORY_SEPARATOR) === 0) { |
|
| 89 | - $file = resourcePath().DIRECTORY_SEPARATOR.substr($file, strlen(resourcePath().DIRECTORY_SEPARATOR)); |
|
| 90 | - } |
|
| 73 | + /** |
|
| 74 | + * Clean Path: This makes nicer looking paths for the error output. |
|
| 75 | + * |
|
| 76 | + * @param string $file |
|
| 77 | + * |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + public function cleanPath($file): string |
|
| 81 | + { |
|
| 82 | + if (strpos($file, appPath().DIRECTORY_SEPARATOR) === 0) { |
|
| 83 | + $file = appPath().DIRECTORY_SEPARATOR.substr($file, strlen(appPath().DIRECTORY_SEPARATOR)); |
|
| 84 | + } elseif (strpos($file, basePath().DIRECTORY_SEPARATOR) === 0) { |
|
| 85 | + $file = basePath().DIRECTORY_SEPARATOR.substr($file, strlen(basePath().DIRECTORY_SEPARATOR)); |
|
| 86 | + } elseif (strpos($file, configPath().DIRECTORY_SEPARATOR) === 0) { |
|
| 87 | + $file = configPath().DIRECTORY_SEPARATOR.substr($file, strlen(configPath().DIRECTORY_SEPARATOR)); |
|
| 88 | + } elseif (strpos($file, resourcePath().DIRECTORY_SEPARATOR) === 0) { |
|
| 89 | + $file = resourcePath().DIRECTORY_SEPARATOR.substr($file, strlen(resourcePath().DIRECTORY_SEPARATOR)); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return $file; |
|
| 93 | - } |
|
| 92 | + return $file; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Display memory usage in real-world units. Intended for use |
|
| 97 | - * with memory_get_usage, etc. |
|
| 98 | - * |
|
| 99 | - * @param int $bytes |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - public function displayMemory(int $bytes): string |
|
| 104 | - { |
|
| 105 | - if ($bytes < 1024) { |
|
| 106 | - return $bytes.'B'; |
|
| 107 | - } else if ($bytes < 1048576) { |
|
| 108 | - return round($bytes/1024, 2).'KB'; |
|
| 109 | - } |
|
| 95 | + /** |
|
| 96 | + * Display memory usage in real-world units. Intended for use |
|
| 97 | + * with memory_get_usage, etc. |
|
| 98 | + * |
|
| 99 | + * @param int $bytes |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + public function displayMemory(int $bytes): string |
|
| 104 | + { |
|
| 105 | + if ($bytes < 1024) { |
|
| 106 | + return $bytes.'B'; |
|
| 107 | + } else if ($bytes < 1048576) { |
|
| 108 | + return round($bytes/1024, 2).'KB'; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - return round($bytes/1048576, 2).'MB'; |
|
| 112 | - } |
|
| 111 | + return round($bytes/1048576, 2).'MB'; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Escapes a string for output in an HTML document. |
|
| 116 | - * |
|
| 117 | - * @param string $text |
|
| 118 | - * |
|
| 119 | - * @return string |
|
| 120 | - */ |
|
| 121 | - public function escape($text): string |
|
| 122 | - { |
|
| 123 | - $flags = ENT_QUOTES; |
|
| 114 | + /** |
|
| 115 | + * Escapes a string for output in an HTML document. |
|
| 116 | + * |
|
| 117 | + * @param string $text |
|
| 118 | + * |
|
| 119 | + * @return string |
|
| 120 | + */ |
|
| 121 | + public function escape($text): string |
|
| 122 | + { |
|
| 123 | + $flags = ENT_QUOTES; |
|
| 124 | 124 | |
| 125 | - // HHVM has all constants defined, but only ENT_IGNORE |
|
| 126 | - // works at the moment |
|
| 127 | - if (defined("ENT_SUBSTITUTE") && ! defined("HHVM_VERSION")) { |
|
| 128 | - $flags |= ENT_SUBSTITUTE; |
|
| 129 | - } else { |
|
| 130 | - $flags |= ENT_IGNORE; |
|
| 131 | - } |
|
| 125 | + // HHVM has all constants defined, but only ENT_IGNORE |
|
| 126 | + // works at the moment |
|
| 127 | + if (defined("ENT_SUBSTITUTE") && ! defined("HHVM_VERSION")) { |
|
| 128 | + $flags |= ENT_SUBSTITUTE; |
|
| 129 | + } else { |
|
| 130 | + $flags |= ENT_IGNORE; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - $text = str_replace(chr(9), ' ', $text); |
|
| 133 | + $text = str_replace(chr(9), ' ', $text); |
|
| 134 | 134 | |
| 135 | - return htmlspecialchars($text, $flags, "UTF-8"); |
|
| 136 | - } |
|
| 135 | + return htmlspecialchars($text, $flags, "UTF-8"); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * Returns all variables for this helper. |
|
| 140 | - * |
|
| 141 | - * @return array |
|
| 142 | - */ |
|
| 143 | - public function getVariables(): array |
|
| 144 | - { |
|
| 145 | - return $this->variables; |
|
| 146 | - } |
|
| 138 | + /** |
|
| 139 | + * Returns all variables for this helper. |
|
| 140 | + * |
|
| 141 | + * @return array |
|
| 142 | + */ |
|
| 143 | + public function getVariables(): array |
|
| 144 | + { |
|
| 145 | + return $this->variables; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Creates a syntax-highlighted version of a PHP file. |
|
| 150 | - * |
|
| 151 | - * @param string $file |
|
| 152 | - * @param int $lineNumber |
|
| 153 | - * @param int $lines |
|
| 154 | - * |
|
| 155 | - * @return bool|string |
|
| 156 | - * |
|
| 157 | - * @throws \Exception |
|
| 158 | - */ |
|
| 159 | - public function highlightFile($file, $lineNumber, $lines = 15) |
|
| 160 | - { |
|
| 161 | - if (empty ($file) || ! is_readable($file)) { |
|
| 162 | - return false; |
|
| 163 | - } |
|
| 148 | + /** |
|
| 149 | + * Creates a syntax-highlighted version of a PHP file. |
|
| 150 | + * |
|
| 151 | + * @param string $file |
|
| 152 | + * @param int $lineNumber |
|
| 153 | + * @param int $lines |
|
| 154 | + * |
|
| 155 | + * @return bool|string |
|
| 156 | + * |
|
| 157 | + * @throws \Exception |
|
| 158 | + */ |
|
| 159 | + public function highlightFile($file, $lineNumber, $lines = 15) |
|
| 160 | + { |
|
| 161 | + if (empty ($file) || ! is_readable($file)) { |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - // Set our highlight colors: |
|
| 166 | - if (function_exists('ini_set')) { |
|
| 167 | - ini_set('highlight.bg', '#000'); |
|
| 168 | - ini_set('highlight.comment', '#757575'); |
|
| 169 | - ini_set('highlight.default', '#717DE8'); |
|
| 170 | - ini_set('highlight.html', '#2d70a6ff'); |
|
| 171 | - ini_set('highlight.keyword', '#fc9356ff'); |
|
| 172 | - ini_set('highlight.string', '#90ec52ff'); |
|
| 173 | - } |
|
| 165 | + // Set our highlight colors: |
|
| 166 | + if (function_exists('ini_set')) { |
|
| 167 | + ini_set('highlight.bg', '#000'); |
|
| 168 | + ini_set('highlight.comment', '#757575'); |
|
| 169 | + ini_set('highlight.default', '#717DE8'); |
|
| 170 | + ini_set('highlight.html', '#2d70a6ff'); |
|
| 171 | + ini_set('highlight.keyword', '#fc9356ff'); |
|
| 172 | + ini_set('highlight.string', '#90ec52ff'); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - try { |
|
| 176 | - $origin = file_get_contents($file); |
|
| 177 | - } catch (Exception $e) { |
|
| 178 | - return false; |
|
| 179 | - } |
|
| 175 | + try { |
|
| 176 | + $origin = file_get_contents($file); |
|
| 177 | + } catch (Exception $e) { |
|
| 178 | + return false; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - $origin = str_replace(["\r\n", "\r"], "\n", $origin); |
|
| 182 | - $origin = explode("\n", highlight_string($origin , true)); |
|
| 183 | - $origin = str_replace('<br />', "\n", $origin [1]); |
|
| 181 | + $origin = str_replace(["\r\n", "\r"], "\n", $origin); |
|
| 182 | + $origin = explode("\n", highlight_string($origin , true)); |
|
| 183 | + $origin = str_replace('<br />', "\n", $origin [1]); |
|
| 184 | 184 | |
| 185 | - $origin = explode("\n", str_replace("\r\n", "\n", $origin)); |
|
| 185 | + $origin = explode("\n", str_replace("\r\n", "\n", $origin)); |
|
| 186 | 186 | |
| 187 | - // Get just the part to show |
|
| 188 | - $start = $lineNumber - (int) round($lines / 2); |
|
| 189 | - $start = $start < 0 ? 0 : $start; |
|
| 187 | + // Get just the part to show |
|
| 188 | + $start = $lineNumber - (int) round($lines / 2); |
|
| 189 | + $start = $start < 0 ? 0 : $start; |
|
| 190 | 190 | |
| 191 | - // Get just the lines we need to display, while keeping line numbers... |
|
| 192 | - $origin = array_splice($origin, $start, $lines, true); |
|
| 191 | + // Get just the lines we need to display, while keeping line numbers... |
|
| 192 | + $origin = array_splice($origin, $start, $lines, true); |
|
| 193 | 193 | |
| 194 | - // Used to format the line number in the source |
|
| 195 | - $format = '% '.strlen($start + $lines).'d'; |
|
| 194 | + // Used to format the line number in the source |
|
| 195 | + $format = '% '.strlen($start + $lines).'d'; |
|
| 196 | 196 | |
| 197 | - $out = ''; |
|
| 198 | - // Because the highlighting may have an uneven number |
|
| 199 | - // of open and close span tags on one line, we need |
|
| 200 | - // to ensure we can close them all to get the lines |
|
| 201 | - // showing correctly. |
|
| 202 | - $spans = 1; |
|
| 197 | + $out = ''; |
|
| 198 | + // Because the highlighting may have an uneven number |
|
| 199 | + // of open and close span tags on one line, we need |
|
| 200 | + // to ensure we can close them all to get the lines |
|
| 201 | + // showing correctly. |
|
| 202 | + $spans = 1; |
|
| 203 | 203 | |
| 204 | - foreach ($origin as $n => $row) { |
|
| 205 | - $spans += substr_count($row, '<span') - substr_count($row, '</span'); |
|
| 206 | - $row = str_replace(["\r", "\n"], ['', ''], $row); |
|
| 204 | + foreach ($origin as $n => $row) { |
|
| 205 | + $spans += substr_count($row, '<span') - substr_count($row, '</span'); |
|
| 206 | + $row = str_replace(["\r", "\n"], ['', ''], $row); |
|
| 207 | 207 | |
| 208 | - if (($n+$start+1) == $lineNumber) { |
|
| 209 | - preg_match_all('#<[^>]+>#', $row, $tags); |
|
| 210 | - $out .= sprintf("<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s", |
|
| 211 | - $n + $start + 1, |
|
| 212 | - strip_tags($row), |
|
| 213 | - implode('', $tags[0]) |
|
| 214 | - ); |
|
| 215 | - } else { |
|
| 216 | - $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start + 1, $row) ."\n"; |
|
| 217 | - } |
|
| 218 | - } |
|
| 208 | + if (($n+$start+1) == $lineNumber) { |
|
| 209 | + preg_match_all('#<[^>]+>#', $row, $tags); |
|
| 210 | + $out .= sprintf("<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s", |
|
| 211 | + $n + $start + 1, |
|
| 212 | + strip_tags($row), |
|
| 213 | + implode('', $tags[0]) |
|
| 214 | + ); |
|
| 215 | + } else { |
|
| 216 | + $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start + 1, $row) ."\n"; |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - $out .= str_repeat('</span>', $spans); |
|
| 220 | + $out .= str_repeat('</span>', $spans); |
|
| 221 | 221 | |
| 222 | - return '<pre class="code-blocks"><code>'.$out.'</code></pre>'; |
|
| 223 | - } |
|
| 222 | + return '<pre class="code-blocks"><code>'.$out.'</code></pre>'; |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - /** |
|
| 226 | - * Sets the variables to be passed to all templates rendered |
|
| 227 | - * by this template helper. |
|
| 228 | - * |
|
| 229 | - * @param array $variables |
|
| 230 | - * |
|
| 231 | - * @return void |
|
| 232 | - */ |
|
| 233 | - public function setVariables(array $variables): void |
|
| 234 | - { |
|
| 235 | - $this->variables = $variables; |
|
| 236 | - } |
|
| 225 | + /** |
|
| 226 | + * Sets the variables to be passed to all templates rendered |
|
| 227 | + * by this template helper. |
|
| 228 | + * |
|
| 229 | + * @param array $variables |
|
| 230 | + * |
|
| 231 | + * @return void |
|
| 232 | + */ |
|
| 233 | + public function setVariables(array $variables): void |
|
| 234 | + { |
|
| 235 | + $this->variables = $variables; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Convert a string to a slug version of itself. |
|
| 240 | - * |
|
| 241 | - * @param string $original |
|
| 242 | - * |
|
| 243 | - * @return string |
|
| 244 | - */ |
|
| 245 | - public function slug($original): string |
|
| 246 | - { |
|
| 247 | - $slug = str_replace(" ", "-", $original); |
|
| 248 | - $slug = preg_replace('/[^\w\d\-\_]/i',' ', $slug); |
|
| 238 | + /** |
|
| 239 | + * Convert a string to a slug version of itself. |
|
| 240 | + * |
|
| 241 | + * @param string $original |
|
| 242 | + * |
|
| 243 | + * @return string |
|
| 244 | + */ |
|
| 245 | + public function slug($original): string |
|
| 246 | + { |
|
| 247 | + $slug = str_replace(" ", "-", $original); |
|
| 248 | + $slug = preg_replace('/[^\w\d\-\_]/i',' ', $slug); |
|
| 249 | 249 | |
| 250 | - return strtolower($slug); |
|
| 251 | - } |
|
| 250 | + return strtolower($slug); |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Given an exception and status code will display the error to the client. |
|
| 255 | - * |
|
| 256 | - * @param string $template |
|
| 257 | - * |
|
| 258 | - * @return void |
|
| 259 | - */ |
|
| 260 | - public function render($template): void |
|
| 261 | - { |
|
| 262 | - $vars = $this->getVariables(); |
|
| 253 | + /** |
|
| 254 | + * Given an exception and status code will display the error to the client. |
|
| 255 | + * |
|
| 256 | + * @param string $template |
|
| 257 | + * |
|
| 258 | + * @return void |
|
| 259 | + */ |
|
| 260 | + public function render($template): void |
|
| 261 | + { |
|
| 262 | + $vars = $this->getVariables(); |
|
| 263 | 263 | |
| 264 | - $vars['template'] = $this; |
|
| 264 | + $vars['template'] = $this; |
|
| 265 | 265 | |
| 266 | - if ($this->system->getOutputBufferLevel() > $this->obLevel + 1) { |
|
| 267 | - @$this->system->endOutputBuffering(); |
|
| 268 | - } |
|
| 266 | + if ($this->system->getOutputBufferLevel() > $this->obLevel + 1) { |
|
| 267 | + @$this->system->endOutputBuffering(); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - // Instantiate the error view and prepare the vars |
|
| 271 | - call_user_func(function () { |
|
| 272 | - extract(func_get_arg(1)); |
|
| 273 | - include func_get_arg(0); |
|
| 274 | - }, $template, $vars); |
|
| 275 | - } |
|
| 270 | + // Instantiate the error view and prepare the vars |
|
| 271 | + call_user_func(function () { |
|
| 272 | + extract(func_get_arg(1)); |
|
| 273 | + include func_get_arg(0); |
|
| 274 | + }, $template, $vars); |
|
| 275 | + } |
|
| 276 | 276 | } |
| 277 | 277 | \ No newline at end of file |