@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | string $mergeMode = self::FOLLOW, |
42 | 42 | int $mode = FilesInterface::READONLY |
43 | 43 | ): void { |
44 | - if (!$this->files->isFile($filename)) { |
|
44 | + if (!$this->files->isFile($filename)){ |
|
45 | 45 | throw new PublishException("Given '{$filename}' is not valid file"); |
46 | 46 | } |
47 | 47 | |
48 | - if ($this->files->exists($destination)) { |
|
49 | - if ($this->files->md5($destination) === $this->files->md5($filename)) { |
|
48 | + if ($this->files->exists($destination)){ |
|
49 | + if ($this->files->md5($destination) === $this->files->md5($filename)){ |
|
50 | 50 | //Nothing to do |
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | - if ($mergeMode === self::FOLLOW) { |
|
54 | + if ($mergeMode === self::FOLLOW){ |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | } |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | string $mergeMode = self::REPLACE, |
74 | 74 | int $mode = FilesInterface::READONLY |
75 | 75 | ): void { |
76 | - if (!$this->files->isDirectory($directory)) { |
|
76 | + if (!$this->files->isDirectory($directory)){ |
|
77 | 77 | throw new PublishException("Given '{$directory}' is not valid directory"); |
78 | 78 | } |
79 | 79 | |
80 | 80 | $finder = new Finder(); |
81 | 81 | $finder->files()->in($directory); |
82 | 82 | |
83 | - foreach ($finder->getIterator() as $file) { |
|
83 | + foreach ($finder->getIterator() as $file){ |
|
84 | 84 | $this->publish( |
85 | 85 | (string)$file, |
86 | - $destination . '/' . $file->getRelativePathname(), |
|
86 | + $destination.'/'.$file->getRelativePathname(), |
|
87 | 87 | $mergeMode, |
88 | 88 | $mode |
89 | 89 | ); |
@@ -41,17 +41,21 @@ discard block |
||
41 | 41 | string $mergeMode = self::FOLLOW, |
42 | 42 | int $mode = FilesInterface::READONLY |
43 | 43 | ): void { |
44 | - if (!$this->files->isFile($filename)) { |
|
44 | + if (!$this->files->isFile($filename)) |
|
45 | + { |
|
45 | 46 | throw new PublishException("Given '{$filename}' is not valid file"); |
46 | 47 | } |
47 | 48 | |
48 | - if ($this->files->exists($destination)) { |
|
49 | - if ($this->files->md5($destination) === $this->files->md5($filename)) { |
|
49 | + if ($this->files->exists($destination)) |
|
50 | + { |
|
51 | + if ($this->files->md5($destination) === $this->files->md5($filename)) |
|
52 | + { |
|
50 | 53 | //Nothing to do |
51 | 54 | return; |
52 | 55 | } |
53 | 56 | |
54 | - if ($mergeMode === self::FOLLOW) { |
|
57 | + if ($mergeMode === self::FOLLOW) |
|
58 | + { |
|
55 | 59 | return; |
56 | 60 | } |
57 | 61 | } |
@@ -73,14 +77,16 @@ discard block |
||
73 | 77 | string $mergeMode = self::REPLACE, |
74 | 78 | int $mode = FilesInterface::READONLY |
75 | 79 | ): void { |
76 | - if (!$this->files->isDirectory($directory)) { |
|
80 | + if (!$this->files->isDirectory($directory)) |
|
81 | + { |
|
77 | 82 | throw new PublishException("Given '{$directory}' is not valid directory"); |
78 | 83 | } |
79 | 84 | |
80 | 85 | $finder = new Finder(); |
81 | 86 | $finder->files()->in($directory); |
82 | 87 | |
83 | - foreach ($finder->getIterator() as $file) { |
|
88 | + foreach ($finder->getIterator() as $file) |
|
89 | + { |
|
84 | 90 | $this->publish( |
85 | 91 | (string)$file, |
86 | 92 | $destination . '/' . $file->getRelativePathname(), |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ScopeInterface $scope, |
51 | 51 | ResolverInterface $resolver, |
52 | 52 | ResponseFactoryInterface $responseFactory |
53 | - ) { |
|
53 | + ){ |
|
54 | 54 | $this->config = $config; |
55 | 55 | $this->scope = $scope; |
56 | 56 | $this->resolver = $resolver; |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
69 | 69 | { |
70 | - if ($request->getUri()->getPath() !== $this->config->getPath()) { |
|
70 | + if ($request->getUri()->getPath() !== $this->config->getPath()){ |
|
71 | 71 | return $handler->handle($request); |
72 | 72 | } |
73 | 73 | |
74 | 74 | // server authorization |
75 | - if ($request->getAttribute('ws:joinServer', null) !== null) { |
|
76 | - if (!$this->authorizeServer($request)) { |
|
75 | + if ($request->getAttribute('ws:joinServer', null) !== null){ |
|
76 | + if (!$this->authorizeServer($request)){ |
|
77 | 77 | return $this->responseFactory->createResponse(403); |
78 | 78 | } |
79 | 79 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // topic authorization |
84 | - if (is_string($request->getAttribute('ws:joinTopics', null))) { |
|
84 | + if (is_string($request->getAttribute('ws:joinTopics', null))){ |
|
85 | 85 | $topics = explode(',', $request->getAttribute('ws:joinTopics')); |
86 | - foreach ($topics as $topic) { |
|
87 | - if (!$this->authorizeTopic($request, $topic)) { |
|
86 | + foreach ($topics as $topic){ |
|
87 | + if (!$this->authorizeTopic($request, $topic)){ |
|
88 | 88 | return $this->responseFactory->createResponse(403); |
89 | 89 | } |
90 | 90 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | private function authorizeServer(ServerRequestInterface $request): bool |
105 | 105 | { |
106 | 106 | $callback = $this->config->getServerCallback(); |
107 | - if ($callback === null) { |
|
107 | + if ($callback === null){ |
|
108 | 108 | return true; |
109 | 109 | } |
110 | 110 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | { |
123 | 123 | $parameters = []; |
124 | 124 | $callback = $this->config->findTopicCallback($topic, $parameters); |
125 | - if ($callback === null) { |
|
125 | + if ($callback === null){ |
|
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | private function invoke(ServerRequestInterface $request, callable $callback, array $parameters = []): bool |
141 | 141 | { |
142 | - switch (true) { |
|
142 | + switch (true){ |
|
143 | 143 | case $callback instanceof \Closure || is_string($callback): |
144 | 144 | $reflection = new \ReflectionFunction($callback); |
145 | 145 | break; |
@@ -67,13 +67,16 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
69 | 69 | { |
70 | - if ($request->getUri()->getPath() !== $this->config->getPath()) { |
|
70 | + if ($request->getUri()->getPath() !== $this->config->getPath()) |
|
71 | + { |
|
71 | 72 | return $handler->handle($request); |
72 | 73 | } |
73 | 74 | |
74 | 75 | // server authorization |
75 | - if ($request->getAttribute('ws:joinServer', null) !== null) { |
|
76 | - if (!$this->authorizeServer($request)) { |
|
76 | + if ($request->getAttribute('ws:joinServer', null) !== null) |
|
77 | + { |
|
78 | + if (!$this->authorizeServer($request)) |
|
79 | + { |
|
77 | 80 | return $this->responseFactory->createResponse(403); |
78 | 81 | } |
79 | 82 | |
@@ -81,10 +84,13 @@ discard block |
||
81 | 84 | } |
82 | 85 | |
83 | 86 | // topic authorization |
84 | - if (is_string($request->getAttribute('ws:joinTopics', null))) { |
|
87 | + if (is_string($request->getAttribute('ws:joinTopics', null))) |
|
88 | + { |
|
85 | 89 | $topics = explode(',', $request->getAttribute('ws:joinTopics')); |
86 | - foreach ($topics as $topic) { |
|
87 | - if (!$this->authorizeTopic($request, $topic)) { |
|
90 | + foreach ($topics as $topic) |
|
91 | + { |
|
92 | + if (!$this->authorizeTopic($request, $topic)) |
|
93 | + { |
|
88 | 94 | return $this->responseFactory->createResponse(403); |
89 | 95 | } |
90 | 96 | } |
@@ -104,7 +110,8 @@ discard block |
||
104 | 110 | private function authorizeServer(ServerRequestInterface $request): bool |
105 | 111 | { |
106 | 112 | $callback = $this->config->getServerCallback(); |
107 | - if ($callback === null) { |
|
113 | + if ($callback === null) |
|
114 | + { |
|
108 | 115 | return true; |
109 | 116 | } |
110 | 117 | |
@@ -122,7 +129,8 @@ discard block |
||
122 | 129 | { |
123 | 130 | $parameters = []; |
124 | 131 | $callback = $this->config->findTopicCallback($topic, $parameters); |
125 | - if ($callback === null) { |
|
132 | + if ($callback === null) |
|
133 | + { |
|
126 | 134 | return false; |
127 | 135 | } |
128 | 136 | |
@@ -139,7 +147,8 @@ discard block |
||
139 | 147 | */ |
140 | 148 | private function invoke(ServerRequestInterface $request, callable $callback, array $parameters = []): bool |
141 | 149 | { |
142 | - switch (true) { |
|
150 | + switch (true) |
|
151 | + { |
|
143 | 152 | case $callback instanceof \Closure || is_string($callback): |
144 | 153 | $reflection = new \ReflectionFunction($callback); |
145 | 154 | break; |
@@ -160,7 +169,8 @@ discard block |
||
160 | 169 | [ |
161 | 170 | ServerRequestInterface::class => $request, |
162 | 171 | ], |
163 | - function () use ($reflection, $parameters, $callback) { |
|
172 | + function () use ($reflection, $parameters, $callback) |
|
173 | + { |
|
164 | 174 | return call_user_func_array( |
165 | 175 | $callback, |
166 | 176 | $this->resolver->resolveArguments($reflection, $parameters) |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | parent::__construct($config); |
36 | 36 | |
37 | - foreach ($config['authorizeTopics'] as $topic => $callback) { |
|
37 | + foreach ($config['authorizeTopics'] as $topic => $callback){ |
|
38 | 38 | $this->patterns[$this->compilePattern($topic)] = $callback; |
39 | 39 | } |
40 | 40 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function findTopicCallback(string $topic, array &$matches): ?callable |
64 | 64 | { |
65 | - foreach ($this->patterns as $pattern => $callback) { |
|
66 | - if (preg_match($pattern, $topic, $matches)) { |
|
65 | + foreach ($this->patterns as $pattern => $callback){ |
|
66 | + if (preg_match($pattern, $topic, $matches)){ |
|
67 | 67 | return $callback; |
68 | 68 | } |
69 | 69 | } |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | private function compilePattern(string $topic): string |
79 | 79 | { |
80 | 80 | $replaces = []; |
81 | - if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
81 | + if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){ |
|
82 | 82 | $variables = array_combine($matches[1], $matches[2]); |
83 | - foreach ($variables as $key => $_) { |
|
84 | - $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
|
83 | + foreach ($variables as $key => $_){ |
|
84 | + $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)'; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - return '/^' . strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu'; |
|
88 | + return '/^'.strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu'; |
|
89 | 89 | } |
90 | 90 | } |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | { |
35 | 35 | parent::__construct($config); |
36 | 36 | |
37 | - foreach ($config['authorizeTopics'] as $topic => $callback) { |
|
37 | + foreach ($config['authorizeTopics'] as $topic => $callback) |
|
38 | + { |
|
38 | 39 | $this->patterns[$this->compilePattern($topic)] = $callback; |
39 | 40 | } |
40 | 41 | } |
@@ -62,8 +63,10 @@ discard block |
||
62 | 63 | */ |
63 | 64 | public function findTopicCallback(string $topic, array &$matches): ?callable |
64 | 65 | { |
65 | - foreach ($this->patterns as $pattern => $callback) { |
|
66 | - if (preg_match($pattern, $topic, $matches)) { |
|
66 | + foreach ($this->patterns as $pattern => $callback) |
|
67 | + { |
|
68 | + if (preg_match($pattern, $topic, $matches)) |
|
69 | + { |
|
67 | 70 | return $callback; |
68 | 71 | } |
69 | 72 | } |
@@ -78,9 +81,11 @@ discard block |
||
78 | 81 | private function compilePattern(string $topic): string |
79 | 82 | { |
80 | 83 | $replaces = []; |
81 | - if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
84 | + if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) |
|
85 | + { |
|
82 | 86 | $variables = array_combine($matches[1], $matches[2]); |
83 | - foreach ($variables as $key => $_) { |
|
87 | + foreach ($variables as $key => $_) |
|
88 | + { |
|
84 | 89 | $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
85 | 90 | } |
86 | 91 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function getLocales(): array |
50 | 50 | { |
51 | - if (!is_dir($this->config->getLocalesDirectory())) { |
|
51 | + if (!is_dir($this->config->getLocalesDirectory())){ |
|
52 | 52 | return []; |
53 | 53 | } |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | $locales = []; |
59 | 59 | |
60 | - foreach ($finder->directories() as $directory) { |
|
60 | + foreach ($finder->directories() as $directory){ |
|
61 | 61 | $locales[] = $directory->getFilename(); |
62 | 62 | } |
63 | 63 | |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | $locale = preg_replace('/[^a-zA-Z_]/', '', mb_strtolower($locale)); |
73 | 73 | $catalogue = new Catalogue($locale); |
74 | 74 | |
75 | - if (!$this->hasLocale($locale)) { |
|
75 | + if (!$this->hasLocale($locale)){ |
|
76 | 76 | return $catalogue; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $finder = new Finder(); |
80 | 80 | $finder->in($this->config->getLocaleDirectory($locale)); |
81 | 81 | |
82 | - foreach ($finder->getIterator() as $file) { |
|
82 | + foreach ($finder->getIterator() as $file){ |
|
83 | 83 | $this->getLogger()->info( |
84 | 84 | sprintf( |
85 | 85 | "found locale domain file '%s'", |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | //Per application agreement domain name must present in filename |
92 | 92 | $domain = strstr($file->getFilename(), '.', true); |
93 | 93 | |
94 | - if (!$this->config->hasLoader($file->getExtension())) { |
|
94 | + if (!$this->config->hasLoader($file->getExtension())){ |
|
95 | 95 | $this->getLogger()->warning( |
96 | 96 | sprintf( |
97 | 97 | "unable to load domain file '%s', no loader found", |
@@ -48,7 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function getLocales(): array |
50 | 50 | { |
51 | - if (!is_dir($this->config->getLocalesDirectory())) { |
|
51 | + if (!is_dir($this->config->getLocalesDirectory())) |
|
52 | + { |
|
52 | 53 | return []; |
53 | 54 | } |
54 | 55 | |
@@ -57,7 +58,8 @@ discard block |
||
57 | 58 | |
58 | 59 | $locales = []; |
59 | 60 | |
60 | - foreach ($finder->directories() as $directory) { |
|
61 | + foreach ($finder->directories() as $directory) |
|
62 | + { |
|
61 | 63 | $locales[] = $directory->getFilename(); |
62 | 64 | } |
63 | 65 | |
@@ -72,14 +74,16 @@ discard block |
||
72 | 74 | $locale = preg_replace('/[^a-zA-Z_]/', '', mb_strtolower($locale)); |
73 | 75 | $catalogue = new Catalogue($locale); |
74 | 76 | |
75 | - if (!$this->hasLocale($locale)) { |
|
77 | + if (!$this->hasLocale($locale)) |
|
78 | + { |
|
76 | 79 | return $catalogue; |
77 | 80 | } |
78 | 81 | |
79 | 82 | $finder = new Finder(); |
80 | 83 | $finder->in($this->config->getLocaleDirectory($locale)); |
81 | 84 | |
82 | - foreach ($finder->getIterator() as $file) { |
|
85 | + foreach ($finder->getIterator() as $file) |
|
86 | + { |
|
83 | 87 | $this->getLogger()->info( |
84 | 88 | sprintf( |
85 | 89 | "found locale domain file '%s'", |
@@ -91,7 +95,8 @@ discard block |
||
91 | 95 | //Per application agreement domain name must present in filename |
92 | 96 | $domain = strstr($file->getFilename(), '.', true); |
93 | 97 | |
94 | - if (!$this->config->hasLoader($file->getExtension())) { |
|
98 | + if (!$this->config->hasLoader($file->getExtension())) |
|
99 | + { |
|
95 | 100 | $this->getLogger()->warning( |
96 | 101 | sprintf( |
97 | 102 | "unable to load domain file '%s', no loader found", |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | 'field' => 'value' |
75 | 75 | ]); |
76 | 76 | |
77 | - if ($this->classMetadataCount === 0) { |
|
77 | + if ($this->classMetadataCount === 0){ |
|
78 | 78 | $this->expectNotToPerformAssertions(); |
79 | 79 | } |
80 | 80 | |
81 | - foreach ($this->getClassMetadata(AnnotatedClass::class) as $actual) { |
|
81 | + foreach ($this->getClassMetadata(AnnotatedClass::class) as $actual){ |
|
82 | 82 | $this->assertEquals($expected, $actual); |
83 | 83 | } |
84 | 84 | } |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | 'field' => 'value' |
97 | 97 | ]); |
98 | 98 | |
99 | - if ($this->constantMetadataCount === 0) { |
|
99 | + if ($this->constantMetadataCount === 0){ |
|
100 | 100 | $this->expectNotToPerformAssertions(); |
101 | 101 | } |
102 | 102 | |
103 | - foreach ($this->getConstantMetadata(AnnotatedClass::class, 'CONSTANT') as $actual) { |
|
103 | + foreach ($this->getConstantMetadata(AnnotatedClass::class, 'CONSTANT') as $actual){ |
|
104 | 104 | $this->assertEquals($expected, $actual); |
105 | 105 | } |
106 | 106 | } |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | 'field' => 'value' |
119 | 119 | ]); |
120 | 120 | |
121 | - if ($this->propertyMetadataCount === 0) { |
|
121 | + if ($this->propertyMetadataCount === 0){ |
|
122 | 122 | $this->expectNotToPerformAssertions(); |
123 | 123 | } |
124 | 124 | |
125 | - foreach ($this->getPropertyMetadata(AnnotatedClass::class, 'property') as $actual) { |
|
125 | + foreach ($this->getPropertyMetadata(AnnotatedClass::class, 'property') as $actual){ |
|
126 | 126 | $this->assertEquals($expected, $actual); |
127 | 127 | } |
128 | 128 | } |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | 'field' => 'value' |
141 | 141 | ]); |
142 | 142 | |
143 | - if ($this->methodMetadataCount === 0) { |
|
143 | + if ($this->methodMetadataCount === 0){ |
|
144 | 144 | $this->expectNotToPerformAssertions(); |
145 | 145 | } |
146 | 146 | |
147 | - foreach ($this->getMethodMetadata(AnnotatedClass::class, 'method') as $actual) { |
|
147 | + foreach ($this->getMethodMetadata(AnnotatedClass::class, 'method') as $actual){ |
|
148 | 148 | $this->assertEquals($expected, $actual); |
149 | 149 | } |
150 | 150 | } |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | 'field' => 'value' |
163 | 163 | ]); |
164 | 164 | |
165 | - if ($this->methodParameterMetadataCount === 0) { |
|
165 | + if ($this->methodParameterMetadataCount === 0){ |
|
166 | 166 | $this->expectNotToPerformAssertions(); |
167 | 167 | } |
168 | 168 | |
169 | - foreach ($this->getMethodParameterMetadata(AnnotatedClass::class, 'method', 'parameter') as $actual) { |
|
169 | + foreach ($this->getMethodParameterMetadata(AnnotatedClass::class, 'method', 'parameter') as $actual){ |
|
170 | 170 | $this->assertEquals($expected, $actual); |
171 | 171 | } |
172 | 172 | } |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | 'field' => 'value' |
187 | 187 | ]); |
188 | 188 | |
189 | - if ($this->functionMetadataCount === 0) { |
|
189 | + if ($this->functionMetadataCount === 0){ |
|
190 | 190 | $this->expectNotToPerformAssertions(); |
191 | 191 | } |
192 | 192 | |
193 | 193 | $function = '\Spiral\Tests\Attributes\Fixture\annotated_function'; |
194 | 194 | |
195 | - foreach ($this->getFunctionMetadata($function) as $actual) { |
|
195 | + foreach ($this->getFunctionMetadata($function) as $actual){ |
|
196 | 196 | $this->assertEquals($expected, $actual); |
197 | 197 | } |
198 | 198 | } |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | 'field' => 'value' |
213 | 213 | ]); |
214 | 214 | |
215 | - if ($this->functionParameterMetadataCount === 0) { |
|
215 | + if ($this->functionParameterMetadataCount === 0){ |
|
216 | 216 | $this->expectNotToPerformAssertions(); |
217 | 217 | } |
218 | 218 | |
219 | 219 | $function = '\Spiral\Tests\Attributes\Fixture\annotated_function'; |
220 | 220 | |
221 | - foreach ($this->getFunctionParameterMetadata($function, 'parameter') as $actual) { |
|
221 | + foreach ($this->getFunctionParameterMetadata($function, 'parameter') as $actual){ |
|
222 | 222 | $this->assertEquals($expected, $actual); |
223 | 223 | } |
224 | 224 | } |
@@ -74,11 +74,13 @@ discard block |
||
74 | 74 | 'field' => 'value' |
75 | 75 | ]); |
76 | 76 | |
77 | - if ($this->classMetadataCount === 0) { |
|
77 | + if ($this->classMetadataCount === 0) |
|
78 | + { |
|
78 | 79 | $this->expectNotToPerformAssertions(); |
79 | 80 | } |
80 | 81 | |
81 | - foreach ($this->getClassMetadata(AnnotatedClass::class) as $actual) { |
|
82 | + foreach ($this->getClassMetadata(AnnotatedClass::class) as $actual) |
|
83 | + { |
|
82 | 84 | $this->assertEquals($expected, $actual); |
83 | 85 | } |
84 | 86 | } |
@@ -96,11 +98,13 @@ discard block |
||
96 | 98 | 'field' => 'value' |
97 | 99 | ]); |
98 | 100 | |
99 | - if ($this->constantMetadataCount === 0) { |
|
101 | + if ($this->constantMetadataCount === 0) |
|
102 | + { |
|
100 | 103 | $this->expectNotToPerformAssertions(); |
101 | 104 | } |
102 | 105 | |
103 | - foreach ($this->getConstantMetadata(AnnotatedClass::class, 'CONSTANT') as $actual) { |
|
106 | + foreach ($this->getConstantMetadata(AnnotatedClass::class, 'CONSTANT') as $actual) |
|
107 | + { |
|
104 | 108 | $this->assertEquals($expected, $actual); |
105 | 109 | } |
106 | 110 | } |
@@ -118,11 +122,13 @@ discard block |
||
118 | 122 | 'field' => 'value' |
119 | 123 | ]); |
120 | 124 | |
121 | - if ($this->propertyMetadataCount === 0) { |
|
125 | + if ($this->propertyMetadataCount === 0) |
|
126 | + { |
|
122 | 127 | $this->expectNotToPerformAssertions(); |
123 | 128 | } |
124 | 129 | |
125 | - foreach ($this->getPropertyMetadata(AnnotatedClass::class, 'property') as $actual) { |
|
130 | + foreach ($this->getPropertyMetadata(AnnotatedClass::class, 'property') as $actual) |
|
131 | + { |
|
126 | 132 | $this->assertEquals($expected, $actual); |
127 | 133 | } |
128 | 134 | } |
@@ -140,11 +146,13 @@ discard block |
||
140 | 146 | 'field' => 'value' |
141 | 147 | ]); |
142 | 148 | |
143 | - if ($this->methodMetadataCount === 0) { |
|
149 | + if ($this->methodMetadataCount === 0) |
|
150 | + { |
|
144 | 151 | $this->expectNotToPerformAssertions(); |
145 | 152 | } |
146 | 153 | |
147 | - foreach ($this->getMethodMetadata(AnnotatedClass::class, 'method') as $actual) { |
|
154 | + foreach ($this->getMethodMetadata(AnnotatedClass::class, 'method') as $actual) |
|
155 | + { |
|
148 | 156 | $this->assertEquals($expected, $actual); |
149 | 157 | } |
150 | 158 | } |
@@ -162,11 +170,13 @@ discard block |
||
162 | 170 | 'field' => 'value' |
163 | 171 | ]); |
164 | 172 | |
165 | - if ($this->methodParameterMetadataCount === 0) { |
|
173 | + if ($this->methodParameterMetadataCount === 0) |
|
174 | + { |
|
166 | 175 | $this->expectNotToPerformAssertions(); |
167 | 176 | } |
168 | 177 | |
169 | - foreach ($this->getMethodParameterMetadata(AnnotatedClass::class, 'method', 'parameter') as $actual) { |
|
178 | + foreach ($this->getMethodParameterMetadata(AnnotatedClass::class, 'method', 'parameter') as $actual) |
|
179 | + { |
|
170 | 180 | $this->assertEquals($expected, $actual); |
171 | 181 | } |
172 | 182 | } |
@@ -186,13 +196,15 @@ discard block |
||
186 | 196 | 'field' => 'value' |
187 | 197 | ]); |
188 | 198 | |
189 | - if ($this->functionMetadataCount === 0) { |
|
199 | + if ($this->functionMetadataCount === 0) |
|
200 | + { |
|
190 | 201 | $this->expectNotToPerformAssertions(); |
191 | 202 | } |
192 | 203 | |
193 | 204 | $function = '\Spiral\Tests\Attributes\Fixture\annotated_function'; |
194 | 205 | |
195 | - foreach ($this->getFunctionMetadata($function) as $actual) { |
|
206 | + foreach ($this->getFunctionMetadata($function) as $actual) |
|
207 | + { |
|
196 | 208 | $this->assertEquals($expected, $actual); |
197 | 209 | } |
198 | 210 | } |
@@ -212,13 +224,15 @@ discard block |
||
212 | 224 | 'field' => 'value' |
213 | 225 | ]); |
214 | 226 | |
215 | - if ($this->functionParameterMetadataCount === 0) { |
|
227 | + if ($this->functionParameterMetadataCount === 0) |
|
228 | + { |
|
216 | 229 | $this->expectNotToPerformAssertions(); |
217 | 230 | } |
218 | 231 | |
219 | 232 | $function = '\Spiral\Tests\Attributes\Fixture\annotated_function'; |
220 | 233 | |
221 | - foreach ($this->getFunctionParameterMetadata($function, 'parameter') as $actual) { |
|
234 | + foreach ($this->getFunctionParameterMetadata($function, 'parameter') as $actual) |
|
235 | + { |
|
222 | 236 | $this->assertEquals($expected, $actual); |
223 | 237 | } |
224 | 238 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | parent::setUpBeforeClass(); |
24 | 24 | |
25 | - require_once __DIR__ . '/Fixture/function.php'; |
|
25 | + require_once __DIR__.'/Fixture/function.php'; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected function iterableToArray(iterable $iterable): array |
33 | 33 | { |
34 | - if ($iterable instanceof \Traversable) { |
|
34 | + if ($iterable instanceof \Traversable){ |
|
35 | 35 | return \iterator_to_array($iterable, false); |
36 | 36 | } |
37 | 37 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | $instance = new $class(); |
49 | 49 | |
50 | - foreach ($fields as $field => $value) { |
|
50 | + foreach ($fields as $field => $value){ |
|
51 | 51 | $instance->$field = $value; |
52 | 52 | } |
53 | 53 |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected function iterableToArray(iterable $iterable): array |
33 | 33 | { |
34 | - if ($iterable instanceof \Traversable) { |
|
34 | + if ($iterable instanceof \Traversable) |
|
35 | + { |
|
35 | 36 | return \iterator_to_array($iterable, false); |
36 | 37 | } |
37 | 38 | |
@@ -47,7 +48,8 @@ discard block |
||
47 | 48 | { |
48 | 49 | $instance = new $class(); |
49 | 50 | |
50 | - foreach ($fields as $field => $value) { |
|
51 | + foreach ($fields as $field => $value) |
|
52 | + { |
|
51 | 53 | $instance->$field = $value; |
52 | 54 | } |
53 | 55 |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | ->getReflectionConstants() |
44 | 44 | ; |
45 | 45 | |
46 | - foreach ($constants as $reflection) { |
|
47 | - if ($reflection->getName() === $name) { |
|
46 | + foreach ($constants as $reflection){ |
|
47 | + if ($reflection->getName() === $name){ |
|
48 | 48 | return $reflection; |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - throw new \ReflectionException('Constant ' . $name . ' not found'); |
|
52 | + throw new \ReflectionException('Constant '.$name.' not found'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | protected function getReflectionFunctionParameter(string $function, string $name): \ReflectionParameter |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | ->getParameters() |
59 | 59 | ; |
60 | 60 | |
61 | - foreach ($parameters as $reflection) { |
|
62 | - if ($reflection->getName() === $name) { |
|
61 | + foreach ($parameters as $reflection){ |
|
62 | + if ($reflection->getName() === $name){ |
|
63 | 63 | return $reflection; |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - throw new \ReflectionException('Parameter ' . $name . ' not found'); |
|
67 | + throw new \ReflectionException('Parameter '.$name.' not found'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | protected function getReflectionMethodParameter(string $class, string $method, string $name): \ReflectionParameter |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | ->getParameters() |
74 | 74 | ; |
75 | 75 | |
76 | - foreach ($parameters as $reflection) { |
|
77 | - if ($reflection->getName() === $name) { |
|
76 | + foreach ($parameters as $reflection){ |
|
77 | + if ($reflection->getName() === $name){ |
|
78 | 78 | return $reflection; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - throw new \ReflectionException('Parameter ' . $name . ' not found'); |
|
82 | + throw new \ReflectionException('Parameter '.$name.' not found'); |
|
83 | 83 | } |
84 | 84 | } |
@@ -43,8 +43,10 @@ discard block |
||
43 | 43 | ->getReflectionConstants() |
44 | 44 | ; |
45 | 45 | |
46 | - foreach ($constants as $reflection) { |
|
47 | - if ($reflection->getName() === $name) { |
|
46 | + foreach ($constants as $reflection) |
|
47 | + { |
|
48 | + if ($reflection->getName() === $name) |
|
49 | + { |
|
48 | 50 | return $reflection; |
49 | 51 | } |
50 | 52 | } |
@@ -58,8 +60,10 @@ discard block |
||
58 | 60 | ->getParameters() |
59 | 61 | ; |
60 | 62 | |
61 | - foreach ($parameters as $reflection) { |
|
62 | - if ($reflection->getName() === $name) { |
|
63 | + foreach ($parameters as $reflection) |
|
64 | + { |
|
65 | + if ($reflection->getName() === $name) |
|
66 | + { |
|
63 | 67 | return $reflection; |
64 | 68 | } |
65 | 69 | } |
@@ -73,8 +77,10 @@ discard block |
||
73 | 77 | ->getParameters() |
74 | 78 | ; |
75 | 79 | |
76 | - foreach ($parameters as $reflection) { |
|
77 | - if ($reflection->getName() === $name) { |
|
80 | + foreach ($parameters as $reflection) |
|
81 | + { |
|
82 | + if ($reflection->getName() === $name) |
|
83 | + { |
|
78 | 84 | return $reflection; |
79 | 85 | } |
80 | 86 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function has(string $section): bool |
48 | 48 | { |
49 | - foreach (self::LOADERS as $extension => $_) { |
|
49 | + foreach (self::LOADERS as $extension => $_){ |
|
50 | 50 | $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension); |
51 | - if (file_exists($filename)) { |
|
51 | + if (file_exists($filename)){ |
|
52 | 52 | return true; |
53 | 53 | } |
54 | 54 | } |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function load(string $section): array |
63 | 63 | { |
64 | - foreach (self::LOADERS as $extension => $_) { |
|
64 | + foreach (self::LOADERS as $extension => $_){ |
|
65 | 65 | $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension); |
66 | - if (!file_exists($filename)) { |
|
66 | + if (!file_exists($filename)){ |
|
67 | 67 | continue; |
68 | 68 | } |
69 | 69 | |
70 | - try { |
|
70 | + try{ |
|
71 | 71 | return $this->getLoader($extension)->loadFile($section, $filename); |
72 | - } catch (LoaderException $e) { |
|
72 | + }catch (LoaderException $e){ |
|
73 | 73 | throw new LoaderException("Unable to load config `{$section}`.", $e->getCode(), $e); |
74 | 74 | } |
75 | 75 | } |
@@ -46,9 +46,11 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function has(string $section): bool |
48 | 48 | { |
49 | - foreach (self::LOADERS as $extension => $_) { |
|
49 | + foreach (self::LOADERS as $extension => $_) |
|
50 | + { |
|
50 | 51 | $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension); |
51 | - if (file_exists($filename)) { |
|
52 | + if (file_exists($filename)) |
|
53 | + { |
|
52 | 54 | return true; |
53 | 55 | } |
54 | 56 | } |
@@ -61,15 +63,20 @@ discard block |
||
61 | 63 | */ |
62 | 64 | public function load(string $section): array |
63 | 65 | { |
64 | - foreach (self::LOADERS as $extension => $_) { |
|
66 | + foreach (self::LOADERS as $extension => $_) |
|
67 | + { |
|
65 | 68 | $filename = sprintf('%s/%s.%s', $this->directory, $section, $extension); |
66 | - if (!file_exists($filename)) { |
|
69 | + if (!file_exists($filename)) |
|
70 | + { |
|
67 | 71 | continue; |
68 | 72 | } |
69 | 73 | |
70 | - try { |
|
74 | + try |
|
75 | + { |
|
71 | 76 | return $this->getLoader($extension)->loadFile($section, $filename); |
72 | - } catch (LoaderException $e) { |
|
77 | + } |
|
78 | + catch (LoaderException $e) |
|
79 | + { |
|
73 | 80 | throw new LoaderException("Unable to load config `{$section}`.", $e->getCode(), $e); |
74 | 81 | } |
75 | 82 | } |
@@ -27,14 +27,14 @@ |
||
27 | 27 | */ |
28 | 28 | public function renderInject(Directive $directive): string |
29 | 29 | { |
30 | - if (count($directive->values) < 2 || strlen($directive->values[0]) === 0) { |
|
30 | + if (count($directive->values) < 2 || strlen($directive->values[0]) === 0){ |
|
31 | 31 | throw new DirectiveException( |
32 | 32 | 'Unable to call @inject directive, 2 values required', |
33 | 33 | $directive->getContext() |
34 | 34 | ); |
35 | 35 | } |
36 | 36 | |
37 | - if ($directive->values[0][0] === '$') { |
|
37 | + if ($directive->values[0][0] === '$'){ |
|
38 | 38 | return sprintf( |
39 | 39 | '<?php %s = $this->container->get(%s); ?>', |
40 | 40 | $directive->values[0], |
@@ -27,14 +27,16 @@ |
||
27 | 27 | */ |
28 | 28 | public function renderInject(Directive $directive): string |
29 | 29 | { |
30 | - if (count($directive->values) < 2 || strlen($directive->values[0]) === 0) { |
|
30 | + if (count($directive->values) < 2 || strlen($directive->values[0]) === 0) |
|
31 | + { |
|
31 | 32 | throw new DirectiveException( |
32 | 33 | 'Unable to call @inject directive, 2 values required', |
33 | 34 | $directive->getContext() |
34 | 35 | ); |
35 | 36 | } |
36 | 37 | |
37 | - if ($directive->values[0][0] === '$') { |
|
38 | + if ($directive->values[0][0] === '$') |
|
39 | + { |
|
38 | 40 | return sprintf( |
39 | 41 | '<?php %s = $this->container->get(%s); ?>', |
40 | 42 | $directive->values[0], |