@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function setDefaults(string $section, array $data): void |
64 | 64 | { |
65 | - if (isset($this->defaults[$section])) { |
|
65 | + if (isset($this->defaults[$section])){ |
|
66 | 66 | throw new ConfiguratorException("Unable to set default config `{$section}` more than once."); |
67 | 67 | } |
68 | 68 | |
69 | - if (isset($this->data[$section])) { |
|
69 | + if (isset($this->data[$section])){ |
|
70 | 70 | throw new ConfigDeliveredException("Unable to set default config `{$section}`, config has been loaded."); |
71 | 71 | } |
72 | 72 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function modify(string $section, PatchInterface $patch): array |
80 | 80 | { |
81 | - if (isset($this->instances[$section])) { |
|
82 | - if ($this->strict) { |
|
81 | + if (isset($this->instances[$section])){ |
|
82 | + if ($this->strict){ |
|
83 | 83 | throw new ConfigDeliveredException( |
84 | 84 | "Unable to patch config `{$section}`, config object has already been delivered." |
85 | 85 | ); |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | |
91 | 91 | $data = $this->getConfig($section); |
92 | 92 | |
93 | - try { |
|
93 | + try{ |
|
94 | 94 | return $this->data[$section] = $patch->patch($data); |
95 | - } catch (PatchException $e) { |
|
95 | + }catch (PatchException $e){ |
|
96 | 96 | throw new PatchException("Unable to modify config `{$section}`.", $e->getCode(), $e); |
97 | 97 | } |
98 | 98 | } |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function getConfig(string $section = null): array |
104 | 104 | { |
105 | - if (isset($this->data[$section])) { |
|
105 | + if (isset($this->data[$section])){ |
|
106 | 106 | return $this->data[$section]; |
107 | 107 | } |
108 | 108 | |
109 | - if (isset($this->defaults[$section])) { |
|
109 | + if (isset($this->defaults[$section])){ |
|
110 | 110 | $data = []; |
111 | - if ($this->loader->has($section)) { |
|
111 | + if ($this->loader->has($section)){ |
|
112 | 112 | $data = $this->loader->load($section); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $data = array_merge($this->defaults[$section], $data); |
116 | - } else { |
|
116 | + }else{ |
|
117 | 117 | $data = $this->loader->load($section); |
118 | 118 | } |
119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | public function createInjection(ReflectionClass $class, string $context = null) |
127 | 127 | { |
128 | 128 | $config = $class->getConstant('CONFIG'); |
129 | - if (isset($this->instances[$config])) { |
|
129 | + if (isset($this->instances[$config])){ |
|
130 | 130 | return $this->instances[$config]; |
131 | 131 | } |
132 | 132 |
@@ -62,11 +62,13 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function setDefaults(string $section, array $data): void |
64 | 64 | { |
65 | - if (isset($this->defaults[$section])) { |
|
65 | + if (isset($this->defaults[$section])) |
|
66 | + { |
|
66 | 67 | throw new ConfiguratorException("Unable to set default config `{$section}` more than once."); |
67 | 68 | } |
68 | 69 | |
69 | - if (isset($this->data[$section])) { |
|
70 | + if (isset($this->data[$section])) |
|
71 | + { |
|
70 | 72 | throw new ConfigDeliveredException("Unable to set default config `{$section}`, config has been loaded."); |
71 | 73 | } |
72 | 74 | |
@@ -78,8 +80,10 @@ discard block |
||
78 | 80 | */ |
79 | 81 | public function modify(string $section, PatchInterface $patch): array |
80 | 82 | { |
81 | - if (isset($this->instances[$section])) { |
|
82 | - if ($this->strict) { |
|
83 | + if (isset($this->instances[$section])) |
|
84 | + { |
|
85 | + if ($this->strict) |
|
86 | + { |
|
83 | 87 | throw new ConfigDeliveredException( |
84 | 88 | "Unable to patch config `{$section}`, config object has already been delivered." |
85 | 89 | ); |
@@ -90,9 +94,12 @@ discard block |
||
90 | 94 | |
91 | 95 | $data = $this->getConfig($section); |
92 | 96 | |
93 | - try { |
|
97 | + try |
|
98 | + { |
|
94 | 99 | return $this->data[$section] = $patch->patch($data); |
95 | - } catch (PatchException $e) { |
|
100 | + } |
|
101 | + catch (PatchException $e) |
|
102 | + { |
|
96 | 103 | throw new PatchException("Unable to modify config `{$section}`.", $e->getCode(), $e); |
97 | 104 | } |
98 | 105 | } |
@@ -102,18 +109,23 @@ discard block |
||
102 | 109 | */ |
103 | 110 | public function getConfig(string $section = null): array |
104 | 111 | { |
105 | - if (isset($this->data[$section])) { |
|
112 | + if (isset($this->data[$section])) |
|
113 | + { |
|
106 | 114 | return $this->data[$section]; |
107 | 115 | } |
108 | 116 | |
109 | - if (isset($this->defaults[$section])) { |
|
117 | + if (isset($this->defaults[$section])) |
|
118 | + { |
|
110 | 119 | $data = []; |
111 | - if ($this->loader->has($section)) { |
|
120 | + if ($this->loader->has($section)) |
|
121 | + { |
|
112 | 122 | $data = $this->loader->load($section); |
113 | 123 | } |
114 | 124 | |
115 | 125 | $data = array_merge($this->defaults[$section], $data); |
116 | - } else { |
|
126 | + } |
|
127 | + else |
|
128 | + { |
|
117 | 129 | $data = $this->loader->load($section); |
118 | 130 | } |
119 | 131 | |
@@ -126,7 +138,8 @@ discard block |
||
126 | 138 | public function createInjection(ReflectionClass $class, string $context = null) |
127 | 139 | { |
128 | 140 | $config = $class->getConstant('CONFIG'); |
129 | - if (isset($this->instances[$config])) { |
|
141 | + if (isset($this->instances[$config])) |
|
142 | + { |
|
130 | 143 | return $this->instances[$config]; |
131 | 144 | } |
132 | 145 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | TranslatorConfig $config, |
39 | 39 | CatalogueManagerInterface $catalogueManager, |
40 | 40 | IdentityTranslator $identityTranslator = null |
41 | - ) { |
|
41 | + ){ |
|
42 | 42 | $this->config = $config; |
43 | 43 | $this->identityTranslator = $identityTranslator ?? new IdentityTranslator(); |
44 | 44 | $this->catalogueManager = $catalogueManager; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function setLocale(string $locale): void |
64 | 64 | { |
65 | - if (!$this->catalogueManager->has($locale)) { |
|
65 | + if (!$this->catalogueManager->has($locale)){ |
|
66 | 66 | throw new LocaleException($locale); |
67 | 67 | } |
68 | 68 | |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | array $parameters = [], |
119 | 119 | $domain = null, |
120 | 120 | $locale = null |
121 | - ) { |
|
121 | + ){ |
|
122 | 122 | $domain ??= $this->config->getDefaultDomain(); |
123 | 123 | $locale ??= $this->locale; |
124 | 124 | |
125 | - try { |
|
125 | + try{ |
|
126 | 126 | $message = $this->get($locale, $domain, $id); |
127 | 127 | |
128 | 128 | $pluralized = $this->identityTranslator->trans( |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | null, |
132 | 132 | $locale |
133 | 133 | ); |
134 | - } catch (InvalidArgumentException $e) { |
|
134 | + }catch (InvalidArgumentException $e){ |
|
135 | 135 | //Wrapping into more explanatory exception |
136 | 136 | throw new PluralizationException($e->getMessage(), $e->getCode(), $e); |
137 | 137 | } |
138 | 138 | |
139 | - if (empty($parameters['n']) && is_numeric($number)) { |
|
139 | + if (empty($parameters['n']) && is_numeric($number)){ |
|
140 | 140 | $parameters['n'] = $number; |
141 | 141 | } |
142 | 142 | |
@@ -161,18 +161,18 @@ discard block |
||
161 | 161 | string $postfix = '}' |
162 | 162 | ): string { |
163 | 163 | $replaces = []; |
164 | - foreach ($values as $key => $value) { |
|
164 | + foreach ($values as $key => $value){ |
|
165 | 165 | $value = (is_array($value) || $value instanceof Closure) ? '' : $value; |
166 | 166 | |
167 | - if (is_object($value)) { |
|
168 | - if (method_exists($value, '__toString')) { |
|
167 | + if (is_object($value)){ |
|
168 | + if (method_exists($value, '__toString')){ |
|
169 | 169 | $value = $value->__toString(); |
170 | - } else { |
|
170 | + }else{ |
|
171 | 171 | $value = ''; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
175 | - $replaces[$prefix . $key . $postfix] = $value; |
|
175 | + $replaces[$prefix.$key.$postfix] = $value; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return strtr($string, $replaces); |
@@ -192,18 +192,18 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function get(string &$locale, string $domain, string $string): string |
194 | 194 | { |
195 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
195 | + if ($this->catalogueManager->get($locale)->has($domain, $string)){ |
|
196 | 196 | return $this->catalogueManager->get($locale)->get($domain, $string); |
197 | 197 | } |
198 | 198 | |
199 | 199 | $locale = $this->config->getFallbackLocale(); |
200 | 200 | |
201 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
201 | + if ($this->catalogueManager->get($locale)->has($domain, $string)){ |
|
202 | 202 | return $this->catalogueManager->get($locale)->get($domain, $string); |
203 | 203 | } |
204 | 204 | |
205 | 205 | // we can automatically register message |
206 | - if ($this->config->isAutoRegisterMessages()) { |
|
206 | + if ($this->config->isAutoRegisterMessages()){ |
|
207 | 207 | $this->catalogueManager->get($locale)->set($domain, $string, $string); |
208 | 208 | $this->catalogueManager->save($locale); |
209 | 209 | } |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function setLocale(string $locale): void |
64 | 64 | { |
65 | - if (!$this->catalogueManager->has($locale)) { |
|
65 | + if (!$this->catalogueManager->has($locale)) |
|
66 | + { |
|
66 | 67 | throw new LocaleException($locale); |
67 | 68 | } |
68 | 69 | |
@@ -122,7 +123,8 @@ discard block |
||
122 | 123 | $domain ??= $this->config->getDefaultDomain(); |
123 | 124 | $locale ??= $this->locale; |
124 | 125 | |
125 | - try { |
|
126 | + try |
|
127 | + { |
|
126 | 128 | $message = $this->get($locale, $domain, $id); |
127 | 129 | |
128 | 130 | $pluralized = $this->identityTranslator->trans( |
@@ -131,12 +133,15 @@ discard block |
||
131 | 133 | null, |
132 | 134 | $locale |
133 | 135 | ); |
134 | - } catch (InvalidArgumentException $e) { |
|
136 | + } |
|
137 | + catch (InvalidArgumentException $e) |
|
138 | + { |
|
135 | 139 | //Wrapping into more explanatory exception |
136 | 140 | throw new PluralizationException($e->getMessage(), $e->getCode(), $e); |
137 | 141 | } |
138 | 142 | |
139 | - if (empty($parameters['n']) && is_numeric($number)) { |
|
143 | + if (empty($parameters['n']) && is_numeric($number)) |
|
144 | + { |
|
140 | 145 | $parameters['n'] = $number; |
141 | 146 | } |
142 | 147 | |
@@ -161,13 +166,18 @@ discard block |
||
161 | 166 | string $postfix = '}' |
162 | 167 | ): string { |
163 | 168 | $replaces = []; |
164 | - foreach ($values as $key => $value) { |
|
169 | + foreach ($values as $key => $value) |
|
170 | + { |
|
165 | 171 | $value = (is_array($value) || $value instanceof Closure) ? '' : $value; |
166 | 172 | |
167 | - if (is_object($value)) { |
|
168 | - if (method_exists($value, '__toString')) { |
|
173 | + if (is_object($value)) |
|
174 | + { |
|
175 | + if (method_exists($value, '__toString')) |
|
176 | + { |
|
169 | 177 | $value = $value->__toString(); |
170 | - } else { |
|
178 | + } |
|
179 | + else |
|
180 | + { |
|
171 | 181 | $value = ''; |
172 | 182 | } |
173 | 183 | } |
@@ -192,18 +202,21 @@ discard block |
||
192 | 202 | */ |
193 | 203 | protected function get(string &$locale, string $domain, string $string): string |
194 | 204 | { |
195 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
205 | + if ($this->catalogueManager->get($locale)->has($domain, $string)) |
|
206 | + { |
|
196 | 207 | return $this->catalogueManager->get($locale)->get($domain, $string); |
197 | 208 | } |
198 | 209 | |
199 | 210 | $locale = $this->config->getFallbackLocale(); |
200 | 211 | |
201 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
212 | + if ($this->catalogueManager->get($locale)->has($domain, $string)) |
|
213 | + { |
|
202 | 214 | return $this->catalogueManager->get($locale)->get($domain, $string); |
203 | 215 | } |
204 | 216 | |
205 | 217 | // we can automatically register message |
206 | - if ($this->config->isAutoRegisterMessages()) { |
|
218 | + if ($this->config->isAutoRegisterMessages()) |
|
219 | + { |
|
207 | 220 | $this->catalogueManager->get($locale)->set($domain, $string, $string); |
208 | 221 | $this->catalogueManager->save($locale); |
209 | 222 | } |
@@ -111,7 +111,7 @@ |
||
111 | 111 | */ |
112 | 112 | private function iterableToArray(iterable $meta): array |
113 | 113 | { |
114 | - if ($meta instanceof Traversable) { |
|
114 | + if ($meta instanceof Traversable){ |
|
115 | 115 | return \iterator_to_array($meta, false); |
116 | 116 | } |
117 | 117 |
@@ -111,7 +111,8 @@ |
||
111 | 111 | */ |
112 | 112 | private function iterableToArray(iterable $meta): array |
113 | 113 | { |
114 | - if ($meta instanceof Traversable) { |
|
114 | + if ($meta instanceof Traversable) |
|
115 | + { |
|
115 | 116 | return \iterator_to_array($meta, false); |
116 | 117 | } |
117 | 118 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | use Attribute; |
15 | 15 | use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; |
16 | 16 | |
17 | - if (!\interface_exists(NamedArgumentConstructorAnnotation::class)) { |
|
17 | + if (!\interface_exists(NamedArgumentConstructorAnnotation::class)){ |
|
18 | 18 | /** |
19 | 19 | * Marker interface for PHP7/PHP8 compatible support for named |
20 | 20 | * arguments (and constructor property promotion). |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | namespace Doctrine\Common\Annotations\Annotation { |
34 | 34 | |
35 | - if (!\class_exists(NamedArgumentConstructor::class, false)) { |
|
35 | + if (!\class_exists(NamedArgumentConstructor::class, false)){ |
|
36 | 36 | /** |
37 | 37 | * Annotation that indicates that the annotated class should be |
38 | 38 | * constructed with a named argument call. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | use JetBrains\PhpStorm\ExpectedValues; |
54 | 54 | |
55 | - if (!\class_exists(Attribute::class, false)) { |
|
55 | + if (!\class_exists(Attribute::class, false)){ |
|
56 | 56 | #[Attribute(Attribute::TARGET_CLASS)] |
57 | 57 | final class Attribute |
58 | 58 | { |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | use Attribute; |
15 | 15 | use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor; |
16 | 16 | |
17 | - if (!\interface_exists(NamedArgumentConstructorAnnotation::class)) { |
|
17 | + if (!\interface_exists(NamedArgumentConstructorAnnotation::class)) |
|
18 | + { |
|
18 | 19 | /** |
19 | 20 | * Marker interface for PHP7/PHP8 compatible support for named |
20 | 21 | * arguments (and constructor property promotion). |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | |
33 | 34 | namespace Doctrine\Common\Annotations\Annotation { |
34 | 35 | |
35 | - if (!\class_exists(NamedArgumentConstructor::class, false)) { |
|
36 | + if (!\class_exists(NamedArgumentConstructor::class, false)) |
|
37 | + { |
|
36 | 38 | /** |
37 | 39 | * Annotation that indicates that the annotated class should be |
38 | 40 | * constructed with a named argument call. |
@@ -52,7 +54,8 @@ discard block |
||
52 | 54 | |
53 | 55 | use JetBrains\PhpStorm\ExpectedValues; |
54 | 56 | |
55 | - if (!\class_exists(Attribute::class, false)) { |
|
57 | + if (!\class_exists(Attribute::class, false)) |
|
58 | + { |
|
56 | 59 | #[Attribute(Attribute::TARGET_CLASS)] |
57 | 60 | final class Attribute |
58 | 61 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function firstClassMetadata(ReflectionClass $class, string $name): ?object |
27 | 27 | { |
28 | - foreach ($this->getClassMetadata($class, $name) as $attribute) { |
|
28 | + foreach ($this->getClassMetadata($class, $name) as $attribute){ |
|
29 | 29 | return $attribute; |
30 | 30 | } |
31 | 31 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function firstFunctionMetadata(ReflectionFunctionAbstract $function, string $name): ?object |
39 | 39 | { |
40 | - foreach ($this->getFunctionMetadata($function, $name) as $attribute) { |
|
40 | + foreach ($this->getFunctionMetadata($function, $name) as $attribute){ |
|
41 | 41 | return $attribute; |
42 | 42 | } |
43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function firstPropertyMetadata(ReflectionProperty $property, string $name): ?object |
51 | 51 | { |
52 | - foreach ($this->getPropertyMetadata($property, $name) as $attribute) { |
|
52 | + foreach ($this->getPropertyMetadata($property, $name) as $attribute){ |
|
53 | 53 | return $attribute; |
54 | 54 | } |
55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function firstConstantMetadata(ReflectionClassConstant $constant, string $name): ?object |
63 | 63 | { |
64 | - foreach ($this->getConstantMetadata($constant, $name) as $attribute) { |
|
64 | + foreach ($this->getConstantMetadata($constant, $name) as $attribute){ |
|
65 | 65 | return $attribute; |
66 | 66 | } |
67 | 67 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function firstParameterMetadata(ReflectionParameter $parameter, string $name): ?object |
75 | 75 | { |
76 | - foreach ($this->getParameterMetadata($parameter, $name) as $attribute) { |
|
76 | + foreach ($this->getParameterMetadata($parameter, $name) as $attribute){ |
|
77 | 77 | return $attribute; |
78 | 78 | } |
79 | 79 | |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function filter(?string $name, iterable $annotations): Generator |
92 | 92 | { |
93 | - if ($name === null) { |
|
93 | + if ($name === null){ |
|
94 | 94 | yield from $annotations; |
95 | 95 | |
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | - foreach ($annotations as $annotation) { |
|
100 | - if ($annotation instanceof $name) { |
|
99 | + foreach ($annotations as $annotation){ |
|
100 | + if ($annotation instanceof $name){ |
|
101 | 101 | yield $annotation; |
102 | 102 | } |
103 | 103 | } |
@@ -25,7 +25,8 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function firstClassMetadata(ReflectionClass $class, string $name): ?object |
27 | 27 | { |
28 | - foreach ($this->getClassMetadata($class, $name) as $attribute) { |
|
28 | + foreach ($this->getClassMetadata($class, $name) as $attribute) |
|
29 | + { |
|
29 | 30 | return $attribute; |
30 | 31 | } |
31 | 32 | |
@@ -37,7 +38,8 @@ discard block |
||
37 | 38 | */ |
38 | 39 | public function firstFunctionMetadata(ReflectionFunctionAbstract $function, string $name): ?object |
39 | 40 | { |
40 | - foreach ($this->getFunctionMetadata($function, $name) as $attribute) { |
|
41 | + foreach ($this->getFunctionMetadata($function, $name) as $attribute) |
|
42 | + { |
|
41 | 43 | return $attribute; |
42 | 44 | } |
43 | 45 | |
@@ -49,7 +51,8 @@ discard block |
||
49 | 51 | */ |
50 | 52 | public function firstPropertyMetadata(ReflectionProperty $property, string $name): ?object |
51 | 53 | { |
52 | - foreach ($this->getPropertyMetadata($property, $name) as $attribute) { |
|
54 | + foreach ($this->getPropertyMetadata($property, $name) as $attribute) |
|
55 | + { |
|
53 | 56 | return $attribute; |
54 | 57 | } |
55 | 58 | |
@@ -61,7 +64,8 @@ discard block |
||
61 | 64 | */ |
62 | 65 | public function firstConstantMetadata(ReflectionClassConstant $constant, string $name): ?object |
63 | 66 | { |
64 | - foreach ($this->getConstantMetadata($constant, $name) as $attribute) { |
|
67 | + foreach ($this->getConstantMetadata($constant, $name) as $attribute) |
|
68 | + { |
|
65 | 69 | return $attribute; |
66 | 70 | } |
67 | 71 | |
@@ -73,7 +77,8 @@ discard block |
||
73 | 77 | */ |
74 | 78 | public function firstParameterMetadata(ReflectionParameter $parameter, string $name): ?object |
75 | 79 | { |
76 | - foreach ($this->getParameterMetadata($parameter, $name) as $attribute) { |
|
80 | + foreach ($this->getParameterMetadata($parameter, $name) as $attribute) |
|
81 | + { |
|
77 | 82 | return $attribute; |
78 | 83 | } |
79 | 84 | |
@@ -90,14 +95,17 @@ discard block |
||
90 | 95 | */ |
91 | 96 | protected function filter(?string $name, iterable $annotations): Generator |
92 | 97 | { |
93 | - if ($name === null) { |
|
98 | + if ($name === null) |
|
99 | + { |
|
94 | 100 | yield from $annotations; |
95 | 101 | |
96 | 102 | return; |
97 | 103 | } |
98 | 104 | |
99 | - foreach ($annotations as $annotation) { |
|
100 | - if ($annotation instanceof $name) { |
|
105 | + foreach ($annotations as $annotation) |
|
106 | + { |
|
107 | + if ($annotation instanceof $name) |
|
108 | + { |
|
101 | 109 | yield $annotation; |
102 | 110 | } |
103 | 111 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | public function render(?Reflector $reflector): string |
70 | 70 | { |
71 | - switch (true) { |
|
71 | + switch (true){ |
|
72 | 72 | case $reflector instanceof ReflectionClass: |
73 | 73 | return $this->renderClassContext($reflector); |
74 | 74 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | public function renderClassContext(ReflectionClass $class): string |
93 | 93 | { |
94 | - if ($class->isAnonymous()) { |
|
94 | + if ($class->isAnonymous()){ |
|
95 | 95 | return \sprintf(self::FORMAT_ANONYMOUS_CLASS, $class->getFileName(), $class->getStartLine()); |
96 | 96 | } |
97 | 97 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function renderFunctionContext(ReflectionFunction $fn): string |
109 | 109 | { |
110 | - if ($fn->isClosure()) { |
|
110 | + if ($fn->isClosure()){ |
|
111 | 111 | return \sprintf(self::FORMAT_ANONYMOUS_FUNCTION, $fn->getFileName(), $fn->getStartLine()); |
112 | 112 | } |
113 | 113 | |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | |
117 | 117 | public function renderCallableContext(ReflectionFunctionAbstract $function): string |
118 | 118 | { |
119 | - if ($function instanceof ReflectionMethod) { |
|
119 | + if ($function instanceof ReflectionMethod){ |
|
120 | 120 | return $this->renderMethodContext($function); |
121 | 121 | } |
122 | 122 | |
123 | - if ($function instanceof ReflectionFunction) { |
|
123 | + if ($function instanceof ReflectionFunction){ |
|
124 | 124 | return $this->renderFunctionContext($function); |
125 | 125 | } |
126 | 126 |
@@ -68,7 +68,8 @@ discard block |
||
68 | 68 | |
69 | 69 | public function render(?Reflector $reflector): string |
70 | 70 | { |
71 | - switch (true) { |
|
71 | + switch (true) |
|
72 | + { |
|
72 | 73 | case $reflector instanceof ReflectionClass: |
73 | 74 | return $this->renderClassContext($reflector); |
74 | 75 | |
@@ -91,7 +92,8 @@ discard block |
||
91 | 92 | |
92 | 93 | public function renderClassContext(ReflectionClass $class): string |
93 | 94 | { |
94 | - if ($class->isAnonymous()) { |
|
95 | + if ($class->isAnonymous()) |
|
96 | + { |
|
95 | 97 | return \sprintf(self::FORMAT_ANONYMOUS_CLASS, $class->getFileName(), $class->getStartLine()); |
96 | 98 | } |
97 | 99 | |
@@ -107,7 +109,8 @@ discard block |
||
107 | 109 | |
108 | 110 | public function renderFunctionContext(ReflectionFunction $fn): string |
109 | 111 | { |
110 | - if ($fn->isClosure()) { |
|
112 | + if ($fn->isClosure()) |
|
113 | + { |
|
111 | 114 | return \sprintf(self::FORMAT_ANONYMOUS_FUNCTION, $fn->getFileName(), $fn->getStartLine()); |
112 | 115 | } |
113 | 116 | |
@@ -116,11 +119,13 @@ discard block |
||
116 | 119 | |
117 | 120 | public function renderCallableContext(ReflectionFunctionAbstract $function): string |
118 | 121 | { |
119 | - if ($function instanceof ReflectionMethod) { |
|
122 | + if ($function instanceof ReflectionMethod) |
|
123 | + { |
|
120 | 124 | return $this->renderMethodContext($function); |
121 | 125 | } |
122 | 126 | |
123 | - if ($function instanceof ReflectionFunction) { |
|
127 | + if ($function instanceof ReflectionFunction) |
|
128 | + { |
|
124 | 129 | return $this->renderFunctionContext($function); |
125 | 130 | } |
126 | 131 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function forClass(ReflectionClass $class): string |
35 | 35 | { |
36 | - if ($class->isUserDefined()) { |
|
36 | + if ($class->isUserDefined()){ |
|
37 | 37 | return (string)\filemtime( |
38 | 38 | $class->getFileName() |
39 | 39 | ); |
@@ -69,23 +69,23 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function forFunction(ReflectionFunctionAbstract $fn): string |
71 | 71 | { |
72 | - if ($fn instanceof ReflectionMethod) { |
|
72 | + if ($fn instanceof ReflectionMethod){ |
|
73 | 73 | return $this->forClass( |
74 | 74 | $fn->getDeclaringClass() |
75 | 75 | ); |
76 | 76 | } |
77 | 77 | |
78 | - if ($fn->isUserDefined()) { |
|
78 | + if ($fn->isUserDefined()){ |
|
79 | 79 | return (string)\filemtime( |
80 | 80 | $fn->getFileName() |
81 | 81 | ); |
82 | 82 | } |
83 | 83 | |
84 | - if ($extension = $fn->getExtension()) { |
|
84 | + if ($extension = $fn->getExtension()){ |
|
85 | 85 | return $extension->getVersion(); |
86 | 86 | } |
87 | 87 | |
88 | - throw new LogicException('Can not determine modification time of [' . $fn->getName() . ']'); |
|
88 | + throw new LogicException('Can not determine modification time of ['.$fn->getName().']'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -33,7 +33,8 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function forClass(ReflectionClass $class): string |
35 | 35 | { |
36 | - if ($class->isUserDefined()) { |
|
36 | + if ($class->isUserDefined()) |
|
37 | + { |
|
37 | 38 | return (string)\filemtime( |
38 | 39 | $class->getFileName() |
39 | 40 | ); |
@@ -69,19 +70,22 @@ discard block |
||
69 | 70 | */ |
70 | 71 | public function forFunction(ReflectionFunctionAbstract $fn): string |
71 | 72 | { |
72 | - if ($fn instanceof ReflectionMethod) { |
|
73 | + if ($fn instanceof ReflectionMethod) |
|
74 | + { |
|
73 | 75 | return $this->forClass( |
74 | 76 | $fn->getDeclaringClass() |
75 | 77 | ); |
76 | 78 | } |
77 | 79 | |
78 | - if ($fn->isUserDefined()) { |
|
80 | + if ($fn->isUserDefined()) |
|
81 | + { |
|
79 | 82 | return (string)\filemtime( |
80 | 83 | $fn->getFileName() |
81 | 84 | ); |
82 | 85 | } |
83 | 86 | |
84 | - if ($extension = $fn->getExtension()) { |
|
87 | + if ($extension = $fn->getExtension()) |
|
88 | + { |
|
85 | 89 | return $extension->getVersion(); |
86 | 90 | } |
87 | 91 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function forClass(ReflectionClass $class): string |
64 | 64 | { |
65 | - if ($class->isAnonymous()) { |
|
65 | + if ($class->isAnonymous()){ |
|
66 | 66 | return \vsprintf(self::TPL_ANONYMOUS_CLASS, [ |
67 | 67 | $class->getFileName(), |
68 | 68 | $class->getStartLine(), |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function forFunction(ReflectionFunctionAbstract $fn): string |
113 | 113 | { |
114 | - if ($fn instanceof ReflectionMethod) { |
|
114 | + if ($fn instanceof ReflectionMethod){ |
|
115 | 115 | return \vsprintf(self::TPL_METHOD, [ |
116 | 116 | $this->forClass($fn->getDeclaringClass()), |
117 | 117 | $fn->getName(), |
118 | 118 | ]); |
119 | 119 | } |
120 | 120 | |
121 | - if ($fn->isClosure()) { |
|
121 | + if ($fn->isClosure()){ |
|
122 | 122 | return \vsprintf(self::TPL_ANONYMOUS_FN, [ |
123 | 123 | $fn->getFileName(), |
124 | 124 | $fn->getStartLine(), |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function forClass(ReflectionClass $class): string |
64 | 64 | { |
65 | - if ($class->isAnonymous()) { |
|
65 | + if ($class->isAnonymous()) |
|
66 | + { |
|
66 | 67 | return \vsprintf(self::TPL_ANONYMOUS_CLASS, [ |
67 | 68 | $class->getFileName(), |
68 | 69 | $class->getStartLine(), |
@@ -111,14 +112,16 @@ discard block |
||
111 | 112 | */ |
112 | 113 | public function forFunction(ReflectionFunctionAbstract $fn): string |
113 | 114 | { |
114 | - if ($fn instanceof ReflectionMethod) { |
|
115 | + if ($fn instanceof ReflectionMethod) |
|
116 | + { |
|
115 | 117 | return \vsprintf(self::TPL_METHOD, [ |
116 | 118 | $this->forClass($fn->getDeclaringClass()), |
117 | 119 | $fn->getName(), |
118 | 120 | ]); |
119 | 121 | } |
120 | 122 | |
121 | - if ($fn->isClosure()) { |
|
123 | + if ($fn->isClosure()) |
|
124 | + { |
|
122 | 125 | return \vsprintf(self::TPL_ANONYMOUS_FN, [ |
123 | 126 | $fn->getFileName(), |
124 | 127 | $fn->getStartLine(), |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @var string |
35 | 35 | */ |
36 | 36 | private const ERROR_INVALID_PROPERTY = |
37 | - 'The attribute #[%s] declared on %s does not have a property named "%s".' . "\n" . |
|
37 | + 'The attribute #[%s] declared on %s does not have a property named "%s".'."\n". |
|
38 | 38 | 'Available properties: %s' |
39 | 39 | ; |
40 | 40 | |
@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | $arguments = $this->formatArguments($arguments); |
62 | 62 | |
63 | 63 | // Using constructor |
64 | - if ($this->getConstructor($attr)) { |
|
64 | + if ($this->getConstructor($attr)){ |
|
65 | 65 | return $attr->newInstance($arguments); |
66 | 66 | } |
67 | 67 | |
68 | 68 | // Using direct insert |
69 | 69 | $instance = $attr->newInstanceWithoutConstructor(); |
70 | 70 | |
71 | - foreach ($arguments as $name => $value) { |
|
72 | - try { |
|
71 | + foreach ($arguments as $name => $value){ |
|
72 | + try{ |
|
73 | 73 | $property = $attr->getProperty($name); |
74 | 74 | |
75 | - if (!$property->isPublic()) { |
|
75 | + if (!$property->isPublic()){ |
|
76 | 76 | throw $this->propertyNotFound($attr, $name, $context); |
77 | 77 | } |
78 | 78 | |
79 | 79 | $instance->$name = $value; |
80 | - } catch (Throwable $e) { |
|
80 | + }catch (Throwable $e){ |
|
81 | 81 | throw $this->propertyNotFound($attr, $name, $context); |
82 | 82 | } |
83 | 83 | } |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | { |
90 | 90 | $result = []; |
91 | 91 | |
92 | - foreach ($arguments as $name => $value) { |
|
93 | - if (\is_int($name)) { |
|
92 | + foreach ($arguments as $name => $value){ |
|
93 | + if (\is_int($name)){ |
|
94 | 94 | $this->validateArgumentPosition($name, $value); |
95 | 95 | |
96 | 96 | $name = self::DEFAULT_PROPERTY_NAME; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private function validateArgumentPosition(int $index, $value): void |
109 | 109 | { |
110 | - if ($index === 0) { |
|
110 | + if ($index === 0){ |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 |
@@ -61,23 +61,29 @@ discard block |
||
61 | 61 | $arguments = $this->formatArguments($arguments); |
62 | 62 | |
63 | 63 | // Using constructor |
64 | - if ($this->getConstructor($attr)) { |
|
64 | + if ($this->getConstructor($attr)) |
|
65 | + { |
|
65 | 66 | return $attr->newInstance($arguments); |
66 | 67 | } |
67 | 68 | |
68 | 69 | // Using direct insert |
69 | 70 | $instance = $attr->newInstanceWithoutConstructor(); |
70 | 71 | |
71 | - foreach ($arguments as $name => $value) { |
|
72 | - try { |
|
72 | + foreach ($arguments as $name => $value) |
|
73 | + { |
|
74 | + try |
|
75 | + { |
|
73 | 76 | $property = $attr->getProperty($name); |
74 | 77 | |
75 | - if (!$property->isPublic()) { |
|
78 | + if (!$property->isPublic()) |
|
79 | + { |
|
76 | 80 | throw $this->propertyNotFound($attr, $name, $context); |
77 | 81 | } |
78 | 82 | |
79 | 83 | $instance->$name = $value; |
80 | - } catch (Throwable $e) { |
|
84 | + } |
|
85 | + catch (Throwable $e) |
|
86 | + { |
|
81 | 87 | throw $this->propertyNotFound($attr, $name, $context); |
82 | 88 | } |
83 | 89 | } |
@@ -89,8 +95,10 @@ discard block |
||
89 | 95 | { |
90 | 96 | $result = []; |
91 | 97 | |
92 | - foreach ($arguments as $name => $value) { |
|
93 | - if (\is_int($name)) { |
|
98 | + foreach ($arguments as $name => $value) |
|
99 | + { |
|
100 | + if (\is_int($name)) |
|
101 | + { |
|
94 | 102 | $this->validateArgumentPosition($name, $value); |
95 | 103 | |
96 | 104 | $name = self::DEFAULT_PROPERTY_NAME; |
@@ -107,7 +115,8 @@ discard block |
||
107 | 115 | */ |
108 | 116 | private function validateArgumentPosition(int $index, $value): void |
109 | 117 | { |
110 | - if ($index === 0) { |
|
118 | + if ($index === 0) |
|
119 | + { |
|
111 | 120 | return; |
112 | 121 | } |
113 | 122 |