Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d0959c6

Browse files
committed
fix routing config type information
1 parent 54e691d commit d0959c6

2 files changed

Lines changed: 3 additions & 23 deletions

File tree

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PhpConfigReferenceDumpPass.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,10 @@ public static function config(array $config): array
6969

7070
private const ROUTES_TYPES_TEMPLATE = <<<'PHPDOC'
7171
72-
* @psalm-type RoutesConfig = array{{SHAPE}
73-
* ...<string, RouteConfig|ImportConfig|AliasConfig>
74-
* }
72+
* @psalm-type RoutesConfig = array<string, RouteConfig|ImportConfig|AliasConfig|array<string, RouteConfig|ImportConfig|AliasConfig>>
7573
*/
7674
PHPDOC;
7775

78-
private const WHEN_ENV_ROUTES_TEMPLATE = <<<'PHPDOC'
79-
80-
* "when@{ENV}"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
81-
PHPDOC;
82-
8376
public function __construct(
8477
private string $referenceFile,
8578
private array $bundlesDefinition,
@@ -145,19 +138,11 @@ public function process(ContainerBuilder $container): void
145138
if (false === $i = strpos($phpdoc = $r->getDocComment(), "\n * @psalm-type RoutesConfig = ")) {
146139
throw new \LogicException(\sprintf('Cannot insert config shape in "%s".', RoutesReference::class));
147140
}
148-
$routesTypes = '';
149-
foreach ($knownEnvs as $env) {
150-
$routesTypes .= strtr(self::WHEN_ENV_ROUTES_TEMPLATE, ['{ENV}' => $env]);
151-
}
152-
if ('' !== $routesTypes) {
153-
$routesTypes = strtr(self::ROUTES_TYPES_TEMPLATE, ['{SHAPE}' => $routesTypes]);
154-
$routesTypes = substr_replace($phpdoc, $routesTypes, $i);
155-
}
156141

157142
$configReference = strtr(self::REFERENCE_TEMPLATE, [
158143
'{APP_TYPES}' => $appTypes,
159144
'{APP_PARAM}' => $appParam,
160-
'{ROUTES_TYPES}' => $routesTypes,
145+
'{ROUTES_TYPES}' => substr_replace($phpdoc, self::ROUTES_TYPES_TEMPLATE, $i),
161146
'{ROUTES_PARAM}' => $r->getMethod('config')->getDocComment(),
162147
]);
163148

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/reference.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,7 @@ public static function config(array $config): array
231231
* alias: string,
232232
* deprecated?: array{package:string, version:string, message?:string},
233233
* }
234-
* @psalm-type RoutesConfig = array{
235-
* "when@dev"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
236-
* "when@prod"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
237-
* "when@test"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
238-
* ...<string, RouteConfig|ImportConfig|AliasConfig>
239-
* }
234+
* @psalm-type RoutesConfig = array<string, RouteConfig|ImportConfig|AliasConfig|array<string, RouteConfig|ImportConfig|AliasConfig>>
240235
*/
241236
final class Routes extends RoutesReference
242237
{

0 commit comments

Comments
 (0)