@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | private readonly FactoryInterface $factory, |
| 37 | 37 | private readonly ResolverInterface $resolver, |
| 38 | 38 | private readonly ConfiguratorInterface $config, |
| 39 | - ) { |
|
| 39 | + ){ |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param non-empty-string $key |
| 53 | 53 | * @param TTag $value |
| 54 | 54 | */ |
| 55 | - public function addTag(string $key, string|\Stringable|\Closure $value): void |
|
| 55 | + public function addTag(string $key, string | \Stringable | \Closure $value): void |
|
| 56 | 56 | { |
| 57 | 57 | $this->config->modify(DebugConfig::CONFIG, new Append('tags', $key, $value)); |
| 58 | 58 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * @psalm-param TCollector $collector |
| 62 | 62 | */ |
| 63 | - public function addStateCollector(string|StateCollectorInterface|Autowire $collector): void |
|
| 63 | + public function addStateCollector(string | StateCollectorInterface | Autowire $collector): void |
|
| 64 | 64 | { |
| 65 | 65 | $this->config->modify(DebugConfig::CONFIG, new Append('collectors', null, $collector)); |
| 66 | 66 | } |
@@ -72,29 +72,29 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | $state = new State(); |
| 74 | 74 | |
| 75 | - foreach ($config->getTags() as $key => $value) { |
|
| 76 | - if ($value instanceof \Closure) { |
|
| 75 | + foreach ($config->getTags() as $key => $value){ |
|
| 76 | + if ($value instanceof \Closure){ |
|
| 77 | 77 | $value = $value(...$this->resolver->resolveArguments(new \ReflectionFunction($value))); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if (!\is_string($value) && !$value instanceof \Stringable) { |
|
| 80 | + if (!\is_string($value) && !$value instanceof \Stringable){ |
|
| 81 | 81 | throw new StateException(\sprintf( |
| 82 | 82 | 'Invalid tag value, `string` expected got `%s`', |
| 83 | 83 | \is_object($value) ? $value::class : \gettype($value) |
| 84 | 84 | )); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $state->setTag((string) $key, (string) $value); |
|
| 87 | + $state->setTag((string)$key, (string)$value); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - foreach ($config->getCollectors() as $collector) { |
|
| 90 | + foreach ($config->getCollectors() as $collector){ |
|
| 91 | 91 | $collector = match (true) { |
| 92 | 92 | \is_string($collector) => $this->factory->make($collector), |
| 93 | 93 | $collector instanceof Autowire => $collector->resolve($this->factory), |
| 94 | 94 | default => $collector, |
| 95 | 95 | }; |
| 96 | 96 | |
| 97 | - if (!$collector instanceof StateCollectorInterface) { |
|
| 97 | + if (!$collector instanceof StateCollectorInterface){ |
|
| 98 | 98 | throw new StateException( |
| 99 | 99 | \sprintf( |
| 100 | 100 | 'Unable to populate state, invalid state collector %s', |
@@ -72,12 +72,15 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | $state = new State(); |
| 74 | 74 | |
| 75 | - foreach ($config->getTags() as $key => $value) { |
|
| 76 | - if ($value instanceof \Closure) { |
|
| 75 | + foreach ($config->getTags() as $key => $value) |
|
| 76 | + { |
|
| 77 | + if ($value instanceof \Closure) |
|
| 78 | + { |
|
| 77 | 79 | $value = $value(...$this->resolver->resolveArguments(new \ReflectionFunction($value))); |
| 78 | 80 | } |
| 79 | 81 | |
| 80 | - if (!\is_string($value) && !$value instanceof \Stringable) { |
|
| 82 | + if (!\is_string($value) && !$value instanceof \Stringable) |
|
| 83 | + { |
|
| 81 | 84 | throw new StateException(\sprintf( |
| 82 | 85 | 'Invalid tag value, `string` expected got `%s`', |
| 83 | 86 | \is_object($value) ? $value::class : \gettype($value) |
@@ -87,14 +90,16 @@ discard block |
||
| 87 | 90 | $state->setTag((string) $key, (string) $value); |
| 88 | 91 | } |
| 89 | 92 | |
| 90 | - foreach ($config->getCollectors() as $collector) { |
|
| 93 | + foreach ($config->getCollectors() as $collector) |
|
| 94 | + { |
|
| 91 | 95 | $collector = match (true) { |
| 92 | 96 | \is_string($collector) => $this->factory->make($collector), |
| 93 | 97 | $collector instanceof Autowire => $collector->resolve($this->factory), |
| 94 | 98 | default => $collector, |
| 95 | 99 | }; |
| 96 | 100 | |
| 97 | - if (!$collector instanceof StateCollectorInterface) { |
|
| 101 | + if (!$collector instanceof StateCollectorInterface) |
|
| 102 | + { |
|
| 98 | 103 | throw new StateException( |
| 99 | 104 | \sprintf( |
| 100 | 105 | 'Unable to populate state, invalid state collector %s', |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $class = $this->classify($name); |
| 59 | 59 | $postfix = $this->elementPostfix($element); |
| 60 | 60 | |
| 61 | - return \str_ends_with($class, $postfix) ? $class : $class . $postfix; |
|
| 61 | + return \str_ends_with($class, $postfix) ? $class : $class.$postfix; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -69,15 +69,15 @@ discard block |
||
| 69 | 69 | $localNamespace = \trim($this->getOption($element, 'namespace', ''), '\\'); |
| 70 | 70 | ['namespace' => $namespace] = $this->parseName($name); |
| 71 | 71 | |
| 72 | - if (!empty($namespace)) { |
|
| 73 | - $localNamespace .= '\\' . $this->classify($namespace); |
|
| 72 | + if (!empty($namespace)){ |
|
| 73 | + $localNamespace .= '\\'.$this->classify($namespace); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if (empty($this->baseNamespace($element))) { |
|
| 76 | + if (empty($this->baseNamespace($element))){ |
|
| 77 | 77 | return $localNamespace; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - return \trim($this->baseNamespace($element) . '\\' . $localNamespace, '\\'); |
|
| 80 | + return \trim($this->baseNamespace($element).'\\'.$localNamespace, '\\'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return $this->joinPathChunks([ |
| 95 | 95 | $this->declarationDirectory($element), |
| 96 | 96 | \str_replace('\\', '/', $elementNamespace), |
| 97 | - $this->className($element, $name) . '.php', |
|
| 97 | + $this->className($element, $name).'.php', |
|
| 98 | 98 | ], '/'); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $class = $this->getOption($element, 'class'); |
| 109 | 109 | |
| 110 | - if (empty($class)) { |
|
| 110 | + if (empty($class)){ |
|
| 111 | 111 | throw new ScaffolderException( |
| 112 | 112 | \sprintf("Unable to scaffold '%s', no declaration class found", $element) |
| 113 | 113 | ); |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | $declaration = $this->getDeclaration($element); |
| 144 | 144 | |
| 145 | - if ($declaration === []) { |
|
| 145 | + if ($declaration === []){ |
|
| 146 | 146 | throw new ScaffolderException(\sprintf("Undefined declaration '%s'.", $element)); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if (\array_key_exists($section, $declaration)) { |
|
| 149 | + if (\array_key_exists($section, $declaration)){ |
|
| 150 | 150 | return $declaration[$section]; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | { |
| 165 | 165 | $name = \str_replace('/', '\\', $name); |
| 166 | 166 | |
| 167 | - if (str_contains($name, '\\')) { |
|
| 167 | + if (str_contains($name, '\\')){ |
|
| 168 | 168 | $names = \explode('\\', $name); |
| 169 | 169 | $class = \array_pop($names); |
| 170 | 170 | |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | $declaration = $this->getDeclaration($element); |
| 184 | 184 | |
| 185 | - if (\array_key_exists('baseNamespace', $declaration)) { |
|
| 186 | - return \trim((string) $this->getOption($element, 'baseNamespace', ''), '\\'); |
|
| 185 | + if (\array_key_exists('baseNamespace', $declaration)){ |
|
| 186 | + return \trim((string)$this->getOption($element, 'baseNamespace', ''), '\\'); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | return \trim($this->config['namespace'], '\\'); |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | { |
| 194 | 194 | $firstChunkIterated = false; |
| 195 | 195 | $joinedPath = ''; |
| 196 | - foreach ($chunks as $chunk) { |
|
| 197 | - if (!$firstChunkIterated) { |
|
| 196 | + foreach ($chunks as $chunk){ |
|
| 197 | + if (!$firstChunkIterated){ |
|
| 198 | 198 | $firstChunkIterated = true; |
| 199 | 199 | $joinedPath = $chunk; |
| 200 | - } else { |
|
| 201 | - $joinedPath = \rtrim($joinedPath, $joint) . $joint . \ltrim($chunk, $joint); |
|
| 200 | + }else{ |
|
| 201 | + $joinedPath = \rtrim($joinedPath, $joint).$joint.\ltrim($chunk, $joint); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |