@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | $schema = $this->constant('SCHEMA')->getValue(); |
50 | 50 | $validates = $this->constant('VALIDATES')->getValue(); |
51 | 51 | |
52 | - if (!isset($this->mapping[$type])) { |
|
53 | - $schema[$field] = ($source ?? self::DEFAULT_SOURCE) . ':' . ($origin ?: $field); |
|
52 | + if (!isset($this->mapping[$type])){ |
|
53 | + $schema[$field] = ($source ?? self::DEFAULT_SOURCE).':'.($origin ?: $field); |
|
54 | 54 | |
55 | 55 | $this->constant('SCHEMA')->setValue($schema); |
56 | 56 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | |
62 | 62 | //Source can depend on type |
63 | 63 | $source ??= $definition['source']; |
64 | - $schema[$field] = $source . ':' . ($origin ?: $field); |
|
64 | + $schema[$field] = $source.':'.($origin ?: $field); |
|
65 | 65 | |
66 | - if (!empty($definition['validates'])) { |
|
66 | + if (!empty($definition['validates'])){ |
|
67 | 67 | //Pre-defined validation |
68 | 68 | $validates[$field] = $definition['validates']; |
69 | 69 | } |
@@ -49,7 +49,8 @@ discard block |
||
49 | 49 | $schema = $this->constant('SCHEMA')->getValue(); |
50 | 50 | $validates = $this->constant('VALIDATES')->getValue(); |
51 | 51 | |
52 | - if (!isset($this->mapping[$type])) { |
|
52 | + if (!isset($this->mapping[$type])) |
|
53 | + { |
|
53 | 54 | $schema[$field] = ($source ?? self::DEFAULT_SOURCE) . ':' . ($origin ?: $field); |
54 | 55 | |
55 | 56 | $this->constant('SCHEMA')->setValue($schema); |
@@ -63,7 +64,8 @@ discard block |
||
63 | 64 | $source ??= $definition['source']; |
64 | 65 | $schema[$field] = $source . ':' . ($origin ?: $field); |
65 | 66 | |
66 | - if (!empty($definition['validates'])) { |
|
67 | + if (!empty($definition['validates'])) |
|
68 | + { |
|
67 | 69 | //Pre-defined validation |
68 | 70 | $validates[$field] = $definition['validates']; |
69 | 71 | } |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | $console->addCommand(MiddlewareCommand::class); |
77 | 77 | $console->addCommand(MigrationCommand::class, true); |
78 | 78 | |
79 | - try { |
|
79 | + try{ |
|
80 | 80 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
81 | - } catch (ReflectionException $e) { |
|
81 | + }catch (ReflectionException $e){ |
|
82 | 82 | $defaultNamespace = ''; |
83 | 83 | } |
84 | 84 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * Base directory for generated classes, class will be automatically localed into sub directory |
98 | 98 | * using given namespace. |
99 | 99 | */ |
100 | - 'directory' => directory('app') . 'src/', |
|
100 | + 'directory' => directory('app').'src/', |
|
101 | 101 | |
102 | 102 | /* |
103 | 103 | * Default namespace to be applied for every generated class. By default uses Kernel namespace |
@@ -76,9 +76,12 @@ |
||
76 | 76 | $console->addCommand(MiddlewareCommand::class); |
77 | 77 | $console->addCommand(MigrationCommand::class, true); |
78 | 78 | |
79 | - try { |
|
79 | + try |
|
80 | + { |
|
80 | 81 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
81 | - } catch (ReflectionException $e) { |
|
82 | + } |
|
83 | + catch (ReflectionException $e) |
|
84 | + { |
|
82 | 85 | $defaultNamespace = ''; |
83 | 86 | } |
84 | 87 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public function __construct(array $config = []) |
35 | 35 | { |
36 | 36 | parent::__construct($config); |
37 | - if (!empty($this->config['aliases'])) { |
|
37 | + if (!empty($this->config['aliases'])){ |
|
38 | 38 | $this->config['aliases'] = $this->normalizeAliases($this->config['aliases']); |
39 | 39 | } |
40 | 40 | } |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function getChecker(string $name): Autowire |
52 | 52 | { |
53 | - if (!$this->hasChecker($name)) { |
|
53 | + if (!$this->hasChecker($name)){ |
|
54 | 54 | throw new ValidationException("Undefined checker `{$name}``."); |
55 | 55 | } |
56 | 56 | |
57 | 57 | $instance = $this->wire('checkers', $name); |
58 | - if ($instance !== null) { |
|
58 | + if ($instance !== null){ |
|
59 | 59 | return $instance; |
60 | 60 | } |
61 | 61 | |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | |
70 | 70 | public function getCondition(string $name): Autowire |
71 | 71 | { |
72 | - if (!$this->hasCondition($name)) { |
|
72 | + if (!$this->hasCondition($name)){ |
|
73 | 73 | throw new ValidationException("Undefined condition `{$name}`."); |
74 | 74 | } |
75 | 75 | |
76 | 76 | $instance = $this->wire('conditions', $name); |
77 | - if ($instance !== null) { |
|
77 | + if ($instance !== null){ |
|
78 | 78 | return $instance; |
79 | 79 | } |
80 | 80 | |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function mapFunction($function) |
92 | 92 | { |
93 | - if (is_string($function)) { |
|
93 | + if (is_string($function)){ |
|
94 | 94 | $function = $this->resolveAlias($function); |
95 | - if (strpos($function, ':') !== false) { |
|
95 | + if (strpos($function, ':') !== false){ |
|
96 | 96 | $function = explode(':', $function); |
97 | 97 | } |
98 | 98 | } |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | |
103 | 103 | private function wire(string $section, string $name): ?Autowire |
104 | 104 | { |
105 | - if (is_string($this->config[$section][$name])) { |
|
105 | + if (is_string($this->config[$section][$name])){ |
|
106 | 106 | return new Autowire($this->config[$section][$name]); |
107 | 107 | } |
108 | 108 | |
109 | - if (isset($this->config[$section][$name]['class'])) { |
|
109 | + if (isset($this->config[$section][$name]['class'])){ |
|
110 | 110 | return new Autowire( |
111 | 111 | $this->config[$section][$name]['class'], |
112 | 112 | $this->config[$section][$name]['options'] ?? [] |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | public function __construct(array $config = []) |
35 | 35 | { |
36 | 36 | parent::__construct($config); |
37 | - if (!empty($this->config['aliases'])) { |
|
37 | + if (!empty($this->config['aliases'])) |
|
38 | + { |
|
38 | 39 | $this->config['aliases'] = $this->normalizeAliases($this->config['aliases']); |
39 | 40 | } |
40 | 41 | } |
@@ -50,12 +51,14 @@ discard block |
||
50 | 51 | */ |
51 | 52 | public function getChecker(string $name): Autowire |
52 | 53 | { |
53 | - if (!$this->hasChecker($name)) { |
|
54 | + if (!$this->hasChecker($name)) |
|
55 | + { |
|
54 | 56 | throw new ValidationException("Undefined checker `{$name}``."); |
55 | 57 | } |
56 | 58 | |
57 | 59 | $instance = $this->wire('checkers', $name); |
58 | - if ($instance !== null) { |
|
60 | + if ($instance !== null) |
|
61 | + { |
|
59 | 62 | return $instance; |
60 | 63 | } |
61 | 64 | |
@@ -69,12 +72,14 @@ discard block |
||
69 | 72 | |
70 | 73 | public function getCondition(string $name): Autowire |
71 | 74 | { |
72 | - if (!$this->hasCondition($name)) { |
|
75 | + if (!$this->hasCondition($name)) |
|
76 | + { |
|
73 | 77 | throw new ValidationException("Undefined condition `{$name}`."); |
74 | 78 | } |
75 | 79 | |
76 | 80 | $instance = $this->wire('conditions', $name); |
77 | - if ($instance !== null) { |
|
81 | + if ($instance !== null) |
|
82 | + { |
|
78 | 83 | return $instance; |
79 | 84 | } |
80 | 85 | |
@@ -90,9 +95,11 @@ discard block |
||
90 | 95 | */ |
91 | 96 | public function mapFunction($function) |
92 | 97 | { |
93 | - if (is_string($function)) { |
|
98 | + if (is_string($function)) |
|
99 | + { |
|
94 | 100 | $function = $this->resolveAlias($function); |
95 | - if (strpos($function, ':') !== false) { |
|
101 | + if (strpos($function, ':') !== false) |
|
102 | + { |
|
96 | 103 | $function = explode(':', $function); |
97 | 104 | } |
98 | 105 | } |
@@ -102,11 +109,13 @@ discard block |
||
102 | 109 | |
103 | 110 | private function wire(string $section, string $name): ?Autowire |
104 | 111 | { |
105 | - if (is_string($this->config[$section][$name])) { |
|
112 | + if (is_string($this->config[$section][$name])) |
|
113 | + { |
|
106 | 114 | return new Autowire($this->config[$section][$name]); |
107 | 115 | } |
108 | 116 | |
109 | - if (isset($this->config[$section][$name]['class'])) { |
|
117 | + if (isset($this->config[$section][$name]['class'])) |
|
118 | + { |
|
110 | 119 | return new Autowire( |
111 | 120 | $this->config[$section][$name]['class'], |
112 | 121 | $this->config[$section][$name]['options'] ?? [] |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | 'namespaces' => $config->getNamespaces(), |
37 | 37 | ]); |
38 | 38 | |
39 | - foreach ($this->config->getDependencies() as $dependency) { |
|
39 | + foreach ($this->config->getDependencies() as $dependency){ |
|
40 | 40 | $this->addDependency($dependency->resolve($factory)); |
41 | 41 | } |
42 | 42 | |
43 | - foreach ($this->config->getEngines() as $engine) { |
|
43 | + foreach ($this->config->getEngines() as $engine){ |
|
44 | 44 | $this->addEngine($engine->resolve($factory)); |
45 | 45 | } |
46 | 46 | |
47 | - if ($this->config->isCacheEnabled()) { |
|
47 | + if ($this->config->isCacheEnabled()){ |
|
48 | 48 | $this->cache = new ViewCache(); |
49 | 49 | } |
50 | 50 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function compile(string $path): void |
98 | 98 | { |
99 | - if ($this->cache !== null) { |
|
99 | + if ($this->cache !== null){ |
|
100 | 100 | $this->cache->resetPath($path); |
101 | 101 | } |
102 | 102 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | // Rotate all possible context variants and warm up cache |
106 | 106 | $generator = new ContextGenerator($this->context); |
107 | - foreach ($generator->generate() as $context) { |
|
107 | + foreach ($generator->generate() as $context){ |
|
108 | 108 | $engine->reset($path, $context); |
109 | 109 | $engine->compile($path, $context); |
110 | 110 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function reset(string $path): void |
117 | 117 | { |
118 | - if ($this->cache !== null) { |
|
118 | + if ($this->cache !== null){ |
|
119 | 119 | $this->cache->resetPath($path); |
120 | 120 | } |
121 | 121 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | // Rotate all possible context variants and warm up cache |
125 | 125 | $generator = new ContextGenerator($this->context); |
126 | - foreach ($generator->generate() as $context) { |
|
126 | + foreach ($generator->generate() as $context){ |
|
127 | 127 | $engine->reset($path, $context); |
128 | 128 | } |
129 | 129 | } |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function get(string $path): ViewInterface |
138 | 138 | { |
139 | - if ($this->cache !== null && $this->cache->has($this->context, $path)) { |
|
139 | + if ($this->cache !== null && $this->cache->has($this->context, $path)){ |
|
140 | 140 | return $this->cache->get($this->context, $path); |
141 | 141 | } |
142 | 142 | |
143 | 143 | $view = $this->findEngine($path)->get($path, $this->context); |
144 | 144 | |
145 | - if ($this->cache !== null) { |
|
145 | + if ($this->cache !== null){ |
|
146 | 146 | $this->cache->set($this->context, $path, $view); |
147 | 147 | } |
148 | 148 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function findEngine(string $path): EngineInterface |
166 | 166 | { |
167 | - foreach ($this->engines as $engine) { |
|
168 | - if ($engine->getLoader()->exists($path)) { |
|
167 | + foreach ($this->engines as $engine){ |
|
168 | + if ($engine->getLoader()->exists($path)){ |
|
169 | 169 | return $engine; |
170 | 170 | } |
171 | 171 | } |
@@ -36,15 +36,18 @@ discard block |
||
36 | 36 | 'namespaces' => $config->getNamespaces(), |
37 | 37 | ]); |
38 | 38 | |
39 | - foreach ($this->config->getDependencies() as $dependency) { |
|
39 | + foreach ($this->config->getDependencies() as $dependency) |
|
40 | + { |
|
40 | 41 | $this->addDependency($dependency->resolve($factory)); |
41 | 42 | } |
42 | 43 | |
43 | - foreach ($this->config->getEngines() as $engine) { |
|
44 | + foreach ($this->config->getEngines() as $engine) |
|
45 | + { |
|
44 | 46 | $this->addEngine($engine->resolve($factory)); |
45 | 47 | } |
46 | 48 | |
47 | - if ($this->config->isCacheEnabled()) { |
|
49 | + if ($this->config->isCacheEnabled()) |
|
50 | + { |
|
48 | 51 | $this->cache = new ViewCache(); |
49 | 52 | } |
50 | 53 | } |
@@ -96,7 +99,8 @@ discard block |
||
96 | 99 | */ |
97 | 100 | public function compile(string $path): void |
98 | 101 | { |
99 | - if ($this->cache !== null) { |
|
102 | + if ($this->cache !== null) |
|
103 | + { |
|
100 | 104 | $this->cache->resetPath($path); |
101 | 105 | } |
102 | 106 | |
@@ -104,7 +108,8 @@ discard block |
||
104 | 108 | |
105 | 109 | // Rotate all possible context variants and warm up cache |
106 | 110 | $generator = new ContextGenerator($this->context); |
107 | - foreach ($generator->generate() as $context) { |
|
111 | + foreach ($generator->generate() as $context) |
|
112 | + { |
|
108 | 113 | $engine->reset($path, $context); |
109 | 114 | $engine->compile($path, $context); |
110 | 115 | } |
@@ -115,7 +120,8 @@ discard block |
||
115 | 120 | */ |
116 | 121 | public function reset(string $path): void |
117 | 122 | { |
118 | - if ($this->cache !== null) { |
|
123 | + if ($this->cache !== null) |
|
124 | + { |
|
119 | 125 | $this->cache->resetPath($path); |
120 | 126 | } |
121 | 127 | |
@@ -123,7 +129,8 @@ discard block |
||
123 | 129 | |
124 | 130 | // Rotate all possible context variants and warm up cache |
125 | 131 | $generator = new ContextGenerator($this->context); |
126 | - foreach ($generator->generate() as $context) { |
|
132 | + foreach ($generator->generate() as $context) |
|
133 | + { |
|
127 | 134 | $engine->reset($path, $context); |
128 | 135 | } |
129 | 136 | } |
@@ -136,13 +143,15 @@ discard block |
||
136 | 143 | */ |
137 | 144 | public function get(string $path): ViewInterface |
138 | 145 | { |
139 | - if ($this->cache !== null && $this->cache->has($this->context, $path)) { |
|
146 | + if ($this->cache !== null && $this->cache->has($this->context, $path)) |
|
147 | + { |
|
140 | 148 | return $this->cache->get($this->context, $path); |
141 | 149 | } |
142 | 150 | |
143 | 151 | $view = $this->findEngine($path)->get($path, $this->context); |
144 | 152 | |
145 | - if ($this->cache !== null) { |
|
153 | + if ($this->cache !== null) |
|
154 | + { |
|
146 | 155 | $this->cache->set($this->context, $path, $view); |
147 | 156 | } |
148 | 157 | |
@@ -164,8 +173,10 @@ discard block |
||
164 | 173 | */ |
165 | 174 | private function findEngine(string $path): EngineInterface |
166 | 175 | { |
167 | - foreach ($this->engines as $engine) { |
|
168 | - if ($engine->getLoader()->exists($path)) { |
|
176 | + foreach ($this->engines as $engine) |
|
177 | + { |
|
178 | + if ($engine->getLoader()->exists($path)) |
|
179 | + { |
|
169 | 180 | return $engine; |
170 | 181 | } |
171 | 182 | } |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function handle(string $name, string $id, $payload): void |
47 | 47 | { |
48 | - if (\is_string($payload)) { |
|
48 | + if (\is_string($payload)){ |
|
49 | 49 | $payload = json_decode($payload, true, 512, JSON_THROW_ON_ERROR); |
50 | 50 | } |
51 | 51 | |
52 | - if (!\is_array($payload)) { |
|
52 | + if (!\is_array($payload)){ |
|
53 | 53 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
54 | 54 | } |
55 | 55 | |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | |
58 | 58 | $email = $this->renderer->render($message); |
59 | 59 | |
60 | - if ($email->getFrom() === []) { |
|
60 | + if ($email->getFrom() === []){ |
|
61 | 61 | $email->from(Address::create($this->config->getFromAddress())); |
62 | 62 | } |
63 | 63 | |
64 | 64 | $recipients = $this->getRecipients($email); |
65 | 65 | |
66 | - try { |
|
66 | + try{ |
|
67 | 67 | $this->mailer->send($email); |
68 | - } catch (TransportExceptionInterface $e) { |
|
68 | + }catch (TransportExceptionInterface $e){ |
|
69 | 69 | $this->getLogger()->error( |
70 | 70 | sprintf( |
71 | 71 | 'Failed to send `%s` to "%s": %s', |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
97 | 97 | |
98 | - foreach ($addresses as $address) { |
|
98 | + foreach ($addresses as $address){ |
|
99 | 99 | $emails[] = $address->toString(); |
100 | 100 | } |
101 | 101 |
@@ -45,11 +45,13 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function handle(string $name, string $id, $payload): void |
47 | 47 | { |
48 | - if (\is_string($payload)) { |
|
48 | + if (\is_string($payload)) |
|
49 | + { |
|
49 | 50 | $payload = json_decode($payload, true, 512, JSON_THROW_ON_ERROR); |
50 | 51 | } |
51 | 52 | |
52 | - if (!\is_array($payload)) { |
|
53 | + if (!\is_array($payload)) |
|
54 | + { |
|
53 | 55 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
54 | 56 | } |
55 | 57 | |
@@ -57,15 +59,19 @@ discard block |
||
57 | 59 | |
58 | 60 | $email = $this->renderer->render($message); |
59 | 61 | |
60 | - if ($email->getFrom() === []) { |
|
62 | + if ($email->getFrom() === []) |
|
63 | + { |
|
61 | 64 | $email->from(Address::create($this->config->getFromAddress())); |
62 | 65 | } |
63 | 66 | |
64 | 67 | $recipients = $this->getRecipients($email); |
65 | 68 | |
66 | - try { |
|
69 | + try |
|
70 | + { |
|
67 | 71 | $this->mailer->send($email); |
68 | - } catch (TransportExceptionInterface $e) { |
|
72 | + } |
|
73 | + catch (TransportExceptionInterface $e) |
|
74 | + { |
|
69 | 75 | $this->getLogger()->error( |
70 | 76 | sprintf( |
71 | 77 | 'Failed to send `%s` to "%s": %s', |
@@ -95,7 +101,8 @@ discard block |
||
95 | 101 | |
96 | 102 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
97 | 103 | |
98 | - foreach ($addresses as $address) { |
|
104 | + foreach ($addresses as $address) |
|
105 | + { |
|
99 | 106 | $emails[] = $address->toString(); |
100 | 107 | } |
101 | 108 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | // Replaces alias with real pipeline name |
29 | 29 | $name = $this->config->getAliases()[$name] ?? $name; |
30 | 30 | |
31 | - if (!isset($this->pipelines[$name])) { |
|
31 | + if (!isset($this->pipelines[$name])){ |
|
32 | 32 | $this->pipelines[$name] = $this->resolveConnection($name); |
33 | 33 | } |
34 | 34 | |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | { |
44 | 44 | $config = $this->config->getConnection($name); |
45 | 45 | |
46 | - try { |
|
46 | + try{ |
|
47 | 47 | return $this->factory->make($config['driver'], $config); |
48 | - } catch (ContainerException $e) { |
|
48 | + }catch (ContainerException $e){ |
|
49 | 49 | throw new NotSupportedDriverException( |
50 | 50 | \sprintf( |
51 | 51 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | // Replaces alias with real pipeline name |
29 | 29 | $name = $this->config->getAliases()[$name] ?? $name; |
30 | 30 | |
31 | - if (!isset($this->pipelines[$name])) { |
|
31 | + if (!isset($this->pipelines[$name])) |
|
32 | + { |
|
32 | 33 | $this->pipelines[$name] = $this->resolveConnection($name); |
33 | 34 | } |
34 | 35 | |
@@ -43,9 +44,12 @@ discard block |
||
43 | 44 | { |
44 | 45 | $config = $this->config->getConnection($name); |
45 | 46 | |
46 | - try { |
|
47 | + try |
|
48 | + { |
|
47 | 49 | return $this->factory->make($config['driver'], $config); |
48 | - } catch (ContainerException $e) { |
|
50 | + } |
|
51 | + catch (ContainerException $e) |
|
52 | + { |
|
49 | 53 | throw new NotSupportedDriverException( |
50 | 54 | \sprintf( |
51 | 55 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Argument types. |
23 | 23 | */ |
24 | - public const CONSTANT = 'constant'; //Scalar constant and not variable. |
|
25 | - public const VARIABLE = 'variable'; //PHP variable |
|
24 | + public const CONSTANT = 'constant'; //Scalar constant and not variable. |
|
25 | + public const VARIABLE = 'variable'; //PHP variable |
|
26 | 26 | public const EXPRESSION = 'expression'; //PHP code (expression). |
27 | 27 | public const STRING = 'string'; |
28 | 28 | private string $type; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function stringValue(): string |
61 | 61 | { |
62 | - if ($this->type != self::STRING) { |
|
62 | + if ($this->type != self::STRING){ |
|
63 | 63 | throw new ReflectionException( |
64 | 64 | "Unable to represent value as string, value type is '{$this->type}'" |
65 | 65 | ); |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | $level = 0; |
81 | 81 | |
82 | 82 | $result = []; |
83 | - foreach ($tokens as $token) { |
|
84 | - if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE) { |
|
83 | + foreach ($tokens as $token){ |
|
84 | + if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE){ |
|
85 | 85 | continue; |
86 | 86 | } |
87 | 87 | |
88 | - if (empty($definition)) { |
|
88 | + if (empty($definition)){ |
|
89 | 89 | $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []]; |
90 | 90 | } |
91 | 91 | |
92 | 92 | if ( |
93 | 93 | $token[ReflectionFile::TOKEN_TYPE] == '(' |
94 | 94 | || $token[ReflectionFile::TOKEN_TYPE] == '[' |
95 | - ) { |
|
95 | + ){ |
|
96 | 96 | ++$level; |
97 | 97 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
98 | 98 | continue; |
@@ -101,18 +101,18 @@ discard block |
||
101 | 101 | if ( |
102 | 102 | $token[ReflectionFile::TOKEN_TYPE] == ')' |
103 | 103 | || $token[ReflectionFile::TOKEN_TYPE] == ']' |
104 | - ) { |
|
104 | + ){ |
|
105 | 105 | --$level; |
106 | 106 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
107 | 107 | continue; |
108 | 108 | } |
109 | 109 | |
110 | - if ($level) { |
|
110 | + if ($level){ |
|
111 | 111 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | |
115 | - if ($token[ReflectionFile::TOKEN_TYPE] == ',') { |
|
115 | + if ($token[ReflectionFile::TOKEN_TYPE] == ','){ |
|
116 | 116 | $result[] = self::createArgument($definition); |
117 | 117 | $definition = null; |
118 | 118 | continue; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | //Last argument |
126 | - if (is_array($definition)) { |
|
126 | + if (is_array($definition)){ |
|
127 | 127 | $definition = self::createArgument($definition); |
128 | - if (!empty($definition->getType())) { |
|
128 | + if (!empty($definition->getType())){ |
|
129 | 129 | $result[] = $definition; |
130 | 130 | } |
131 | 131 | } |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | { |
143 | 143 | $result = new static(self::EXPRESSION, $definition['value']); |
144 | 144 | |
145 | - if (count($definition['tokens']) == 1) { |
|
145 | + if (count($definition['tokens']) == 1){ |
|
146 | 146 | //If argument represent by one token we can try to resolve it's type more precisely |
147 | - switch ($definition['tokens'][0][0]) { |
|
147 | + switch ($definition['tokens'][0][0]){ |
|
148 | 148 | case T_VARIABLE: |
149 | 149 | $result->type = self::VARIABLE; |
150 | 150 | break; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | public function getGuard(): GuardInterface |
28 | 28 | { |
29 | 29 | $container = ContainerScope::getContainer(); |
30 | - if (empty($container) || !$container->has(GuardInterface::class)) { |
|
30 | + if (empty($container) || !$container->has(GuardInterface::class)){ |
|
31 | 31 | throw new ScopeException( |
32 | 32 | 'Unable to get `GuardInterface`, binding is missing or container scope is not set' |
33 | 33 | ); |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | protected function resolvePermission(string $permission): string |
53 | 53 | { |
54 | - if (defined('static::GUARD_NAMESPACE')) { |
|
54 | + if (defined('static::GUARD_NAMESPACE')){ |
|
55 | 55 | // Yay! Isolation |
56 | - $permission = constant(static::class . '::' . 'GUARD_NAMESPACE') . '.' . $permission; |
|
56 | + $permission = constant(static::class.'::'.'GUARD_NAMESPACE').'.'.$permission; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return $permission; |
@@ -27,7 +27,8 @@ discard block |
||
27 | 27 | public function getGuard(): GuardInterface |
28 | 28 | { |
29 | 29 | $container = ContainerScope::getContainer(); |
30 | - if (empty($container) || !$container->has(GuardInterface::class)) { |
|
30 | + if (empty($container) || !$container->has(GuardInterface::class)) |
|
31 | + { |
|
31 | 32 | throw new ScopeException( |
32 | 33 | 'Unable to get `GuardInterface`, binding is missing or container scope is not set' |
33 | 34 | ); |
@@ -51,7 +52,8 @@ discard block |
||
51 | 52 | */ |
52 | 53 | protected function resolvePermission(string $permission): string |
53 | 54 | { |
54 | - if (defined('static::GUARD_NAMESPACE')) { |
|
55 | + if (defined('static::GUARD_NAMESPACE')) |
|
56 | + { |
|
55 | 57 | // Yay! Isolation |
56 | 58 | $permission = constant(static::class . '::' . 'GUARD_NAMESPACE') . '.' . $permission; |
57 | 59 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
70 | 70 | { |
71 | - switch ($token->type) { |
|
71 | + switch ($token->type){ |
|
72 | 72 | case HTMLGrammar::TYPE_OPEN: |
73 | 73 | case HTMLGrammar::TYPE_OPEN_SHORT: |
74 | 74 | $this->node = new Tag(new Context($token, $parser->getPath())); |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | break; |
78 | 78 | |
79 | 79 | case HTMLGrammar::TYPE_KEYWORD: |
80 | - if ($this->node->name === null) { |
|
80 | + if ($this->node->name === null){ |
|
81 | 81 | $this->node->name = $this->parseToken($parser, $token); |
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - if ($this->attr !== null && !$this->attr->value instanceof Nil) { |
|
85 | + if ($this->attr !== null && !$this->attr->value instanceof Nil){ |
|
86 | 86 | $this->attr->value = $this->parseToken($parser, $token); |
87 | 87 | $this->attr = null; |
88 | 88 | break; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | break; |
99 | 99 | |
100 | 100 | case HTMLGrammar::TYPE_EQUAL: |
101 | - if ($this->attr === null) { |
|
101 | + if ($this->attr === null){ |
|
102 | 102 | throw new SyntaxException('unexpected attribute token', $token); |
103 | 103 | } |
104 | 104 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | break; |
108 | 108 | |
109 | 109 | case HTMLGrammar::TYPE_ATTRIBUTE: |
110 | - if ($this->attr === null) { |
|
110 | + if ($this->attr === null){ |
|
111 | 111 | throw new SyntaxException('unexpected attribute token', $token); |
112 | 112 | } |
113 | 113 | |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | strpos($this->attr->name, 'on') === 0 |
118 | 118 | || in_array($this->attr->name, self::VERBATIM_ATTRIBUTES, true) |
119 | 119 | ) |
120 | - ) { |
|
120 | + ){ |
|
121 | 121 | $this->attr->value = $this->parseVerbatim($parser, $token); |
122 | - } else { |
|
122 | + }else{ |
|
123 | 123 | $this->attr->value = $this->parseToken($parser, $token); |
124 | 124 | } |
125 | 125 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | break; |
134 | 134 | |
135 | 135 | case HTMLGrammar::TYPE_CLOSE: |
136 | - if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) { |
|
137 | - if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) { |
|
136 | + if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT){ |
|
137 | + if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name){ |
|
138 | 138 | throw new SyntaxException( |
139 | 139 | "Invalid closing tag `{$this->node->name}`, expected `{$asm->getNode()->name}`", |
140 | 140 | $this->token |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | $asm->close(); |
145 | - } else { |
|
146 | - if (in_array($this->node->name, self::VOID_TAGS)) { |
|
145 | + }else{ |
|
146 | + if (in_array($this->node->name, self::VOID_TAGS)){ |
|
147 | 147 | $this->node->void = true; |
148 | 148 | $asm->push($this->node); |
149 | - } else { |
|
149 | + }else{ |
|
150 | 150 | $asm->open($this->node, 'nodes'); |
151 | 151 | } |
152 | 152 | } |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | break; |
160 | 160 | |
161 | 161 | default: |
162 | - if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) { |
|
162 | + if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim){ |
|
163 | 163 | $node = $this->parseToken($parser, $token); |
164 | - if (is_string($node)) { |
|
164 | + if (is_string($node)){ |
|
165 | 165 | $node = new Raw($node, new Context($token, $parser->getPath())); |
166 | 166 | } |
167 | 167 | |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | { |
185 | 185 | $verbatim = new Verbatim(new Context($token, $parser->getPath())); |
186 | 186 | |
187 | - if ($token->tokens === []) { |
|
188 | - if ($token->content) { |
|
187 | + if ($token->tokens === []){ |
|
188 | + if ($token->content){ |
|
189 | 189 | $verbatim->nodes[] = $token->content; |
190 | 190 | } |
191 | - } else { |
|
191 | + }else{ |
|
192 | 192 | $parser->parseTokens( |
193 | 193 | new Assembler($verbatim, 'nodes'), |
194 | 194 | $token->tokens |
@@ -68,7 +68,8 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
70 | 70 | { |
71 | - switch ($token->type) { |
|
71 | + switch ($token->type) |
|
72 | + { |
|
72 | 73 | case HTMLGrammar::TYPE_OPEN: |
73 | 74 | case HTMLGrammar::TYPE_OPEN_SHORT: |
74 | 75 | $this->node = new Tag(new Context($token, $parser->getPath())); |
@@ -77,12 +78,14 @@ discard block |
||
77 | 78 | break; |
78 | 79 | |
79 | 80 | case HTMLGrammar::TYPE_KEYWORD: |
80 | - if ($this->node->name === null) { |
|
81 | + if ($this->node->name === null) |
|
82 | + { |
|
81 | 83 | $this->node->name = $this->parseToken($parser, $token); |
82 | 84 | return; |
83 | 85 | } |
84 | 86 | |
85 | - if ($this->attr !== null && !$this->attr->value instanceof Nil) { |
|
87 | + if ($this->attr !== null && !$this->attr->value instanceof Nil) |
|
88 | + { |
|
86 | 89 | $this->attr->value = $this->parseToken($parser, $token); |
87 | 90 | $this->attr = null; |
88 | 91 | break; |
@@ -98,7 +101,8 @@ discard block |
||
98 | 101 | break; |
99 | 102 | |
100 | 103 | case HTMLGrammar::TYPE_EQUAL: |
101 | - if ($this->attr === null) { |
|
104 | + if ($this->attr === null) |
|
105 | + { |
|
102 | 106 | throw new SyntaxException('unexpected attribute token', $token); |
103 | 107 | } |
104 | 108 | |
@@ -107,7 +111,8 @@ discard block |
||
107 | 111 | break; |
108 | 112 | |
109 | 113 | case HTMLGrammar::TYPE_ATTRIBUTE: |
110 | - if ($this->attr === null) { |
|
114 | + if ($this->attr === null) |
|
115 | + { |
|
111 | 116 | throw new SyntaxException('unexpected attribute token', $token); |
112 | 117 | } |
113 | 118 | |
@@ -119,7 +124,9 @@ discard block |
||
119 | 124 | ) |
120 | 125 | ) { |
121 | 126 | $this->attr->value = $this->parseVerbatim($parser, $token); |
122 | - } else { |
|
127 | + } |
|
128 | + else |
|
129 | + { |
|
123 | 130 | $this->attr->value = $this->parseToken($parser, $token); |
124 | 131 | } |
125 | 132 | |
@@ -133,8 +140,10 @@ discard block |
||
133 | 140 | break; |
134 | 141 | |
135 | 142 | case HTMLGrammar::TYPE_CLOSE: |
136 | - if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) { |
|
137 | - if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) { |
|
143 | + if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) |
|
144 | + { |
|
145 | + if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) |
|
146 | + { |
|
138 | 147 | throw new SyntaxException( |
139 | 148 | "Invalid closing tag `{$this->node->name}`, expected `{$asm->getNode()->name}`", |
140 | 149 | $this->token |
@@ -142,11 +151,16 @@ discard block |
||
142 | 151 | } |
143 | 152 | |
144 | 153 | $asm->close(); |
145 | - } else { |
|
146 | - if (in_array($this->node->name, self::VOID_TAGS)) { |
|
154 | + } |
|
155 | + else |
|
156 | + { |
|
157 | + if (in_array($this->node->name, self::VOID_TAGS)) |
|
158 | + { |
|
147 | 159 | $this->node->void = true; |
148 | 160 | $asm->push($this->node); |
149 | - } else { |
|
161 | + } |
|
162 | + else |
|
163 | + { |
|
150 | 164 | $asm->open($this->node, 'nodes'); |
151 | 165 | } |
152 | 166 | } |
@@ -159,9 +173,11 @@ discard block |
||
159 | 173 | break; |
160 | 174 | |
161 | 175 | default: |
162 | - if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) { |
|
176 | + if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) |
|
177 | + { |
|
163 | 178 | $node = $this->parseToken($parser, $token); |
164 | - if (is_string($node)) { |
|
179 | + if (is_string($node)) |
|
180 | + { |
|
165 | 181 | $node = new Raw($node, new Context($token, $parser->getPath())); |
166 | 182 | } |
167 | 183 | |
@@ -184,11 +200,15 @@ discard block |
||
184 | 200 | { |
185 | 201 | $verbatim = new Verbatim(new Context($token, $parser->getPath())); |
186 | 202 | |
187 | - if ($token->tokens === []) { |
|
188 | - if ($token->content) { |
|
203 | + if ($token->tokens === []) |
|
204 | + { |
|
205 | + if ($token->content) |
|
206 | + { |
|
189 | 207 | $verbatim->nodes[] = $token->content; |
190 | 208 | } |
191 | - } else { |
|
209 | + } |
|
210 | + else |
|
211 | + { |
|
192 | 212 | $parser->parseTokens( |
193 | 213 | new Assembler($verbatim, 'nodes'), |
194 | 214 | $token->tokens |