@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | EnvironmentInterface $env, |
49 | 49 | FinalizerInterface $finalizer, |
50 | 50 | ContainerInterface $container |
51 | - ) { |
|
51 | + ){ |
|
52 | 52 | $this->env = $env; |
53 | 53 | $this->finalizer = $finalizer; |
54 | 54 | $this->container = $container; |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | /** @var Console $console */ |
80 | 80 | $console = $this->container->get(Console::class); |
81 | 81 | |
82 | - try { |
|
82 | + try{ |
|
83 | 83 | return $console->start($input ?? new ArgvInput(), $output); |
84 | - } catch (Throwable $e) { |
|
84 | + }catch (Throwable $e){ |
|
85 | 85 | $this->handleException($e, $output); |
86 | 86 | |
87 | 87 | return 255; |
88 | - } finally { |
|
88 | + }finally{ |
|
89 | 89 | $listener->disable(); |
90 | 90 | $this->finalizer->finalize(false); |
91 | 91 | } |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function handleException(Throwable $e, OutputInterface $output): void |
99 | 99 | { |
100 | - try { |
|
100 | + try{ |
|
101 | 101 | $this->container->get(SnapshotterInterface::class)->register($e); |
102 | - } catch (Throwable | ContainerExceptionInterface $se) { |
|
102 | + }catch (Throwable | ContainerExceptionInterface $se){ |
|
103 | 103 | // no need to notify when unable to register an exception |
104 | 104 | } |
105 | 105 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | */ |
115 | 115 | private function mapVerbosity(OutputInterface $output): int |
116 | 116 | { |
117 | - if ($output->isDebug()) { |
|
117 | + if ($output->isDebug()){ |
|
118 | 118 | return ConsoleHandler::VERBOSITY_DEBUG; |
119 | 119 | } |
120 | 120 | |
121 | - if ($output->isVeryVerbose()) { |
|
121 | + if ($output->isVeryVerbose()){ |
|
122 | 122 | return ConsoleHandler::VERBOSITY_VERBOSE; |
123 | 123 | } |
124 | 124 |
@@ -79,13 +79,18 @@ discard block |
||
79 | 79 | /** @var Console $console */ |
80 | 80 | $console = $this->container->get(Console::class); |
81 | 81 | |
82 | - try { |
|
82 | + try |
|
83 | + { |
|
83 | 84 | return $console->start($input ?? new ArgvInput(), $output); |
84 | - } catch (Throwable $e) { |
|
85 | + } |
|
86 | + catch (Throwable $e) |
|
87 | + { |
|
85 | 88 | $this->handleException($e, $output); |
86 | 89 | |
87 | 90 | return 255; |
88 | - } finally { |
|
91 | + } |
|
92 | + finally |
|
93 | + { |
|
89 | 94 | $listener->disable(); |
90 | 95 | $this->finalizer->finalize(false); |
91 | 96 | } |
@@ -97,9 +102,12 @@ discard block |
||
97 | 102 | */ |
98 | 103 | protected function handleException(Throwable $e, OutputInterface $output): void |
99 | 104 | { |
100 | - try { |
|
105 | + try |
|
106 | + { |
|
101 | 107 | $this->container->get(SnapshotterInterface::class)->register($e); |
102 | - } catch (Throwable | ContainerExceptionInterface $se) { |
|
108 | + } |
|
109 | + catch (Throwable | ContainerExceptionInterface $se) |
|
110 | + { |
|
103 | 111 | // no need to notify when unable to register an exception |
104 | 112 | } |
105 | 113 | |
@@ -114,11 +122,13 @@ discard block |
||
114 | 122 | */ |
115 | 123 | private function mapVerbosity(OutputInterface $output): int |
116 | 124 | { |
117 | - if ($output->isDebug()) { |
|
125 | + if ($output->isDebug()) |
|
126 | + { |
|
118 | 127 | return ConsoleHandler::VERBOSITY_DEBUG; |
119 | 128 | } |
120 | 129 | |
121 | - if ($output->isVeryVerbose()) { |
|
130 | + if ($output->isVeryVerbose()) |
|
131 | + { |
|
122 | 132 | return ConsoleHandler::VERBOSITY_VERBOSE; |
123 | 133 | } |
124 | 134 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function populate(StateInterface $state): void |
41 | 41 | { |
42 | - if ($this->request === null) { |
|
42 | + if ($this->request === null){ |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | |
49 | 49 | $state->setVariable('headers', $this->request->getHeaders()); |
50 | 50 | |
51 | - if ($this->request->getQueryParams() !== []) { |
|
51 | + if ($this->request->getQueryParams() !== []){ |
|
52 | 52 | $state->setVariable('query', $this->request->getQueryParams()); |
53 | 53 | } |
54 | 54 | |
55 | - if ($this->request->getParsedBody() !== null) { |
|
55 | + if ($this->request->getParsedBody() !== null){ |
|
56 | 56 | $state->setVariable('data', $this->request->getParsedBody()); |
57 | 57 | } |
58 | 58 | } |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function populate(StateInterface $state): void |
41 | 41 | { |
42 | - if ($this->request === null) { |
|
42 | + if ($this->request === null) |
|
43 | + { |
|
43 | 44 | return; |
44 | 45 | } |
45 | 46 | |
@@ -48,11 +49,13 @@ discard block |
||
48 | 49 | |
49 | 50 | $state->setVariable('headers', $this->request->getHeaders()); |
50 | 51 | |
51 | - if ($this->request->getQueryParams() !== []) { |
|
52 | + if ($this->request->getQueryParams() !== []) |
|
53 | + { |
|
52 | 54 | $state->setVariable('query', $this->request->getQueryParams()); |
53 | 55 | } |
54 | 56 | |
55 | - if ($this->request->getParsedBody() !== null) { |
|
57 | + if ($this->request->getParsedBody() !== null) |
|
58 | + { |
|
56 | 59 | $state->setVariable('data', $this->request->getParsedBody()); |
57 | 60 | } |
58 | 61 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs): void |
38 | 38 | { |
39 | 39 | $protoFile = $this->argument('proto'); |
40 | - if (!file_exists($protoFile)) { |
|
40 | + if (!file_exists($protoFile)){ |
|
41 | 41 | $this->sprintf('<error>File `%s` not found.</error>', $protoFile); |
42 | 42 | return; |
43 | 43 | } |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | |
51 | 51 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
52 | 52 | |
53 | - try { |
|
53 | + try{ |
|
54 | 54 | $result = $compiler->compile($protoFile); |
55 | - } catch (\Throwable $e) { |
|
55 | + }catch (\Throwable $e){ |
|
56 | 56 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | - if ($result === []) { |
|
60 | + if ($result === []){ |
|
61 | 61 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - foreach ($result as $file) { |
|
65 | + foreach ($result as $file){ |
|
66 | 66 | $this->sprintf( |
67 | 67 | "<fg=green>•</fg=green> %s%s%s\n", |
68 | 68 | Color::LIGHT_WHITE, |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | protected function getPath(KernelInterface $kernel): string |
82 | 82 | { |
83 | 83 | $path = $this->argument('path'); |
84 | - if ($path !== 'auto') { |
|
84 | + if ($path !== 'auto'){ |
|
85 | 85 | return $path; |
86 | 86 | } |
87 | 87 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | protected function getNamespace(KernelInterface $kernel): string |
100 | 100 | { |
101 | 101 | $namespace = $this->argument('namespace'); |
102 | - if ($namespace !== 'auto') { |
|
102 | + if ($namespace !== 'auto'){ |
|
103 | 103 | return $namespace; |
104 | 104 | } |
105 | 105 |
@@ -37,7 +37,8 @@ discard block |
||
37 | 37 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs): void |
38 | 38 | { |
39 | 39 | $protoFile = $this->argument('proto'); |
40 | - if (!file_exists($protoFile)) { |
|
40 | + if (!file_exists($protoFile)) |
|
41 | + { |
|
41 | 42 | $this->sprintf('<error>File `%s` not found.</error>', $protoFile); |
42 | 43 | return; |
43 | 44 | } |
@@ -50,19 +51,24 @@ discard block |
||
50 | 51 | |
51 | 52 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
52 | 53 | |
53 | - try { |
|
54 | + try |
|
55 | + { |
|
54 | 56 | $result = $compiler->compile($protoFile); |
55 | - } catch (\Throwable $e) { |
|
57 | + } |
|
58 | + catch (\Throwable $e) |
|
59 | + { |
|
56 | 60 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
57 | 61 | return; |
58 | 62 | } |
59 | 63 | |
60 | - if ($result === []) { |
|
64 | + if ($result === []) |
|
65 | + { |
|
61 | 66 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
62 | 67 | return; |
63 | 68 | } |
64 | 69 | |
65 | - foreach ($result as $file) { |
|
70 | + foreach ($result as $file) |
|
71 | + { |
|
66 | 72 | $this->sprintf( |
67 | 73 | "<fg=green>•</fg=green> %s%s%s\n", |
68 | 74 | Color::LIGHT_WHITE, |
@@ -81,7 +87,8 @@ discard block |
||
81 | 87 | protected function getPath(KernelInterface $kernel): string |
82 | 88 | { |
83 | 89 | $path = $this->argument('path'); |
84 | - if ($path !== 'auto') { |
|
90 | + if ($path !== 'auto') |
|
91 | + { |
|
85 | 92 | return $path; |
86 | 93 | } |
87 | 94 | |
@@ -99,7 +106,8 @@ discard block |
||
99 | 106 | protected function getNamespace(KernelInterface $kernel): string |
100 | 107 | { |
101 | 108 | $namespace = $this->argument('namespace'); |
102 | - if ($namespace !== 'auto') { |
|
109 | + if ($namespace !== 'auto') |
|
110 | + { |
|
103 | 111 | return $namespace; |
104 | 112 | } |
105 | 113 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | FinalizerInterface $finalizer, |
50 | 50 | ContainerInterface $container, |
51 | 51 | FactoryInterface $factory |
52 | - ) { |
|
52 | + ){ |
|
53 | 53 | $this->env = $env; |
54 | 54 | $this->finalizer = $finalizer; |
55 | 55 | $this->container = $container; |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | |
76 | 76 | /** @var Http $http */ |
77 | 77 | $http = $this->container->get(Http::class); |
78 | - while ($request = $client->acceptRequest()) { |
|
79 | - try { |
|
78 | + while ($request = $client->acceptRequest()){ |
|
79 | + try{ |
|
80 | 80 | $client->respond($http->handle($request)); |
81 | - } catch (\Throwable $e) { |
|
81 | + }catch (\Throwable $e){ |
|
82 | 82 | $this->handleException($client, $e); |
83 | - } finally { |
|
83 | + }finally{ |
|
84 | 84 | $this->finalizer->finalize(false); |
85 | 85 | } |
86 | 86 | } |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | { |
95 | 95 | $handler = new HtmlHandler(); |
96 | 96 | |
97 | - try { |
|
97 | + try{ |
|
98 | 98 | /** @var SnapshotInterface $snapshot */ |
99 | 99 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
100 | 100 | error_log($snapshot->getMessage()); |
101 | 101 | |
102 | 102 | // on demand |
103 | 103 | $state = $this->container->get(StateInterface::class); |
104 | - if ($state !== null) { |
|
104 | + if ($state !== null){ |
|
105 | 105 | $handler = $handler->withState($state); |
106 | 106 | } |
107 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
107 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
108 | 108 | error_log((string)$e); |
109 | 109 | } |
110 | 110 |
@@ -75,12 +75,18 @@ discard block |
||
75 | 75 | |
76 | 76 | /** @var Http $http */ |
77 | 77 | $http = $this->container->get(Http::class); |
78 | - while ($request = $client->acceptRequest()) { |
|
79 | - try { |
|
78 | + while ($request = $client->acceptRequest()) |
|
79 | + { |
|
80 | + try |
|
81 | + { |
|
80 | 82 | $client->respond($http->handle($request)); |
81 | - } catch (\Throwable $e) { |
|
83 | + } |
|
84 | + catch (\Throwable $e) |
|
85 | + { |
|
82 | 86 | $this->handleException($client, $e); |
83 | - } finally { |
|
87 | + } |
|
88 | + finally |
|
89 | + { |
|
84 | 90 | $this->finalizer->finalize(false); |
85 | 91 | } |
86 | 92 | } |
@@ -94,17 +100,21 @@ discard block |
||
94 | 100 | { |
95 | 101 | $handler = new HtmlHandler(); |
96 | 102 | |
97 | - try { |
|
103 | + try |
|
104 | + { |
|
98 | 105 | /** @var SnapshotInterface $snapshot */ |
99 | 106 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
100 | 107 | error_log($snapshot->getMessage()); |
101 | 108 | |
102 | 109 | // on demand |
103 | 110 | $state = $this->container->get(StateInterface::class); |
104 | - if ($state !== null) { |
|
111 | + if ($state !== null) |
|
112 | + { |
|
105 | 113 | $handler = $handler->withState($state); |
106 | 114 | } |
107 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
115 | + } |
|
116 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
117 | + { |
|
108 | 118 | error_log((string)$e); |
109 | 119 | } |
110 | 120 |
@@ -43,8 +43,8 @@ |
||
43 | 43 | { |
44 | 44 | $state->setTag('php', phpversion()); |
45 | 45 | |
46 | - if ($this->container->get(DispatcherInterface::class)) { |
|
47 | - switch (get_class($this->container->get(DispatcherInterface::class))) { |
|
46 | + if ($this->container->get(DispatcherInterface::class)){ |
|
47 | + switch (get_class($this->container->get(DispatcherInterface::class))){ |
|
48 | 48 | case RrDispatcher::class: |
49 | 49 | $state->setTag('dispatcher', 'roadrunner'); |
50 | 50 | break; |
@@ -43,8 +43,10 @@ |
||
43 | 43 | { |
44 | 44 | $state->setTag('php', phpversion()); |
45 | 45 | |
46 | - if ($this->container->get(DispatcherInterface::class)) { |
|
47 | - switch (get_class($this->container->get(DispatcherInterface::class))) { |
|
46 | + if ($this->container->get(DispatcherInterface::class)) |
|
47 | + { |
|
48 | + switch (get_class($this->container->get(DispatcherInterface::class))) |
|
49 | + { |
|
48 | 50 | case RrDispatcher::class: |
49 | 51 | $state->setTag('dispatcher', 'roadrunner'); |
50 | 52 | break; |
@@ -74,7 +74,7 @@ |
||
74 | 74 | |
75 | 75 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
76 | 76 | |
77 | - if (class_exists(PSR7Client::class)) { |
|
77 | + if (class_exists(PSR7Client::class)){ |
|
78 | 78 | $kernel->addDispatcher($factory->make(RrDispatcher::class)); |
79 | 79 | } |
80 | 80 | } |
@@ -74,7 +74,8 @@ |
||
74 | 74 | |
75 | 75 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
76 | 76 | |
77 | - if (class_exists(PSR7Client::class)) { |
|
77 | + if (class_exists(PSR7Client::class)) |
|
78 | + { |
|
78 | 79 | $kernel->addDispatcher($factory->make(RrDispatcher::class)); |
79 | 80 | } |
80 | 81 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function getActor(TokenInterface $token): ?object |
54 | 54 | { |
55 | - foreach ($this->getProviders() as $provider) { |
|
56 | - if (!$provider instanceof ActorProviderInterface) { |
|
55 | + foreach ($this->getProviders() as $provider){ |
|
56 | + if (!$provider instanceof ActorProviderInterface){ |
|
57 | 57 | throw new AuthException( |
58 | 58 | sprintf( |
59 | 59 | 'Expected `ActorProviderInterface`, got `%s`', |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | $actor = $provider->getActor($token); |
66 | - if ($actor !== null) { |
|
66 | + if ($actor !== null){ |
|
67 | 67 | return $actor; |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - if ($this->actorProvider === []) { |
|
71 | + if ($this->actorProvider === []){ |
|
72 | 72 | throw new AuthException('No actor provider'); |
73 | 73 | } |
74 | 74 | |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | */ |
91 | 91 | private function getProviders(): \Generator |
92 | 92 | { |
93 | - foreach ($this->actorProvider as $provider) { |
|
94 | - if ($provider instanceof Autowire) { |
|
93 | + foreach ($this->actorProvider as $provider){ |
|
94 | + if ($provider instanceof Autowire){ |
|
95 | 95 | yield $provider->resolve($this->factory); |
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | - if (is_object($provider)) { |
|
99 | + if (is_object($provider)){ |
|
100 | 100 | yield $provider; |
101 | 101 | continue; |
102 | 102 | } |
@@ -52,8 +52,10 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function getActor(TokenInterface $token): ?object |
54 | 54 | { |
55 | - foreach ($this->getProviders() as $provider) { |
|
56 | - if (!$provider instanceof ActorProviderInterface) { |
|
55 | + foreach ($this->getProviders() as $provider) |
|
56 | + { |
|
57 | + if (!$provider instanceof ActorProviderInterface) |
|
58 | + { |
|
57 | 59 | throw new AuthException( |
58 | 60 | sprintf( |
59 | 61 | 'Expected `ActorProviderInterface`, got `%s`', |
@@ -63,12 +65,14 @@ discard block |
||
63 | 65 | } |
64 | 66 | |
65 | 67 | $actor = $provider->getActor($token); |
66 | - if ($actor !== null) { |
|
68 | + if ($actor !== null) |
|
69 | + { |
|
67 | 70 | return $actor; |
68 | 71 | } |
69 | 72 | } |
70 | 73 | |
71 | - if ($this->actorProvider === []) { |
|
74 | + if ($this->actorProvider === []) |
|
75 | + { |
|
72 | 76 | throw new AuthException('No actor provider'); |
73 | 77 | } |
74 | 78 | |
@@ -90,13 +94,16 @@ discard block |
||
90 | 94 | */ |
91 | 95 | private function getProviders(): \Generator |
92 | 96 | { |
93 | - foreach ($this->actorProvider as $provider) { |
|
94 | - if ($provider instanceof Autowire) { |
|
97 | + foreach ($this->actorProvider as $provider) |
|
98 | + { |
|
99 | + if ($provider instanceof Autowire) |
|
100 | + { |
|
95 | 101 | yield $provider->resolve($this->factory); |
96 | 102 | continue; |
97 | 103 | } |
98 | 104 | |
99 | - if (is_object($provider)) { |
|
105 | + if (is_object($provider)) |
|
106 | + { |
|
100 | 107 | yield $provider; |
101 | 108 | continue; |
102 | 109 | } |
@@ -142,7 +142,7 @@ |
||
142 | 142 | ['value' => $value] + $data, |
143 | 143 | ['value' => [['entity::unique', User::class, $field, $fields]]] |
144 | 144 | ); |
145 | - if ($context !== null) { |
|
145 | + if ($context !== null){ |
|
146 | 146 | $validator = $validator->withContext($context); |
147 | 147 | } |
148 | 148 |
@@ -142,7 +142,8 @@ |
||
142 | 142 | ['value' => $value] + $data, |
143 | 143 | ['value' => [['entity::unique', User::class, $field, $fields]]] |
144 | 144 | ); |
145 | - if ($context !== null) { |
|
145 | + if ($context !== null) |
|
146 | + { |
|
146 | 147 | $validator = $validator->withContext($context); |
147 | 148 | } |
148 | 149 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | public function exists($value, string $role, ?string $field = null): bool |
39 | 39 | { |
40 | 40 | $repository = $this->orm->getRepository($role); |
41 | - if ($field === null) { |
|
41 | + if ($field === null){ |
|
42 | 42 | return $repository->findByPK($value) !== null; |
43 | 43 | } |
44 | 44 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $values = $this->withValues($withFields); |
58 | 58 | $values[$field] = $value; |
59 | 59 | |
60 | - if ($this->isProvidedByContext($role, $values)) { |
|
60 | + if ($this->isProvidedByContext($role, $values)){ |
|
61 | 61 | return true; |
62 | 62 | } |
63 | 63 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | private function withValues(array $fields): array |
72 | 72 | { |
73 | 73 | $values = []; |
74 | - foreach ($fields as $field) { |
|
75 | - if ($this->getValidator()->hasValue($field)) { |
|
74 | + foreach ($fields as $field){ |
|
75 | + if ($this->getValidator()->hasValue($field)){ |
|
76 | 76 | $values[$field] = $this->getValidator()->getValue($field); |
77 | 77 | } |
78 | 78 | } |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | private function isProvidedByContext(string $role, array $values): bool |
89 | 89 | { |
90 | 90 | $entity = $this->getValidator()->getContext(); |
91 | - if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) { |
|
91 | + if (!is_object($entity) || !$this->orm->getHeap()->has($entity)){ |
|
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
95 | 95 | $extract = $this->orm->getMapper($role)->extract($entity); |
96 | - foreach ($values as $field => $value) { |
|
97 | - if (!isset($extract[$field]) || $extract[$field] !== $value) { |
|
96 | + foreach ($values as $field => $value){ |
|
97 | + if (!isset($extract[$field]) || $extract[$field] !== $value){ |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | } |
@@ -38,7 +38,8 @@ discard block |
||
38 | 38 | public function exists($value, string $role, ?string $field = null): bool |
39 | 39 | { |
40 | 40 | $repository = $this->orm->getRepository($role); |
41 | - if ($field === null) { |
|
41 | + if ($field === null) |
|
42 | + { |
|
42 | 43 | return $repository->findByPK($value) !== null; |
43 | 44 | } |
44 | 45 | |
@@ -57,7 +58,8 @@ discard block |
||
57 | 58 | $values = $this->withValues($withFields); |
58 | 59 | $values[$field] = $value; |
59 | 60 | |
60 | - if ($this->isProvidedByContext($role, $values)) { |
|
61 | + if ($this->isProvidedByContext($role, $values)) |
|
62 | + { |
|
61 | 63 | return true; |
62 | 64 | } |
63 | 65 | |
@@ -71,8 +73,10 @@ discard block |
||
71 | 73 | private function withValues(array $fields): array |
72 | 74 | { |
73 | 75 | $values = []; |
74 | - foreach ($fields as $field) { |
|
75 | - if ($this->getValidator()->hasValue($field)) { |
|
76 | + foreach ($fields as $field) |
|
77 | + { |
|
78 | + if ($this->getValidator()->hasValue($field)) |
|
79 | + { |
|
76 | 80 | $values[$field] = $this->getValidator()->getValue($field); |
77 | 81 | } |
78 | 82 | } |
@@ -88,13 +92,16 @@ discard block |
||
88 | 92 | private function isProvidedByContext(string $role, array $values): bool |
89 | 93 | { |
90 | 94 | $entity = $this->getValidator()->getContext(); |
91 | - if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) { |
|
95 | + if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) |
|
96 | + { |
|
92 | 97 | return false; |
93 | 98 | } |
94 | 99 | |
95 | 100 | $extract = $this->orm->getMapper($role)->extract($entity); |
96 | - foreach ($values as $field => $value) { |
|
97 | - if (!isset($extract[$field]) || $extract[$field] !== $value) { |
|
101 | + foreach ($values as $field => $value) |
|
102 | + { |
|
103 | + if (!isset($extract[$field]) || $extract[$field] !== $value) |
|
104 | + { |
|
98 | 105 | return false; |
99 | 106 | } |
100 | 107 | } |