@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ); |
44 | 44 | |
45 | 45 | $psr->shouldReceive('respond')->once()->with( |
46 | - \Mockery::on(function ($r) { |
|
46 | + \Mockery::on(function ($r){ |
|
47 | 47 | $this->assertSame('Hello, dave.', (string)$r->getBody()); |
48 | 48 | return true; |
49 | 49 | }) |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ); |
66 | 66 | |
67 | 67 | $psr->shouldReceive('respond')->once()->with( |
68 | - \Mockery::on(function ($r) { |
|
68 | + \Mockery::on(function ($r){ |
|
69 | 69 | $this->assertStringContainsString('500', (string)$r->getBody()); |
70 | 70 | return true; |
71 | 71 | }) |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $psr->shouldReceive('acceptRequest')->once()->andReturn(null); |
75 | 75 | |
76 | 76 | $files = $this->app->get(FilesInterface::class)->getFiles( |
77 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
77 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | $this->assertCount(0, $files); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $this->app->get(RrDispatcher::class)->serve($psr); |
83 | 83 | |
84 | 84 | $files = $this->app->get(FilesInterface::class)->getFiles( |
85 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
85 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | $this->assertCount(1, $files); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ); |
104 | 104 | |
105 | 105 | $psr->shouldReceive('respond')->once()->with( |
106 | - \Mockery::on(function ($r) { |
|
106 | + \Mockery::on(function ($r){ |
|
107 | 107 | $this->assertStringContainsString('undefined', (string)$r->getBody()); |
108 | 108 | return true; |
109 | 109 | }) |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $psr->shouldReceive('acceptRequest')->once()->andReturn(null); |
113 | 113 | |
114 | 114 | $files = $this->app->get(FilesInterface::class)->getFiles( |
115 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
115 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
116 | 116 | ); |
117 | 117 | |
118 | 118 | $this->assertCount(0, $files); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->app->get(RrDispatcher::class)->serve($psr); |
121 | 121 | |
122 | 122 | $files = $this->app->get(FilesInterface::class)->getFiles( |
123 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
123 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
124 | 124 | ); |
125 | 125 | |
126 | 126 | $this->assertCount(1, $files); |
@@ -43,7 +43,8 @@ discard block |
||
43 | 43 | ); |
44 | 44 | |
45 | 45 | $psr->shouldReceive('respond')->once()->with( |
46 | - \Mockery::on(function ($r) { |
|
46 | + \Mockery::on(function ($r) |
|
47 | + { |
|
47 | 48 | $this->assertSame('Hello, dave.', (string)$r->getBody()); |
48 | 49 | return true; |
49 | 50 | }) |
@@ -65,7 +66,8 @@ discard block |
||
65 | 66 | ); |
66 | 67 | |
67 | 68 | $psr->shouldReceive('respond')->once()->with( |
68 | - \Mockery::on(function ($r) { |
|
69 | + \Mockery::on(function ($r) |
|
70 | + { |
|
69 | 71 | $this->assertStringContainsString('500', (string)$r->getBody()); |
70 | 72 | return true; |
71 | 73 | }) |
@@ -103,7 +105,8 @@ discard block |
||
103 | 105 | ); |
104 | 106 | |
105 | 107 | $psr->shouldReceive('respond')->once()->with( |
106 | - \Mockery::on(function ($r) { |
|
108 | + \Mockery::on(function ($r) |
|
109 | + { |
|
107 | 110 | $this->assertStringContainsString('undefined', (string)$r->getBody()); |
108 | 111 | return true; |
109 | 112 | }) |
@@ -19,7 +19,7 @@ |
||
19 | 19 | { |
20 | 20 | $output = $this->runCommand('php:extensions'); |
21 | 21 | |
22 | - foreach (get_loaded_extensions() as $extension) { |
|
22 | + foreach (get_loaded_extensions() as $extension){ |
|
23 | 23 | $this->assertStringContainsString($extension, $output); |
24 | 24 | } |
25 | 25 | } |
@@ -19,7 +19,8 @@ |
||
19 | 19 | { |
20 | 20 | $output = $this->runCommand('php:extensions'); |
21 | 21 | |
22 | - foreach (get_loaded_extensions() as $extension) { |
|
22 | + foreach (get_loaded_extensions() as $extension) |
|
23 | + { |
|
23 | 24 | $this->assertStringContainsString($extension, $output); |
24 | 25 | } |
25 | 26 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | $dirs = $this->app->get(DirectoriesInterface::class); |
40 | 40 | $fs = $this->app->get(FilesInterface::class); |
41 | - $fs->write($dirs->get('cache') . '/views/test.php', 'test', null, true); |
|
41 | + $fs->write($dirs->get('cache').'/views/test.php', 'test', null, true); |
|
42 | 42 | |
43 | 43 | $out = $this->runCommandDebug('views:reset'); |
44 | 44 | $this->assertStringContainsString('test.php', $out); |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
51 | 51 | { |
52 | - foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) { |
|
53 | - if (isset($parameters[$parameter])) { |
|
52 | + foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){ |
|
53 | + if (isset($parameters[$parameter])){ |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** @var FilterInterface $filter */ |
58 | 58 | $filter = $this->container->get($filterClass); |
59 | 59 | |
60 | - if (isset($parameters['@context'])) { |
|
60 | + if (isset($parameters['@context'])){ |
|
61 | 61 | // other interceptors can define the validation contex |
62 | 62 | $filter->setContext($parameters['@context']); |
63 | 63 | } |
64 | 64 | |
65 | - if (!$filter->isValid()) { |
|
65 | + if (!$filter->isValid()){ |
|
66 | 66 | return $this->renderInvalid($filter); |
67 | 67 | } |
68 | 68 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function renderInvalid(FilterInterface $filter) |
82 | 82 | { |
83 | - switch ($this->strategy) { |
|
83 | + switch ($this->strategy){ |
|
84 | 84 | case self::STRATEGY_JSON_RESPONSE: |
85 | 85 | return [ |
86 | 86 | 'status' => 400, |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | private function getDeclaredFilters(string $controller, string $action): array |
100 | 100 | { |
101 | 101 | $key = sprintf('%s:%s', $controller, $action); |
102 | - if (array_key_exists($key, $this->cache)) { |
|
102 | + if (array_key_exists($key, $this->cache)){ |
|
103 | 103 | return $this->cache[$key]; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->cache[$key] = []; |
107 | - try { |
|
107 | + try{ |
|
108 | 108 | $method = new \ReflectionMethod($controller, $action); |
109 | - } catch (\ReflectionException $e) { |
|
109 | + }catch (\ReflectionException $e){ |
|
110 | 110 | return []; |
111 | 111 | } |
112 | 112 | |
113 | - foreach ($method->getParameters() as $parameter) { |
|
114 | - if ($parameter->getClass() === null) { |
|
113 | + foreach ($method->getParameters() as $parameter){ |
|
114 | + if ($parameter->getClass() === null){ |
|
115 | 115 | continue; |
116 | 116 | } |
117 | 117 | |
118 | - if ($parameter->getClass()->implementsInterface(FilterInterface::class)) { |
|
118 | + if ($parameter->getClass()->implementsInterface(FilterInterface::class)){ |
|
119 | 119 | $this->cache[$key][$parameter->getName()] = $parameter->getClass()->getName(); |
120 | 120 | } |
121 | 121 | } |
@@ -49,20 +49,24 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
51 | 51 | { |
52 | - foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) { |
|
53 | - if (isset($parameters[$parameter])) { |
|
52 | + foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) |
|
53 | + { |
|
54 | + if (isset($parameters[$parameter])) |
|
55 | + { |
|
54 | 56 | continue; |
55 | 57 | } |
56 | 58 | |
57 | 59 | /** @var FilterInterface $filter */ |
58 | 60 | $filter = $this->container->get($filterClass); |
59 | 61 | |
60 | - if (isset($parameters['@context'])) { |
|
62 | + if (isset($parameters['@context'])) |
|
63 | + { |
|
61 | 64 | // other interceptors can define the validation contex |
62 | 65 | $filter->setContext($parameters['@context']); |
63 | 66 | } |
64 | 67 | |
65 | - if (!$filter->isValid()) { |
|
68 | + if (!$filter->isValid()) |
|
69 | + { |
|
66 | 70 | return $this->renderInvalid($filter); |
67 | 71 | } |
68 | 72 | |
@@ -80,7 +84,8 @@ discard block |
||
80 | 84 | */ |
81 | 85 | protected function renderInvalid(FilterInterface $filter) |
82 | 86 | { |
83 | - switch ($this->strategy) { |
|
87 | + switch ($this->strategy) |
|
88 | + { |
|
84 | 89 | case self::STRATEGY_JSON_RESPONSE: |
85 | 90 | return [ |
86 | 91 | 'status' => 400, |
@@ -99,23 +104,30 @@ discard block |
||
99 | 104 | private function getDeclaredFilters(string $controller, string $action): array |
100 | 105 | { |
101 | 106 | $key = sprintf('%s:%s', $controller, $action); |
102 | - if (array_key_exists($key, $this->cache)) { |
|
107 | + if (array_key_exists($key, $this->cache)) |
|
108 | + { |
|
103 | 109 | return $this->cache[$key]; |
104 | 110 | } |
105 | 111 | |
106 | 112 | $this->cache[$key] = []; |
107 | - try { |
|
113 | + try |
|
114 | + { |
|
108 | 115 | $method = new \ReflectionMethod($controller, $action); |
109 | - } catch (\ReflectionException $e) { |
|
116 | + } |
|
117 | + catch (\ReflectionException $e) |
|
118 | + { |
|
110 | 119 | return []; |
111 | 120 | } |
112 | 121 | |
113 | - foreach ($method->getParameters() as $parameter) { |
|
114 | - if ($parameter->getClass() === null) { |
|
122 | + foreach ($method->getParameters() as $parameter) |
|
123 | + { |
|
124 | + if ($parameter->getClass() === null) |
|
125 | + { |
|
115 | 126 | continue; |
116 | 127 | } |
117 | 128 | |
118 | - if ($parameter->getClass()->implementsInterface(FilterInterface::class)) { |
|
129 | + if ($parameter->getClass()->implementsInterface(FilterInterface::class)) |
|
130 | + { |
|
119 | 131 | $this->cache[$key][$parameter->getName()] = $parameter->getClass()->getName(); |
120 | 132 | } |
121 | 133 | } |
@@ -42,12 +42,12 @@ |
||
42 | 42 | */ |
43 | 43 | public function push(string $jobType, array $payload = [], Options $options = null): string |
44 | 44 | { |
45 | - if ($options === null) { |
|
45 | + if ($options === null){ |
|
46 | 46 | $options = new Options(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | $pipeline = $this->registry->getPipeline($jobType); |
50 | - if ($pipeline !== null && $options->getPipeline() === null) { |
|
50 | + if ($pipeline !== null && $options->getPipeline() === null){ |
|
51 | 51 | $options = $options->withPipeline($pipeline); |
52 | 52 | } |
53 | 53 |
@@ -42,12 +42,14 @@ |
||
42 | 42 | */ |
43 | 43 | public function push(string $jobType, array $payload = [], Options $options = null): string |
44 | 44 | { |
45 | - if ($options === null) { |
|
45 | + if ($options === null) |
|
46 | + { |
|
46 | 47 | $options = new Options(); |
47 | 48 | } |
48 | 49 | |
49 | 50 | $pipeline = $this->registry->getPipeline($jobType); |
50 | - if ($pipeline !== null && $options->getPipeline() === null) { |
|
51 | + if ($pipeline !== null && $options->getPipeline() === null) |
|
52 | + { |
|
51 | 53 | $options = $options->withPipeline($pipeline); |
52 | 54 | } |
53 | 55 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | ContainerInterface $container, |
46 | 46 | HandlerRegistryInterface $handlers, |
47 | 47 | SerializerRegistryInterface $serializers |
48 | - ) { |
|
48 | + ){ |
|
49 | 49 | $this->container = $container; |
50 | 50 | $this->fallbackHandlers = $handlers; |
51 | 51 | $this->fallbackSerializers = $serializers; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getHandler(string $jobType): HandlerInterface |
68 | 68 | { |
69 | - if (isset($this->handlers[$jobType])) { |
|
70 | - if ($this->handlers[$jobType] instanceof HandlerInterface) { |
|
69 | + if (isset($this->handlers[$jobType])){ |
|
70 | + if ($this->handlers[$jobType] instanceof HandlerInterface){ |
|
71 | 71 | return $this->handlers[$jobType]; |
72 | 72 | } |
73 | 73 | |
@@ -92,20 +92,20 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getSerializer(string $jobType): SerializerInterface |
94 | 94 | { |
95 | - if (isset($this->serializers[$jobType])) { |
|
96 | - if ($this->serializers[$jobType] instanceof SerializerInterface) { |
|
95 | + if (isset($this->serializers[$jobType])){ |
|
96 | + if ($this->serializers[$jobType] instanceof SerializerInterface){ |
|
97 | 97 | return $this->serializers[$jobType]; |
98 | 98 | } |
99 | 99 | |
100 | 100 | return $this->container->get($this->serializers[$jobType]); |
101 | 101 | } |
102 | 102 | |
103 | - if (!isset($this->handlers[$jobType])) { |
|
103 | + if (!isset($this->handlers[$jobType])){ |
|
104 | 104 | return $this->fallbackSerializers->getSerializer($jobType); |
105 | 105 | } |
106 | 106 | |
107 | 107 | $handler = $this->getHandler($jobType); |
108 | - if ($handler instanceof SerializerInterface) { |
|
108 | + if ($handler instanceof SerializerInterface){ |
|
109 | 109 | return $handler; |
110 | 110 | } |
111 | 111 |
@@ -66,8 +66,10 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getHandler(string $jobType): HandlerInterface |
68 | 68 | { |
69 | - if (isset($this->handlers[$jobType])) { |
|
70 | - if ($this->handlers[$jobType] instanceof HandlerInterface) { |
|
69 | + if (isset($this->handlers[$jobType])) |
|
70 | + { |
|
71 | + if ($this->handlers[$jobType] instanceof HandlerInterface) |
|
72 | + { |
|
71 | 73 | return $this->handlers[$jobType]; |
72 | 74 | } |
73 | 75 | |
@@ -92,20 +94,24 @@ discard block |
||
92 | 94 | */ |
93 | 95 | public function getSerializer(string $jobType): SerializerInterface |
94 | 96 | { |
95 | - if (isset($this->serializers[$jobType])) { |
|
96 | - if ($this->serializers[$jobType] instanceof SerializerInterface) { |
|
97 | + if (isset($this->serializers[$jobType])) |
|
98 | + { |
|
99 | + if ($this->serializers[$jobType] instanceof SerializerInterface) |
|
100 | + { |
|
97 | 101 | return $this->serializers[$jobType]; |
98 | 102 | } |
99 | 103 | |
100 | 104 | return $this->container->get($this->serializers[$jobType]); |
101 | 105 | } |
102 | 106 | |
103 | - if (!isset($this->handlers[$jobType])) { |
|
107 | + if (!isset($this->handlers[$jobType])) |
|
108 | + { |
|
104 | 109 | return $this->fallbackSerializers->getSerializer($jobType); |
105 | 110 | } |
106 | 111 | |
107 | 112 | $handler = $this->getHandler($jobType); |
108 | - if ($handler instanceof SerializerInterface) { |
|
113 | + if ($handler instanceof SerializerInterface) |
|
114 | + { |
|
109 | 115 | return $handler; |
110 | 116 | } |
111 | 117 |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | $entities = $this->getDeclaredEntities($controller, $action); |
47 | 47 | |
48 | 48 | $contextCandidates = []; |
49 | - foreach ($entities as $parameter => $role) { |
|
49 | + foreach ($entities as $parameter => $role){ |
|
50 | 50 | $value = $this->getParameter($parameter, $parameters, count($entities) === 1); |
51 | - if ($value === null) { |
|
51 | + if ($value === null){ |
|
52 | 52 | throw new ControllerException( |
53 | 53 | "Entity `{$parameter}` can not be found", |
54 | 54 | ControllerException::NOT_FOUND |
55 | 55 | ); |
56 | 56 | } |
57 | 57 | |
58 | - if (is_object($value)) { |
|
59 | - if ($this->orm->getHeap()->has($value)) { |
|
58 | + if (is_object($value)){ |
|
59 | + if ($this->orm->getHeap()->has($value)){ |
|
60 | 60 | $contextCandidates[] = $value; |
61 | 61 | } |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | $entity = $this->resolveEntity($role, $value); |
68 | - if ($entity === null) { |
|
68 | + if ($entity === null){ |
|
69 | 69 | throw new ControllerException( |
70 | 70 | "Entity `{$parameter}` can not be found", |
71 | 71 | ControllerException::NOT_FOUND |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $contextCandidates[] = $entity; |
77 | 77 | } |
78 | 78 | |
79 | - if (!isset($parameters['@context']) && count($contextCandidates) === 1) { |
|
79 | + if (!isset($parameters['@context']) && count($contextCandidates) === 1){ |
|
80 | 80 | $parameters['@context'] = current($contextCandidates); |
81 | 81 | } |
82 | 82 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected function getParameter(string $role, array $parameters, bool $useDefault = false) |
93 | 93 | { |
94 | - if (!$useDefault) { |
|
94 | + if (!$useDefault){ |
|
95 | 95 | return $parameters[$role] ?? null; |
96 | 96 | } |
97 | 97 | |
@@ -116,23 +116,23 @@ discard block |
||
116 | 116 | private function getDeclaredEntities(string $controller, string $action): array |
117 | 117 | { |
118 | 118 | $key = sprintf('%s:%s', $controller, $action); |
119 | - if (array_key_exists($key, $this->cache)) { |
|
119 | + if (array_key_exists($key, $this->cache)){ |
|
120 | 120 | return $this->cache[$key]; |
121 | 121 | } |
122 | 122 | |
123 | 123 | $this->cache[$key] = []; |
124 | - try { |
|
124 | + try{ |
|
125 | 125 | $method = new \ReflectionMethod($controller, $action); |
126 | - } catch (\ReflectionException $e) { |
|
126 | + }catch (\ReflectionException $e){ |
|
127 | 127 | return []; |
128 | 128 | } |
129 | 129 | |
130 | - foreach ($method->getParameters() as $parameter) { |
|
131 | - if ($parameter->getClass() === null) { |
|
130 | + foreach ($method->getParameters() as $parameter){ |
|
131 | + if ($parameter->getClass() === null){ |
|
132 | 132 | continue; |
133 | 133 | } |
134 | 134 | |
135 | - if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) { |
|
135 | + if ($this->orm->getSchema()->defines($parameter->getClass()->getName())){ |
|
136 | 136 | $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($parameter->getClass()->getName()); |
137 | 137 | } |
138 | 138 | } |
@@ -46,17 +46,21 @@ discard block |
||
46 | 46 | $entities = $this->getDeclaredEntities($controller, $action); |
47 | 47 | |
48 | 48 | $contextCandidates = []; |
49 | - foreach ($entities as $parameter => $role) { |
|
49 | + foreach ($entities as $parameter => $role) |
|
50 | + { |
|
50 | 51 | $value = $this->getParameter($parameter, $parameters, count($entities) === 1); |
51 | - if ($value === null) { |
|
52 | + if ($value === null) |
|
53 | + { |
|
52 | 54 | throw new ControllerException( |
53 | 55 | "Entity `{$parameter}` can not be found", |
54 | 56 | ControllerException::NOT_FOUND |
55 | 57 | ); |
56 | 58 | } |
57 | 59 | |
58 | - if (is_object($value)) { |
|
59 | - if ($this->orm->getHeap()->has($value)) { |
|
60 | + if (is_object($value)) |
|
61 | + { |
|
62 | + if ($this->orm->getHeap()->has($value)) |
|
63 | + { |
|
60 | 64 | $contextCandidates[] = $value; |
61 | 65 | } |
62 | 66 | |
@@ -65,7 +69,8 @@ discard block |
||
65 | 69 | } |
66 | 70 | |
67 | 71 | $entity = $this->resolveEntity($role, $value); |
68 | - if ($entity === null) { |
|
72 | + if ($entity === null) |
|
73 | + { |
|
69 | 74 | throw new ControllerException( |
70 | 75 | "Entity `{$parameter}` can not be found", |
71 | 76 | ControllerException::NOT_FOUND |
@@ -76,7 +81,8 @@ discard block |
||
76 | 81 | $contextCandidates[] = $entity; |
77 | 82 | } |
78 | 83 | |
79 | - if (!isset($parameters['@context']) && count($contextCandidates) === 1) { |
|
84 | + if (!isset($parameters['@context']) && count($contextCandidates) === 1) |
|
85 | + { |
|
80 | 86 | $parameters['@context'] = current($contextCandidates); |
81 | 87 | } |
82 | 88 | |
@@ -91,7 +97,8 @@ discard block |
||
91 | 97 | */ |
92 | 98 | protected function getParameter(string $role, array $parameters, bool $useDefault = false) |
93 | 99 | { |
94 | - if (!$useDefault) { |
|
100 | + if (!$useDefault) |
|
101 | + { |
|
95 | 102 | return $parameters[$role] ?? null; |
96 | 103 | } |
97 | 104 | |
@@ -116,23 +123,30 @@ discard block |
||
116 | 123 | private function getDeclaredEntities(string $controller, string $action): array |
117 | 124 | { |
118 | 125 | $key = sprintf('%s:%s', $controller, $action); |
119 | - if (array_key_exists($key, $this->cache)) { |
|
126 | + if (array_key_exists($key, $this->cache)) |
|
127 | + { |
|
120 | 128 | return $this->cache[$key]; |
121 | 129 | } |
122 | 130 | |
123 | 131 | $this->cache[$key] = []; |
124 | - try { |
|
132 | + try |
|
133 | + { |
|
125 | 134 | $method = new \ReflectionMethod($controller, $action); |
126 | - } catch (\ReflectionException $e) { |
|
135 | + } |
|
136 | + catch (\ReflectionException $e) |
|
137 | + { |
|
127 | 138 | return []; |
128 | 139 | } |
129 | 140 | |
130 | - foreach ($method->getParameters() as $parameter) { |
|
131 | - if ($parameter->getClass() === null) { |
|
141 | + foreach ($method->getParameters() as $parameter) |
|
142 | + { |
|
143 | + if ($parameter->getClass() === null) |
|
144 | + { |
|
132 | 145 | continue; |
133 | 146 | } |
134 | 147 | |
135 | - if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) { |
|
148 | + if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) |
|
149 | + { |
|
136 | 150 | $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($parameter->getClass()->getName()); |
137 | 151 | } |
138 | 152 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | { |
43 | 43 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:']); |
44 | 44 | |
45 | - foreach ($router->getRoutes() as $name => $route) { |
|
46 | - if ($route instanceof Route) { |
|
45 | + foreach ($router->getRoutes() as $name => $route){ |
|
46 | + if ($route instanceof Route){ |
|
47 | 47 | $grid->addRow( |
48 | 48 | [ |
49 | 49 | $name, |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | */ |
65 | 65 | private function getVerbs(Route $route): string |
66 | 66 | { |
67 | - if ($route->getVerbs() === Route::VERBS) { |
|
67 | + if ($route->getVerbs() === Route::VERBS){ |
|
68 | 68 | return '*'; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $result = []; |
72 | 72 | |
73 | - foreach ($route->getVerbs() as $verb) { |
|
74 | - switch (strtolower($verb)) { |
|
73 | + foreach ($route->getVerbs() as $verb){ |
|
74 | + switch (strtolower($verb)){ |
|
75 | 75 | case 'get': |
76 | 76 | $verb = '<fg=green>GET</>'; |
77 | 77 | break; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | return preg_replace_callback( |
109 | 109 | '/<([^>]*)>/', |
110 | - static function ($m) { |
|
110 | + static function ($m){ |
|
111 | 111 | return sprintf('<fg=magenta>%s</>', $m[0]); |
112 | 112 | }, |
113 | 113 | $pattern |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | private function getTarget(Route $route, KernelInterface $kernel): string |
125 | 125 | { |
126 | 126 | $target = $this->getValue($route, 'target'); |
127 | - switch (true) { |
|
127 | + switch (true){ |
|
128 | 128 | case $target instanceof Closure: |
129 | 129 | $reflection = new ReflectionFunction($target); |
130 | 130 | return sprintf( |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | return sprintf( |
138 | 138 | '%s->%s', |
139 | 139 | $this->relativeClass($this->getValue($target, 'controller'), $kernel), |
140 | - join('|', (array) $this->getValue($target, 'action')) |
|
140 | + join('|', (array)$this->getValue($target, 'action')) |
|
141 | 141 | ); |
142 | 142 | |
143 | 143 | case $target instanceof Controller: |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | case $target instanceof Group: |
150 | 150 | $result = []; |
151 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
151 | + foreach ($this->getValue($target, 'controllers') as $alias => $class){ |
|
152 | 152 | $result[] = sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
153 | 153 | } |
154 | 154 | |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | */ |
175 | 175 | private function getValue(object $object, string $property) |
176 | 176 | { |
177 | - try { |
|
177 | + try{ |
|
178 | 178 | $r = new ReflectionObject($object); |
179 | 179 | $prop = $r->getProperty($property); |
180 | 180 | $prop->setAccessible(true); |
181 | - } catch (Throwable $e) { |
|
181 | + }catch (Throwable $e){ |
|
182 | 182 | return $e->getMessage(); |
183 | 183 | } |
184 | 184 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $r = new ReflectionObject($kernel); |
196 | 196 | $r->getNamespaceName(); |
197 | 197 | |
198 | - if (strpos($class, $r->getNamespaceName()) === 0) { |
|
198 | + if (strpos($class, $r->getNamespaceName()) === 0){ |
|
199 | 199 | return substr($class, strlen($r->getNamespaceName()) + 1); |
200 | 200 | } |
201 | 201 |
@@ -42,8 +42,10 @@ discard block |
||
42 | 42 | { |
43 | 43 | $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:']); |
44 | 44 | |
45 | - foreach ($router->getRoutes() as $name => $route) { |
|
46 | - if ($route instanceof Route) { |
|
45 | + foreach ($router->getRoutes() as $name => $route) |
|
46 | + { |
|
47 | + if ($route instanceof Route) |
|
48 | + { |
|
47 | 49 | $grid->addRow( |
48 | 50 | [ |
49 | 51 | $name, |
@@ -64,14 +66,17 @@ discard block |
||
64 | 66 | */ |
65 | 67 | private function getVerbs(Route $route): string |
66 | 68 | { |
67 | - if ($route->getVerbs() === Route::VERBS) { |
|
69 | + if ($route->getVerbs() === Route::VERBS) |
|
70 | + { |
|
68 | 71 | return '*'; |
69 | 72 | } |
70 | 73 | |
71 | 74 | $result = []; |
72 | 75 | |
73 | - foreach ($route->getVerbs() as $verb) { |
|
74 | - switch (strtolower($verb)) { |
|
76 | + foreach ($route->getVerbs() as $verb) |
|
77 | + { |
|
78 | + switch (strtolower($verb)) |
|
79 | + { |
|
75 | 80 | case 'get': |
76 | 81 | $verb = '<fg=green>GET</>'; |
77 | 82 | break; |
@@ -107,7 +112,8 @@ discard block |
||
107 | 112 | |
108 | 113 | return preg_replace_callback( |
109 | 114 | '/<([^>]*)>/', |
110 | - static function ($m) { |
|
115 | + static function ($m) |
|
116 | + { |
|
111 | 117 | return sprintf('<fg=magenta>%s</>', $m[0]); |
112 | 118 | }, |
113 | 119 | $pattern |
@@ -124,7 +130,8 @@ discard block |
||
124 | 130 | private function getTarget(Route $route, KernelInterface $kernel): string |
125 | 131 | { |
126 | 132 | $target = $this->getValue($route, 'target'); |
127 | - switch (true) { |
|
133 | + switch (true) |
|
134 | + { |
|
128 | 135 | case $target instanceof Closure: |
129 | 136 | $reflection = new ReflectionFunction($target); |
130 | 137 | return sprintf( |
@@ -148,7 +155,8 @@ discard block |
||
148 | 155 | |
149 | 156 | case $target instanceof Group: |
150 | 157 | $result = []; |
151 | - foreach ($this->getValue($target, 'controllers') as $alias => $class) { |
|
158 | + foreach ($this->getValue($target, 'controllers') as $alias => $class) |
|
159 | + { |
|
152 | 160 | $result[] = sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel)); |
153 | 161 | } |
154 | 162 | |
@@ -174,11 +182,14 @@ discard block |
||
174 | 182 | */ |
175 | 183 | private function getValue(object $object, string $property) |
176 | 184 | { |
177 | - try { |
|
185 | + try |
|
186 | + { |
|
178 | 187 | $r = new ReflectionObject($object); |
179 | 188 | $prop = $r->getProperty($property); |
180 | 189 | $prop->setAccessible(true); |
181 | - } catch (Throwable $e) { |
|
190 | + } |
|
191 | + catch (Throwable $e) |
|
192 | + { |
|
182 | 193 | return $e->getMessage(); |
183 | 194 | } |
184 | 195 | |
@@ -195,7 +206,8 @@ discard block |
||
195 | 206 | $r = new ReflectionObject($kernel); |
196 | 207 | $r->getNamespaceName(); |
197 | 208 | |
198 | - if (strpos($class, $r->getNamespaceName()) === 0) { |
|
209 | + if (strpos($class, $r->getNamespaceName()) === 0) |
|
210 | + { |
|
199 | 211 | return substr($class, strlen($r->getNamespaceName()) + 1); |
200 | 212 | } |
201 | 213 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | array $payload, |
52 | 52 | DateTimeInterface $createdAt, |
53 | 53 | DateTimeInterface $expiresAt = null |
54 | - ) { |
|
54 | + ){ |
|
55 | 55 | $this->id = $id; |
56 | 56 | |
57 | 57 | $this->secretValue = $secretValue; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function getPayload(): array |
110 | 110 | { |
111 | - if (is_resource($this->payload)) { |
|
111 | + if (is_resource($this->payload)){ |
|
112 | 112 | // postgres |
113 | 113 | return json_decode(stream_get_contents($this->payload), true); |
114 | 114 | } |
@@ -108,7 +108,8 @@ |
||
108 | 108 | */ |
109 | 109 | public function getPayload(): array |
110 | 110 | { |
111 | - if (is_resource($this->payload)) { |
|
111 | + if (is_resource($this->payload)) |
|
112 | + { |
|
112 | 113 | // postgres |
113 | 114 | return json_decode(stream_get_contents($this->payload), true); |
114 | 115 | } |