@@ -40,6 +40,5 @@ |
||
40 | 40 | * @class HttpClientException |
41 | 41 | * @package Platine\Framework\Http\Client |
42 | 42 | */ |
43 | -class HttpClientException extends Exception |
|
44 | -{ |
|
43 | +class HttpClientException extends Exception { |
|
45 | 44 | } |
@@ -59,14 +59,12 @@ discard block |
||
59 | 59 | * @package Platine\Framework\Form\Param |
60 | 60 | * @template TEntity as Entity |
61 | 61 | */ |
62 | -class BaseParam implements JsonSerializable |
|
63 | -{ |
|
62 | +class BaseParam implements JsonSerializable { |
|
64 | 63 | /** |
65 | 64 | * Create new instance |
66 | 65 | * @param array<string, mixed> $data |
67 | 66 | */ |
68 | - public function __construct(array $data = []) |
|
69 | - { |
|
67 | + public function __construct(array $data = []) { |
|
70 | 68 | // Load default values |
71 | 69 | $this->loadDefaultValues(); |
72 | 70 | |
@@ -81,14 +79,14 @@ discard block |
||
81 | 79 | */ |
82 | 80 | public function load(array $data): void |
83 | 81 | { |
84 | - foreach ($data as $name => $value) { |
|
82 | + foreach ($data as $name => $value) { |
|
85 | 83 | $key = Str::camel($name, true); |
86 | 84 | $typedValue = $this->getPropertyValue($key, $value); |
87 | 85 | |
88 | 86 | $setterMethod = 'set' . ucfirst($key); |
89 | - if (method_exists($this, $setterMethod)) { |
|
87 | + if (method_exists($this, $setterMethod)) { |
|
90 | 88 | $this->{$setterMethod}($typedValue); |
91 | - } elseif (property_exists($this, $key)) { |
|
89 | + } elseif (property_exists($this, $key)) { |
|
92 | 90 | $this->{$key} = $typedValue; |
93 | 91 | } |
94 | 92 | } |
@@ -126,8 +124,7 @@ discard block |
||
126 | 124 | * Convert parameter to JSON array |
127 | 125 | * @return array<string, mixed> |
128 | 126 | */ |
129 | - public function jsonSerialize() |
|
130 | - { |
|
127 | + public function jsonSerialize() { |
|
131 | 128 | return $this->data(); |
132 | 129 | } |
133 | 130 | |
@@ -136,15 +133,14 @@ discard block |
||
136 | 133 | * @param string $name |
137 | 134 | * @return mixed|null |
138 | 135 | */ |
139 | - public function __get($name) |
|
140 | - { |
|
141 | - if (property_exists($this, $name)) { |
|
136 | + public function __get($name) { |
|
137 | + if (property_exists($this, $name)) { |
|
142 | 138 | return $this->{$name}; |
143 | 139 | } |
144 | 140 | |
145 | 141 | //convert to camel |
146 | 142 | $key = Str::camel($name, true); |
147 | - if (property_exists($this, $key)) { |
|
143 | + if (property_exists($this, $key)) { |
|
148 | 144 | return $this->{$key}; |
149 | 145 | } |
150 | 146 | |
@@ -157,11 +153,10 @@ discard block |
||
157 | 153 | * @param mixed $value |
158 | 154 | * @return mixed |
159 | 155 | */ |
160 | - protected function getPropertyValue(string $attribute, $value) |
|
161 | - { |
|
156 | + protected function getPropertyValue(string $attribute, $value) { |
|
162 | 157 | $types = $this->getPropertyTypes(); |
163 | 158 | $property = $types[$attribute] ?? null; |
164 | - if ($property === null) { |
|
159 | + if ($property === null) { |
|
165 | 160 | return $value; |
166 | 161 | } |
167 | 162 | |
@@ -171,13 +166,13 @@ discard block |
||
171 | 166 | if ( |
172 | 167 | in_array($type, ['array', 'object']) === false && |
173 | 168 | strlen((string) $value) === 0 && $allowNull |
174 | - ) { |
|
169 | + ) { |
|
175 | 170 | return null; |
176 | 171 | } |
177 | 172 | |
178 | 173 | $maps = $this->getPropertiesCastMaps(); |
179 | 174 | $map = $maps[$type] ?? []; |
180 | - if (count($map) === 0) { |
|
175 | + if (count($map) === 0) { |
|
181 | 176 | return $value; |
182 | 177 | } |
183 | 178 | |
@@ -197,10 +192,10 @@ discard block |
||
197 | 192 | $reflectionClass = new ReflectionClass($this); |
198 | 193 | /** @var ReflectionProperty[] $properties */ |
199 | 194 | $properties = $reflectionClass->getProperties(ReflectionProperty::IS_PROTECTED); |
200 | - foreach ($properties as $property) { |
|
195 | + foreach ($properties as $property) { |
|
201 | 196 | /** @var ReflectionNamedType|null $type */ |
202 | 197 | $type = $property->getType(); |
203 | - if ($type !== null && $type->isBuiltin()) { |
|
198 | + if ($type !== null && $type->isBuiltin()) { |
|
204 | 199 | $props[$property->getName()] = [$type->getName(), $type->allowsNull(), $property]; |
205 | 200 | } |
206 | 201 | } |
@@ -234,11 +229,11 @@ discard block |
||
234 | 229 | $types = $this->getPropertyTypes(); |
235 | 230 | $maps = $this->getPropertiesCastMaps(); |
236 | 231 | |
237 | - foreach ($types as $attr => $val) { |
|
232 | + foreach ($types as $attr => $val) { |
|
238 | 233 | /** @var ReflectionProperty $property */ |
239 | 234 | $property = $val[2]; |
240 | 235 | $property->setAccessible(true); |
241 | - if (isset($maps[$val[0]]) && $property->isInitialized($this) === false) { |
|
236 | + if (isset($maps[$val[0]]) && $property->isInitialized($this) === false) { |
|
242 | 237 | $data[$attr] = $maps[$val[0]][1]; |
243 | 238 | } |
244 | 239 | } |
@@ -54,14 +54,12 @@ |
||
54 | 54 | * @class AbstractValidator |
55 | 55 | * @package Platine\Framework\Form\Validator |
56 | 56 | */ |
57 | -abstract class AbstractValidator extends Validator |
|
58 | -{ |
|
57 | +abstract class AbstractValidator extends Validator { |
|
59 | 58 | /** |
60 | 59 | * Create new instance |
61 | 60 | * @param Lang $lang |
62 | 61 | */ |
63 | - public function __construct(Lang $lang) |
|
64 | - { |
|
62 | + public function __construct(Lang $lang) { |
|
65 | 63 | parent::__construct($lang); |
66 | 64 | } |
67 | 65 |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | * @class BaseKernel |
54 | 54 | * @package Platine\Framework\Kernel |
55 | 55 | */ |
56 | -class BaseKernel |
|
57 | -{ |
|
56 | +class BaseKernel { |
|
58 | 57 | /** |
59 | 58 | * Application instance |
60 | 59 | * @var Application |
@@ -65,8 +64,7 @@ discard block |
||
65 | 64 | * Create new instance |
66 | 65 | * @param Application $app |
67 | 66 | */ |
68 | - public function __construct(Application $app) |
|
69 | - { |
|
67 | + public function __construct(Application $app) { |
|
70 | 68 | $this->app = $app; |
71 | 69 | } |
72 | 70 |
@@ -66,8 +66,7 @@ discard block |
||
66 | 66 | * @package Platine\Framework\Kernel |
67 | 67 | * @template T |
68 | 68 | */ |
69 | -class HttpKernel extends BaseKernel implements RequestHandlerInterface |
|
70 | -{ |
|
69 | +class HttpKernel extends BaseKernel implements RequestHandlerInterface { |
|
71 | 70 | /** |
72 | 71 | * The router instance |
73 | 72 | * @var Router |
@@ -96,7 +95,7 @@ discard block |
||
96 | 95 | Application $app, |
97 | 96 | Router $router, |
98 | 97 | MiddlewareResolverInterface $middlewareResolver |
99 | - ) { |
|
98 | + ) { |
|
100 | 99 | parent::__construct($app); |
101 | 100 | $this->router = $router; |
102 | 101 | $this->middlewareResolver = $middlewareResolver; |
@@ -167,7 +166,7 @@ discard block |
||
167 | 166 | { |
168 | 167 | $handler = clone $this; |
169 | 168 | $middleware = current($handler->middlewares); |
170 | - if ($middleware === false) { |
|
169 | + if ($middleware === false) { |
|
171 | 170 | throw new HttpNotFoundException($request); |
172 | 171 | } |
173 | 172 | next($handler->middlewares); |
@@ -198,7 +197,7 @@ discard block |
||
198 | 197 | //Load providers routes |
199 | 198 | /** @var ServiceProvider[] $providers */ |
200 | 199 | $providers = $this->app->getProviders(); |
201 | - foreach ($providers as $provider) { |
|
200 | + foreach ($providers as $provider) { |
|
202 | 201 | $provider->addRoutes($this->router); |
203 | 202 | } |
204 | 203 | |
@@ -217,7 +216,7 @@ discard block |
||
217 | 216 | /** @var string[] $middlewares */ |
218 | 217 | $middlewares = $config->get('middlewares', []); |
219 | 218 | $this->app->watch()->start('register-middlewares'); |
220 | - foreach ($middlewares as $middleware) { |
|
219 | + foreach ($middlewares as $middleware) { |
|
221 | 220 | $this->use($middleware); |
222 | 221 | } |
223 | 222 | $this->app->watch()->stop('register-middlewares'); |
@@ -233,7 +232,7 @@ discard block |
||
233 | 232 | protected function determineBasePath(): string |
234 | 233 | { |
235 | 234 | $appBasePath = $this->app->getBasePath(); |
236 | - if (!empty($appBasePath)) { |
|
235 | + if (!empty($appBasePath)) { |
|
237 | 236 | return $appBasePath; |
238 | 237 | } |
239 | 238 | |
@@ -241,7 +240,7 @@ discard block |
||
241 | 240 | $config = $this->app->get(Config::class); |
242 | 241 | $configBasePath = $config->get('app.base_path'); |
243 | 242 | |
244 | - if (!empty($configBasePath)) { |
|
243 | + if (!empty($configBasePath)) { |
|
245 | 244 | $this->app->setBasePath($configBasePath); |
246 | 245 | return $configBasePath; |
247 | 246 | } |
@@ -255,7 +254,7 @@ discard block |
||
255 | 254 | $server['SCRIPT_NAME'] ?? '' |
256 | 255 | ), 0, -1)); |
257 | 256 | $this->app->setBasePath($autoBasePath); |
258 | - if (!empty($autoBasePath)) { |
|
257 | + if (!empty($autoBasePath)) { |
|
259 | 258 | return $autoBasePath; |
260 | 259 | } |
261 | 260 |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * @package Platine\Framework\Kernel |
59 | 59 | * @template T |
60 | 60 | */ |
61 | -class ConsoleKernel extends BaseKernel |
|
62 | -{ |
|
61 | +class ConsoleKernel extends BaseKernel { |
|
63 | 62 | /** |
64 | 63 | * Console application instance |
65 | 64 | * @var ConsoleApp |
@@ -83,8 +82,7 @@ discard block |
||
83 | 82 | * @param Application $app |
84 | 83 | * @param ConsoleApp $console |
85 | 84 | */ |
86 | - public function __construct(Application $app, ConsoleApp $console) |
|
87 | - { |
|
85 | + public function __construct(Application $app, ConsoleApp $console) { |
|
88 | 86 | parent::__construct($app); |
89 | 87 | $this->console = $console; |
90 | 88 | } |
@@ -109,20 +107,20 @@ discard block |
||
109 | 107 | { |
110 | 108 | parent::bootstrap(); |
111 | 109 | |
112 | - if (!$this->commandsLoaded) { |
|
110 | + if (!$this->commandsLoaded) { |
|
113 | 111 | $this->registerConfiguredCommands(); |
114 | 112 | |
115 | 113 | //Load providers commands |
116 | 114 | /** @var class-string[] $commands */ |
117 | 115 | $commands = $this->app->getProvidersCommands(); |
118 | - foreach ($commands as $command) { |
|
116 | + foreach ($commands as $command) { |
|
119 | 117 | $this->addCommand($command); |
120 | 118 | } |
121 | 119 | |
122 | 120 | $this->commandsLoaded = true; |
123 | 121 | } |
124 | 122 | |
125 | - foreach ($this->commands as $command) { |
|
123 | + foreach ($this->commands as $command) { |
|
126 | 124 | $this->console->addCommand($command); |
127 | 125 | } |
128 | 126 | } |
@@ -134,7 +132,7 @@ discard block |
||
134 | 132 | */ |
135 | 133 | public function addCommand($command): void |
136 | 134 | { |
137 | - if (is_string($command)) { |
|
135 | + if (is_string($command)) { |
|
138 | 136 | $command = $this->createCommand($command); |
139 | 137 | } |
140 | 138 | |
@@ -161,7 +159,7 @@ discard block |
||
161 | 159 | |
162 | 160 | /** @var string[] $commands */ |
163 | 161 | $commands = $config->get('commands', []); |
164 | - foreach ($commands as $command) { |
|
162 | + foreach ($commands as $command) { |
|
165 | 163 | $this->addCommand($command); |
166 | 164 | } |
167 | 165 | } |
@@ -173,11 +171,11 @@ discard block |
||
173 | 171 | */ |
174 | 172 | protected function createCommand(string $command): Command |
175 | 173 | { |
176 | - if ($this->app->has($command)) { |
|
174 | + if ($this->app->has($command)) { |
|
177 | 175 | return $this->app->get($command); |
178 | 176 | } |
179 | 177 | |
180 | - if (class_exists($command)) { |
|
178 | + if (class_exists($command)) { |
|
181 | 179 | /** @var Command $o */ |
182 | 180 | $o = new $command(); |
183 | 181 | return $o; |
@@ -68,8 +68,8 @@ |
||
68 | 68 | protected string $name; |
69 | 69 | |
70 | 70 | /** |
71 | - * {@inheritdoc} |
|
72 | - */ |
|
71 | + * {@inheritdoc} |
|
72 | + */ |
|
73 | 73 | public function __construct(string $markup, &$tokens, Parser $parser) |
74 | 74 | { |
75 | 75 | $lexer = new Lexer('/' . Token::QUOTED_FRAGMENT . '/'); |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | * @class RouteUrlTag |
60 | 60 | * @package Platine\Framework\Template\Tag |
61 | 61 | */ |
62 | -class RouteUrlTag extends AbstractTag |
|
63 | -{ |
|
62 | +class RouteUrlTag extends AbstractTag { |
|
64 | 63 | /** |
65 | 64 | * The name of the route |
66 | 65 | * @var string |
@@ -70,13 +69,12 @@ discard block |
||
70 | 69 | /** |
71 | 70 | * {@inheritdoc} |
72 | 71 | */ |
73 | - public function __construct(string $markup, &$tokens, Parser $parser) |
|
74 | - { |
|
72 | + public function __construct(string $markup, &$tokens, Parser $parser) { |
|
75 | 73 | $lexer = new Lexer('/' . Token::QUOTED_FRAGMENT . '/'); |
76 | - if ($lexer->match($markup)) { |
|
74 | + if ($lexer->match($markup)) { |
|
77 | 75 | $this->name = $lexer->getStringMatch(0); |
78 | 76 | $this->extractAttributes($markup); |
79 | - } else { |
|
77 | + } else { |
|
80 | 78 | throw new ParseException(sprintf( |
81 | 79 | 'Syntax Error in "%s" - Valid syntax: route_url [name] [PARAMETERS ...]', |
82 | 80 | 'route_url' |
@@ -90,8 +88,8 @@ discard block |
||
90 | 88 | public function render(Context $context): string |
91 | 89 | { |
92 | 90 | $parameters = []; |
93 | - foreach ($this->attributes as $key => $value) { |
|
94 | - if ($context->hasKey($value)) { |
|
91 | + foreach ($this->attributes as $key => $value) { |
|
92 | + if ($context->hasKey($value)) { |
|
95 | 93 | $value = (string) $context->get($value); |
96 | 94 | } |
97 | 95 |
@@ -68,8 +68,8 @@ |
||
68 | 68 | protected string $value; |
69 | 69 | |
70 | 70 | /** |
71 | - * {@inheritdoc} |
|
72 | - */ |
|
71 | + * {@inheritdoc} |
|
72 | + */ |
|
73 | 73 | public function __construct(string $markup, &$tokens, Parser $parser) |
74 | 74 | { |
75 | 75 | $lexer = new Lexer('/' . Token::QUOTED_FRAGMENT . '/'); |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | * @class LangTag |
60 | 60 | * @package Platine\Framework\Template\Tag |
61 | 61 | */ |
62 | -class LangTag extends AbstractTag |
|
63 | -{ |
|
62 | +class LangTag extends AbstractTag { |
|
64 | 63 | /** |
65 | 64 | * Value to debug |
66 | 65 | * @var string |
@@ -70,12 +69,11 @@ discard block |
||
70 | 69 | /** |
71 | 70 | * {@inheritdoc} |
72 | 71 | */ |
73 | - public function __construct(string $markup, &$tokens, Parser $parser) |
|
74 | - { |
|
72 | + public function __construct(string $markup, &$tokens, Parser $parser) { |
|
75 | 73 | $lexer = new Lexer('/' . Token::QUOTED_FRAGMENT . '/'); |
76 | - if ($lexer->match($markup)) { |
|
74 | + if ($lexer->match($markup)) { |
|
77 | 75 | $this->value = $lexer->getStringMatch(0); |
78 | - } else { |
|
76 | + } else { |
|
79 | 77 | throw new ParseException(sprintf( |
80 | 78 | 'Syntax Error in "%s" - Valid syntax: tr [name]', |
81 | 79 | 'tr' |
@@ -88,7 +86,7 @@ discard block |
||
88 | 86 | */ |
89 | 87 | public function render(Context $context): string |
90 | 88 | { |
91 | - if ($context->hasKey($this->value)) { |
|
89 | + if ($context->hasKey($this->value)) { |
|
92 | 90 | $this->value = (string) $context->get($this->value); |
93 | 91 | } |
94 | 92 | /** @var Lang $lang */ |
@@ -55,8 +55,7 @@ |
||
55 | 55 | * @class CurrentUrlTag |
56 | 56 | * @package Platine\Framework\Template\Tag |
57 | 57 | */ |
58 | -class CurrentUrlTag extends AbstractTag |
|
59 | -{ |
|
58 | +class CurrentUrlTag extends AbstractTag { |
|
60 | 59 | /** |
61 | 60 | * {@inheritdoc} |
62 | 61 | */ |