@@ -9,19 +9,19 @@ discard block |
||
| 9 | 9 | * @subpackage WPB/bootstrap |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -require_once ABSPATH . 'wp-includes/pluggable.php'; |
|
| 13 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 14 | -require_once __DIR__ . '/../src/helpers.php'; |
|
| 12 | +require_once ABSPATH.'wp-includes/pluggable.php'; |
|
| 13 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 14 | +require_once __DIR__.'/../src/helpers.php'; |
|
| 15 | 15 | |
| 16 | 16 | use WPB\Application; |
| 17 | 17 | |
| 18 | -$app = ( new Application( |
|
| 18 | +$app = (new Application( |
|
| 19 | 19 | array( |
| 20 | 20 | 'paths' => array( |
| 21 | 21 | 'root' => WPB_APP_ROOT, |
| 22 | 22 | ), |
| 23 | 23 | ) |
| 24 | -) ); |
|
| 24 | +)); |
|
| 25 | 25 | |
| 26 | 26 | $container = $app->get_instance(); |
| 27 | 27 | |
@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | \WPB\App\Exceptions\Handler::class |
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | -if ( \WPB\Support\Facades\Route::exists( \Illuminate\Http\Request::capture() ) ) { |
|
| 37 | +if (\WPB\Support\Facades\Route::exists(\Illuminate\Http\Request::capture())) { |
|
| 38 | 38 | try { |
| 39 | 39 | |
| 40 | - $kernel = $container->make( \Illuminate\Contracts\Http\Kernel::class ); |
|
| 40 | + $kernel = $container->make(\Illuminate\Contracts\Http\Kernel::class); |
|
| 41 | 41 | |
| 42 | - $response = $kernel->handle( \Illuminate\Http\Request::capture() ); |
|
| 42 | + $response = $kernel->handle(\Illuminate\Http\Request::capture()); |
|
| 43 | 43 | |
| 44 | 44 | $response->send(); |
| 45 | 45 | |
| 46 | - } catch ( \Exception $ex ) { |
|
| 47 | - if ( ! \WPB\Support\Facades\Route::current() ) { |
|
| 46 | + } catch (\Exception $ex) { |
|
| 47 | + if (!\WPB\Support\Facades\Route::current()) { |
|
| 48 | 48 | return true; |
| 49 | 49 | } |
| 50 | - throw new \Exception( $ex, 1 ); |
|
| 50 | + throw new \Exception($ex, 1); |
|
| 51 | 51 | } |
| 52 | 52 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | - public function __construct( Container $app, Router $router ) { |
|
| 93 | + public function __construct(Container $app, Router $router) { |
|
| 94 | 94 | $this->app = $app; |
| 95 | 95 | $this->router = $router; |
| 96 | 96 | |
@@ -106,17 +106,17 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return \Illuminate\Http\Response |
| 108 | 108 | */ |
| 109 | - public function handle( $request ) { |
|
| 109 | + public function handle($request) { |
|
| 110 | 110 | try { |
| 111 | 111 | $request->enableHttpMethodParameterOverride(); |
| 112 | - $response = $this->send_request_through_router( $request ); |
|
| 113 | - } catch ( Throwable $e ) { |
|
| 114 | - $this->report_exception( $e ); |
|
| 115 | - $response = $this->render_exception( $request, $e ); |
|
| 112 | + $response = $this->send_request_through_router($request); |
|
| 113 | + } catch (Throwable $e) { |
|
| 114 | + $this->report_exception($e); |
|
| 115 | + $response = $this->render_exception($request, $e); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $this->app['events']->dispatch( |
| 119 | - new RequestHandled( $request, $response ) |
|
| 119 | + new RequestHandled($request, $response) |
|
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | 122 | return $response; |
@@ -129,17 +129,17 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return \Illuminate\Http\Response |
| 131 | 131 | */ |
| 132 | - protected function send_request_through_router( $request ) { |
|
| 133 | - $this->app->instance( 'request', $request ); |
|
| 132 | + protected function send_request_through_router($request) { |
|
| 133 | + $this->app->instance('request', $request); |
|
| 134 | 134 | |
| 135 | - Facade::clearResolvedInstance( 'request' ); |
|
| 135 | + Facade::clearResolvedInstance('request'); |
|
| 136 | 136 | |
| 137 | 137 | $this->bootstrap(); |
| 138 | 138 | |
| 139 | - return ( new Pipeline( $this->app ) ) |
|
| 140 | - ->send( $request ) |
|
| 141 | - ->through( $this->middleware ) |
|
| 142 | - ->then( $this->dispatch_to_router() ); |
|
| 139 | + return (new Pipeline($this->app)) |
|
| 140 | + ->send($request) |
|
| 141 | + ->through($this->middleware) |
|
| 142 | + ->then($this->dispatch_to_router()); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | * @return \Closure |
| 156 | 156 | */ |
| 157 | 157 | protected function dispatch_to_router() { |
| 158 | - return function ( $request ) { |
|
| 159 | - $this->app->instance( 'request', $request ); |
|
| 158 | + return function($request) { |
|
| 159 | + $this->app->instance('request', $request); |
|
| 160 | 160 | |
| 161 | - return $this->router->dispatch( $request ); |
|
| 161 | + return $this->router->dispatch($request); |
|
| 162 | 162 | }; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @return void |
| 172 | 172 | */ |
| 173 | - public function terminate( $request, $response ) { |
|
| 174 | - $this->terminate_middleware( $request, $response ); |
|
| 173 | + public function terminate($request, $response) { |
|
| 174 | + $this->terminate_middleware($request, $response); |
|
| 175 | 175 | |
| 176 | 176 | $this->app->terminate(); |
| 177 | 177 | } |
@@ -184,23 +184,23 @@ discard block |
||
| 184 | 184 | * |
| 185 | 185 | * @return void |
| 186 | 186 | */ |
| 187 | - protected function terminate_middleware( $request, $response ) { |
|
| 187 | + protected function terminate_middleware($request, $response) { |
|
| 188 | 188 | $middlewares = $this->app->shouldSkipMiddleware() ? array() : array_merge( |
| 189 | - $this->gather_route_middleware( $request ), |
|
| 189 | + $this->gather_route_middleware($request), |
|
| 190 | 190 | $this->middleware |
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - foreach ( $middlewares as $middleware ) { |
|
| 194 | - if ( ! is_string( $middleware ) ) { |
|
| 193 | + foreach ($middlewares as $middleware) { |
|
| 194 | + if (!is_string($middleware)) { |
|
| 195 | 195 | continue; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - list( $name ) = $this->parse_middleware( $middleware ); |
|
| 198 | + list($name) = $this->parse_middleware($middleware); |
|
| 199 | 199 | |
| 200 | - $instance = $this->app->make( $name ); |
|
| 200 | + $instance = $this->app->make($name); |
|
| 201 | 201 | |
| 202 | - if ( method_exists( $instance, 'terminate' ) ) { |
|
| 203 | - $instance->terminate( $request, $response ); |
|
| 202 | + if (method_exists($instance, 'terminate')) { |
|
| 203 | + $instance->terminate($request, $response); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | - protected function gather_route_middleware( $request ) { |
|
| 215 | + protected function gather_route_middleware($request) { |
|
| 216 | 216 | $route = $request->route(); |
| 217 | - if ( $route ) { |
|
| 218 | - return $this->router->gatherRouteMiddleware( $route ); |
|
| 217 | + if ($route) { |
|
| 218 | + return $this->router->gatherRouteMiddleware($route); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | return array(); |
@@ -228,15 +228,15 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return array |
| 230 | 230 | */ |
| 231 | - protected function parse_middleware( $middleware ) { |
|
| 231 | + protected function parse_middleware($middleware) { |
|
| 232 | 232 | |
| 233 | - list( $name, $parameters ) = array_pad( explode( ':', $middleware, 2 ), 2, array() ); |
|
| 233 | + list($name, $parameters) = array_pad(explode(':', $middleware, 2), 2, array()); |
|
| 234 | 234 | |
| 235 | - if ( is_string( $parameters ) ) { |
|
| 236 | - $parameters = explode( ',', $parameters ); |
|
| 235 | + if (is_string($parameters)) { |
|
| 236 | + $parameters = explode(',', $parameters); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - return array( $name, $parameters ); |
|
| 239 | + return array($name, $parameters); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @return bool |
| 248 | 248 | */ |
| 249 | - public function has_middleware( $middleware ) { |
|
| 250 | - return in_array( $middleware, $this->middleware ); |
|
| 249 | + public function has_middleware($middleware) { |
|
| 250 | + return in_array($middleware, $this->middleware); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @return $this |
| 259 | 259 | */ |
| 260 | - public function prepend_middleware( $middleware ) { |
|
| 261 | - if ( array_search( $middleware, $this->middleware ) === false ) { |
|
| 262 | - array_unshift( $this->middleware, $middleware ); |
|
| 260 | + public function prepend_middleware($middleware) { |
|
| 261 | + if (array_search($middleware, $this->middleware) === false) { |
|
| 262 | + array_unshift($this->middleware, $middleware); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | return $this; |
@@ -272,8 +272,8 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return $this |
| 274 | 274 | */ |
| 275 | - public function push_middleware( $middleware ) { |
|
| 276 | - if ( array_search( $middleware, $this->middleware ) === false ) { |
|
| 275 | + public function push_middleware($middleware) { |
|
| 276 | + if (array_search($middleware, $this->middleware) === false) { |
|
| 277 | 277 | $this->middleware[] = $middleware; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -290,13 +290,13 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * @return $this |
| 292 | 292 | */ |
| 293 | - public function prepend_middleware_to_group( $group, $middleware ) { |
|
| 294 | - if ( ! isset( $this->middleware_groups[ $group ] ) ) { |
|
| 295 | - throw new InvalidArgumentException( "The [{$group}] middleware group has not been defined." ); |
|
| 293 | + public function prepend_middleware_to_group($group, $middleware) { |
|
| 294 | + if (!isset($this->middleware_groups[$group])) { |
|
| 295 | + throw new InvalidArgumentException("The [{$group}] middleware group has not been defined."); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if ( array_search( $middleware, $this->middleware_groups[ $group ] ) === false ) { |
|
| 299 | - array_unshift( $this->middleware_groups[ $group ], $middleware ); |
|
| 298 | + if (array_search($middleware, $this->middleware_groups[$group]) === false) { |
|
| 299 | + array_unshift($this->middleware_groups[$group], $middleware); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | $this->sync_middleware_to_router(); |
@@ -314,13 +314,13 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @return $this |
| 316 | 316 | */ |
| 317 | - public function append_middleware_to_group( $group, $middleware ) { |
|
| 318 | - if ( ! isset( $this->middleware_groups[ $group ] ) ) { |
|
| 319 | - throw new InvalidArgumentException( "The [{$group}] middleware group has not been defined." ); |
|
| 317 | + public function append_middleware_to_group($group, $middleware) { |
|
| 318 | + if (!isset($this->middleware_groups[$group])) { |
|
| 319 | + throw new InvalidArgumentException("The [{$group}] middleware group has not been defined."); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - if ( array_search( $middleware, $this->middleware_groups[ $group ] ) === false ) { |
|
| 323 | - $this->middleware_groups[ $group ][] = $middleware; |
|
| 322 | + if (array_search($middleware, $this->middleware_groups[$group]) === false) { |
|
| 323 | + $this->middleware_groups[$group][] = $middleware; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | $this->sync_middleware_to_router(); |
@@ -335,9 +335,9 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @return $this |
| 337 | 337 | */ |
| 338 | - public function prepend_to_middleware_priority( $middleware ) { |
|
| 339 | - if ( ! in_array( $middleware, $this->middleware_priority ) ) { |
|
| 340 | - array_unshift( $this->middleware_priority, $middleware ); |
|
| 338 | + public function prepend_to_middleware_priority($middleware) { |
|
| 339 | + if (!in_array($middleware, $this->middleware_priority)) { |
|
| 340 | + array_unshift($this->middleware_priority, $middleware); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | $this->sync_middleware_to_router(); |
@@ -352,8 +352,8 @@ discard block |
||
| 352 | 352 | * |
| 353 | 353 | * @return $this |
| 354 | 354 | */ |
| 355 | - public function append_to_middleware_priority( $middleware ) { |
|
| 356 | - if ( ! in_array( $middleware, $this->middleware_priority ) ) { |
|
| 355 | + public function append_to_middleware_priority($middleware) { |
|
| 356 | + if (!in_array($middleware, $this->middleware_priority)) { |
|
| 357 | 357 | $this->middleware_priority[] = $middleware; |
| 358 | 358 | } |
| 359 | 359 | |
@@ -370,12 +370,12 @@ discard block |
||
| 370 | 370 | protected function sync_middleware_to_router() { |
| 371 | 371 | $this->router->middlewarePriority = $this->middleware_priority; |
| 372 | 372 | |
| 373 | - foreach ( $this->middleware_groups as $key => $middleware ) { |
|
| 374 | - $this->router->middlewareGroup( $key, $middleware ); |
|
| 373 | + foreach ($this->middleware_groups as $key => $middleware) { |
|
| 374 | + $this->router->middlewareGroup($key, $middleware); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - foreach ( $this->route_middleware as $key => $middleware ) { |
|
| 378 | - $this->router->aliasMiddleware( $key, $middleware ); |
|
| 377 | + foreach ($this->route_middleware as $key => $middleware) { |
|
| 378 | + $this->router->aliasMiddleware($key, $middleware); |
|
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | * |
| 396 | 396 | * @return void |
| 397 | 397 | */ |
| 398 | - protected function report_exception( Throwable $e ) { |
|
| 399 | - $this->app[ ExceptionHandler::class ]->report( $e ); |
|
| 398 | + protected function report_exception(Throwable $e) { |
|
| 399 | + $this->app[ExceptionHandler::class]->report($e); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -407,8 +407,8 @@ discard block |
||
| 407 | 407 | * |
| 408 | 408 | * @return \Symfony\Component\HttpFoundation\Response |
| 409 | 409 | */ |
| 410 | - protected function render_exception( $request, Throwable $e ) { |
|
| 411 | - return $this->app[ ExceptionHandler::class ]->render( $request, $e ); |
|
| 410 | + protected function render_exception($request, Throwable $e) { |
|
| 411 | + return $this->app[ExceptionHandler::class]->render($request, $e); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |