@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @return null |
21 | 21 | */ |
22 | 22 | public function boot() { |
23 | - add_action( 'template_include', array( $this, 'execute' ), 1000 ); |
|
23 | + add_action('template_include', array($this, 'execute'), 1000); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | * @param string $template |
30 | 30 | * @return string |
31 | 31 | */ |
32 | - public function execute( $template ) { |
|
32 | + public function execute($template) { |
|
33 | 33 | $routes = $this->getRoutes(); |
34 | - $global_middleware = Framework::resolve( 'framework.global_middleware' ); |
|
34 | + $global_middleware = Framework::resolve('framework.global_middleware'); |
|
35 | 35 | |
36 | - foreach ( $routes as $route ) { |
|
37 | - $route->addMiddleware( $global_middleware ); |
|
36 | + foreach ($routes as $route) { |
|
37 | + $route->addMiddleware($global_middleware); |
|
38 | 38 | } |
39 | 39 | |
40 | - foreach ( $routes as $route ) { |
|
41 | - if ( $route->satisfied() ) { |
|
42 | - return $this->handle( $route ); |
|
40 | + foreach ($routes as $route) { |
|
41 | + if ($route->satisfied()) { |
|
42 | + return $this->handle($route); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | * @param RouteInterface $route |
53 | 53 | * @return string |
54 | 54 | */ |
55 | - protected function handle( RouteInterface $route ) { |
|
55 | + protected function handle(RouteInterface $route) { |
|
56 | 56 | $request = Request::fromGlobals(); |
57 | - $response = $route->handle( $request ); |
|
57 | + $response = $route->handle($request); |
|
58 | 58 | |
59 | - if ( ! is_a( $response, ResponseInterface::class ) ) { |
|
60 | - if ( Framework::debugging() ) { |
|
61 | - throw new Exception( 'Response returned by controller is not valid (expectected ' . ResponseInterface::class . '; received ' . gettype( $response ) . ').' ); |
|
59 | + if ( ! is_a($response, ResponseInterface::class)) { |
|
60 | + if (Framework::debugging()) { |
|
61 | + throw new Exception('Response returned by controller is not valid (expectected ' . ResponseInterface::class . '; received ' . gettype($response) . ').'); |
|
62 | 62 | } |
63 | - $response = FrameworkResponse::error( FrameworkResponse::response(), 500 ); |
|
63 | + $response = FrameworkResponse::error(FrameworkResponse::response(), 500); |
|
64 | 64 | } |
65 | 65 | |
66 | - add_filter( 'carbon_framework_response', function() use ( $response ) { |
|
66 | + add_filter('carbon_framework_response', function() use ($response) { |
|
67 | 67 | return $response; |
68 | 68 | } ); |
69 | 69 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param RouteInterface $route |
22 | 22 | * @return RouteInterface |
23 | 23 | */ |
24 | - public function addRoute( $route ); |
|
24 | + public function addRoute($route); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Create and add a new route |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string|Closure $handler |
32 | 32 | * @return RouteInterface |
33 | 33 | */ |
34 | - public function route( $methods, $target, $handler ); |
|
34 | + public function route($methods, $target, $handler); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Create and add a route group |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param Closure $callable |
41 | 41 | * @return RouteInterface |
42 | 42 | */ |
43 | - public function group( $target, Closure $callable ); |
|
43 | + public function group($target, Closure $callable); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Create and add a route for the GET and HEAD methods |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string|Closure $handler |
50 | 50 | * @return RouteInterface |
51 | 51 | */ |
52 | - public function get( $target, $handler ); |
|
52 | + public function get($target, $handler); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Create and add a route for the POST method |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param string|Closure $handler |
59 | 59 | * @return RouteInterface |
60 | 60 | */ |
61 | - public function post( $target, $handler ); |
|
61 | + public function post($target, $handler); |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Create and add a route for the PUT method |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param string|Closure $handler |
68 | 68 | * @return RouteInterface |
69 | 69 | */ |
70 | - public function put( $target, $handler ); |
|
70 | + public function put($target, $handler); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Create and add a route for the PATCH method |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string|Closure $handler |
77 | 77 | * @return RouteInterface |
78 | 78 | */ |
79 | - public function patch( $target, $handler ); |
|
79 | + public function patch($target, $handler); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Create and add a route for the DELETE method |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string|Closure $handler |
86 | 86 | * @return RouteInterface |
87 | 87 | */ |
88 | - public function delete( $target, $handler ); |
|
88 | + public function delete($target, $handler); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Create and add a route for the OPTIONS method |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param string|Closure $handler |
95 | 95 | * @return RouteInterface |
96 | 96 | */ |
97 | - public function options( $target, $handler ); |
|
97 | + public function options($target, $handler); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Create and add a route for all supported methods |
@@ -103,5 +103,5 @@ discard block |
||
103 | 103 | * @param string|Closure $handler |
104 | 104 | * @return RouteInterface |
105 | 105 | */ |
106 | - public function any( $target, $handler ); |
|
106 | + public function any($target, $handler); |
|
107 | 107 | } |
@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | * @param string|ConditionInterface $target |
31 | 31 | * @param Closure $callable |
32 | 32 | */ |
33 | - public function __construct( $target, Closure $callable ) { |
|
34 | - if ( is_string( $target ) ) { |
|
35 | - $target = new UrlCondition( $target ); |
|
33 | + public function __construct($target, Closure $callable) { |
|
34 | + if (is_string($target)) { |
|
35 | + $target = new UrlCondition($target); |
|
36 | 36 | } |
37 | 37 | |
38 | - if ( ! is_a( $target, UrlCondition::class ) ) { |
|
39 | - throw new Exception( 'Route groups can only use route strings.' ); |
|
38 | + if ( ! is_a($target, UrlCondition::class)) { |
|
39 | + throw new Exception('Route groups can only use route strings.'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $this->target = $target; |
43 | 43 | |
44 | - $callable( $this ); |
|
44 | + $callable($this); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | */ |
52 | 52 | protected function getSatisfiedRoute() { |
53 | 53 | $routes = $this->getRoutes(); |
54 | - foreach ( $routes as $route ) { |
|
55 | - if ( $route->satisfied() ) { |
|
54 | + foreach ($routes as $route) { |
|
55 | + if ($route->satisfied()) { |
|
56 | 56 | return $route; |
57 | 57 | } |
58 | 58 | } |
@@ -70,37 +70,37 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * {@inheritDoc} |
72 | 72 | */ |
73 | - public function handle( $request ) { |
|
73 | + public function handle($request) { |
|
74 | 74 | $route = $this->getSatisfiedRoute(); |
75 | - return $route ? $route->handle( $request ) : null; |
|
75 | + return $route ? $route->handle($request) : null; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * {@inheritDoc} |
80 | 80 | */ |
81 | - public function route( $methods, $target, $handler ) { |
|
82 | - if ( is_string( $target ) ) { |
|
83 | - $target = new UrlCondition( $target ); |
|
81 | + public function route($methods, $target, $handler) { |
|
82 | + if (is_string($target)) { |
|
83 | + $target = new UrlCondition($target); |
|
84 | 84 | } |
85 | 85 | |
86 | - if ( ! is_a( $target, UrlCondition::class ) ) { |
|
87 | - throw new Exception( 'Routes inside route groups can only use route strings.' ); |
|
86 | + if ( ! is_a($target, UrlCondition::class)) { |
|
87 | + throw new Exception('Routes inside route groups can only use route strings.'); |
|
88 | 88 | } |
89 | 89 | |
90 | - $target = $this->target->concatenate( $target ); |
|
91 | - return $this->traitRoute( $methods, $target, $handler ); |
|
90 | + $target = $this->target->concatenate($target); |
|
91 | + return $this->traitRoute($methods, $target, $handler); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
95 | 95 | * {@inheritDoc} |
96 | 96 | */ |
97 | - public function addMiddleware( $middleware ) { |
|
97 | + public function addMiddleware($middleware) { |
|
98 | 98 | $routes = $this->getRoutes(); |
99 | 99 | |
100 | - foreach ( $routes as $route ) { |
|
101 | - $route->addMiddleware( $middleware ); |
|
100 | + foreach ($routes as $route) { |
|
101 | + $route->addMiddleware($middleware); |
|
102 | 102 | } |
103 | 103 | |
104 | - return $this->traitAddMiddleware( $middleware ); |
|
104 | + return $this->traitAddMiddleware($middleware); |
|
105 | 105 | } |
106 | 106 | } |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param string $url |
44 | 44 | */ |
45 | - public function __construct( $url ) { |
|
46 | - $url = UrlUtility::addLeadingSlash( $url ); |
|
47 | - $url = UrlUtility::addTrailingSlash( $url ); |
|
45 | + public function __construct($url) { |
|
46 | + $url = UrlUtility::addLeadingSlash($url); |
|
47 | + $url = UrlUtility::addTrailingSlash($url); |
|
48 | 48 | $this->url = $url; |
49 | 49 | } |
50 | 50 | |
@@ -52,28 +52,28 @@ discard block |
||
52 | 52 | * {@inheritDoc} |
53 | 53 | */ |
54 | 54 | public function satisfied() { |
55 | - $validation_regex = $this->getValidationRegex( $this->getUrl() ); |
|
55 | + $validation_regex = $this->getValidationRegex($this->getUrl()); |
|
56 | 56 | $url = $this->getCurrentPath(); |
57 | - return (bool) preg_match( $validation_regex, $url ); |
|
57 | + return (bool) preg_match($validation_regex, $url); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * {@inheritDoc} |
62 | 62 | */ |
63 | 63 | public function getArguments() { |
64 | - $validation_regex = $this->getValidationRegex( $this->getUrl() ); |
|
64 | + $validation_regex = $this->getValidationRegex($this->getUrl()); |
|
65 | 65 | $url = $this->getCurrentPath(); |
66 | 66 | $matches = []; |
67 | - $success = preg_match( $validation_regex, $url, $matches ); |
|
67 | + $success = preg_match($validation_regex, $url, $matches); |
|
68 | 68 | |
69 | - if ( ! $success ) { |
|
69 | + if ( ! $success) { |
|
70 | 70 | return []; // this should not normally happen |
71 | 71 | } |
72 | 72 | |
73 | 73 | $arguments = []; |
74 | - $parameter_names = $this->getParameterNames( $this->getUrl() ); |
|
75 | - foreach ( $parameter_names as $parameter_name ) { |
|
76 | - $arguments[] = ! empty( $matches[ $parameter_name ] ) ? $matches[ $parameter_name ] : ''; |
|
74 | + $parameter_names = $this->getParameterNames($this->getUrl()); |
|
75 | + foreach ($parameter_names as $parameter_name) { |
|
76 | + $arguments[] = ! empty($matches[$parameter_name]) ? $matches[$parameter_name] : ''; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $arguments; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return string |
95 | 95 | */ |
96 | 96 | protected function getCurrentPath() { |
97 | - return UrlUtility::addTrailingSlash( UrlUtility::getCurrentPath() ); |
|
97 | + return UrlUtility::addTrailingSlash(UrlUtility::getCurrentPath()); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | * @param Url $url |
104 | 104 | * @return Url |
105 | 105 | */ |
106 | - public function concatenate( Url $url ) { |
|
107 | - return new static( UrlUtility::removeTrailingSlash( $this->getUrl() ) . $url->getUrl() ); |
|
106 | + public function concatenate(Url $url) { |
|
107 | + return new static(UrlUtility::removeTrailingSlash($this->getUrl()) . $url->getUrl()); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | * @param string $url |
114 | 114 | * @return string[] |
115 | 115 | */ |
116 | - protected function getParameterNames( $url ) { |
|
116 | + protected function getParameterNames($url) { |
|
117 | 117 | $matches = []; |
118 | - preg_match_all( $this->url_regex, $url, $matches ); |
|
118 | + preg_match_all($this->url_regex, $url, $matches); |
|
119 | 119 | return $matches['name']; |
120 | 120 | } |
121 | 121 | |
@@ -125,29 +125,29 @@ discard block |
||
125 | 125 | * @param string $url |
126 | 126 | * @return string |
127 | 127 | */ |
128 | - protected function getValidationRegex( $url ) { |
|
128 | + protected function getValidationRegex($url) { |
|
129 | 129 | $parameters = []; |
130 | 130 | |
131 | 131 | // Replace all parameters with placeholders |
132 | - $validation_regex = preg_replace_callback( $this->url_regex, function( $matches ) use ( &$parameters ) { |
|
132 | + $validation_regex = preg_replace_callback($this->url_regex, function($matches) use (&$parameters) { |
|
133 | 133 | $name = $matches['name']; |
134 | - $optional = ! empty( $matches['optional'] ); |
|
135 | - $regex = ! empty( $matches['regex'] ) ? $matches['regex'] : $this->parameter_regex; |
|
134 | + $optional = ! empty($matches['optional']); |
|
135 | + $regex = ! empty($matches['regex']) ? $matches['regex'] : $this->parameter_regex; |
|
136 | 136 | $replacement = '(?:/(?P<' . $name . '>' . $regex . '))'; |
137 | - if ( $optional ) { |
|
137 | + if ($optional) { |
|
138 | 138 | $replacement .= '?'; |
139 | 139 | } |
140 | 140 | |
141 | - $placeholder = '___placeholder_' . sha1( count( $parameters) . '_' . $replacement . '_' . uniqid() ) . '___'; |
|
142 | - $parameters[ $placeholder ] = $replacement; |
|
141 | + $placeholder = '___placeholder_' . sha1(count($parameters) . '_' . $replacement . '_' . uniqid()) . '___'; |
|
142 | + $parameters[$placeholder] = $replacement; |
|
143 | 143 | return $placeholder; |
144 | - }, $url ); |
|
144 | + }, $url); |
|
145 | 145 | |
146 | 146 | // quote the remaining string so that it does not get evaluated as regex |
147 | - $validation_regex = preg_quote( $validation_regex, '~' ); |
|
147 | + $validation_regex = preg_quote($validation_regex, '~'); |
|
148 | 148 | |
149 | 149 | // replace the placeholders with the real parameter regexes |
150 | - $validation_regex = str_replace( array_keys( $parameters ), array_values( $parameters ), $validation_regex ); |
|
150 | + $validation_regex = str_replace(array_keys($parameters), array_values($parameters), $validation_regex); |
|
151 | 151 | |
152 | 152 | // make sure that the regex matches the entire string |
153 | 153 | $validation_regex = '~\A' . $validation_regex . '\z~'; |
@@ -12,22 +12,22 @@ |
||
12 | 12 | /** |
13 | 13 | * {@inheritDoc} |
14 | 14 | */ |
15 | - public function register( $container ) { |
|
16 | - $container['framework.global_middleware'] = array_merge( $container['framework.global_middleware'], [ |
|
15 | + public function register($container) { |
|
16 | + $container['framework.global_middleware'] = array_merge($container['framework.global_middleware'], [ |
|
17 | 17 | OldInputMiddleware::class, |
18 | - ] ); |
|
18 | + ]); |
|
19 | 19 | |
20 | 20 | $container['framework.old_input.old_input'] = function() { |
21 | 21 | return new \CarbonFramework\Input\OldInput(); |
22 | 22 | }; |
23 | 23 | |
24 | - Framework::facade( 'OldInput', \CarbonFramework\Facades\OldInput::class ); |
|
24 | + Framework::facade('OldInput', \CarbonFramework\Facades\OldInput::class); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * {@inheritDoc} |
29 | 29 | */ |
30 | - public function boot( $container ) { |
|
30 | + public function boot($container) { |
|
31 | 31 | // nothing to boot |
32 | 32 | } |
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * {@inheritDoc} |
13 | 13 | */ |
14 | - public function register( $container ) { |
|
14 | + public function register($container) { |
|
15 | 15 | $container['framework.templating.engine'] = function() { |
16 | 16 | return new \CarbonFramework\Templating\Php(); |
17 | 17 | }; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * {@inheritDoc} |
22 | 22 | */ |
23 | - public function boot( $container ) { |
|
23 | + public function boot($container) { |
|
24 | 24 | // nothing to boot |
25 | 25 | } |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * {@inheritDoc} |
13 | 13 | */ |
14 | - public function register( $container ) { |
|
15 | - $container['framework.config'] = array_merge( [ |
|
14 | + public function register($container) { |
|
15 | + $container['framework.config'] = array_merge([ |
|
16 | 16 | 'global_middleware' => [], |
17 | - ], $container['framework.config'] ); |
|
17 | + ], $container['framework.config']); |
|
18 | 18 | |
19 | 19 | $container['framework.global_middleware'] = $container['framework.config']['global_middleware']; |
20 | - $container['framework.global_middleware'] = apply_filters( 'carbon_framework_global_middleware', $container['framework.global_middleware'] ); |
|
20 | + $container['framework.global_middleware'] = apply_filters('carbon_framework_global_middleware', $container['framework.global_middleware']); |
|
21 | 21 | |
22 | 22 | $container['framework.routing.conditions.custom'] = \CarbonFramework\Routing\Conditions\Custom::class; |
23 | 23 | $container['framework.routing.conditions.url'] = \CarbonFramework\Routing\Conditions\Url::class; |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | return new \CarbonFramework\Routing\Router(); |
31 | 31 | }; |
32 | 32 | |
33 | - Framework::facade( 'Router', \CarbonFramework\Facades\Router::class ); |
|
33 | + Framework::facade('Router', \CarbonFramework\Facades\Router::class); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * {@inheritDoc} |
38 | 38 | */ |
39 | - public function boot( $container ) { |
|
39 | + public function boot($container) { |
|
40 | 40 | \Router::boot(); // facade |
41 | 41 | } |
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return Request |
57 | 57 | */ |
58 | 58 | public static function fromGlobals() { |
59 | - return new static( stripslashes_deep( $_GET ), stripslashes_deep( $_POST ), $_COOKIE, $_FILES, $_SERVER, getallheaders() ); |
|
59 | + return new static(stripslashes_deep($_GET), stripslashes_deep($_POST), $_COOKIE, $_FILES, $_SERVER, getallheaders()); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param array $server |
70 | 70 | * @param array $headers |
71 | 71 | */ |
72 | - public function __construct( $get, $post, $cookie, $files, $server, $headers ) { |
|
72 | + public function __construct($get, $post, $cookie, $files, $server, $headers) { |
|
73 | 73 | $this->get = $get; |
74 | 74 | $this->post = $post; |
75 | 75 | $this->cookie = $cookie; |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * @return string |
85 | 85 | */ |
86 | 86 | public function getMethod() { |
87 | - $method = (string) Arr::get( $this->server, 'REQUEST_METHOD', 'GET' ); |
|
87 | + $method = (string) Arr::get($this->server, 'REQUEST_METHOD', 'GET'); |
|
88 | 88 | |
89 | - $override = (string) Arr::get( $this->headers, 'X-HTTP-METHOD-OVERRIDE' ); |
|
90 | - if ( $method === 'POST' && $override ) { |
|
89 | + $override = (string) Arr::get($this->headers, 'X-HTTP-METHOD-OVERRIDE'); |
|
90 | + if ($method === 'POST' && $override) { |
|
91 | 91 | $method = $override; |
92 | 92 | } |
93 | 93 | |
94 | - return strtoupper( $method ); |
|
94 | + return strtoupper($method); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | * @return string |
101 | 101 | */ |
102 | 102 | public function getUrl() { |
103 | - $https = Arr::get( $this->server, 'HTTPS' ); |
|
103 | + $https = Arr::get($this->server, 'HTTPS'); |
|
104 | 104 | |
105 | 105 | $protocol = $https ? 'https' : 'http'; |
106 | - $host = (string) Arr::get( $this->server, 'HTTP_HOST', '' ); |
|
107 | - $uri = (string) Arr::get( $this->server, 'REQUEST_URI', '' ); |
|
106 | + $host = (string) Arr::get($this->server, 'HTTP_HOST', ''); |
|
107 | + $uri = (string) Arr::get($this->server, 'REQUEST_URI', ''); |
|
108 | 108 | |
109 | 109 | return $protocol . '://' . $host . $uri; |
110 | 110 | } |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | $args = func_get_args(); |
119 | 119 | $source = $this->{$args[0]}; |
120 | 120 | |
121 | - if ( count( $args ) === 1 ) { |
|
121 | + if (count($args) === 1) { |
|
122 | 122 | return $source; |
123 | 123 | } |
124 | 124 | |
125 | 125 | $args[0] = $source; |
126 | - return call_user_func_array( [Arr::class, 'get'], $args ); |
|
126 | + return call_user_func_array([Arr::class, 'get'], $args); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @return mixed |
133 | 133 | */ |
134 | 134 | public function get() { |
135 | - return call_user_func_array( [$this, 'input'], array_merge( ['get'], func_get_args() ) ); |
|
135 | + return call_user_func_array([$this, 'input'], array_merge(['get'], func_get_args())); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @return mixed |
142 | 142 | */ |
143 | 143 | public function post() { |
144 | - return call_user_func_array( [$this, 'input'], array_merge( ['post'], func_get_args() ) ); |
|
144 | + return call_user_func_array([$this, 'input'], array_merge(['post'], func_get_args())); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return mixed |
151 | 151 | */ |
152 | 152 | public function cookie() { |
153 | - return call_user_func_array( [$this, 'input'], array_merge( ['cookie'], func_get_args() ) ); |
|
153 | + return call_user_func_array([$this, 'input'], array_merge(['cookie'], func_get_args())); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @return mixed |
160 | 160 | */ |
161 | 161 | public function files() { |
162 | - return call_user_func_array( [$this, 'input'], array_merge( ['files'], func_get_args() ) ); |
|
162 | + return call_user_func_array([$this, 'input'], array_merge(['files'], func_get_args())); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return mixed |
169 | 169 | */ |
170 | 170 | public function server() { |
171 | - return call_user_func_array( [$this, 'input'], array_merge( ['server'], func_get_args() ) ); |
|
171 | + return call_user_func_array([$this, 'input'], array_merge(['server'], func_get_args())); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -177,6 +177,6 @@ discard block |
||
177 | 177 | * @return mixed |
178 | 178 | */ |
179 | 179 | public function headers() { |
180 | - return call_user_func_array( [$this, 'input'], array_merge( ['headers'], func_get_args() ) ); |
|
180 | + return call_user_func_array([$this, 'input'], array_merge(['headers'], func_get_args())); |
|
181 | 181 | } |
182 | 182 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @return boolean |
39 | 39 | */ |
40 | 40 | public static function debugging() { |
41 | - return ( defined( 'WP_DEBUG' ) && WP_DEBUG ); |
|
41 | + return (defined('WP_DEBUG') && WP_DEBUG); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | * @return null |
58 | 58 | */ |
59 | 59 | public static function verifyBoot() { |
60 | - if ( ! static::isBooted() ) { |
|
61 | - throw new Exception( get_called_class() . ' must be booted first.' ); |
|
60 | + if ( ! static::isBooted()) { |
|
61 | + throw new Exception(get_called_class() . ' must be booted first.'); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return Container |
69 | 69 | */ |
70 | 70 | public static function getContainer() { |
71 | - if ( static::$container === null ) { |
|
71 | + if (static::$container === null) { |
|
72 | 72 | static::$container = new Container(); |
73 | 73 | } |
74 | 74 | return static::$container; |
@@ -82,29 +82,29 @@ discard block |
||
82 | 82 | * @throws Exception |
83 | 83 | * @return null |
84 | 84 | */ |
85 | - public static function boot( $config ) { |
|
86 | - if ( static::isBooted() ) { |
|
87 | - throw new Exception( get_called_class() . ' already booted.' ); |
|
85 | + public static function boot($config) { |
|
86 | + if (static::isBooted()) { |
|
87 | + throw new Exception(get_called_class() . ' already booted.'); |
|
88 | 88 | } |
89 | 89 | static::$booted = true; |
90 | 90 | |
91 | 91 | $container = static::getContainer(); |
92 | 92 | |
93 | - $container['framework.config'] = array_merge( [ |
|
93 | + $container['framework.config'] = array_merge([ |
|
94 | 94 | 'providers' => [], |
95 | - ], $config ); |
|
95 | + ], $config); |
|
96 | 96 | |
97 | - $container['framework.service_providers'] = array_merge( [ |
|
97 | + $container['framework.service_providers'] = array_merge([ |
|
98 | 98 | RoutingServiceProvider::class, |
99 | 99 | FlashServiceProvider::class, |
100 | 100 | OldInputServiceProvider::class, |
101 | 101 | TemplatingServiceProvider::class, |
102 | - ], $container['framework.config']['providers'] ); |
|
102 | + ], $container['framework.config']['providers']); |
|
103 | 103 | |
104 | - Facade::setFacadeApplication( $container ); |
|
104 | + Facade::setFacadeApplication($container); |
|
105 | 105 | AliasLoader::getInstance()->register(); |
106 | 106 | |
107 | - static::loadServiceProviders( $container ); |
|
107 | + static::loadServiceProviders($container); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | * @param Container $container |
114 | 114 | * @return null |
115 | 115 | */ |
116 | - protected static function loadServiceProviders( $container ) { |
|
117 | - $container['framework.service_providers'] = apply_filters( 'carbon_framework_service_providers', $container['framework.service_providers'] ); |
|
116 | + protected static function loadServiceProviders($container) { |
|
117 | + $container['framework.service_providers'] = apply_filters('carbon_framework_service_providers', $container['framework.service_providers']); |
|
118 | 118 | |
119 | - $service_providers = array_map( function( $service_provider ) { |
|
119 | + $service_providers = array_map(function($service_provider) { |
|
120 | 120 | return new $service_provider(); |
121 | - }, $container['framework.service_providers'] ); |
|
121 | + }, $container['framework.service_providers']); |
|
122 | 122 | |
123 | - static::registerServiceProviders( $service_providers, $container ); |
|
124 | - static::bootServiceProviders( $service_providers, $container ); |
|
123 | + static::registerServiceProviders($service_providers, $container); |
|
124 | + static::bootServiceProviders($service_providers, $container); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param Container $container |
131 | 131 | * @return null |
132 | 132 | */ |
133 | - protected static function registerServiceProviders( $service_providers, $container ) { |
|
134 | - foreach ( $service_providers as $provider ) { |
|
135 | - $provider->register( $container ); |
|
133 | + protected static function registerServiceProviders($service_providers, $container) { |
|
134 | + foreach ($service_providers as $provider) { |
|
135 | + $provider->register($container); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @param Container $container |
143 | 143 | * @return null |
144 | 144 | */ |
145 | - protected static function bootServiceProviders( $service_providers, $container ) { |
|
146 | - foreach ( $service_providers as $provider ) { |
|
147 | - $provider->boot( $container ); |
|
145 | + protected static function bootServiceProviders($service_providers, $container) { |
|
146 | + foreach ($service_providers as $provider) { |
|
147 | + $provider->boot($container); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @param string $facade_class |
156 | 156 | * @return null |
157 | 157 | */ |
158 | - public static function facade( $alias, $facade_class ) { |
|
159 | - AliasLoader::getInstance()->alias( $alias, $facade_class ); |
|
158 | + public static function facade($alias, $facade_class) { |
|
159 | + AliasLoader::getInstance()->alias($alias, $facade_class); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | * @param string $key |
166 | 166 | * @return mixed|null |
167 | 167 | */ |
168 | - public static function resolve( $key ) { |
|
168 | + public static function resolve($key) { |
|
169 | 169 | static::verifyBoot(); |
170 | 170 | |
171 | - if ( ! isset( static::getContainer()[ $key ] ) ) { |
|
171 | + if ( ! isset(static::getContainer()[$key])) { |
|
172 | 172 | return null; |
173 | 173 | } |
174 | 174 | |
175 | - return static::getContainer()[ $key ]; |
|
175 | + return static::getContainer()[$key]; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -181,28 +181,28 @@ discard block |
||
181 | 181 | * @param string $class |
182 | 182 | * @return object |
183 | 183 | */ |
184 | - public static function instantiate( $class ) { |
|
184 | + public static function instantiate($class) { |
|
185 | 185 | static::verifyBoot(); |
186 | 186 | |
187 | - $instance = static::resolve( $class ); |
|
188 | - if ( $instance === null ) { |
|
187 | + $instance = static::resolve($class); |
|
188 | + if ($instance === null) { |
|
189 | 189 | try { |
190 | - $reflection = new ReflectionMethod( $class, '__construct' ); |
|
190 | + $reflection = new ReflectionMethod($class, '__construct'); |
|
191 | 191 | |
192 | - if ( ! $reflection->isPublic() ) { |
|
193 | - throw new Exception( $class . '::__construct() is not public.' ); |
|
192 | + if ( ! $reflection->isPublic()) { |
|
193 | + throw new Exception($class . '::__construct() is not public.'); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | $parameters = $reflection->getParameters(); |
197 | 197 | |
198 | - $required_parameters = array_filter( $parameters, function( $parameter ) { |
|
198 | + $required_parameters = array_filter($parameters, function($parameter) { |
|
199 | 199 | return ! $parameter->isOptional(); |
200 | 200 | } ); |
201 | 201 | |
202 | - if ( ! empty( $required_parameters ) ) { |
|
203 | - throw new Exception( $class . '::__construct() has requird parameters but could not be resolved from container. Did you miss to define it into the container?' ); |
|
202 | + if ( ! empty($required_parameters)) { |
|
203 | + throw new Exception($class . '::__construct() has requird parameters but could not be resolved from container. Did you miss to define it into the container?'); |
|
204 | 204 | } |
205 | - } catch ( ReflectionException $e ) { |
|
205 | + } catch (ReflectionException $e) { |
|
206 | 206 | // __constructor is not defined so we are free to create a new instance |
207 | 207 | } |
208 | 208 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param ResponseInterface $response |
219 | 219 | * @return null |
220 | 220 | */ |
221 | - public static function respond( ResponseInterface $response ) { |
|
222 | - Response::respond( $response ); |
|
221 | + public static function respond(ResponseInterface $response) { |
|
222 | + Response::respond($response); |
|
223 | 223 | } |
224 | 224 | } |