@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function tearDown(): void |
| 29 | 29 | { |
| 30 | - $this->files()->deleteDirectory($this->app->directory('app') . 'migrations', true); |
|
| 30 | + $this->files()->deleteDirectory($this->app->directory('app').'migrations', true); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | clearstatcache(); |
| 42 | 42 | |
| 43 | - foreach ($this->files()->getFiles($this->app->directory('app') . 'migrations') as $file) { |
|
| 43 | + foreach ($this->files()->getFiles($this->app->directory('app').'migrations') as $file){ |
|
| 44 | 44 | require_once $file; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | clearstatcache(); |
| 65 | 65 | |
| 66 | - foreach ($this->files()->getFiles($this->app->directory('app') . 'migrations') as $file) { |
|
| 66 | + foreach ($this->files()->getFiles($this->app->directory('app').'migrations') as $file){ |
|
| 67 | 67 | require_once $file; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $this->console()->run('create:migration', [ |
| 83 | 83 | 'name' => 'sample3', |
| 84 | 84 | '--table' => 'sample3_table', |
| 85 | - '--field' => ['id',] |
|
| 85 | + '--field' => ['id', ] |
|
| 86 | 86 | ]); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | ] |
| 97 | 97 | ]; |
| 98 | 98 | |
| 99 | - if ($withTable) { |
|
| 99 | + if ($withTable){ |
|
| 100 | 100 | $input['--table'] = 'sample_table'; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | clearstatcache(); |
| 115 | 115 | |
| 116 | - foreach ($this->files()->getFiles($this->app->directory('app') . 'migrations') as $file) { |
|
| 116 | + foreach ($this->files()->getFiles($this->app->directory('app').'migrations') as $file){ |
|
| 117 | 117 | require_once $file; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -40,7 +40,8 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | clearstatcache(); |
| 42 | 42 | |
| 43 | - foreach ($this->files()->getFiles($this->app->directory('app') . 'migrations') as $file) { |
|
| 43 | + foreach ($this->files()->getFiles($this->app->directory('app') . 'migrations') as $file) |
|
| 44 | + { |
|
| 44 | 45 | require_once $file; |
| 45 | 46 | } |
| 46 | 47 | |
@@ -63,7 +64,8 @@ discard block |
||
| 63 | 64 | |
| 64 | 65 | clearstatcache(); |
| 65 | 66 | |
| 66 | - foreach ($this->files()->getFiles($this->app->directory('app') . 'migrations') as $file) { |
|
| 67 | + foreach ($this->files()->getFiles($this->app->directory('app') . 'migrations') as $file) |
|
| 68 | + { |
|
| 67 | 69 | require_once $file; |
| 68 | 70 | } |
| 69 | 71 | |
@@ -96,7 +98,8 @@ discard block |
||
| 96 | 98 | ] |
| 97 | 99 | ]; |
| 98 | 100 | |
| 99 | - if ($withTable) { |
|
| 101 | + if ($withTable) |
|
| 102 | + { |
|
| 100 | 103 | $input['--table'] = 'sample_table'; |
| 101 | 104 | } |
| 102 | 105 | |
@@ -113,7 +116,8 @@ discard block |
||
| 113 | 116 | { |
| 114 | 117 | clearstatcache(); |
| 115 | 118 | |
| 116 | - foreach ($this->files()->getFiles($this->app->directory('app') . 'migrations') as $file) { |
|
| 119 | + foreach ($this->files()->getFiles($this->app->directory('app') . 'migrations') as $file) |
|
| 120 | + { |
|
| 117 | 121 | require_once $file; |
| 118 | 122 | } |
| 119 | 123 | |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | public function testScaffold(): void |
| 34 | 34 | { |
| 35 | 35 | $line = __LINE__; |
| 36 | - $className = self::CLASS_NAME . $line; |
|
| 36 | + $className = self::CLASS_NAME.$line; |
|
| 37 | 37 | $this->console()->run('create:entity', [ |
| 38 | - 'name' => 'sample' . $line, |
|
| 38 | + 'name' => 'sample'.$line, |
|
| 39 | 39 | '--field' => [ |
| 40 | 40 | 'id:primary', |
| 41 | 41 | 'value:int' |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function testAccessibility(int $line, ?string $accessibility, string $modifier): void |
| 107 | 107 | { |
| 108 | - $className = self::CLASS_NAME . $line; |
|
| 108 | + $className = self::CLASS_NAME.$line; |
|
| 109 | 109 | $input = [ |
| 110 | - 'name' => 'sample' . $line, |
|
| 110 | + 'name' => 'sample'.$line, |
|
| 111 | 111 | '--field' => [ |
| 112 | 112 | 'id:primary', |
| 113 | 113 | ], |
| 114 | 114 | ]; |
| 115 | - if (!empty($accessibility)) { |
|
| 115 | + if (!empty($accessibility)){ |
|
| 116 | 116 | $input['--accessibility'] = $accessibility; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -153,15 +153,15 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function testAccessors(int $line, ?string $accessibility, bool $hasAccessors): void |
| 155 | 155 | { |
| 156 | - $className = self::CLASS_NAME . $line; |
|
| 156 | + $className = self::CLASS_NAME.$line; |
|
| 157 | 157 | $input = [ |
| 158 | - 'name' => 'sample' . $line, |
|
| 158 | + 'name' => 'sample'.$line, |
|
| 159 | 159 | '--field' => [ |
| 160 | 160 | 'id:primary', |
| 161 | 161 | 'name:string', |
| 162 | 162 | ], |
| 163 | 163 | ]; |
| 164 | - if (!empty($accessibility)) { |
|
| 164 | + if (!empty($accessibility)){ |
|
| 165 | 165 | $input['--accessibility'] = $accessibility; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | $reflection = new ReflectionClass($className); |
| 174 | 174 | |
| 175 | 175 | $methods = []; |
| 176 | - foreach ($reflection->getMethods() as $method) { |
|
| 176 | + foreach ($reflection->getMethods() as $method){ |
|
| 177 | 177 | $methods[] = $method->getName(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if ($hasAccessors) { |
|
| 180 | + if ($hasAccessors){ |
|
| 181 | 181 | $this->assertContains('getId', $methods); |
| 182 | 182 | $this->assertContains('getName', $methods); |
| 183 | 183 | $this->assertContains('setId', $methods); |
| 184 | 184 | $this->assertContains('setName', $methods); |
| 185 | - } else { |
|
| 185 | + }else{ |
|
| 186 | 186 | $this->assertNotContains('getId', $methods); |
| 187 | 187 | $this->assertNotContains('setId', $methods); |
| 188 | 188 | $this->assertNotContains('setId', $methods); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | clearstatcache(); |
| 227 | 227 | $this->assertEquals($exists, class_exists($repositoryClassName)); |
| 228 | 228 | |
| 229 | - if ($exists) { |
|
| 229 | + if ($exists){ |
|
| 230 | 230 | $reflection = new ReflectionClass($className); |
| 231 | 231 | $source = $this->files()->read($reflection->getFileName()); |
| 232 | 232 | |
@@ -243,14 +243,14 @@ discard block |
||
| 243 | 243 | $line2 = __LINE__; |
| 244 | 244 | $line3 = __LINE__; |
| 245 | 245 | |
| 246 | - $repositoryClassName1 = trimPostfix(self::REPOSITORY_CLASS_NAME, 'repository') . $line1 . 'Repository'; |
|
| 247 | - $repositoryClassName2 = trimPostfix(self::REPOSITORY_CLASS_NAME, 'repository') . $line2 . 'Repository'; |
|
| 248 | - $repositoryClassName3 = trimPostfix(self::REPOSITORY_CLASS_NAME, 'repository') . $line3 . 'Repository'; |
|
| 246 | + $repositoryClassName1 = trimPostfix(self::REPOSITORY_CLASS_NAME, 'repository').$line1.'Repository'; |
|
| 247 | + $repositoryClassName2 = trimPostfix(self::REPOSITORY_CLASS_NAME, 'repository').$line2.'Repository'; |
|
| 248 | + $repositoryClassName3 = trimPostfix(self::REPOSITORY_CLASS_NAME, 'repository').$line3.'Repository'; |
|
| 249 | 249 | |
| 250 | 250 | return [ |
| 251 | - [self::CLASS_NAME . $line1, 'sample' . $line1, $repositoryClassName1, 'sample', true], |
|
| 252 | - [self::CLASS_NAME . $line2, 'sample' . $line2, $repositoryClassName2, 'repository', true], |
|
| 253 | - [self::CLASS_NAME . $line3, 'sample' . $line3, $repositoryClassName3, '', false], |
|
| 251 | + [self::CLASS_NAME.$line1, 'sample'.$line1, $repositoryClassName1, 'sample', true], |
|
| 252 | + [self::CLASS_NAME.$line2, 'sample'.$line2, $repositoryClassName2, 'repository', true], |
|
| 253 | + [self::CLASS_NAME.$line3, 'sample'.$line3, $repositoryClassName3, '', false], |
|
| 254 | 254 | ]; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | public function testAnnotated(): void |
| 262 | 262 | { |
| 263 | 263 | $line = __LINE__; |
| 264 | - $className = self::CLASS_NAME . $line; |
|
| 264 | + $className = self::CLASS_NAME.$line; |
|
| 265 | 265 | $this->console()->run('create:entity', [ |
| 266 | - 'name' => 'sample' . $line, |
|
| 266 | + 'name' => 'sample'.$line, |
|
| 267 | 267 | '--field' => [ |
| 268 | 268 | 'id:primary', |
| 269 | 269 | 'myValue:?int' |
@@ -300,9 +300,9 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | public function testAnnotatedInflection(int $line, string $inflection, string $needle): void |
| 302 | 302 | { |
| 303 | - $className = self::CLASS_NAME . $line; |
|
| 303 | + $className = self::CLASS_NAME.$line; |
|
| 304 | 304 | $this->console()->run('create:entity', [ |
| 305 | - 'name' => 'sample' . $line, |
|
| 305 | + 'name' => 'sample'.$line, |
|
| 306 | 306 | '--field' => [ |
| 307 | 307 | 'id:primary', |
| 308 | 308 | 'myValue:int', |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | public function inflectionDataProvider(): array |
| 331 | 331 | { |
| 332 | 332 | return [ |
| 333 | - [__LINE__ + random_int(101, 200), 'tableize', 'my_value'], |
|
| 334 | - [__LINE__ + random_int(101, 200), 't', 'my_value'], |
|
| 335 | - [__LINE__ + random_int(201, 300), 'camelize', 'myAnotherValue'], |
|
| 336 | - [__LINE__ + random_int(201, 300), 'c', 'myAnotherValue'], |
|
| 333 | + [__LINE__ +random_int(101, 200), 'tableize', 'my_value'], |
|
| 334 | + [__LINE__ +random_int(101, 200), 't', 'my_value'], |
|
| 335 | + [__LINE__ +random_int(201, 300), 'camelize', 'myAnotherValue'], |
|
| 336 | + [__LINE__ +random_int(201, 300), 'c', 'myAnotherValue'], |
|
| 337 | 337 | ]; |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -112,7 +112,8 @@ discard block |
||
| 112 | 112 | 'id:primary', |
| 113 | 113 | ], |
| 114 | 114 | ]; |
| 115 | - if (!empty($accessibility)) { |
|
| 115 | + if (!empty($accessibility)) |
|
| 116 | + { |
|
| 116 | 117 | $input['--accessibility'] = $accessibility; |
| 117 | 118 | } |
| 118 | 119 | |
@@ -161,7 +162,8 @@ discard block |
||
| 161 | 162 | 'name:string', |
| 162 | 163 | ], |
| 163 | 164 | ]; |
| 164 | - if (!empty($accessibility)) { |
|
| 165 | + if (!empty($accessibility)) |
|
| 166 | + { |
|
| 165 | 167 | $input['--accessibility'] = $accessibility; |
| 166 | 168 | } |
| 167 | 169 | |
@@ -173,16 +175,20 @@ discard block |
||
| 173 | 175 | $reflection = new ReflectionClass($className); |
| 174 | 176 | |
| 175 | 177 | $methods = []; |
| 176 | - foreach ($reflection->getMethods() as $method) { |
|
| 178 | + foreach ($reflection->getMethods() as $method) |
|
| 179 | + { |
|
| 177 | 180 | $methods[] = $method->getName(); |
| 178 | 181 | } |
| 179 | 182 | |
| 180 | - if ($hasAccessors) { |
|
| 183 | + if ($hasAccessors) |
|
| 184 | + { |
|
| 181 | 185 | $this->assertContains('getId', $methods); |
| 182 | 186 | $this->assertContains('getName', $methods); |
| 183 | 187 | $this->assertContains('setId', $methods); |
| 184 | 188 | $this->assertContains('setName', $methods); |
| 185 | - } else { |
|
| 189 | + } |
|
| 190 | + else |
|
| 191 | + { |
|
| 186 | 192 | $this->assertNotContains('getId', $methods); |
| 187 | 193 | $this->assertNotContains('setId', $methods); |
| 188 | 194 | $this->assertNotContains('setId', $methods); |
@@ -226,7 +232,8 @@ discard block |
||
| 226 | 232 | clearstatcache(); |
| 227 | 233 | $this->assertEquals($exists, class_exists($repositoryClassName)); |
| 228 | 234 | |
| 229 | - if ($exists) { |
|
| 235 | + if ($exists) |
|
| 236 | + { |
|
| 230 | 237 | $reflection = new ReflectionClass($className); |
| 231 | 238 | $source = $this->files()->read($reflection->getFileName()); |
| 232 | 239 | |
@@ -24,11 +24,11 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | protected function deleteDeclaration(string $class): void |
| 26 | 26 | { |
| 27 | - if (class_exists($class)) { |
|
| 28 | - try { |
|
| 27 | + if (class_exists($class)){ |
|
| 28 | + try{ |
|
| 29 | 29 | $reflection = new ReflectionClass($class); |
| 30 | 30 | $this->files()->delete($reflection->getFileName()); |
| 31 | - } catch (Throwable $exception) { |
|
| 31 | + }catch (Throwable $exception){ |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -24,11 +24,15 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | protected function deleteDeclaration(string $class): void |
| 26 | 26 | { |
| 27 | - if (class_exists($class)) { |
|
| 28 | - try { |
|
| 27 | + if (class_exists($class)) |
|
| 28 | + { |
|
| 29 | + try |
|
| 30 | + { |
|
| 29 | 31 | $reflection = new ReflectionClass($class); |
| 30 | 32 | $this->files()->delete($reflection->getFileName()); |
| 31 | - } catch (Throwable $exception) { |
|
| 33 | + } |
|
| 34 | + catch (Throwable $exception) |
|
| 35 | + { |
|
| 32 | 36 | } |
| 33 | 37 | } |
| 34 | 38 | } |
@@ -61,18 +61,18 @@ |
||
| 61 | 61 | */ |
| 62 | 62 | protected function mapDirectories(array $directories): array |
| 63 | 63 | { |
| 64 | - if (!isset($directories['root'])) { |
|
| 64 | + if (!isset($directories['root'])){ |
|
| 65 | 65 | throw new Boot\Exception\BootException('Missing required directory `root`.'); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if (!isset($directories['app'])) { |
|
| 69 | - $directories['app'] = $directories['root'] . '/'; |
|
| 68 | + if (!isset($directories['app'])){ |
|
| 69 | + $directories['app'] = $directories['root'].'/'; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return array_merge([ |
| 73 | - 'vendor' => $directories['root'] . '/vendor/', |
|
| 74 | - 'runtime' => $directories['root'] . '/runtime/', |
|
| 75 | - 'config' => $directories['app'] . '/config/' |
|
| 73 | + 'vendor' => $directories['root'].'/vendor/', |
|
| 74 | + 'runtime' => $directories['root'].'/runtime/', |
|
| 75 | + 'config' => $directories['app'].'/config/' |
|
| 76 | 76 | ], $directories); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -61,11 +61,13 @@ |
||
| 61 | 61 | */ |
| 62 | 62 | protected function mapDirectories(array $directories): array |
| 63 | 63 | { |
| 64 | - if (!isset($directories['root'])) { |
|
| 64 | + if (!isset($directories['root'])) |
|
| 65 | + { |
|
| 65 | 66 | throw new Boot\Exception\BootException('Missing required directory `root`.'); |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | - if (!isset($directories['app'])) { |
|
| 69 | + if (!isset($directories['app'])) |
|
| 70 | + { |
|
| 69 | 71 | $directories['app'] = $directories['root'] . '/'; |
| 70 | 72 | } |
| 71 | 73 | |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | declare(strict_types=1); |
| 15 | 15 | |
| 16 | 16 | return [ |
| 17 | - 'directory' => directory('app') . 'migrations/', |
|
| 17 | + 'directory' => directory('app').'migrations/', |
|
| 18 | 18 | 'database' => 'runtime', |
| 19 | 19 | 'table' => 'migrations', |
| 20 | 20 | 'safe' => env('SPIRAL_ENV') === 'develop' |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | 'connections' => [ |
| 34 | 34 | 'runtime' => [ |
| 35 | 35 | 'driver' => SQLiteDriver::class, |
| 36 | - 'connection' => 'sqlite:' . directory('runtime') . 'runtime.db', |
|
| 36 | + 'connection' => 'sqlite:'.directory('runtime').'runtime.db', |
|
| 37 | 37 | 'profiling' => env('DEBUG', false), |
| 38 | 38 | 'username' => 'sqlite', |
| 39 | 39 | 'password' => '', |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | public function testFromEntity(): void |
| 27 | 27 | { |
| 28 | 28 | $line = __LINE__; |
| 29 | - $className = __NAMESPACE__ . "\\App\\Request\\Sample{$line}Request"; |
|
| 29 | + $className = __NAMESPACE__."\\App\\Request\\Sample{$line}Request"; |
|
| 30 | 30 | $output = $this->console()->run('create:filter', [ |
| 31 | - 'name' => 'sample' . $line, |
|
| 31 | + 'name' => 'sample'.$line, |
|
| 32 | 32 | '--entity' => SourceEntity74::class |
| 33 | 33 | ]); |
| 34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $reflection = new ReflectionClass($className); |
| 41 | 41 | |
| 42 | - try { |
|
| 42 | + try{ |
|
| 43 | 43 | $schema = $reflection->getConstant('SCHEMA'); |
| 44 | 44 | $this->assertSame('data:typedBool', $schema['typedBool']); |
| 45 | 45 | $this->assertSame('data:noTypeString', $schema['noTypeString']); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $this->assertSame(['notEmpty', 'string'], $validates['obj']); |
| 54 | 54 | $this->assertSame(['notEmpty', 'integer'], $validates['intFromPhpDoc']); |
| 55 | 55 | $this->assertSame(['notEmpty', 'float'], $validates['noTypeWithFloatDefault']); |
| 56 | - } finally { |
|
| 56 | + }finally{ |
|
| 57 | 57 | $this->deleteDeclaration($className); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -39,7 +39,8 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $reflection = new ReflectionClass($className); |
| 41 | 41 | |
| 42 | - try { |
|
| 42 | + try |
|
| 43 | + { |
|
| 43 | 44 | $schema = $reflection->getConstant('SCHEMA'); |
| 44 | 45 | $this->assertSame('data:typedBool', $schema['typedBool']); |
| 45 | 46 | $this->assertSame('data:noTypeString', $schema['noTypeString']); |
@@ -53,7 +54,9 @@ discard block |
||
| 53 | 54 | $this->assertSame(['notEmpty', 'string'], $validates['obj']); |
| 54 | 55 | $this->assertSame(['notEmpty', 'integer'], $validates['intFromPhpDoc']); |
| 55 | 56 | $this->assertSame(['notEmpty', 'float'], $validates['noTypeWithFloatDefault']); |
| 56 | - } finally { |
|
| 57 | + } |
|
| 58 | + finally |
|
| 59 | + { |
|
| 57 | 60 | $this->deleteDeclaration($className); |
| 58 | 61 | } |
| 59 | 62 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | public function testFromEntity(): void |
| 27 | 27 | { |
| 28 | 28 | $line = __LINE__; |
| 29 | - $className = __NAMESPACE__ . "\\App\\Request\\Sample{$line}Request"; |
|
| 29 | + $className = __NAMESPACE__ . "\\App\\Request\\Sample{$line}request"; |
|
| 30 | 30 | $output = $this->console()->run('create:filter', [ |
| 31 | 31 | 'name' => 'sample' . $line, |
| 32 | 32 | '--entity' => SourceEntity74::class |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function findClasses(string $annotation): iterable |
| 65 | 65 | { |
| 66 | - foreach ($this->getTargets() as $target) { |
|
| 66 | + foreach ($this->getTargets() as $target){ |
|
| 67 | 67 | $found = $this->reader->getClassAnnotation($target, $annotation); |
| 68 | - if ($found !== null) { |
|
| 68 | + if ($found !== null){ |
|
| 69 | 69 | yield new AnnotatedClass($target, $found); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function findMethods(string $annotation): iterable |
| 81 | 81 | { |
| 82 | - foreach ($this->getTargets() as $target) { |
|
| 83 | - foreach ($target->getMethods() as $method) { |
|
| 82 | + foreach ($this->getTargets() as $target){ |
|
| 83 | + foreach ($target->getMethods() as $method){ |
|
| 84 | 84 | $found = $this->reader->getMethodAnnotation($method, $annotation); |
| 85 | - if ($found !== null) { |
|
| 85 | + if ($found !== null){ |
|
| 86 | 86 | yield new AnnotatedMethod($method, $found); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function findProperties(string $annotation): iterable |
| 99 | 99 | { |
| 100 | - foreach ($this->getTargets() as $target) { |
|
| 101 | - foreach ($target->getProperties() as $property) { |
|
| 100 | + foreach ($this->getTargets() as $target){ |
|
| 101 | + foreach ($target->getProperties() as $property){ |
|
| 102 | 102 | $found = $this->reader->getPropertyAnnotation($property, $annotation); |
| 103 | - if ($found !== null) { |
|
| 103 | + if ($found !== null){ |
|
| 104 | 104 | yield new AnnotatedProperty($property, $found); |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | private function getTargets(): iterable |
| 114 | 114 | { |
| 115 | - if ($this->targets === []) { |
|
| 115 | + if ($this->targets === []){ |
|
| 116 | 116 | yield from $this->classLocator->getClasses(); |
| 117 | 117 | return; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - foreach ($this->targets as $target) { |
|
| 120 | + foreach ($this->targets as $target){ |
|
| 121 | 121 | yield from $this->classLocator->getClasses($target); |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -63,9 +63,11 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function findClasses(string $annotation): iterable |
| 65 | 65 | { |
| 66 | - foreach ($this->getTargets() as $target) { |
|
| 66 | + foreach ($this->getTargets() as $target) |
|
| 67 | + { |
|
| 67 | 68 | $found = $this->reader->getClassAnnotation($target, $annotation); |
| 68 | - if ($found !== null) { |
|
| 69 | + if ($found !== null) |
|
| 70 | + { |
|
| 69 | 71 | yield new AnnotatedClass($target, $found); |
| 70 | 72 | } |
| 71 | 73 | } |
@@ -79,10 +81,13 @@ discard block |
||
| 79 | 81 | */ |
| 80 | 82 | public function findMethods(string $annotation): iterable |
| 81 | 83 | { |
| 82 | - foreach ($this->getTargets() as $target) { |
|
| 83 | - foreach ($target->getMethods() as $method) { |
|
| 84 | + foreach ($this->getTargets() as $target) |
|
| 85 | + { |
|
| 86 | + foreach ($target->getMethods() as $method) |
|
| 87 | + { |
|
| 84 | 88 | $found = $this->reader->getMethodAnnotation($method, $annotation); |
| 85 | - if ($found !== null) { |
|
| 89 | + if ($found !== null) |
|
| 90 | + { |
|
| 86 | 91 | yield new AnnotatedMethod($method, $found); |
| 87 | 92 | } |
| 88 | 93 | } |
@@ -97,10 +102,13 @@ discard block |
||
| 97 | 102 | */ |
| 98 | 103 | public function findProperties(string $annotation): iterable |
| 99 | 104 | { |
| 100 | - foreach ($this->getTargets() as $target) { |
|
| 101 | - foreach ($target->getProperties() as $property) { |
|
| 105 | + foreach ($this->getTargets() as $target) |
|
| 106 | + { |
|
| 107 | + foreach ($target->getProperties() as $property) |
|
| 108 | + { |
|
| 102 | 109 | $found = $this->reader->getPropertyAnnotation($property, $annotation); |
| 103 | - if ($found !== null) { |
|
| 110 | + if ($found !== null) |
|
| 111 | + { |
|
| 104 | 112 | yield new AnnotatedProperty($property, $found); |
| 105 | 113 | } |
| 106 | 114 | } |
@@ -112,12 +120,14 @@ discard block |
||
| 112 | 120 | */ |
| 113 | 121 | private function getTargets(): iterable |
| 114 | 122 | { |
| 115 | - if ($this->targets === []) { |
|
| 123 | + if ($this->targets === []) |
|
| 124 | + { |
|
| 116 | 125 | yield from $this->classLocator->getClasses(); |
| 117 | 126 | return; |
| 118 | 127 | } |
| 119 | 128 | |
| 120 | - foreach ($this->targets as $target) { |
|
| 129 | + foreach ($this->targets as $target) |
|
| 130 | + { |
|
| 121 | 131 | yield from $this->classLocator->getClasses($target); |
| 122 | 132 | } |
| 123 | 133 | } |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | public function testLocateClasses() |
| 25 | 25 | { |
| 26 | - $classes = $this->getLocator(__DIR__ . '/Fixtures')->findClasses(Value::class); |
|
| 26 | + $classes = $this->getLocator(__DIR__.'/Fixtures')->findClasses(Value::class); |
|
| 27 | 27 | $classes = iterator_to_array($classes); |
| 28 | 28 | |
| 29 | 29 | $this->assertCount(1, $classes); |
| 30 | 30 | |
| 31 | - foreach ($classes as $class) { |
|
| 31 | + foreach ($classes as $class){ |
|
| 32 | 32 | $this->assertSame(TestClass::class, $class->getClass()->getName()); |
| 33 | 33 | $this->assertSame('abc', $class->getAnnotation()->value); |
| 34 | 34 | } |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function testLocateProperties() |
| 38 | 38 | { |
| 39 | - $props = $this->getLocator(__DIR__ . '/Fixtures')->findProperties(Another::class); |
|
| 39 | + $props = $this->getLocator(__DIR__.'/Fixtures')->findProperties(Another::class); |
|
| 40 | 40 | $props = iterator_to_array($props); |
| 41 | 41 | |
| 42 | 42 | $this->assertCount(1, $props); |
| 43 | 43 | |
| 44 | - foreach ($props as $prop) { |
|
| 44 | + foreach ($props as $prop){ |
|
| 45 | 45 | $this->assertSame(TestClass::class, $prop->getClass()->getName()); |
| 46 | 46 | $this->assertSame('name', $prop->getProperty()->getName()); |
| 47 | 47 | $this->assertSame('123', $prop->getAnnotation()->id); |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function testLocateMethods() |
| 52 | 52 | { |
| 53 | - $methods = $this->getLocator(__DIR__ . '/Fixtures')->findMethods(Route::class); |
|
| 53 | + $methods = $this->getLocator(__DIR__.'/Fixtures')->findMethods(Route::class); |
|
| 54 | 54 | $methods = iterator_to_array($methods); |
| 55 | 55 | |
| 56 | 56 | $this->assertCount(1, $methods); |
| 57 | 57 | |
| 58 | - foreach ($methods as $m) { |
|
| 58 | + foreach ($methods as $m){ |
|
| 59 | 59 | $this->assertSame(TestClass::class, $m->getClass()->getName()); |
| 60 | 60 | $this->assertSame('testMethod', $m->getMethod()->getName()); |
| 61 | 61 | $this->assertSame('/', $m->getAnnotation()->path); |
@@ -28,7 +28,8 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $this->assertCount(1, $classes); |
| 30 | 30 | |
| 31 | - foreach ($classes as $class) { |
|
| 31 | + foreach ($classes as $class) |
|
| 32 | + { |
|
| 32 | 33 | $this->assertSame(TestClass::class, $class->getClass()->getName()); |
| 33 | 34 | $this->assertSame('abc', $class->getAnnotation()->value); |
| 34 | 35 | } |
@@ -41,7 +42,8 @@ discard block |
||
| 41 | 42 | |
| 42 | 43 | $this->assertCount(1, $props); |
| 43 | 44 | |
| 44 | - foreach ($props as $prop) { |
|
| 45 | + foreach ($props as $prop) |
|
| 46 | + { |
|
| 45 | 47 | $this->assertSame(TestClass::class, $prop->getClass()->getName()); |
| 46 | 48 | $this->assertSame('name', $prop->getProperty()->getName()); |
| 47 | 49 | $this->assertSame('123', $prop->getAnnotation()->id); |
@@ -55,7 +57,8 @@ discard block |
||
| 55 | 57 | |
| 56 | 58 | $this->assertCount(1, $methods); |
| 57 | 59 | |
| 58 | - foreach ($methods as $m) { |
|
| 60 | + foreach ($methods as $m) |
|
| 61 | + { |
|
| 59 | 62 | $this->assertSame(TestClass::class, $m->getClass()->getName()); |
| 60 | 63 | $this->assertSame('testMethod', $m->getMethod()->getName()); |
| 61 | 64 | $this->assertSame('/', $m->getAnnotation()->path); |