Skip to content

Commit 3681411

Browse files
authored
[CodeQuality] Handle crash on no extensions on StringExtensionToConfigBuilderRector (#717)
1 parent b5f953a commit 3681411

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
6+
7+
use Http\Discovery\Psr17Factory;
8+
use Psr\Http\Message\RequestFactoryInterface;
9+
use Psr\Http\Message\ResponseFactoryInterface;
10+
use Psr\Http\Message\ServerRequestFactoryInterface;
11+
use Psr\Http\Message\StreamFactoryInterface;
12+
use Psr\Http\Message\UploadedFileFactoryInterface;
13+
use Psr\Http\Message\UriFactoryInterface;
14+
15+
return static function (ContainerConfigurator $containerConfigurator): void {
16+
$services = $containerConfigurator->services();
17+
18+
$services->alias(RequestFactoryInterface::class, 'http_discovery.psr17_factory');
19+
20+
$services->alias(ResponseFactoryInterface::class, 'http_discovery.psr17_factory');
21+
22+
$services->alias(ServerRequestFactoryInterface::class, 'http_discovery.psr17_factory');
23+
24+
$services->alias(StreamFactoryInterface::class, 'http_discovery.psr17_factory');
25+
26+
$services->alias(UploadedFileFactoryInterface::class, 'http_discovery.psr17_factory');
27+
28+
$services->alias(UriFactoryInterface::class, 'http_discovery.psr17_factory');
29+
30+
$services->set('http_discovery.psr17_factory', Psr17Factory::class);
31+
};

src/NodeAnalyzer/SymfonyClosureExtensionMatcher.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public function match(Closure $closure): ?ExtensionKeyAndConfiguration
2929
return null;
3030
}
3131

32+
if ($extensionNames === []) {
33+
return null;
34+
}
35+
3236
// warn use early about it, to avoid silent skip
3337
$errorMessage = sprintf(
3438
'Split extensions "%s" to multiple separated files first',

0 commit comments

Comments
 (0)