@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected function isFillable(string $field): bool |
72 | 72 | { |
73 | - if (static::FILLABLE === '*') { |
|
73 | + if (static::FILLABLE === '*'){ |
|
74 | 74 | return true; |
75 | 75 | } |
76 | 76 | |
77 | - if (!empty(static::FILLABLE)) { |
|
77 | + if (!empty(static::FILLABLE)){ |
|
78 | 78 | return \in_array($field, static::FILLABLE, true); |
79 | 79 | } |
80 | 80 | |
81 | - if (static::SECURED === '*') { |
|
81 | + if (static::SECURED === '*'){ |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | protected function getMutator(string $field, string $type) |
97 | 97 | { |
98 | 98 | $target = []; |
99 | - switch ($type) { |
|
99 | + switch ($type){ |
|
100 | 100 | case ModelSchema::MUTATOR_ACCESSOR: |
101 | 101 | $target = static::ACCESSORS; |
102 | 102 | break; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | break; |
109 | 109 | } |
110 | 110 | |
111 | - if (isset($target[$field])) { |
|
111 | + if (isset($target[$field])){ |
|
112 | 112 | return $target[$field]; |
113 | 113 | } |
114 | 114 |
@@ -70,15 +70,18 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected function isFillable(string $field): bool |
72 | 72 | { |
73 | - if (static::FILLABLE === '*') { |
|
73 | + if (static::FILLABLE === '*') |
|
74 | + { |
|
74 | 75 | return true; |
75 | 76 | } |
76 | 77 | |
77 | - if (!empty(static::FILLABLE)) { |
|
78 | + if (!empty(static::FILLABLE)) |
|
79 | + { |
|
78 | 80 | return \in_array($field, static::FILLABLE, true); |
79 | 81 | } |
80 | 82 | |
81 | - if (static::SECURED === '*') { |
|
83 | + if (static::SECURED === '*') |
|
84 | + { |
|
82 | 85 | return false; |
83 | 86 | } |
84 | 87 | |
@@ -96,7 +99,8 @@ discard block |
||
96 | 99 | protected function getMutator(string $field, string $type) |
97 | 100 | { |
98 | 101 | $target = []; |
99 | - switch ($type) { |
|
102 | + switch ($type) |
|
103 | + { |
|
100 | 104 | case ModelSchema::MUTATOR_ACCESSOR: |
101 | 105 | $target = static::ACCESSORS; |
102 | 106 | break; |
@@ -108,7 +112,8 @@ discard block |
||
108 | 112 | break; |
109 | 113 | } |
110 | 114 | |
111 | - if (isset($target[$field])) { |
|
115 | + if (isset($target[$field])) |
|
116 | + { |
|
112 | 117 | return $target[$field]; |
113 | 118 | } |
114 | 119 |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function __construct(string $pattern, $target, array $defaults = []) |
61 | 61 | { |
62 | - if ($target instanceof TargetInterface) { |
|
62 | + if ($target instanceof TargetInterface){ |
|
63 | 63 | parent::__construct($pattern, array_merge($target->getDefaults(), $defaults)); |
64 | - } else { |
|
64 | + }else{ |
|
65 | 65 | parent::__construct($pattern, $defaults); |
66 | 66 | } |
67 | 67 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public function withUriHandler(UriHandler $uriHandler): RouteInterface |
72 | 72 | { |
73 | 73 | $route = parent::withUriHandler($uriHandler); |
74 | - if ($this->target instanceof TargetInterface) { |
|
74 | + if ($this->target instanceof TargetInterface){ |
|
75 | 75 | $route->uriHandler = $route->uriHandler->withConstrains( |
76 | 76 | $this->target->getConstrains(), |
77 | 77 | $this->defaults |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $route = clone $this; |
92 | 92 | $route->container = $container; |
93 | 93 | |
94 | - if ($route->target instanceof TargetInterface) { |
|
94 | + if ($route->target instanceof TargetInterface){ |
|
95 | 95 | $route->target = clone $route->target; |
96 | 96 | } |
97 | 97 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function handle(ServerRequestInterface $request): ResponseInterface |
108 | 108 | { |
109 | - if (empty($this->requestHandler)) { |
|
109 | + if (empty($this->requestHandler)){ |
|
110 | 110 | $this->requestHandler = $this->requestHandler(); |
111 | 111 | } |
112 | 112 | |
@@ -121,30 +121,30 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function requestHandler(): RequestHandlerInterface |
123 | 123 | { |
124 | - if (!$this->hasContainer()) { |
|
124 | + if (!$this->hasContainer()){ |
|
125 | 125 | throw new RouteException('Unable to configure route pipeline without associated container'); |
126 | 126 | } |
127 | 127 | |
128 | - if ($this->target instanceof TargetInterface) { |
|
129 | - try { |
|
128 | + if ($this->target instanceof TargetInterface){ |
|
129 | + try{ |
|
130 | 130 | return $this->target->getHandler($this->container, $this->matches); |
131 | - } catch (TargetException $e) { |
|
131 | + }catch (TargetException $e){ |
|
132 | 132 | throw new RouteException('Invalid target resolution', $e->getCode(), $e); |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | - if ($this->target instanceof RequestHandlerInterface) { |
|
136 | + if ($this->target instanceof RequestHandlerInterface){ |
|
137 | 137 | return $this->target; |
138 | 138 | } |
139 | 139 | |
140 | - try { |
|
141 | - if (is_object($this->target) || is_array($this->target)) { |
|
140 | + try{ |
|
141 | + if (is_object($this->target) || is_array($this->target)){ |
|
142 | 142 | $target = $this->target; |
143 | - } else { |
|
143 | + }else{ |
|
144 | 144 | $target = $this->container->get($this->target); |
145 | 145 | } |
146 | 146 | |
147 | - if ($target instanceof RequestHandlerInterface) { |
|
147 | + if ($target instanceof RequestHandlerInterface){ |
|
148 | 148 | return $target; |
149 | 149 | } |
150 | 150 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $target, |
153 | 153 | $this->container->get(ResponseFactoryInterface::class) |
154 | 154 | ); |
155 | - } catch (ContainerExceptionInterface $e) { |
|
155 | + }catch (ContainerExceptionInterface $e){ |
|
156 | 156 | throw new RouteException($e->getMessage(), $e->getCode(), $e); |
157 | 157 | } |
158 | 158 | } |
@@ -59,9 +59,12 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function __construct(string $pattern, $target, array $defaults = []) |
61 | 61 | { |
62 | - if ($target instanceof TargetInterface) { |
|
62 | + if ($target instanceof TargetInterface) |
|
63 | + { |
|
63 | 64 | parent::__construct($pattern, array_merge($target->getDefaults(), $defaults)); |
64 | - } else { |
|
65 | + } |
|
66 | + else |
|
67 | + { |
|
65 | 68 | parent::__construct($pattern, $defaults); |
66 | 69 | } |
67 | 70 | |
@@ -71,7 +74,8 @@ discard block |
||
71 | 74 | public function withUriHandler(UriHandler $uriHandler): RouteInterface |
72 | 75 | { |
73 | 76 | $route = parent::withUriHandler($uriHandler); |
74 | - if ($this->target instanceof TargetInterface) { |
|
77 | + if ($this->target instanceof TargetInterface) |
|
78 | + { |
|
75 | 79 | $route->uriHandler = $route->uriHandler->withConstrains( |
76 | 80 | $this->target->getConstrains(), |
77 | 81 | $this->defaults |
@@ -91,7 +95,8 @@ discard block |
||
91 | 95 | $route = clone $this; |
92 | 96 | $route->container = $container; |
93 | 97 | |
94 | - if ($route->target instanceof TargetInterface) { |
|
98 | + if ($route->target instanceof TargetInterface) |
|
99 | + { |
|
95 | 100 | $route->target = clone $route->target; |
96 | 101 | } |
97 | 102 | |
@@ -106,7 +111,8 @@ discard block |
||
106 | 111 | */ |
107 | 112 | public function handle(ServerRequestInterface $request): ResponseInterface |
108 | 113 | { |
109 | - if (empty($this->requestHandler)) { |
|
114 | + if (empty($this->requestHandler)) |
|
115 | + { |
|
110 | 116 | $this->requestHandler = $this->requestHandler(); |
111 | 117 | } |
112 | 118 | |
@@ -121,30 +127,41 @@ discard block |
||
121 | 127 | */ |
122 | 128 | protected function requestHandler(): RequestHandlerInterface |
123 | 129 | { |
124 | - if (!$this->hasContainer()) { |
|
130 | + if (!$this->hasContainer()) |
|
131 | + { |
|
125 | 132 | throw new RouteException('Unable to configure route pipeline without associated container'); |
126 | 133 | } |
127 | 134 | |
128 | - if ($this->target instanceof TargetInterface) { |
|
129 | - try { |
|
135 | + if ($this->target instanceof TargetInterface) |
|
136 | + { |
|
137 | + try |
|
138 | + { |
|
130 | 139 | return $this->target->getHandler($this->container, $this->matches); |
131 | - } catch (TargetException $e) { |
|
140 | + } |
|
141 | + catch (TargetException $e) |
|
142 | + { |
|
132 | 143 | throw new RouteException('Invalid target resolution', $e->getCode(), $e); |
133 | 144 | } |
134 | 145 | } |
135 | 146 | |
136 | - if ($this->target instanceof RequestHandlerInterface) { |
|
147 | + if ($this->target instanceof RequestHandlerInterface) |
|
148 | + { |
|
137 | 149 | return $this->target; |
138 | 150 | } |
139 | 151 | |
140 | - try { |
|
141 | - if (is_object($this->target) || is_array($this->target)) { |
|
152 | + try |
|
153 | + { |
|
154 | + if (is_object($this->target) || is_array($this->target)) |
|
155 | + { |
|
142 | 156 | $target = $this->target; |
143 | - } else { |
|
157 | + } |
|
158 | + else |
|
159 | + { |
|
144 | 160 | $target = $this->container->get($this->target); |
145 | 161 | } |
146 | 162 | |
147 | - if ($target instanceof RequestHandlerInterface) { |
|
163 | + if ($target instanceof RequestHandlerInterface) |
|
164 | + { |
|
148 | 165 | return $target; |
149 | 166 | } |
150 | 167 | |
@@ -152,7 +169,9 @@ discard block |
||
152 | 169 | $target, |
153 | 170 | $this->container->get(ResponseFactoryInterface::class) |
154 | 171 | ); |
155 | - } catch (ContainerExceptionInterface $e) { |
|
172 | + } |
|
173 | + catch (ContainerExceptionInterface $e) |
|
174 | + { |
|
156 | 175 | throw new RouteException($e->getMessage(), $e->getCode(), $e); |
157 | 176 | } |
158 | 177 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | |
92 | 92 | protected function coreHandler(ContainerInterface $container): CoreHandler |
93 | 93 | { |
94 | - if ($this->handler !== null) { |
|
94 | + if ($this->handler !== null){ |
|
95 | 95 | return $this->handler; |
96 | 96 | } |
97 | 97 | |
98 | - try { |
|
98 | + try{ |
|
99 | 99 | // construct on demand |
100 | 100 | $this->handler = new CoreHandler( |
101 | 101 | $this->core ?? $container->get(CoreInterface::class), |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | ); |
105 | 105 | |
106 | 106 | return $this->handler; |
107 | - } catch (ContainerExceptionInterface $e) { |
|
107 | + }catch (ContainerExceptionInterface $e){ |
|
108 | 108 | throw new TargetException($e->getMessage(), $e->getCode(), $e); |
109 | 109 | } |
110 | 110 | } |
@@ -91,11 +91,13 @@ discard block |
||
91 | 91 | |
92 | 92 | protected function coreHandler(ContainerInterface $container): CoreHandler |
93 | 93 | { |
94 | - if ($this->handler !== null) { |
|
94 | + if ($this->handler !== null) |
|
95 | + { |
|
95 | 96 | return $this->handler; |
96 | 97 | } |
97 | 98 | |
98 | - try { |
|
99 | + try |
|
100 | + { |
|
99 | 101 | // construct on demand |
100 | 102 | $this->handler = new CoreHandler( |
101 | 103 | $this->core ?? $container->get(CoreInterface::class), |
@@ -104,7 +106,9 @@ discard block |
||
104 | 106 | ); |
105 | 107 | |
106 | 108 | return $this->handler; |
107 | - } catch (ContainerExceptionInterface $e) { |
|
109 | + } |
|
110 | + catch (ContainerExceptionInterface $e) |
|
111 | + { |
|
108 | 112 | throw new TargetException($e->getMessage(), $e->getCode(), $e); |
109 | 113 | } |
110 | 114 | } |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | AnnotationRegistry::registerLoader('class_exists'); |
61 | 61 | |
62 | 62 | $schema = $this->memory->loadData(self::MEMORY_SECTION); |
63 | - if (empty($schema) || !$cached) { |
|
63 | + if (empty($schema) || !$cached){ |
|
64 | 64 | $schema = $locator->findDeclarations(); |
65 | 65 | $this->memory->saveData(self::MEMORY_SECTION, $schema); |
66 | 66 | } |
67 | 67 | |
68 | 68 | $this->configureRoutes($schema); |
69 | 69 | |
70 | - foreach ($this->groups as $group) { |
|
70 | + foreach ($this->groups as $group){ |
|
71 | 71 | $group->flushRoutes(); |
72 | 72 | } |
73 | 73 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | private function configureRoutes(array $routes): void |
81 | 81 | { |
82 | - foreach ($routes as $name => $schema) { |
|
82 | + foreach ($routes as $name => $schema){ |
|
83 | 83 | $this->groups |
84 | 84 | ->getGroup($schema['group']) |
85 | 85 | ->registerRoute( |
@@ -60,14 +60,16 @@ discard block |
||
60 | 60 | AnnotationRegistry::registerLoader('class_exists'); |
61 | 61 | |
62 | 62 | $schema = $this->memory->loadData(self::MEMORY_SECTION); |
63 | - if (empty($schema) || !$cached) { |
|
63 | + if (empty($schema) || !$cached) |
|
64 | + { |
|
64 | 65 | $schema = $locator->findDeclarations(); |
65 | 66 | $this->memory->saveData(self::MEMORY_SECTION, $schema); |
66 | 67 | } |
67 | 68 | |
68 | 69 | $this->configureRoutes($schema); |
69 | 70 | |
70 | - foreach ($this->groups as $group) { |
|
71 | + foreach ($this->groups as $group) |
|
72 | + { |
|
71 | 73 | $group->flushRoutes(); |
72 | 74 | } |
73 | 75 | } |
@@ -79,7 +81,8 @@ discard block |
||
79 | 81 | |
80 | 82 | private function configureRoutes(array $routes): void |
81 | 83 | { |
82 | - foreach ($routes as $name => $schema) { |
|
84 | + foreach ($routes as $name => $schema) |
|
85 | + { |
|
83 | 86 | $this->groups |
84 | 87 | ->getGroup($schema['group']) |
85 | 88 | ->registerRoute( |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | { |
26 | 26 | $result = ''; |
27 | 27 | |
28 | - $result .= '[' . get_class($e) . "]\n" . $e->getMessage(); |
|
28 | + $result .= '['.get_class($e)."]\n".$e->getMessage(); |
|
29 | 29 | |
30 | 30 | $result .= sprintf(" in %s:%s\n", $e->getFile(), $e->getLine()); |
31 | 31 | |
32 | - if ($verbosity >= self::VERBOSITY_DEBUG) { |
|
32 | + if ($verbosity >= self::VERBOSITY_DEBUG){ |
|
33 | 33 | $result .= $this->renderTrace($e, new Highlighter(new PlainStyle())); |
34 | - } elseif ($verbosity >= self::VERBOSITY_VERBOSE) { |
|
34 | + } elseif ($verbosity >= self::VERBOSITY_VERBOSE){ |
|
35 | 35 | $result .= $this->renderTrace($e); |
36 | 36 | } |
37 | 37 | |
@@ -46,38 +46,38 @@ discard block |
||
46 | 46 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
47 | 47 | { |
48 | 48 | $stacktrace = $this->getStacktrace($e); |
49 | - if (empty($stacktrace)) { |
|
49 | + if (empty($stacktrace)){ |
|
50 | 50 | return ''; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $result = "\nException Trace:\n"; |
54 | 54 | |
55 | - foreach ($stacktrace as $trace) { |
|
56 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
55 | + foreach ($stacktrace as $trace){ |
|
56 | + if (isset($trace['type']) && isset($trace['class'])){ |
|
57 | 57 | $line = sprintf( |
58 | 58 | ' %s%s%s()', |
59 | 59 | $trace['class'], |
60 | 60 | $trace['type'], |
61 | 61 | $trace['function'] |
62 | 62 | ); |
63 | - } else { |
|
63 | + }else{ |
|
64 | 64 | $line = $trace['function']; |
65 | 65 | } |
66 | 66 | |
67 | - if (isset($trace['file'])) { |
|
67 | + if (isset($trace['file'])){ |
|
68 | 68 | $line .= sprintf(' at %s:%s', $trace['file'], $trace['line']); |
69 | - } else { |
|
69 | + }else{ |
|
70 | 70 | $line .= sprintf(' at %s:%s', 'n/a', 'n/a'); |
71 | 71 | } |
72 | 72 | |
73 | - $result .= $line . "\n"; |
|
73 | + $result .= $line."\n"; |
|
74 | 74 | |
75 | - if (!empty($h) && !empty($trace['file'])) { |
|
75 | + if (!empty($h) && !empty($trace['file'])){ |
|
76 | 76 | $result .= $h->highlightLines( |
77 | 77 | file_get_contents($trace['file']), |
78 | 78 | $trace['line'], |
79 | 79 | static::SHOW_LINES |
80 | - ) . "\n"; |
|
80 | + )."\n"; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 |
@@ -29,9 +29,12 @@ discard block |
||
29 | 29 | |
30 | 30 | $result .= sprintf(" in %s:%s\n", $e->getFile(), $e->getLine()); |
31 | 31 | |
32 | - if ($verbosity >= self::VERBOSITY_DEBUG) { |
|
32 | + if ($verbosity >= self::VERBOSITY_DEBUG) |
|
33 | + { |
|
33 | 34 | $result .= $this->renderTrace($e, new Highlighter(new PlainStyle())); |
34 | - } elseif ($verbosity >= self::VERBOSITY_VERBOSE) { |
|
35 | + } |
|
36 | + elseif ($verbosity >= self::VERBOSITY_VERBOSE) |
|
37 | + { |
|
35 | 38 | $result .= $this->renderTrace($e); |
36 | 39 | } |
37 | 40 | |
@@ -46,33 +49,42 @@ discard block |
||
46 | 49 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
47 | 50 | { |
48 | 51 | $stacktrace = $this->getStacktrace($e); |
49 | - if (empty($stacktrace)) { |
|
52 | + if (empty($stacktrace)) |
|
53 | + { |
|
50 | 54 | return ''; |
51 | 55 | } |
52 | 56 | |
53 | 57 | $result = "\nException Trace:\n"; |
54 | 58 | |
55 | - foreach ($stacktrace as $trace) { |
|
56 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
59 | + foreach ($stacktrace as $trace) |
|
60 | + { |
|
61 | + if (isset($trace['type']) && isset($trace['class'])) |
|
62 | + { |
|
57 | 63 | $line = sprintf( |
58 | 64 | ' %s%s%s()', |
59 | 65 | $trace['class'], |
60 | 66 | $trace['type'], |
61 | 67 | $trace['function'] |
62 | 68 | ); |
63 | - } else { |
|
69 | + } |
|
70 | + else |
|
71 | + { |
|
64 | 72 | $line = $trace['function']; |
65 | 73 | } |
66 | 74 | |
67 | - if (isset($trace['file'])) { |
|
75 | + if (isset($trace['file'])) |
|
76 | + { |
|
68 | 77 | $line .= sprintf(' at %s:%s', $trace['file'], $trace['line']); |
69 | - } else { |
|
78 | + } |
|
79 | + else |
|
80 | + { |
|
70 | 81 | $line .= sprintf(' at %s:%s', 'n/a', 'n/a'); |
71 | 82 | } |
72 | 83 | |
73 | 84 | $result .= $line . "\n"; |
74 | 85 | |
75 | - if (!empty($h) && !empty($trace['file'])) { |
|
86 | + if (!empty($h) && !empty($trace['file'])) |
|
87 | + { |
|
76 | 88 | $result .= $h->highlightLines( |
77 | 89 | file_get_contents($trace['file']), |
78 | 90 | $trace['line'], |
@@ -29,24 +29,24 @@ |
||
29 | 29 | |
30 | 30 | private function renderTrace(array $trace, int $verbosity): \Generator |
31 | 31 | { |
32 | - foreach ($trace as $item) { |
|
32 | + foreach ($trace as $item){ |
|
33 | 33 | $result = []; |
34 | 34 | |
35 | - if (isset($item['class'])) { |
|
35 | + if (isset($item['class'])){ |
|
36 | 36 | $result['function'] = sprintf( |
37 | 37 | '%s%s%s()', |
38 | 38 | $item['class'], |
39 | 39 | $item['type'], |
40 | 40 | $item['function'] |
41 | 41 | ); |
42 | - } else { |
|
42 | + }else{ |
|
43 | 43 | $result['function'] = sprintf( |
44 | 44 | '%s()', |
45 | 45 | $item['function'] |
46 | 46 | ); |
47 | 47 | } |
48 | 48 | |
49 | - if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])) { |
|
49 | + if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])){ |
|
50 | 50 | $result['at'] = [ |
51 | 51 | 'file' => $item['file'] ?? null, |
52 | 52 | 'line' => $item['line'] ?? null, |
@@ -29,24 +29,29 @@ |
||
29 | 29 | |
30 | 30 | private function renderTrace(array $trace, int $verbosity): \Generator |
31 | 31 | { |
32 | - foreach ($trace as $item) { |
|
32 | + foreach ($trace as $item) |
|
33 | + { |
|
33 | 34 | $result = []; |
34 | 35 | |
35 | - if (isset($item['class'])) { |
|
36 | + if (isset($item['class'])) |
|
37 | + { |
|
36 | 38 | $result['function'] = sprintf( |
37 | 39 | '%s%s%s()', |
38 | 40 | $item['class'], |
39 | 41 | $item['type'], |
40 | 42 | $item['function'] |
41 | 43 | ); |
42 | - } else { |
|
44 | + } |
|
45 | + else |
|
46 | + { |
|
43 | 47 | $result['function'] = sprintf( |
44 | 48 | '%s()', |
45 | 49 | $item['function'] |
46 | 50 | ); |
47 | 51 | } |
48 | 52 | |
49 | - if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])) { |
|
53 | + if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])) |
|
54 | + { |
|
50 | 55 | $result['at'] = [ |
51 | 56 | 'file' => $item['file'] ?? null, |
52 | 57 | 'line' => $item['line'] ?? null, |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function has(string $name): bool |
73 | 73 | { |
74 | - foreach ($this->elements as $element) { |
|
75 | - if ($element instanceof NamedInterface && $element->getName() === $name) { |
|
74 | + foreach ($this->elements as $element){ |
|
75 | + if ($element instanceof NamedInterface && $element->getName() === $name){ |
|
76 | 76 | return true; |
77 | 77 | } |
78 | 78 | } |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | $reflector = new ReflectionObject($element); |
91 | 91 | |
92 | 92 | $allowed = false; |
93 | - foreach ($this->allowed as $class) { |
|
94 | - if ($reflector->isSubclassOf($class) || get_class($element) === $class) { |
|
93 | + foreach ($this->allowed as $class){ |
|
94 | + if ($reflector->isSubclassOf($class) || get_class($element) === $class){ |
|
95 | 95 | $allowed = true; |
96 | 96 | break; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if (!$allowed) { |
|
100 | + if (!$allowed){ |
|
101 | 101 | $type = get_class($element); |
102 | 102 | throw new ReactorException("Elements with type '{$type}' are not allowed"); |
103 | 103 | } |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function remove(string $name): self |
125 | 125 | { |
126 | - foreach ($this->elements as $index => $element) { |
|
127 | - if ($element instanceof NamedInterface && $element->getName() === $name) { |
|
126 | + foreach ($this->elements as $index => $element){ |
|
127 | + if ($element instanceof NamedInterface && $element->getName() === $name){ |
|
128 | 128 | unset($this->elements[$index]); |
129 | 129 | } |
130 | 130 | } |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function replace($search, $replace): Aggregator |
180 | 180 | { |
181 | - foreach ($this->elements as $element) { |
|
182 | - if ($element instanceof ReplaceableInterface) { |
|
181 | + foreach ($this->elements as $element){ |
|
182 | + if ($element instanceof ReplaceableInterface){ |
|
183 | 183 | $element->replace($search, $replace); |
184 | 184 | } |
185 | 185 | } |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | { |
195 | 195 | $result = ''; |
196 | 196 | |
197 | - foreach ($this->elements as $element) { |
|
198 | - $result .= $element->render($indentLevel) . "\n\n"; |
|
197 | + foreach ($this->elements as $element){ |
|
198 | + $result .= $element->render($indentLevel)."\n\n"; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return rtrim($result, "\n"); |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | */ |
209 | 209 | protected function find(string $name): DeclarationInterface |
210 | 210 | { |
211 | - foreach ($this->elements as $element) { |
|
212 | - if ($element instanceof NamedInterface && $element->getName() === $name) { |
|
211 | + foreach ($this->elements as $element){ |
|
212 | + if ($element instanceof NamedInterface && $element->getName() === $name){ |
|
213 | 213 | return $element; |
214 | 214 | } |
215 | 215 | } |
@@ -71,8 +71,10 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function has(string $name): bool |
73 | 73 | { |
74 | - foreach ($this->elements as $element) { |
|
75 | - if ($element instanceof NamedInterface && $element->getName() === $name) { |
|
74 | + foreach ($this->elements as $element) |
|
75 | + { |
|
76 | + if ($element instanceof NamedInterface && $element->getName() === $name) |
|
77 | + { |
|
76 | 78 | return true; |
77 | 79 | } |
78 | 80 | } |
@@ -90,14 +92,17 @@ discard block |
||
90 | 92 | $reflector = new ReflectionObject($element); |
91 | 93 | |
92 | 94 | $allowed = false; |
93 | - foreach ($this->allowed as $class) { |
|
94 | - if ($reflector->isSubclassOf($class) || get_class($element) === $class) { |
|
95 | + foreach ($this->allowed as $class) |
|
96 | + { |
|
97 | + if ($reflector->isSubclassOf($class) || get_class($element) === $class) |
|
98 | + { |
|
95 | 99 | $allowed = true; |
96 | 100 | break; |
97 | 101 | } |
98 | 102 | } |
99 | 103 | |
100 | - if (!$allowed) { |
|
104 | + if (!$allowed) |
|
105 | + { |
|
101 | 106 | $type = get_class($element); |
102 | 107 | throw new ReactorException("Elements with type '{$type}' are not allowed"); |
103 | 108 | } |
@@ -123,8 +128,10 @@ discard block |
||
123 | 128 | */ |
124 | 129 | public function remove(string $name): self |
125 | 130 | { |
126 | - foreach ($this->elements as $index => $element) { |
|
127 | - if ($element instanceof NamedInterface && $element->getName() === $name) { |
|
131 | + foreach ($this->elements as $index => $element) |
|
132 | + { |
|
133 | + if ($element instanceof NamedInterface && $element->getName() === $name) |
|
134 | + { |
|
128 | 135 | unset($this->elements[$index]); |
129 | 136 | } |
130 | 137 | } |
@@ -178,8 +185,10 @@ discard block |
||
178 | 185 | */ |
179 | 186 | public function replace($search, $replace): Aggregator |
180 | 187 | { |
181 | - foreach ($this->elements as $element) { |
|
182 | - if ($element instanceof ReplaceableInterface) { |
|
188 | + foreach ($this->elements as $element) |
|
189 | + { |
|
190 | + if ($element instanceof ReplaceableInterface) |
|
191 | + { |
|
183 | 192 | $element->replace($search, $replace); |
184 | 193 | } |
185 | 194 | } |
@@ -194,7 +203,8 @@ discard block |
||
194 | 203 | { |
195 | 204 | $result = ''; |
196 | 205 | |
197 | - foreach ($this->elements as $element) { |
|
206 | + foreach ($this->elements as $element) |
|
207 | + { |
|
198 | 208 | $result .= $element->render($indentLevel) . "\n\n"; |
199 | 209 | } |
200 | 210 | |
@@ -208,8 +218,10 @@ discard block |
||
208 | 218 | */ |
209 | 219 | protected function find(string $name): DeclarationInterface |
210 | 220 | { |
211 | - foreach ($this->elements as $element) { |
|
212 | - if ($element instanceof NamedInterface && $element->getName() === $name) { |
|
221 | + foreach ($this->elements as $element) |
|
222 | + { |
|
223 | + if ($element instanceof NamedInterface && $element->getName() === $name) |
|
224 | + { |
|
213 | 225 | return $element; |
214 | 226 | } |
215 | 227 | } |
@@ -25,6 +25,6 @@ |
||
25 | 25 | |
26 | 26 | protected function addIndent(string $string, int $indent = 0): string |
27 | 27 | { |
28 | - return str_repeat(self::INDENT, max($indent, 0)) . $string; |
|
28 | + return str_repeat(self::INDENT, max($indent, 0)).$string; |
|
29 | 29 | } |
30 | 30 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | private function decorateByAnnotations(ReaderInterface $reader): ReaderInterface |
53 | 53 | { |
54 | - if (\interface_exists(DoctrineReaderInterface::class)) { |
|
54 | + if (\interface_exists(DoctrineReaderInterface::class)){ |
|
55 | 55 | $doctrine = new AnnotationReader(new DoctrineAnnotationReader()); |
56 | 56 | |
57 | 57 | $reader = new SelectiveReader([$reader, $doctrine]); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | private function decorateByCache(ReaderInterface $reader): ReaderInterface |
64 | 64 | { |
65 | - switch (true) { |
|
65 | + switch (true){ |
|
66 | 66 | case $this->cache instanceof CacheInterface: |
67 | 67 | return new Psr16CachedReader($reader, $this->cache); |
68 | 68 |
@@ -51,7 +51,8 @@ discard block |
||
51 | 51 | |
52 | 52 | private function decorateByAnnotations(ReaderInterface $reader): ReaderInterface |
53 | 53 | { |
54 | - if (\interface_exists(DoctrineReaderInterface::class)) { |
|
54 | + if (\interface_exists(DoctrineReaderInterface::class)) |
|
55 | + { |
|
55 | 56 | $doctrine = new AnnotationReader(new DoctrineAnnotationReader()); |
56 | 57 | |
57 | 58 | $reader = new SelectiveReader([$reader, $doctrine]); |
@@ -62,7 +63,8 @@ discard block |
||
62 | 63 | |
63 | 64 | private function decorateByCache(ReaderInterface $reader): ReaderInterface |
64 | 65 | { |
65 | - switch (true) { |
|
66 | + switch (true) |
|
67 | + { |
|
66 | 68 | case $this->cache instanceof CacheInterface: |
67 | 69 | return new Psr16CachedReader($reader, $this->cache); |
68 | 70 |