@@ -33,7 +33,8 @@ |
||
| 33 | 33 | public function findDeclarations(): array |
| 34 | 34 | { |
| 35 | 35 | $result = []; |
| 36 | - foreach ($this->locator->findMethods(RouteAnnotation::class) as $match) { |
|
| 36 | + foreach ($this->locator->findMethods(RouteAnnotation::class) as $match) |
|
| 37 | + { |
|
| 37 | 38 | /** @var RouteAnnotation $route */ |
| 38 | 39 | $route = $match->getAnnotation(); |
| 39 | 40 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function findDeclarations(): array |
| 34 | 34 | { |
| 35 | 35 | $result = []; |
| 36 | - foreach ($this->locator->findMethods(RouteAnnotation::class) as $match) { |
|
| 36 | + foreach ($this->locator->findMethods(RouteAnnotation::class) as $match){ |
|
| 37 | 37 | /** @var RouteAnnotation $route */ |
| 38 | 38 | $route = $match->getAnnotation(); |
| 39 | 39 | |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | 'controller' => $match->getClass()->getName(), |
| 43 | 43 | 'action' => $match->getMethod()->getName(), |
| 44 | 44 | 'group' => $route->group, |
| 45 | - 'verbs' => (array) $route->methods, |
|
| 45 | + 'verbs' => (array)$route->methods, |
|
| 46 | 46 | 'defaults' => $route->defaults, |
| 47 | - 'middleware' => (array) $route->middleware, |
|
| 47 | + 'middleware' => (array)$route->middleware, |
|
| 48 | 48 | ]; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | public function getGroup(string $name): RouteGroup |
| 41 | 41 | { |
| 42 | - if (!isset($this->groups[$name])) { |
|
| 42 | + if (!isset($this->groups[$name])){ |
|
| 43 | 43 | $this->groups[$name] = $this->factory->make(RouteGroup::class); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -39,7 +39,8 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | public function getGroup(string $name): RouteGroup |
| 41 | 41 | { |
| 42 | - if (!isset($this->groups[$name])) { |
|
| 42 | + if (!isset($this->groups[$name])) |
|
| 43 | + { |
|
| 43 | 44 | $this->groups[$name] = $this->factory->make(RouteGroup::class); |
| 44 | 45 | } |
| 45 | 46 | |
@@ -25,8 +25,8 @@ |
||
| 25 | 25 | protected function makeApp(array $env): App |
| 26 | 26 | { |
| 27 | 27 | $config = [ |
| 28 | - 'root' => __DIR__ . '/App', |
|
| 29 | - 'app' => __DIR__ . '/App', |
|
| 28 | + 'root' => __DIR__.'/App', |
|
| 29 | + 'app' => __DIR__.'/App', |
|
| 30 | 30 | ]; |
| 31 | 31 | |
| 32 | 32 | return App::init($config, new Environment($env), false); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | array $headers = [] |
| 52 | 52 | ): ResponseInterface { |
| 53 | 53 | $r = $this->request($uri, 'GET', [], $headers, []); |
| 54 | - foreach ($attributes as $k => $v) { |
|
| 54 | + foreach ($attributes as $k => $v){ |
|
| 55 | 55 | $r = $r->withAttribute($k, $v); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function fetchCookies(array $header) |
| 96 | 96 | { |
| 97 | 97 | $result = []; |
| 98 | - foreach ($header as $line) { |
|
| 98 | + foreach ($header as $line){ |
|
| 99 | 99 | $cookie = explode('=', $line); |
| 100 | 100 | $result[$cookie[0]] = rawurldecode(substr($cookie[1], 0, strpos($cookie[1], ';'))); |
| 101 | 101 | } |
@@ -51,7 +51,8 @@ discard block |
||
| 51 | 51 | array $headers = [] |
| 52 | 52 | ): ResponseInterface { |
| 53 | 53 | $r = $this->request($uri, 'GET', [], $headers, []); |
| 54 | - foreach ($attributes as $k => $v) { |
|
| 54 | + foreach ($attributes as $k => $v) |
|
| 55 | + { |
|
| 55 | 56 | $r = $r->withAttribute($k, $v); |
| 56 | 57 | } |
| 57 | 58 | |
@@ -95,7 +96,8 @@ discard block |
||
| 95 | 96 | public function fetchCookies(array $header) |
| 96 | 97 | { |
| 97 | 98 | $result = []; |
| 98 | - foreach ($header as $line) { |
|
| 99 | + foreach ($header as $line) |
|
| 100 | + { |
|
| 99 | 101 | $cookie = explode('=', $line); |
| 100 | 102 | $result[$cookie[0]] = rawurldecode(substr($cookie[1], 0, strpos($cookie[1], ';'))); |
| 101 | 103 | } |
@@ -28,11 +28,11 @@ |
||
| 28 | 28 | |
| 29 | 29 | public function testCache(): void |
| 30 | 30 | { |
| 31 | - $this->assertFileExists(__DIR__ . '/App/runtime/cache/routes.php'); |
|
| 32 | - $this->assertCount(2, include __DIR__ . '/App/runtime/cache/routes.php'); |
|
| 31 | + $this->assertFileExists(__DIR__.'/App/runtime/cache/routes.php'); |
|
| 32 | + $this->assertCount(2, include __DIR__.'/App/runtime/cache/routes.php'); |
|
| 33 | 33 | |
| 34 | 34 | $this->app->getConsole()->run('route:reset'); |
| 35 | 35 | |
| 36 | - $this->assertSame(null, include __DIR__ . '/App/runtime/cache/routes.php'); |
|
| 36 | + $this->assertSame(null, include __DIR__.'/App/runtime/cache/routes.php'); |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php return array ( |
| 2 | - 'index' => |
|
| 3 | - array ( |
|
| 2 | + 'index' => |
|
| 3 | + array ( |
|
| 4 | 4 | 'pattern' => '/', |
| 5 | 5 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
| 6 | 6 | 'action' => 'index', |
| 7 | 7 | 'group' => 'default', |
| 8 | 8 | 'verbs' => |
| 9 | 9 | array ( |
| 10 | - 0 => 'GET', |
|
| 10 | + 0 => 'GET', |
|
| 11 | 11 | ), |
| 12 | 12 | 'defaults' => |
| 13 | 13 | array ( |
@@ -15,16 +15,16 @@ discard block |
||
| 15 | 15 | 'middleware' => |
| 16 | 16 | array ( |
| 17 | 17 | ), |
| 18 | - ), |
|
| 19 | - 'method' => |
|
| 20 | - array ( |
|
| 18 | + ), |
|
| 19 | + 'method' => |
|
| 20 | + array ( |
|
| 21 | 21 | 'pattern' => '/', |
| 22 | 22 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
| 23 | 23 | 'action' => 'method', |
| 24 | 24 | 'group' => 'default', |
| 25 | 25 | 'verbs' => |
| 26 | 26 | array ( |
| 27 | - 0 => 'POST', |
|
| 27 | + 0 => 'POST', |
|
| 28 | 28 | ), |
| 29 | 29 | 'defaults' => |
| 30 | 30 | array ( |
@@ -32,5 +32,5 @@ discard block |
||
| 32 | 32 | 'middleware' => |
| 33 | 33 | array ( |
| 34 | 34 | ), |
| 35 | - ), |
|
| 35 | + ), |
|
| 36 | 36 | ); |
| 37 | 37 | \ No newline at end of file |
@@ -1,36 +1,36 @@ |
||
| 1 | -<?php return array ( |
|
| 1 | +<?php return array( |
|
| 2 | 2 | 'index' => |
| 3 | - array ( |
|
| 3 | + array( |
|
| 4 | 4 | 'pattern' => '/', |
| 5 | 5 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
| 6 | 6 | 'action' => 'index', |
| 7 | 7 | 'group' => 'default', |
| 8 | 8 | 'verbs' => |
| 9 | - array ( |
|
| 9 | + array( |
|
| 10 | 10 | 0 => 'GET', |
| 11 | 11 | ), |
| 12 | 12 | 'defaults' => |
| 13 | - array ( |
|
| 13 | + array( |
|
| 14 | 14 | ), |
| 15 | 15 | 'middleware' => |
| 16 | - array ( |
|
| 16 | + array( |
|
| 17 | 17 | ), |
| 18 | 18 | ), |
| 19 | 19 | 'method' => |
| 20 | - array ( |
|
| 20 | + array( |
|
| 21 | 21 | 'pattern' => '/', |
| 22 | 22 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
| 23 | 23 | 'action' => 'method', |
| 24 | 24 | 'group' => 'default', |
| 25 | 25 | 'verbs' => |
| 26 | - array ( |
|
| 26 | + array( |
|
| 27 | 27 | 0 => 'POST', |
| 28 | 28 | ), |
| 29 | 29 | 'defaults' => |
| 30 | - array ( |
|
| 30 | + array( |
|
| 31 | 31 | ), |
| 32 | 32 | 'middleware' => |
| 33 | - array ( |
|
| 33 | + array( |
|
| 34 | 34 | ), |
| 35 | 35 | ), |
| 36 | 36 | ); |
| 37 | 37 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | ['name', InputArgument::REQUIRED, 'Entity name'], |
| 34 | 34 | ['format', InputArgument::OPTIONAL, 'Declaration format (annotated, xml?, yaml?, php?)', 'annotated'], |
| 35 | 35 | ]; |
| 36 | - protected const OPTIONS = [ |
|
| 36 | + protected const OPTIONS = [ |
|
| 37 | 37 | [ |
| 38 | 38 | 'role', |
| 39 | 39 | 'r', |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $declaration = $this->createDeclaration(); |
| 109 | 109 | |
| 110 | 110 | $repository = trimPostfix((string)$this->argument('name'), 'repository'); |
| 111 | - if ($this->option('repository')) { |
|
| 111 | + if ($this->option('repository')){ |
|
| 112 | 112 | $repositoryClass = $config->className(RepositoryCommand::ELEMENT, $repository); |
| 113 | 113 | $repositoryNamespace = $config->classNamespace(RepositoryCommand::ELEMENT, $repository); |
| 114 | 114 | $declaration->setRepository("\\$repositoryNamespace\\$repositoryClass"); |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | $declaration->setDatabase((string)$this->option('database')); |
| 121 | 121 | $declaration->setInflection((string)$this->option('inflection')); |
| 122 | 122 | |
| 123 | - foreach ($this->option('field') as $field) { |
|
| 124 | - if (strpos($field, ':') === false) { |
|
| 123 | + foreach ($this->option('field') as $field){ |
|
| 124 | + if (strpos($field, ':') === false){ |
|
| 125 | 125 | throw new ScaffolderException("Field definition must in 'name:type' or 'name:type' form"); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $this->writeDeclaration($declaration); |
| 137 | 137 | |
| 138 | - if ($this->option('repository')) { |
|
| 138 | + if ($this->option('repository')){ |
|
| 139 | 139 | $console->run('create:repository', [ |
| 140 | 140 | 'name' => $repository ?? $this->argument('name'), |
| 141 | 141 | ]); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | AbstractDeclaration::ACCESS_PROTECTED, |
| 163 | 163 | AbstractDeclaration::ACCESS_PRIVATE, |
| 164 | 164 | ], true) |
| 165 | - ) { |
|
| 165 | + ){ |
|
| 166 | 166 | throw new ScaffolderException("Invalid accessibility value `$accessibility`"); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -108,7 +108,8 @@ discard block |
||
| 108 | 108 | $declaration = $this->createDeclaration(); |
| 109 | 109 | |
| 110 | 110 | $repository = trimPostfix((string)$this->argument('name'), 'repository'); |
| 111 | - if ($this->option('repository')) { |
|
| 111 | + if ($this->option('repository')) |
|
| 112 | + { |
|
| 112 | 113 | $repositoryClass = $config->className(RepositoryCommand::ELEMENT, $repository); |
| 113 | 114 | $repositoryNamespace = $config->classNamespace(RepositoryCommand::ELEMENT, $repository); |
| 114 | 115 | $declaration->setRepository("\\$repositoryNamespace\\$repositoryClass"); |
@@ -120,8 +121,10 @@ discard block |
||
| 120 | 121 | $declaration->setDatabase((string)$this->option('database')); |
| 121 | 122 | $declaration->setInflection((string)$this->option('inflection')); |
| 122 | 123 | |
| 123 | - foreach ($this->option('field') as $field) { |
|
| 124 | - if (strpos($field, ':') === false) { |
|
| 124 | + foreach ($this->option('field') as $field) |
|
| 125 | + { |
|
| 126 | + if (strpos($field, ':') === false) |
|
| 127 | + { |
|
| 125 | 128 | throw new ScaffolderException("Field definition must in 'name:type' or 'name:type' form"); |
| 126 | 129 | } |
| 127 | 130 | |
@@ -135,7 +138,8 @@ discard block |
||
| 135 | 138 | |
| 136 | 139 | $this->writeDeclaration($declaration); |
| 137 | 140 | |
| 138 | - if ($this->option('repository')) { |
|
| 141 | + if ($this->option('repository')) |
|
| 142 | + { |
|
| 139 | 143 | $console->run('create:repository', [ |
| 140 | 144 | 'name' => $repository ?? $this->argument('name'), |
| 141 | 145 | ]); |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
| 25 | 25 | { |
| 26 | - if (is_array($source)) { |
|
| 26 | + if (is_array($source)){ |
|
| 27 | 27 | $source[] = self::OUTPUT; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -23,7 +23,8 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
| 25 | 25 | { |
| 26 | - if (is_array($source)) { |
|
| 26 | + if (is_array($source)) |
|
| 27 | + { |
|
| 27 | 28 | $source[] = self::OUTPUT; |
| 28 | 29 | } |
| 29 | 30 | |
@@ -52,19 +52,19 @@ |
||
| 52 | 52 | */ |
| 53 | 53 | public function leaveNode($node, VisitorContext $ctx) |
| 54 | 54 | { |
| 55 | - if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)) { |
|
| 55 | + if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)){ |
|
| 56 | 56 | return null; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $inject = $this->blocks->claim($node->name); |
| 60 | 60 | |
| 61 | - if ($inject instanceof QuotedValue) { |
|
| 61 | + if ($inject instanceof QuotedValue){ |
|
| 62 | 62 | // exclude quotes |
| 63 | 63 | $inject = $inject->trimvalue(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // mount block:parent content |
| 67 | - if ($node->name !== 'parent') { |
|
| 67 | + if ($node->name !== 'parent'){ |
|
| 68 | 68 | $traverser = new Traverser(); |
| 69 | 69 | $traverser->addVisitor(new InjectBlocks(new BlockClaims([ |
| 70 | 70 | 'parent' => $node->nodes, |
@@ -52,19 +52,22 @@ |
||
| 52 | 52 | */ |
| 53 | 53 | public function leaveNode($node, VisitorContext $ctx) |
| 54 | 54 | { |
| 55 | - if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)) { |
|
| 55 | + if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)) |
|
| 56 | + { |
|
| 56 | 57 | return null; |
| 57 | 58 | } |
| 58 | 59 | |
| 59 | 60 | $inject = $this->blocks->claim($node->name); |
| 60 | 61 | |
| 61 | - if ($inject instanceof QuotedValue) { |
|
| 62 | + if ($inject instanceof QuotedValue) |
|
| 63 | + { |
|
| 62 | 64 | // exclude quotes |
| 63 | 65 | $inject = $inject->trimvalue(); |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | 68 | // mount block:parent content |
| 67 | - if ($node->name !== 'parent') { |
|
| 69 | + if ($node->name !== 'parent') |
|
| 70 | + { |
|
| 68 | 71 | $traverser = new Traverser(); |
| 69 | 72 | $traverser->addVisitor(new InjectBlocks(new BlockClaims([ |
| 70 | 73 | 'parent' => $node->nodes, |