@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | ['name', InputArgument::REQUIRED, 'Command name'], |
| 17 | 17 | ['alias', InputArgument::OPTIONAL, 'Command id/alias'], |
| 18 | 18 | ]; |
| 19 | - protected const OPTIONS = [ |
|
| 19 | + protected const OPTIONS = [ |
|
| 20 | 20 | [ |
| 21 | 21 | 'description', |
| 22 | 22 | 'd', |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $declaration = $this->createDeclaration(CommandDeclaration::class); |
| 40 | 40 | |
| 41 | - $declaration->setAlias((string) ($this->argument('alias') ?? $this->argument('name'))); |
|
| 42 | - $declaration->setDescription((string) $this->option('description')); |
|
| 41 | + $declaration->setAlias((string)($this->argument('alias') ?? $this->argument('name'))); |
|
| 42 | + $declaration->setDescription((string)$this->option('description')); |
|
| 43 | 43 | |
| 44 | 44 | $this->writeDeclaration($declaration); |
| 45 | 45 | |
@@ -43,11 +43,11 @@ |
||
| 43 | 43 | { |
| 44 | 44 | $declaration = $this->createDeclaration(ControllerDeclaration::class); |
| 45 | 45 | |
| 46 | - foreach ($this->option('action') as $action) { |
|
| 46 | + foreach ($this->option('action') as $action){ |
|
| 47 | 47 | $declaration->addAction($action); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if ((bool)$this->option('prototype')) { |
|
| 50 | + if ((bool)$this->option('prototype')){ |
|
| 51 | 51 | $declaration->addPrototypeTrait(); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -43,11 +43,13 @@ |
||
| 43 | 43 | { |
| 44 | 44 | $declaration = $this->createDeclaration(ControllerDeclaration::class); |
| 45 | 45 | |
| 46 | - foreach ($this->option('action') as $action) { |
|
| 46 | + foreach ($this->option('action') as $action) |
|
| 47 | + { |
|
| 47 | 48 | $declaration->addAction($action); |
| 48 | 49 | } |
| 49 | 50 | |
| 50 | - if ((bool)$this->option('prototype')) { |
|
| 51 | + if ((bool)$this->option('prototype')) |
|
| 52 | + { |
|
| 51 | 53 | $declaration->addPrototypeTrait(); |
| 52 | 54 | } |
| 53 | 55 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | public function __construct( |
| 27 | 27 | private readonly ConfiguratorInterface $config, |
| 28 | 28 | private readonly KernelInterface $kernel |
| 29 | - ) { |
|
| 29 | + ){ |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function init(ConsoleBootloader $console): void |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | $console->addCommand(Command\JobHandlerCommand::class); |
| 39 | 39 | $console->addCommand(Command\MiddlewareCommand::class); |
| 40 | 40 | |
| 41 | - try { |
|
| 41 | + try{ |
|
| 42 | 42 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
| 43 | - } catch (ReflectionException) { |
|
| 43 | + }catch (ReflectionException){ |
|
| 44 | 44 | $defaultNamespace = ''; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * Base directory for generated classes, class will be automatically localed into sub directory |
| 56 | 56 | * using given namespace. |
| 57 | 57 | */ |
| 58 | - 'directory' => directory('app') . 'src/', |
|
| 58 | + 'directory' => directory('app').'src/', |
|
| 59 | 59 | |
| 60 | 60 | /* |
| 61 | 61 | * Default namespace to be applied for every generated class. By default uses Kernel namespace |
@@ -38,9 +38,12 @@ |
||
| 38 | 38 | $console->addCommand(Command\JobHandlerCommand::class); |
| 39 | 39 | $console->addCommand(Command\MiddlewareCommand::class); |
| 40 | 40 | |
| 41 | - try { |
|
| 41 | + try |
|
| 42 | + { |
|
| 42 | 43 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
| 43 | - } catch (ReflectionException) { |
|
| 44 | + } |
|
| 45 | + catch (ReflectionException) |
|
| 46 | + { |
|
| 44 | 47 | $defaultNamespace = ''; |
| 45 | 48 | } |
| 46 | 49 | |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | public function get(array $values): array |
| 27 | 27 | { |
| 28 | 28 | $output = []; |
| 29 | - foreach ($values as $key => $value) { |
|
| 29 | + foreach ($values as $key => $value){ |
|
| 30 | 30 | $output[$key] = self::TYPE_DEFAULTS[\gettype($value)] ?? null; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -26,7 +26,8 @@ |
||
| 26 | 26 | public function get(array $values): array |
| 27 | 27 | { |
| 28 | 28 | $output = []; |
| 29 | - foreach ($values as $key => $value) { |
|
| 29 | + foreach ($values as $key => $value) |
|
| 30 | + { |
|
| 30 | 31 | $output[$key] = self::TYPE_DEFAULTS[\gettype($value)] ?? null; |
| 31 | 32 | } |
| 32 | 33 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | public function getAnnotation(mixed $value): string |
| 28 | 28 | { |
| 29 | - if (\is_array($value)) { |
|
| 29 | + if (\is_array($value)){ |
|
| 30 | 30 | return $this->arrayAnnotationString($value); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | private function arrayAnnotationString(array $value): string |
| 42 | 42 | { |
| 43 | 43 | $types = []; |
| 44 | - foreach ($value as $item) { |
|
| 44 | + foreach ($value as $item){ |
|
| 45 | 45 | $types[] = \gettype($item); |
| 46 | 46 | } |
| 47 | 47 | $types = \array_unique($types); |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | public function getAnnotation(mixed $value): string |
| 28 | 28 | { |
| 29 | - if (\is_array($value)) { |
|
| 29 | + if (\is_array($value)) |
|
| 30 | + { |
|
| 30 | 31 | return $this->arrayAnnotationString($value); |
| 31 | 32 | } |
| 32 | 33 | |
@@ -41,7 +42,8 @@ discard block |
||
| 41 | 42 | private function arrayAnnotationString(array $value): string |
| 42 | 43 | { |
| 43 | 44 | $types = []; |
| 44 | - foreach ($value as $item) { |
|
| 45 | + foreach ($value as $item) |
|
| 46 | + { |
|
| 45 | 47 | $types[] = \gettype($item); |
| 46 | 48 | } |
| 47 | 49 | $types = \array_unique($types); |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | protected readonly ScaffolderConfig $config, |
| 20 | 20 | string $name, |
| 21 | 21 | ?string $comment = null |
| 22 | - ) { |
|
| 22 | + ){ |
|
| 23 | 23 | $this->namespace = new PhpNamespace($this->config->classNamespace(static::TYPE, $name)); |
| 24 | 24 | |
| 25 | 25 | $this->class = $this->namespace |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | string $name, |
| 33 | 33 | ?string $comment = null, |
| 34 | 34 | private readonly string $directory = '' |
| 35 | - ) { |
|
| 35 | + ){ |
|
| 36 | 36 | parent::__construct($config, $name, $comment); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | $this->class->addConstant('CONFIG', $configName)->setPublic(); |
| 42 | 42 | |
| 43 | 43 | $filename = $this->makeConfigFilename($configName); |
| 44 | - if ($reverse) { |
|
| 45 | - if (!$this->files->exists($filename)) { |
|
| 44 | + if ($reverse){ |
|
| 45 | + if (!$this->files->exists($filename)){ |
|
| 46 | 46 | throw new ScaffolderException(\sprintf("Config filename %s doesn't exist", $filename)); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | $this->declareGetters($defaultsFromFile); |
| 51 | 51 | |
| 52 | 52 | $this->class->getProperty('config')->setValue($this->defaultValues->get($defaultsFromFile)); |
| 53 | - } else { |
|
| 54 | - if (!$this->files->exists($filename)) { |
|
| 53 | + }else{ |
|
| 54 | + if (!$this->files->exists($filename)){ |
|
| 55 | 55 | $this->touchConfigFile($filename); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | $this->files->write( |
| 90 | 90 | $filename, |
| 91 | - $file->render() . PHP_EOL . (new Dumper())->dump(new Literal('return [];')), |
|
| 91 | + $file->render().PHP_EOL.(new Dumper())->dump(new Literal('return [];')), |
|
| 92 | 92 | FilesInterface::READONLY, |
| 93 | 93 | true |
| 94 | 94 | ); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $getters = []; |
| 111 | 111 | $gettersByKey = []; |
| 112 | 112 | |
| 113 | - foreach ($defaults as $key => $value) { |
|
| 113 | + foreach ($defaults as $key => $value){ |
|
| 114 | 114 | $key = (string)$key; |
| 115 | 115 | $getter = $this->makeGetterName($key); |
| 116 | 116 | $getters[] = $getter; |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | $method->setBody(\sprintf('return $this->config[\'%s\'];', $key)); |
| 120 | 120 | $method->setComment(\sprintf('@return %s', $this->typeAnnotations->getAnnotation($value))); |
| 121 | 121 | |
| 122 | - if (\is_array($value)) { |
|
| 122 | + if (\is_array($value)){ |
|
| 123 | 123 | $gettersByKey[] = ['key' => $key, 'value' => $value]; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $returnTypeHint = $this->typeHints->getHint(\gettype($value)); |
| 127 | - if ($returnTypeHint !== null) { |
|
| 127 | + if ($returnTypeHint !== null){ |
|
| 128 | 128 | $method->setReturnType($returnTypeHint); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - foreach ($gettersByKey as $item) { |
|
| 132 | + foreach ($gettersByKey as $item){ |
|
| 133 | 133 | $method = $this->declareGettersByKey($getters, $item['key'], $item['value']); |
| 134 | - if ($method !== null) { |
|
| 134 | + if ($method !== null){ |
|
| 135 | 135 | $getters[] = $method->getName(); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -142,30 +142,30 @@ discard block |
||
| 142 | 142 | private function declareGettersByKey(array $methodNames, string $key, array $value): ?Method |
| 143 | 143 | { |
| 144 | 144 | //Won't create if there's less than 2 sub-items |
| 145 | - if (\count($value) < 2) { |
|
| 145 | + if (\count($value) < 2){ |
|
| 146 | 146 | return null; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $singularKey = $this->singularize($key); |
| 150 | 150 | $name = $this->makeGetterName($singularKey); |
| 151 | - if (\in_array($name, $methodNames, true)) { |
|
| 151 | + if (\in_array($name, $methodNames, true)){ |
|
| 152 | 152 | $name = $this->makeGetterName($singularKey, 'get', 'by'); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | //Name conflict, won't merge |
| 156 | - if (\in_array($name, $methodNames, true)) { |
|
| 156 | + if (\in_array($name, $methodNames, true)){ |
|
| 157 | 157 | return null; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $keyType = defineArrayType(\array_keys($value), '-mixed-'); |
| 161 | 161 | $valueType = defineArrayType(\array_values($value), '-mixed-'); |
| 162 | 162 | //We need a fixed structure here |
| 163 | - if ($keyType === '-mixed-' || $valueType === '-mixed-') { |
|
| 163 | + if ($keyType === '-mixed-' || $valueType === '-mixed-'){ |
|
| 164 | 164 | return null; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | //Won't create for associated arrays |
| 168 | - if ($this->typeAnnotations->mapType($keyType) === 'int' && !isAssociativeArray($value)) { |
|
| 168 | + if ($this->typeAnnotations->mapType($keyType) === 'int' && !isAssociativeArray($value)){ |
|
| 169 | 169 | return null; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | $param = $method->addParameter($singularKey); |
| 181 | 181 | $paramTypeHint = $this->typeHints->getHint($keyType); |
| 182 | - if ($paramTypeHint !== null) { |
|
| 182 | + if ($paramTypeHint !== null){ |
|
| 183 | 183 | $param->setType($paramTypeHint); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | private function makeGetterName(string $name, string $prefix = 'get', string $postfix = ''): string |
| 190 | 190 | { |
| 191 | 191 | $chunks = []; |
| 192 | - if (!empty($prefix)) { |
|
| 192 | + if (!empty($prefix)){ |
|
| 193 | 193 | $chunks[] = $prefix; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | $name = $this->slugify->slugify($name, ['lowercase' => false]); |
| 197 | 197 | $chunks[] = \count($chunks) !== 0 ? $this->classify($name) : $name; |
| 198 | - if (!empty($postfix)) { |
|
| 198 | + if (!empty($postfix)){ |
|
| 199 | 199 | $chunks[] = \ucfirst($postfix); |
| 200 | 200 | } |
| 201 | 201 | |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | private function classify(string $name): string |
| 206 | 206 | { |
| 207 | - return ( new InflectorFactory() ) |
|
| 207 | + return (new InflectorFactory()) |
|
| 208 | 208 | ->build() |
| 209 | 209 | ->classify($name); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | private function singularize(string $name): string |
| 213 | 213 | { |
| 214 | - return ( new InflectorFactory() ) |
|
| 214 | + return (new InflectorFactory()) |
|
| 215 | 215 | ->build() |
| 216 | 216 | ->singularize($name); |
| 217 | 217 | } |
@@ -41,8 +41,10 @@ discard block |
||
| 41 | 41 | $this->class->addConstant('CONFIG', $configName)->setPublic(); |
| 42 | 42 | |
| 43 | 43 | $filename = $this->makeConfigFilename($configName); |
| 44 | - if ($reverse) { |
|
| 45 | - if (!$this->files->exists($filename)) { |
|
| 44 | + if ($reverse) |
|
| 45 | + { |
|
| 46 | + if (!$this->files->exists($filename)) |
|
| 47 | + { |
|
| 46 | 48 | throw new ScaffolderException(\sprintf("Config filename %s doesn't exist", $filename)); |
| 47 | 49 | } |
| 48 | 50 | |
@@ -50,8 +52,11 @@ discard block |
||
| 50 | 52 | $this->declareGetters($defaultsFromFile); |
| 51 | 53 | |
| 52 | 54 | $this->class->getProperty('config')->setValue($this->defaultValues->get($defaultsFromFile)); |
| 53 | - } else { |
|
| 54 | - if (!$this->files->exists($filename)) { |
|
| 55 | + } |
|
| 56 | + else |
|
| 57 | + { |
|
| 58 | + if (!$this->files->exists($filename)) |
|
| 59 | + { |
|
| 55 | 60 | $this->touchConfigFile($filename); |
| 56 | 61 | } |
| 57 | 62 | } |
@@ -110,7 +115,8 @@ discard block |
||
| 110 | 115 | $getters = []; |
| 111 | 116 | $gettersByKey = []; |
| 112 | 117 | |
| 113 | - foreach ($defaults as $key => $value) { |
|
| 118 | + foreach ($defaults as $key => $value) |
|
| 119 | + { |
|
| 114 | 120 | $key = (string)$key; |
| 115 | 121 | $getter = $this->makeGetterName($key); |
| 116 | 122 | $getters[] = $getter; |
@@ -119,19 +125,23 @@ discard block |
||
| 119 | 125 | $method->setBody(\sprintf('return $this->config[\'%s\'];', $key)); |
| 120 | 126 | $method->setComment(\sprintf('@return %s', $this->typeAnnotations->getAnnotation($value))); |
| 121 | 127 | |
| 122 | - if (\is_array($value)) { |
|
| 128 | + if (\is_array($value)) |
|
| 129 | + { |
|
| 123 | 130 | $gettersByKey[] = ['key' => $key, 'value' => $value]; |
| 124 | 131 | } |
| 125 | 132 | |
| 126 | 133 | $returnTypeHint = $this->typeHints->getHint(\gettype($value)); |
| 127 | - if ($returnTypeHint !== null) { |
|
| 134 | + if ($returnTypeHint !== null) |
|
| 135 | + { |
|
| 128 | 136 | $method->setReturnType($returnTypeHint); |
| 129 | 137 | } |
| 130 | 138 | } |
| 131 | 139 | |
| 132 | - foreach ($gettersByKey as $item) { |
|
| 140 | + foreach ($gettersByKey as $item) |
|
| 141 | + { |
|
| 133 | 142 | $method = $this->declareGettersByKey($getters, $item['key'], $item['value']); |
| 134 | - if ($method !== null) { |
|
| 143 | + if ($method !== null) |
|
| 144 | + { |
|
| 135 | 145 | $getters[] = $method->getName(); |
| 136 | 146 | } |
| 137 | 147 | } |
@@ -142,30 +152,35 @@ discard block |
||
| 142 | 152 | private function declareGettersByKey(array $methodNames, string $key, array $value): ?Method |
| 143 | 153 | { |
| 144 | 154 | //Won't create if there's less than 2 sub-items |
| 145 | - if (\count($value) < 2) { |
|
| 155 | + if (\count($value) < 2) |
|
| 156 | + { |
|
| 146 | 157 | return null; |
| 147 | 158 | } |
| 148 | 159 | |
| 149 | 160 | $singularKey = $this->singularize($key); |
| 150 | 161 | $name = $this->makeGetterName($singularKey); |
| 151 | - if (\in_array($name, $methodNames, true)) { |
|
| 162 | + if (\in_array($name, $methodNames, true)) |
|
| 163 | + { |
|
| 152 | 164 | $name = $this->makeGetterName($singularKey, 'get', 'by'); |
| 153 | 165 | } |
| 154 | 166 | |
| 155 | 167 | //Name conflict, won't merge |
| 156 | - if (\in_array($name, $methodNames, true)) { |
|
| 168 | + if (\in_array($name, $methodNames, true)) |
|
| 169 | + { |
|
| 157 | 170 | return null; |
| 158 | 171 | } |
| 159 | 172 | |
| 160 | 173 | $keyType = defineArrayType(\array_keys($value), '-mixed-'); |
| 161 | 174 | $valueType = defineArrayType(\array_values($value), '-mixed-'); |
| 162 | 175 | //We need a fixed structure here |
| 163 | - if ($keyType === '-mixed-' || $valueType === '-mixed-') { |
|
| 176 | + if ($keyType === '-mixed-' || $valueType === '-mixed-') |
|
| 177 | + { |
|
| 164 | 178 | return null; |
| 165 | 179 | } |
| 166 | 180 | |
| 167 | 181 | //Won't create for associated arrays |
| 168 | - if ($this->typeAnnotations->mapType($keyType) === 'int' && !isAssociativeArray($value)) { |
|
| 182 | + if ($this->typeAnnotations->mapType($keyType) === 'int' && !isAssociativeArray($value)) |
|
| 183 | + { |
|
| 169 | 184 | return null; |
| 170 | 185 | } |
| 171 | 186 | |
@@ -179,7 +194,8 @@ discard block |
||
| 179 | 194 | |
| 180 | 195 | $param = $method->addParameter($singularKey); |
| 181 | 196 | $paramTypeHint = $this->typeHints->getHint($keyType); |
| 182 | - if ($paramTypeHint !== null) { |
|
| 197 | + if ($paramTypeHint !== null) |
|
| 198 | + { |
|
| 183 | 199 | $param->setType($paramTypeHint); |
| 184 | 200 | } |
| 185 | 201 | |
@@ -189,13 +205,15 @@ discard block |
||
| 189 | 205 | private function makeGetterName(string $name, string $prefix = 'get', string $postfix = ''): string |
| 190 | 206 | { |
| 191 | 207 | $chunks = []; |
| 192 | - if (!empty($prefix)) { |
|
| 208 | + if (!empty($prefix)) |
|
| 209 | + { |
|
| 193 | 210 | $chunks[] = $prefix; |
| 194 | 211 | } |
| 195 | 212 | |
| 196 | 213 | $name = $this->slugify->slugify($name, ['lowercase' => false]); |
| 197 | 214 | $chunks[] = \count($chunks) !== 0 ? $this->classify($name) : $name; |
| 198 | - if (!empty($postfix)) { |
|
| 215 | + if (!empty($postfix)) |
|
| 216 | + { |
|
| 199 | 217 | $chunks[] = \ucfirst($postfix); |
| 200 | 218 | } |
| 201 | 219 | |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | $this->files->write( |
| 90 | 90 | $filename, |
| 91 | 91 | $file->render() . PHP_EOL . (new Dumper())->dump(new Literal('return [];')), |
| 92 | - FilesInterface::READONLY, |
|
| 92 | + FilesInterface::readonly, |
|
| 93 | 93 | true |
| 94 | 94 | ); |
| 95 | 95 | } |
@@ -23,22 +23,22 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function loadEnvVariables(DirectoriesInterface $dirs, EnvironmentInterface $env): void |
| 25 | 25 | { |
| 26 | - if ($this->init) { |
|
| 26 | + if ($this->init){ |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $this->init = true; |
| 31 | 31 | |
| 32 | - $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root') . '.env'); |
|
| 32 | + $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root').'.env'); |
|
| 33 | 33 | |
| 34 | - if (!\file_exists($dotenvPath)) { |
|
| 34 | + if (!\file_exists($dotenvPath)){ |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $path = \dirname($dotenvPath); |
| 39 | 39 | $file = \basename($dotenvPath); |
| 40 | 40 | |
| 41 | - foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) { |
|
| 41 | + foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value){ |
|
| 42 | 42 | $env->set($key, $value); |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function loadEnvVariables(DirectoriesInterface $dirs, EnvironmentInterface $env): void |
| 25 | 25 | { |
| 26 | - if ($this->init) { |
|
| 26 | + if ($this->init) |
|
| 27 | + { |
|
| 27 | 28 | return; |
| 28 | 29 | } |
| 29 | 30 | |
@@ -31,14 +32,16 @@ discard block |
||
| 31 | 32 | |
| 32 | 33 | $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root') . '.env'); |
| 33 | 34 | |
| 34 | - if (!\file_exists($dotenvPath)) { |
|
| 35 | + if (!\file_exists($dotenvPath)) |
|
| 36 | + { |
|
| 35 | 37 | return; |
| 36 | 38 | } |
| 37 | 39 | |
| 38 | 40 | $path = \dirname($dotenvPath); |
| 39 | 41 | $file = \basename($dotenvPath); |
| 40 | 42 | |
| 41 | - foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) { |
|
| 43 | + foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) |
|
| 44 | + { |
|
| 42 | 45 | $env->set($key, $value); |
| 43 | 46 | } |
| 44 | 47 | } |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | public function getDirectives(): array |
| 25 | 25 | { |
| 26 | 26 | $directives = []; |
| 27 | - foreach ($this->config['directives'] as $directive) { |
|
| 28 | - if (\is_object($directive) && !$directive instanceof Autowire) { |
|
| 27 | + foreach ($this->config['directives'] as $directive){ |
|
| 28 | + if (\is_object($directive) && !$directive instanceof Autowire){ |
|
| 29 | 29 | $directives[] = $directive; |
| 30 | 30 | continue; |
| 31 | 31 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | public function getProcessors(): array |
| 43 | 43 | { |
| 44 | 44 | $processors = []; |
| 45 | - foreach ($this->config['processors'] as $processor) { |
|
| 46 | - if (is_object($processor) && !$processor instanceof Autowire) { |
|
| 45 | + foreach ($this->config['processors'] as $processor){ |
|
| 46 | + if (is_object($processor) && !$processor instanceof Autowire){ |
|
| 47 | 47 | $processors[] = $processor; |
| 48 | 48 | continue; |
| 49 | 49 | } |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | public function getVisitors(int $stage): array |
| 58 | 58 | { |
| 59 | 59 | $visitors = []; |
| 60 | - foreach ($this->config['visitors'][$stage] ?? [] as $visitor) { |
|
| 61 | - if (\is_object($visitor) && !$visitor instanceof Autowire) { |
|
| 60 | + foreach ($this->config['visitors'][$stage] ?? [] as $visitor){ |
|
| 61 | + if (\is_object($visitor) && !$visitor instanceof Autowire){ |
|
| 62 | 62 | $visitors[] = $visitor; |
| 63 | 63 | continue; |
| 64 | 64 | } |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | private function wire(mixed $item): Autowire |
| 76 | 76 | { |
| 77 | - if ($item instanceof Autowire) { |
|
| 77 | + if ($item instanceof Autowire){ |
|
| 78 | 78 | return $item; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (\is_string($item)) { |
|
| 81 | + if (\is_string($item)){ |
|
| 82 | 82 | return new Autowire($item); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -24,8 +24,10 @@ discard block |
||
| 24 | 24 | public function getDirectives(): array |
| 25 | 25 | { |
| 26 | 26 | $directives = []; |
| 27 | - foreach ($this->config['directives'] as $directive) { |
|
| 28 | - if (\is_object($directive) && !$directive instanceof Autowire) { |
|
| 27 | + foreach ($this->config['directives'] as $directive) |
|
| 28 | + { |
|
| 29 | + if (\is_object($directive) && !$directive instanceof Autowire) |
|
| 30 | + { |
|
| 29 | 31 | $directives[] = $directive; |
| 30 | 32 | continue; |
| 31 | 33 | } |
@@ -42,8 +44,10 @@ discard block |
||
| 42 | 44 | public function getProcessors(): array |
| 43 | 45 | { |
| 44 | 46 | $processors = []; |
| 45 | - foreach ($this->config['processors'] as $processor) { |
|
| 46 | - if (is_object($processor) && !$processor instanceof Autowire) { |
|
| 47 | + foreach ($this->config['processors'] as $processor) |
|
| 48 | + { |
|
| 49 | + if (is_object($processor) && !$processor instanceof Autowire) |
|
| 50 | + { |
|
| 47 | 51 | $processors[] = $processor; |
| 48 | 52 | continue; |
| 49 | 53 | } |
@@ -57,8 +61,10 @@ discard block |
||
| 57 | 61 | public function getVisitors(int $stage): array |
| 58 | 62 | { |
| 59 | 63 | $visitors = []; |
| 60 | - foreach ($this->config['visitors'][$stage] ?? [] as $visitor) { |
|
| 61 | - if (\is_object($visitor) && !$visitor instanceof Autowire) { |
|
| 64 | + foreach ($this->config['visitors'][$stage] ?? [] as $visitor) |
|
| 65 | + { |
|
| 66 | + if (\is_object($visitor) && !$visitor instanceof Autowire) |
|
| 67 | + { |
|
| 62 | 68 | $visitors[] = $visitor; |
| 63 | 69 | continue; |
| 64 | 70 | } |
@@ -74,11 +80,13 @@ discard block |
||
| 74 | 80 | */ |
| 75 | 81 | private function wire(mixed $item): Autowire |
| 76 | 82 | { |
| 77 | - if ($item instanceof Autowire) { |
|
| 83 | + if ($item instanceof Autowire) |
|
| 84 | + { |
|
| 78 | 85 | return $item; |
| 79 | 86 | } |
| 80 | 87 | |
| 81 | - if (\is_string($item)) { |
|
| 88 | + if (\is_string($item)) |
|
| 89 | + { |
|
| 82 | 90 | return new Autowire($item); |
| 83 | 91 | } |
| 84 | 92 | |