@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function leaveNode(Node $node) |
42 | 42 | { |
43 | - if (!$node instanceof Node\Stmt\Class_) { |
|
43 | + if (!$node instanceof Node\Stmt\Class_){ |
|
44 | 44 | return null; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $nodes = []; |
48 | - foreach ($this->definition->dependencies as $dependency) { |
|
48 | + foreach ($this->definition->dependencies as $dependency){ |
|
49 | 49 | $nodes[] = $this->buildProperty($dependency); |
50 | 50 | } |
51 | 51 | |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | |
58 | 58 | private function definePlacementID(Node\Stmt\Class_ $node): int |
59 | 59 | { |
60 | - foreach ($node->stmts as $index => $child) { |
|
61 | - if ($child instanceof Node\Stmt\ClassMethod || $child instanceof Node\Stmt\Property) { |
|
60 | + foreach ($node->stmts as $index => $child){ |
|
61 | + if ($child instanceof Node\Stmt\ClassMethod || $child instanceof Node\Stmt\Property){ |
|
62 | 62 | return $index; |
63 | 63 | } |
64 | 64 | } |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | $b = new Property($dependency->property); |
72 | 72 | $b->makePrivate(); |
73 | 73 | |
74 | - if ($this->useTypedProperty()) { |
|
74 | + if ($this->useTypedProperty()){ |
|
75 | 75 | $b->setType($this->getPropertyType($dependency)); |
76 | 76 | } |
77 | 77 | |
78 | - if ($this->renderDoc()) { |
|
78 | + if ($this->renderDoc()){ |
|
79 | 79 | $b->setDocComment(new Doc(sprintf('/** @var %s */', $this->getPropertyType($dependency)))); |
80 | 80 | } |
81 | 81 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | |
95 | 95 | private function getPropertyType(Dependency $dependency): string |
96 | 96 | { |
97 | - foreach ($this->definition->getStmts() as $stmt) { |
|
98 | - if (($stmt->name === $dependency->type->fullName) && $stmt->alias) { |
|
97 | + foreach ($this->definition->getStmts() as $stmt){ |
|
98 | + if (($stmt->name === $dependency->type->fullName) && $stmt->alias){ |
|
99 | 99 | return $stmt->alias; |
100 | 100 | } |
101 | 101 | } |
@@ -40,12 +40,14 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function leaveNode(Node $node) |
42 | 42 | { |
43 | - if (!$node instanceof Node\Stmt\Class_) { |
|
43 | + if (!$node instanceof Node\Stmt\Class_) |
|
44 | + { |
|
44 | 45 | return null; |
45 | 46 | } |
46 | 47 | |
47 | 48 | $nodes = []; |
48 | - foreach ($this->definition->dependencies as $dependency) { |
|
49 | + foreach ($this->definition->dependencies as $dependency) |
|
50 | + { |
|
49 | 51 | $nodes[] = $this->buildProperty($dependency); |
50 | 52 | } |
51 | 53 | |
@@ -57,8 +59,10 @@ discard block |
||
57 | 59 | |
58 | 60 | private function definePlacementID(Node\Stmt\Class_ $node): int |
59 | 61 | { |
60 | - foreach ($node->stmts as $index => $child) { |
|
61 | - if ($child instanceof Node\Stmt\ClassMethod || $child instanceof Node\Stmt\Property) { |
|
62 | + foreach ($node->stmts as $index => $child) |
|
63 | + { |
|
64 | + if ($child instanceof Node\Stmt\ClassMethod || $child instanceof Node\Stmt\Property) |
|
65 | + { |
|
62 | 66 | return $index; |
63 | 67 | } |
64 | 68 | } |
@@ -71,11 +75,13 @@ discard block |
||
71 | 75 | $b = new Property($dependency->property); |
72 | 76 | $b->makePrivate(); |
73 | 77 | |
74 | - if ($this->useTypedProperty()) { |
|
78 | + if ($this->useTypedProperty()) |
|
79 | + { |
|
75 | 80 | $b->setType($this->getPropertyType($dependency)); |
76 | 81 | } |
77 | 82 | |
78 | - if ($this->renderDoc()) { |
|
83 | + if ($this->renderDoc()) |
|
84 | + { |
|
79 | 85 | $b->setDocComment(new Doc(sprintf('/** @var %s */', $this->getPropertyType($dependency)))); |
80 | 86 | } |
81 | 87 | |
@@ -94,8 +100,10 @@ discard block |
||
94 | 100 | |
95 | 101 | private function getPropertyType(Dependency $dependency): string |
96 | 102 | { |
97 | - foreach ($this->definition->getStmts() as $stmt) { |
|
98 | - if (($stmt->name === $dependency->type->fullName) && $stmt->alias) { |
|
103 | + foreach ($this->definition->getStmts() as $stmt) |
|
104 | + { |
|
105 | + if (($stmt->name === $dependency->type->fullName) && $stmt->alias) |
|
106 | + { |
|
99 | 107 | return $stmt->alias; |
100 | 108 | } |
101 | 109 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ConflictResolver\Names $namesResolver, |
40 | 40 | ConflictResolver\Namespaces $namespacesResolver, |
41 | 41 | Parser $parser = null |
42 | - ) { |
|
42 | + ){ |
|
43 | 43 | $this->namesResolver = $namesResolver; |
44 | 44 | $this->namespacesResolver = $namespacesResolver; |
45 | 45 | $this->parser = $parser ?? (new ParserFactory())->create(ParserFactory::ONLY_PHP7); |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | $declarator = new DeclareClass(); |
77 | 77 | $this->traverse($filename, $declarator); |
78 | 78 | |
79 | - if (empty($declarator->getClass())) { |
|
79 | + if (empty($declarator->getClass())){ |
|
80 | 80 | throw new ClassNotDeclaredException($filename); |
81 | 81 | } |
82 | 82 | |
83 | - if ($declarator->getNamespace()) { |
|
83 | + if ($declarator->getNamespace()){ |
|
84 | 84 | return ClassNode::createWithNamespace($declarator->getClass(), $declarator->getNamespace()); |
85 | 85 | } |
86 | 86 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $tr = new NodeTraverser(); |
93 | 93 | |
94 | - foreach ($visitors as $visitor) { |
|
94 | + foreach ($visitors as $visitor){ |
|
95 | 95 | $tr->addVisitor($visitor); |
96 | 96 | } |
97 | 97 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | private function fillStmts(ClassNode $definition, array $imports): void |
102 | 102 | { |
103 | - foreach ($imports as $import) { |
|
103 | + foreach ($imports as $import){ |
|
104 | 104 | $definition->addImportUsage($import['name'], $import['alias']); |
105 | 105 | } |
106 | 106 | } |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | $reflection = new \ReflectionClass("{$definition->namespace}\\{$definition->class}"); |
114 | 114 | |
115 | 115 | $constructor = $reflection->getConstructor(); |
116 | - if ($constructor !== null) { |
|
116 | + if ($constructor !== null){ |
|
117 | 117 | $definition->hasConstructor = $constructor->getDeclaringClass()->getName() === $reflection->getName(); |
118 | 118 | |
119 | - foreach ($reflection->getConstructor()->getParameters() as $parameter) { |
|
119 | + foreach ($reflection->getConstructor()->getParameters() as $parameter){ |
|
120 | 120 | $definition->addParam($parameter); |
121 | 121 | } |
122 | 122 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | */ |
129 | 129 | private function fillConstructorVars(array $vars, ClassNode $definition): void |
130 | 130 | { |
131 | - foreach ($vars as $k => $var) { |
|
132 | - if (isset($definition->constructorParams[$var])) { |
|
131 | + foreach ($vars as $k => $var){ |
|
132 | + if (isset($definition->constructorParams[$var])){ |
|
133 | 133 | unset($vars[$k]); |
134 | 134 | } |
135 | 135 | } |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | 'namespaces' => $config->getNamespaces(), |
41 | 41 | ]); |
42 | 42 | |
43 | - foreach ($this->config->getDependencies() as $dependency) { |
|
43 | + foreach ($this->config->getDependencies() as $dependency){ |
|
44 | 44 | $this->addDependency($dependency->resolve($factory)); |
45 | 45 | } |
46 | 46 | |
47 | - foreach ($this->config->getEngines() as $engine) { |
|
47 | + foreach ($this->config->getEngines() as $engine){ |
|
48 | 48 | $this->addEngine($engine->resolve($factory)); |
49 | 49 | } |
50 | 50 | |
51 | - if ($this->config->isCacheEnabled()) { |
|
51 | + if ($this->config->isCacheEnabled()){ |
|
52 | 52 | $this->cache = new ViewCache(); |
53 | 53 | } |
54 | 54 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $this->engines[] = $engine->withLoader($this->loader); |
75 | 75 | |
76 | - \uasort($this->engines, static function (EngineInterface $a, EngineInterface $b) { |
|
76 | + \uasort($this->engines, static function (EngineInterface $a, EngineInterface $b){ |
|
77 | 77 | return \strcmp($a->getLoader()->getExtension(), $b->getLoader()->getExtension()); |
78 | 78 | }); |
79 | 79 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function compile(string $path): void |
100 | 100 | { |
101 | - if ($this->cache !== null) { |
|
101 | + if ($this->cache !== null){ |
|
102 | 102 | $this->cache->resetPath($path); |
103 | 103 | } |
104 | 104 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | // Rotate all possible context variants and warm up cache |
108 | 108 | $generator = new ContextGenerator($this->context); |
109 | - foreach ($generator->generate() as $context) { |
|
109 | + foreach ($generator->generate() as $context){ |
|
110 | 110 | $engine->reset($path, $context); |
111 | 111 | $engine->compile($path, $context); |
112 | 112 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function reset(string $path): void |
119 | 119 | { |
120 | - if ($this->cache !== null) { |
|
120 | + if ($this->cache !== null){ |
|
121 | 121 | $this->cache->resetPath($path); |
122 | 122 | } |
123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | // Rotate all possible context variants and warm up cache |
127 | 127 | $generator = new ContextGenerator($this->context); |
128 | - foreach ($generator->generate() as $context) { |
|
128 | + foreach ($generator->generate() as $context){ |
|
129 | 129 | $engine->reset($path, $context); |
130 | 130 | } |
131 | 131 | } |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function get(string $path): ViewInterface |
140 | 140 | { |
141 | - if ($this->cache !== null && $this->cache->has($this->context, $path)) { |
|
141 | + if ($this->cache !== null && $this->cache->has($this->context, $path)){ |
|
142 | 142 | return $this->cache->get($this->context, $path); |
143 | 143 | } |
144 | 144 | |
145 | 145 | $view = $this->findEngine($path)->get($path, $this->context); |
146 | 146 | |
147 | - if ($this->cache !== null) { |
|
147 | + if ($this->cache !== null){ |
|
148 | 148 | $this->cache->set($this->context, $path, $view); |
149 | 149 | } |
150 | 150 | |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | */ |
167 | 167 | private function findEngine(string $path): EngineInterface |
168 | 168 | { |
169 | - foreach ($this->engines as $engine) { |
|
170 | - if ($engine->getLoader()->exists($path)) { |
|
169 | + foreach ($this->engines as $engine){ |
|
170 | + if ($engine->getLoader()->exists($path)){ |
|
171 | 171 | return $engine; |
172 | 172 | } |
173 | 173 | } |
@@ -40,15 +40,18 @@ discard block |
||
40 | 40 | 'namespaces' => $config->getNamespaces(), |
41 | 41 | ]); |
42 | 42 | |
43 | - foreach ($this->config->getDependencies() as $dependency) { |
|
43 | + foreach ($this->config->getDependencies() as $dependency) |
|
44 | + { |
|
44 | 45 | $this->addDependency($dependency->resolve($factory)); |
45 | 46 | } |
46 | 47 | |
47 | - foreach ($this->config->getEngines() as $engine) { |
|
48 | + foreach ($this->config->getEngines() as $engine) |
|
49 | + { |
|
48 | 50 | $this->addEngine($engine->resolve($factory)); |
49 | 51 | } |
50 | 52 | |
51 | - if ($this->config->isCacheEnabled()) { |
|
53 | + if ($this->config->isCacheEnabled()) |
|
54 | + { |
|
52 | 55 | $this->cache = new ViewCache(); |
53 | 56 | } |
54 | 57 | } |
@@ -73,7 +76,8 @@ discard block |
||
73 | 76 | { |
74 | 77 | $this->engines[] = $engine->withLoader($this->loader); |
75 | 78 | |
76 | - \uasort($this->engines, static function (EngineInterface $a, EngineInterface $b) { |
|
79 | + \uasort($this->engines, static function (EngineInterface $a, EngineInterface $b) |
|
80 | + { |
|
77 | 81 | return \strcmp($a->getLoader()->getExtension(), $b->getLoader()->getExtension()); |
78 | 82 | }); |
79 | 83 | |
@@ -98,7 +102,8 @@ discard block |
||
98 | 102 | */ |
99 | 103 | public function compile(string $path): void |
100 | 104 | { |
101 | - if ($this->cache !== null) { |
|
105 | + if ($this->cache !== null) |
|
106 | + { |
|
102 | 107 | $this->cache->resetPath($path); |
103 | 108 | } |
104 | 109 | |
@@ -106,7 +111,8 @@ discard block |
||
106 | 111 | |
107 | 112 | // Rotate all possible context variants and warm up cache |
108 | 113 | $generator = new ContextGenerator($this->context); |
109 | - foreach ($generator->generate() as $context) { |
|
114 | + foreach ($generator->generate() as $context) |
|
115 | + { |
|
110 | 116 | $engine->reset($path, $context); |
111 | 117 | $engine->compile($path, $context); |
112 | 118 | } |
@@ -117,7 +123,8 @@ discard block |
||
117 | 123 | */ |
118 | 124 | public function reset(string $path): void |
119 | 125 | { |
120 | - if ($this->cache !== null) { |
|
126 | + if ($this->cache !== null) |
|
127 | + { |
|
121 | 128 | $this->cache->resetPath($path); |
122 | 129 | } |
123 | 130 | |
@@ -125,7 +132,8 @@ discard block |
||
125 | 132 | |
126 | 133 | // Rotate all possible context variants and warm up cache |
127 | 134 | $generator = new ContextGenerator($this->context); |
128 | - foreach ($generator->generate() as $context) { |
|
135 | + foreach ($generator->generate() as $context) |
|
136 | + { |
|
129 | 137 | $engine->reset($path, $context); |
130 | 138 | } |
131 | 139 | } |
@@ -138,13 +146,15 @@ discard block |
||
138 | 146 | */ |
139 | 147 | public function get(string $path): ViewInterface |
140 | 148 | { |
141 | - if ($this->cache !== null && $this->cache->has($this->context, $path)) { |
|
149 | + if ($this->cache !== null && $this->cache->has($this->context, $path)) |
|
150 | + { |
|
142 | 151 | return $this->cache->get($this->context, $path); |
143 | 152 | } |
144 | 153 | |
145 | 154 | $view = $this->findEngine($path)->get($path, $this->context); |
146 | 155 | |
147 | - if ($this->cache !== null) { |
|
156 | + if ($this->cache !== null) |
|
157 | + { |
|
148 | 158 | $this->cache->set($this->context, $path, $view); |
149 | 159 | } |
150 | 160 | |
@@ -166,8 +176,10 @@ discard block |
||
166 | 176 | */ |
167 | 177 | private function findEngine(string $path): EngineInterface |
168 | 178 | { |
169 | - foreach ($this->engines as $engine) { |
|
170 | - if ($engine->getLoader()->exists($path)) { |
|
179 | + foreach ($this->engines as $engine) |
|
180 | + { |
|
181 | + if ($engine->getLoader()->exists($path)) |
|
182 | + { |
|
171 | 183 | return $engine; |
172 | 184 | } |
173 | 185 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Default coloring schema. |
23 | 23 | */ |
24 | - public const DEFAULT = [ |
|
24 | + public const default = [ |
|
25 | 25 | 'body' => '<pre style="background-color: white; font-family: monospace;">%s</pre>', |
26 | 26 | 'element' => '<span style="%s;">%s</span>', |
27 | 27 | 'indent' => '· ', |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @var array |
103 | 103 | */ |
104 | - protected $style = self::DEFAULT; |
|
104 | + protected $style = self::default; |
|
105 | 105 | |
106 | - public function __construct(array $style = self::DEFAULT) |
|
106 | + public function __construct(array $style = self::default) |
|
107 | 107 | { |
108 | 108 | $this->style = $style; |
109 | 109 | } |
@@ -66,7 +66,8 @@ discard block |
||
66 | 66 | $input = $input ?? new ArgvInput(); |
67 | 67 | $output = $output ?? new ConsoleOutput(); |
68 | 68 | |
69 | - return ContainerScope::runScope($this->container, function () use ($input, $output) { |
|
69 | + return ContainerScope::runScope($this->container, function () use ($input, $output) |
|
70 | + { |
|
70 | 71 | return $this->run( |
71 | 72 | $input->getFirstArgument() ?? 'list', |
72 | 73 | $input, |
@@ -95,11 +96,13 @@ discard block |
||
95 | 96 | |
96 | 97 | $this->configureIO($input, $output); |
97 | 98 | |
98 | - if ($command !== null) { |
|
99 | + if ($command !== null) |
|
100 | + { |
|
99 | 101 | $input = new InputProxy($input, ['firstArgument' => $command]); |
100 | 102 | } |
101 | 103 | |
102 | - $code = ContainerScope::runScope($this->container, function () use ($input, $output) { |
|
104 | + $code = ContainerScope::runScope($this->container, function () use ($input, $output) |
|
105 | + { |
|
103 | 106 | return $this->getApplication()->doRun($input, $output); |
104 | 107 | }); |
105 | 108 | |
@@ -114,7 +117,8 @@ discard block |
||
114 | 117 | */ |
115 | 118 | public function getApplication(): Application |
116 | 119 | { |
117 | - if ($this->application !== null) { |
|
120 | + if ($this->application !== null) |
|
121 | + { |
|
118 | 122 | return $this->application; |
119 | 123 | } |
120 | 124 | |
@@ -122,7 +126,8 @@ discard block |
||
122 | 126 | $this->application->setCatchExceptions(false); |
123 | 127 | $this->application->setAutoExit(false); |
124 | 128 | |
125 | - if ($this->locator !== null) { |
|
129 | + if ($this->locator !== null) |
|
130 | + { |
|
126 | 131 | $this->addCommands($this->locator->locateCommands()); |
127 | 132 | } |
128 | 133 | |
@@ -135,8 +140,10 @@ discard block |
||
135 | 140 | |
136 | 141 | private function addCommands(iterable $commands): void |
137 | 142 | { |
138 | - foreach ($commands as $command) { |
|
139 | - if ($command instanceof Command) { |
|
143 | + foreach ($commands as $command) |
|
144 | + { |
|
145 | + if ($command instanceof Command) |
|
146 | + { |
|
140 | 147 | $command->setContainer($this->container); |
141 | 148 | } |
142 | 149 | |
@@ -151,27 +158,36 @@ discard block |
||
151 | 158 | */ |
152 | 159 | private function configureIO(InputInterface $input, OutputInterface $output): void |
153 | 160 | { |
154 | - if (true === $input->hasParameterOption(['--ansi'], true)) { |
|
161 | + if (true === $input->hasParameterOption(['--ansi'], true)) |
|
162 | + { |
|
155 | 163 | $output->setDecorated(true); |
156 | - } elseif (true === $input->hasParameterOption(['--no-ansi'], true)) { |
|
164 | + } |
|
165 | + elseif (true === $input->hasParameterOption(['--no-ansi'], true)) |
|
166 | + { |
|
157 | 167 | $output->setDecorated(false); |
158 | 168 | } |
159 | 169 | |
160 | - if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) { |
|
170 | + if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) |
|
171 | + { |
|
161 | 172 | $input->setInteractive(false); |
162 | - } elseif (\function_exists('posix_isatty')) { |
|
173 | + } |
|
174 | + elseif (\function_exists('posix_isatty')) |
|
175 | + { |
|
163 | 176 | $inputStream = null; |
164 | 177 | |
165 | - if ($input instanceof StreamableInputInterface) { |
|
178 | + if ($input instanceof StreamableInputInterface) |
|
179 | + { |
|
166 | 180 | $inputStream = $input->getStream(); |
167 | 181 | } |
168 | 182 | |
169 | - if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) { |
|
183 | + if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) |
|
184 | + { |
|
170 | 185 | $input->setInteractive(false); |
171 | 186 | } |
172 | 187 | } |
173 | 188 | |
174 | - switch ($shellVerbosity = (int)getenv('SHELL_VERBOSITY')) { |
|
189 | + switch ($shellVerbosity = (int)getenv('SHELL_VERBOSITY')) |
|
190 | + { |
|
175 | 191 | case -1: |
176 | 192 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
177 | 193 | break; |
@@ -194,7 +210,9 @@ discard block |
||
194 | 210 | ) { |
195 | 211 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
196 | 212 | $shellVerbosity = -1; |
197 | - } else { |
|
213 | + } |
|
214 | + else |
|
215 | + { |
|
198 | 216 | if ( |
199 | 217 | $input->hasParameterOption('-vvv', true) |
200 | 218 | || $input->hasParameterOption('--verbose=3', true) |
@@ -202,14 +220,16 @@ discard block |
||
202 | 220 | ) { |
203 | 221 | $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); |
204 | 222 | $shellVerbosity = 3; |
205 | - } elseif ( |
|
223 | + } |
|
224 | + elseif ( |
|
206 | 225 | $input->hasParameterOption('-vv', true) |
207 | 226 | || $input->hasParameterOption('--verbose=2', true) |
208 | 227 | || 2 === $input->getParameterOption('--verbose', false, true) |
209 | 228 | ) { |
210 | 229 | $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); |
211 | 230 | $shellVerbosity = 2; |
212 | - } elseif ( |
|
231 | + } |
|
232 | + elseif ( |
|
213 | 233 | $input->hasParameterOption('-v', true) |
214 | 234 | || $input->hasParameterOption('--verbose=1', true) |
215 | 235 | || $input->hasParameterOption('--verbose', true) |
@@ -220,7 +240,8 @@ discard block |
||
220 | 240 | } |
221 | 241 | } |
222 | 242 | |
223 | - if (-1 === $shellVerbosity) { |
|
243 | + if (-1 === $shellVerbosity) |
|
244 | + { |
|
224 | 245 | $input->setInteractive(false); |
225 | 246 | } |
226 | 247 |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | |
61 | 61 | private function validateBoundaries(RangeValue\Boundary $from, RangeValue\Boundary $to): void |
62 | 62 | { |
63 | - if (!$this->acceptsBoundary($from) || !$this->acceptsBoundary($to)) { |
|
63 | + if (!$this->acceptsBoundary($from) || !$this->acceptsBoundary($to)){ |
|
64 | 64 | throw new ValueException('Range boundaries should be applicable via passed type.'); |
65 | 65 | } |
66 | 66 | |
67 | - if ($this->convertBoundaryValue($from) === $this->convertBoundaryValue($to)) { |
|
67 | + if ($this->convertBoundaryValue($from) === $this->convertBoundaryValue($to)){ |
|
68 | 68 | throw new ValueException('Range boundaries should be different.'); |
69 | 69 | } |
70 | 70 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | private function acceptsFrom($value): bool |
89 | 89 | { |
90 | - if ($this->from->empty) { |
|
90 | + if ($this->from->empty){ |
|
91 | 91 | return true; |
92 | 92 | } |
93 | 93 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | private function acceptsTo($value): bool |
103 | 103 | { |
104 | - if ($this->to->empty) { |
|
104 | + if ($this->to->empty){ |
|
105 | 105 | return true; |
106 | 106 | } |
107 | 107 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | private function setBoundaries(RangeValue\Boundary $from, RangeValue\Boundary $to): void |
114 | 114 | { |
115 | 115 | //Swap if from < to and both not empty |
116 | - if (!$from->empty && !$to->empty && $from->value > $to->value) { |
|
116 | + if (!$from->empty && !$to->empty && $from->value > $to->value){ |
|
117 | 117 | [$from, $to] = [$to, $from]; |
118 | 118 | } |
119 | 119 |
@@ -60,11 +60,13 @@ discard block |
||
60 | 60 | |
61 | 61 | private function validateBoundaries(RangeValue\Boundary $from, RangeValue\Boundary $to): void |
62 | 62 | { |
63 | - if (!$this->acceptsBoundary($from) || !$this->acceptsBoundary($to)) { |
|
63 | + if (!$this->acceptsBoundary($from) || !$this->acceptsBoundary($to)) |
|
64 | + { |
|
64 | 65 | throw new ValueException('Range boundaries should be applicable via passed type.'); |
65 | 66 | } |
66 | 67 | |
67 | - if ($this->convertBoundaryValue($from) === $this->convertBoundaryValue($to)) { |
|
68 | + if ($this->convertBoundaryValue($from) === $this->convertBoundaryValue($to)) |
|
69 | + { |
|
68 | 70 | throw new ValueException('Range boundaries should be different.'); |
69 | 71 | } |
70 | 72 | } |
@@ -87,7 +89,8 @@ discard block |
||
87 | 89 | */ |
88 | 90 | private function acceptsFrom($value): bool |
89 | 91 | { |
90 | - if ($this->from->empty) { |
|
92 | + if ($this->from->empty) |
|
93 | + { |
|
91 | 94 | return true; |
92 | 95 | } |
93 | 96 | |
@@ -101,7 +104,8 @@ discard block |
||
101 | 104 | */ |
102 | 105 | private function acceptsTo($value): bool |
103 | 106 | { |
104 | - if ($this->to->empty) { |
|
107 | + if ($this->to->empty) |
|
108 | + { |
|
105 | 109 | return true; |
106 | 110 | } |
107 | 111 | |
@@ -113,7 +117,8 @@ discard block |
||
113 | 117 | private function setBoundaries(RangeValue\Boundary $from, RangeValue\Boundary $to): void |
114 | 118 | { |
115 | 119 | //Swap if from < to and both not empty |
116 | - if (!$from->empty && !$to->empty && $from->value > $to->value) { |
|
120 | + if (!$from->empty && !$to->empty && $from->value > $to->value) |
|
121 | + { |
|
117 | 122 | [$from, $to] = [$to, $from]; |
118 | 123 | } |
119 | 124 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | return static function (ContainerConfigurator $containerConfigurator): void { |
15 | 15 | $parameters = $containerConfigurator->parameters(); |
16 | 16 | $parameters->set(Option::PATHS, [ |
17 | - __DIR__ . '/src/*/src', |
|
17 | + __DIR__.'/src/*/src', |
|
18 | 18 | ]); |
19 | 19 | |
20 | 20 | $parameters->set(Option::PARALLEL, true); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | RemoveUnusedPromotedPropertyRector::class, |
26 | 26 | |
27 | 27 | RemoveUnusedPrivateMethodRector::class => [ |
28 | - __DIR__ . '/src/Boot/src/Bootloader/ConfigurationBootloader.php', |
|
28 | + __DIR__.'/src/Boot/src/Bootloader/ConfigurationBootloader.php', |
|
29 | 29 | ], |
30 | 30 | ]); |
31 | 31 |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | $console->addCommand(Command\MiddlewareCommand::class); |
59 | 59 | $console->addCommand(Command\MigrationCommand::class, true); |
60 | 60 | |
61 | - try { |
|
61 | + try{ |
|
62 | 62 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
63 | - } catch (ReflectionException $e) { |
|
63 | + }catch (ReflectionException $e){ |
|
64 | 64 | $defaultNamespace = ''; |
65 | 65 | } |
66 | 66 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * Base directory for generated classes, class will be automatically localed into sub directory |
80 | 80 | * using given namespace. |
81 | 81 | */ |
82 | - 'directory' => directory('app') . 'src/', |
|
82 | + 'directory' => directory('app').'src/', |
|
83 | 83 | |
84 | 84 | /* |
85 | 85 | * Default namespace to be applied for every generated class. By default uses Kernel namespace |
@@ -58,9 +58,12 @@ |
||
58 | 58 | $console->addCommand(Command\MiddlewareCommand::class); |
59 | 59 | $console->addCommand(Command\MigrationCommand::class, true); |
60 | 60 | |
61 | - try { |
|
61 | + try |
|
62 | + { |
|
62 | 63 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
63 | - } catch (ReflectionException $e) { |
|
64 | + } |
|
65 | + catch (ReflectionException $e) |
|
66 | + { |
|
64 | 67 | $defaultNamespace = ''; |
65 | 68 | } |
66 | 69 |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | array $directories, |
114 | 114 | bool $handleErrors = true |
115 | 115 | ): self { |
116 | - if ($handleErrors) { |
|
116 | + if ($handleErrors){ |
|
117 | 117 | ExceptionHandler::register(); |
118 | 118 | } |
119 | 119 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $environment = $environment ?? new Environment(); |
137 | 137 | $this->container->bindSingleton(EnvironmentInterface::class, $environment); |
138 | 138 | |
139 | - try { |
|
139 | + try{ |
|
140 | 140 | // will protect any against env overwrite action |
141 | 141 | $this->container->runScope( |
142 | 142 | [EnvironmentInterface::class => $environment], |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $this->bootstrap(); |
146 | 146 | } |
147 | 147 | ); |
148 | - } catch (\Throwable $e) { |
|
148 | + }catch (\Throwable $e){ |
|
149 | 149 | ExceptionHandler::handleException($e); |
150 | 150 | |
151 | 151 | return null; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function starting(Closure ...$callbacks): void |
167 | 167 | { |
168 | - foreach ($callbacks as $callback) { |
|
168 | + foreach ($callbacks as $callback){ |
|
169 | 169 | $this->startingCallbacks[] = $callback; |
170 | 170 | } |
171 | 171 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function started(Closure ...$callbacks): void |
183 | 183 | { |
184 | - foreach ($callbacks as $callback) { |
|
184 | + foreach ($callbacks as $callback){ |
|
185 | 185 | $this->startedCallbacks[] = $callback; |
186 | 186 | } |
187 | 187 | } |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function serve() |
207 | 207 | { |
208 | - foreach ($this->dispatchers as $dispatcher) { |
|
209 | - if ($dispatcher->canServe()) { |
|
208 | + foreach ($this->dispatchers as $dispatcher){ |
|
209 | + if ($dispatcher->canServe()){ |
|
210 | 210 | return $this->container->runScope( |
211 | 211 | [DispatcherInterface::class => $dispatcher], |
212 | 212 | [$dispatcher, 'serve'] |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | */ |
261 | 261 | private function fireCallbacks(array &$callbacks): void |
262 | 262 | { |
263 | - if ($callbacks === []) { |
|
263 | + if ($callbacks === []){ |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | - do { |
|
267 | + do{ |
|
268 | 268 | $this->container->invoke(\current($callbacks)); |
269 | - } while (\next($callbacks)); |
|
269 | + }while (\next($callbacks)); |
|
270 | 270 | |
271 | 271 | $callbacks = []; |
272 | 272 | } |
@@ -113,7 +113,8 @@ discard block |
||
113 | 113 | array $directories, |
114 | 114 | bool $handleErrors = true |
115 | 115 | ): self { |
116 | - if ($handleErrors) { |
|
116 | + if ($handleErrors) |
|
117 | + { |
|
117 | 118 | ExceptionHandler::register(); |
118 | 119 | } |
119 | 120 | |
@@ -136,7 +137,8 @@ discard block |
||
136 | 137 | $environment = $environment ?? new Environment(); |
137 | 138 | $this->container->bindSingleton(EnvironmentInterface::class, $environment); |
138 | 139 | |
139 | - try { |
|
140 | + try |
|
141 | + { |
|
140 | 142 | // will protect any against env overwrite action |
141 | 143 | $this->container->runScope( |
142 | 144 | [EnvironmentInterface::class => $environment], |
@@ -145,7 +147,9 @@ discard block |
||
145 | 147 | $this->bootstrap(); |
146 | 148 | } |
147 | 149 | ); |
148 | - } catch (\Throwable $e) { |
|
150 | + } |
|
151 | + catch (\Throwable $e) |
|
152 | + { |
|
149 | 153 | ExceptionHandler::handleException($e); |
150 | 154 | |
151 | 155 | return null; |
@@ -165,7 +169,8 @@ discard block |
||
165 | 169 | */ |
166 | 170 | public function starting(Closure ...$callbacks): void |
167 | 171 | { |
168 | - foreach ($callbacks as $callback) { |
|
172 | + foreach ($callbacks as $callback) |
|
173 | + { |
|
169 | 174 | $this->startingCallbacks[] = $callback; |
170 | 175 | } |
171 | 176 | } |
@@ -181,7 +186,8 @@ discard block |
||
181 | 186 | */ |
182 | 187 | public function started(Closure ...$callbacks): void |
183 | 188 | { |
184 | - foreach ($callbacks as $callback) { |
|
189 | + foreach ($callbacks as $callback) |
|
190 | + { |
|
185 | 191 | $this->startedCallbacks[] = $callback; |
186 | 192 | } |
187 | 193 | } |
@@ -205,8 +211,10 @@ discard block |
||
205 | 211 | */ |
206 | 212 | public function serve() |
207 | 213 | { |
208 | - foreach ($this->dispatchers as $dispatcher) { |
|
209 | - if ($dispatcher->canServe()) { |
|
214 | + foreach ($this->dispatchers as $dispatcher) |
|
215 | + { |
|
216 | + if ($dispatcher->canServe()) |
|
217 | + { |
|
210 | 218 | return $this->container->runScope( |
211 | 219 | [DispatcherInterface::class => $dispatcher], |
212 | 220 | [$dispatcher, 'serve'] |
@@ -260,11 +268,13 @@ discard block |
||
260 | 268 | */ |
261 | 269 | private function fireCallbacks(array &$callbacks): void |
262 | 270 | { |
263 | - if ($callbacks === []) { |
|
271 | + if ($callbacks === []) |
|
272 | + { |
|
264 | 273 | return; |
265 | 274 | } |
266 | 275 | |
267 | - do { |
|
276 | + do |
|
277 | + { |
|
268 | 278 | $this->container->invoke(\current($callbacks)); |
269 | 279 | } while (\next($callbacks)); |
270 | 280 |