Skip to content

Commit 809fd80

Browse files
Merge branch '7.4' into 8.0
* 7.4: (21 commits) [ObjectMapper] lazy loading [Filesystem] Unify logic for isAbsolute() in Path [DependencyInjection] Include return type in AppReference shape [Finder] Make method calls explicit in ExcludeDirectoryFilterIterator [Cache] Remove unset call on undefined variable in PhpArrayAdapter [Twig] Ensure WrappedTemplatedEmail::getReturnPath() returns a string [Routing] Simplify importing routes defined on controller services Fix tests [DependendcyInjection] Improve shape for "from_callable" definitions [PHPDoc] Fix various PHPDoc syntax errors [Console] Add missing VERBOSITY_SILENT case in CommandDataCollector [Notifier] Remove unused $transportName argument in EmailChannel::notify() [Translation] Remove an unused argument passed to parseNode() method [HttpClient] Reject 3xx pushed responses [Serializer] Use Asia/Tokyo instead of Japan in tests [ProxyManagerBridge] Remove comment that reference github discussion [JsonPath] Remove unused "nothing" property from JsonCrawler [ErrorHandler] Improve PHPDoc precision in SerializerErrorRenderer [Routing] Fix matching the "0" URL [Form] Fix EnumType choice_label logic for grouped choices ...
2 parents 5232aad + 302939e commit 809fd80

File tree

3 files changed

+50
-49
lines changed

3 files changed

+50
-49
lines changed

DependencyInjection/Compiler/PhpConfigReferenceDumpPass.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public static function config(array $config): array
6060

6161
private const WHEN_ENV_APP_TEMPLATE = <<<'PHPDOC'
6262
63-
* "when@{ENV}"?: array{
64-
* imports?: ImportsConfig,
65-
* parameters?: ParametersConfig,
66-
* services?: ServicesConfig,{SHAPE}
67-
* },
63+
* "when@{ENV}"?: array{
64+
* imports?: ImportsConfig,
65+
* parameters?: ParametersConfig,
66+
* services?: ServicesConfig,{SHAPE}
67+
* },
6868
PHPDOC;
6969

7070
private const ROUTES_TYPES_TEMPLATE = <<<'PHPDOC'
@@ -121,23 +121,24 @@ public function process(ContainerBuilder $container): void
121121

122122
$r = new \ReflectionClass(AppReference::class);
123123

124-
if (false === $i = strpos($phpdoc = $r->getDocComment(), "\n */")) {
124+
if (false === $i = strpos($phpdoc = $r->getDocComment(), "\n * @psalm-type ConfigType = ")) {
125125
throw new \LogicException(\sprintf('Cannot insert config shape in "%s".', AppReference::class));
126126
}
127127
$appTypes = substr_replace($phpdoc, $appTypes, $i, 0);
128128

129-
if (false === $i = strpos($phpdoc = $r->getMethod('config')->getDocComment(), "\n * ...<string, ExtensionType|array{")) {
129+
if (false === $i = strrpos($phpdoc = $appTypes, "\n * ...<string, ExtensionType|array{")) {
130130
throw new \LogicException(\sprintf('Cannot insert config shape in "%s".', AppReference::class));
131131
}
132-
$appParam = substr_replace($phpdoc, $this->getShapeForExtensions($anyEnvExtensions, $container), $i, 0);
133-
$i += \strlen($appParam) - \strlen($phpdoc);
132+
$appTypes = substr_replace($phpdoc, $this->getShapeForExtensions($anyEnvExtensions, $container), $i, 0);
133+
$i += \strlen($appTypes) - \strlen($phpdoc);
134134

135135
foreach ($extensionsPerEnv as $env => $extensions) {
136-
$appParam = substr_replace($appParam, strtr(self::WHEN_ENV_APP_TEMPLATE, [
136+
$appTypes = substr_replace($appTypes, strtr(self::WHEN_ENV_APP_TEMPLATE, [
137137
'{ENV}' => $env,
138138
'{SHAPE}' => $this->getShapeForExtensions($extensions, $container, ' '),
139139
]), $i, 0);
140140
}
141+
$appParam = $r->getMethod('config')->getDocComment();
141142

142143
$r = new \ReflectionClass(RoutesReference::class);
143144

@@ -191,7 +192,7 @@ private function getShapeForExtensions(array $extensions, ContainerBuilder $cont
191192
foreach ($extensions as $extension) {
192193
if ($this->getConfiguration($extension, $container)) {
193194
$type = $this->camelCase($extension->getAlias()).'Config';
194-
$shape .= \sprintf("\n * %s%s?: %s,", $indent, $extension->getAlias(), $type);
195+
$shape .= \sprintf("\n * %s%s?: %s,", $indent, $extension->getAlias(), $type);
195196
}
196197
}
197198

Kernel/MicroKernelTrait.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ private function configureRoutes(RoutingConfigurator $routes): void
7979
$routes->import($configDir.'/{routes}/'.$this->environment.'/*.{php,yaml}');
8080
$routes->import($configDir.'/{routes}/*.{php,yaml}');
8181

82+
$routes->import('routing.controllers');
83+
8284
if (is_file($this->getConfigDir().'/routes.yaml')) {
8385
$routes->import($configDir.'/routes.yaml');
8486
} else {
8587
$routes->import($configDir.'/{routes}.php');
8688
}
87-
88-
if ($fileName = (new \ReflectionObject($this))->getFileName()) {
89-
$routes->import($fileName, 'attribute');
90-
}
9189
}
9290

9391
/**

Tests/Fixtures/reference.php

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* type?: string|null,
3232
* ignore_errors?: bool,
3333
* }>
34-
* @psalm-type ParametersConfig = array<string, scalar|\UnitEnum|array<scalar|\UnitEnum|array|null>|null>
34+
* @psalm-type ParametersConfig = array<string, scalar|\UnitEnum|array<scalar|\UnitEnum|array<mixed>|null>|null>
3535
* @psalm-type ArgumentsType = list<mixed>|array<string, mixed>
3636
* @psalm-type CallType = array<string, ArgumentsType>|array{0:string, 1?:ArgumentsType, 2?:bool}|array{method:string, arguments?:ArgumentsType, returns_clone?:bool}
3737
* @psalm-type TagsType = list<string|array<string, array<string, mixed>>> // arrays inside the list must have only one element, with the tag name as the key
@@ -83,7 +83,7 @@
8383
* autoconfigure?: bool,
8484
* bind?: array<string, mixed>,
8585
* constructor?: string,
86-
* from_callable?: mixed,
86+
* from_callable?: CallbackType,
8787
* }
8888
* @psalm-type AliasType = string|array{
8989
* alias: string,
@@ -130,40 +130,43 @@
130130
* count?: int,
131131
* },
132132
* }
133+
* @psalm-type ConfigType = array{
134+
* imports?: ImportsConfig,
135+
* parameters?: ParametersConfig,
136+
* services?: ServicesConfig,
137+
* test?: TestConfig,
138+
* "when@dev"?: array{
139+
* imports?: ImportsConfig,
140+
* parameters?: ParametersConfig,
141+
* services?: ServicesConfig,
142+
* test?: TestConfig,
143+
* },
144+
* "when@prod"?: array{
145+
* imports?: ImportsConfig,
146+
* parameters?: ParametersConfig,
147+
* services?: ServicesConfig,
148+
* test?: TestConfig,
149+
* },
150+
* "when@test"?: array{
151+
* imports?: ImportsConfig,
152+
* parameters?: ParametersConfig,
153+
* services?: ServicesConfig,
154+
* test?: TestConfig,
155+
* },
156+
* ...<string, ExtensionType|array{ // extra keys must follow the when@%env% pattern or match an extension alias
157+
* imports?: ImportsConfig,
158+
* parameters?: ParametersConfig,
159+
* services?: ServicesConfig,
160+
* ...<string, ExtensionType>,
161+
* }>
162+
* }
133163
*/
134164
final class App extends AppReference
135165
{
136166
/**
137-
* @param array{
138-
* imports?: ImportsConfig,
139-
* parameters?: ParametersConfig,
140-
* services?: ServicesConfig,
141-
* test?: TestConfig,
142-
* "when@dev"?: array{
143-
* imports?: ImportsConfig,
144-
* parameters?: ParametersConfig,
145-
* services?: ServicesConfig,
146-
* test?: TestConfig,
147-
* },
148-
* "when@prod"?: array{
149-
* imports?: ImportsConfig,
150-
* parameters?: ParametersConfig,
151-
* services?: ServicesConfig,
152-
* test?: TestConfig,
153-
* },
154-
* "when@test"?: array{
155-
* imports?: ImportsConfig,
156-
* parameters?: ParametersConfig,
157-
* services?: ServicesConfig,
158-
* test?: TestConfig,
159-
* },
160-
* ...<string, ExtensionType|array{ // extra keys must follow the when@%env% pattern or match an extension alias
161-
* imports?: ImportsConfig,
162-
* parameters?: ParametersConfig,
163-
* services?: ServicesConfig,
164-
* ...<string, ExtensionType>,
165-
* }>
166-
* } $config
167+
* @param ConfigType $config
168+
*
169+
* @psalm-return ConfigType
167170
*/
168171
public static function config(array $config): array
169172
{
@@ -184,8 +187,7 @@ public static function config(array $config): array
184187
*
185188
* return Routes::config([
186189
* 'controllers' => [
187-
* 'resource' => 'attributes',
188-
* 'type' => 'tagged_services',
190+
* 'resource' => 'routing.controllers',
189191
* ],
190192
* ]);
191193
* ```

0 commit comments

Comments
 (0)