Skip to content

Commit c6c7891

Browse files
Merge branch '4.3' into 4.4
* 4.3: cs fix Fix inconsistent return points. [Config] Add handling for ignored keys in ArrayNode::mergeValues. Fix inconsistent return points. [Security/Core] UserInterface::getPassword() can return null [Router] Fix TraceableUrlMatcher behaviour with trailing slash Revert "bug #33092 [DependencyInjection] Improve an exception message (fabpot)"
2 parents 99b87a8 + f67759e commit c6c7891

File tree

9 files changed

+13
-25
lines changed

9 files changed

+13
-25
lines changed

Compiler/CheckArgumentsValidityPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,7 @@ protected function processValue($value, $isRoot = false)
8181
}
8282
}
8383
}
84+
85+
return null;
8486
}
8587
}

Compiler/ResolveClassPass.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@ public function process(ContainerBuilder $container)
2929
if ($definition->isSynthetic() || null !== $definition->getClass()) {
3030
continue;
3131
}
32-
if (preg_match('/^\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)++$/', $id)) {
32+
if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)++$/', $id)) {
3333
if ($definition instanceof ChildDefinition && !class_exists($id)) {
3434
throw new InvalidArgumentException(sprintf('Service definition "%s" has a parent but no class, and its name looks like a FQCN. Either the class is missing or you want to inherit it from the parent service. To resolve this ambiguity, please rename this service to a non-FQCN (e.g. using dots), or create the missing class.', $id));
3535
}
36-
if ('\\' === $id[0]) {
37-
throw new InvalidArgumentException(sprintf('Service definition "%s" has no class, and its name looks like a FQCN but it starts with a backslash; remove the leading backslash.', $id));
38-
}
3936
$definition->setClass($id);
4037
}
4138
}

Container.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ private function make(string $id, int $invalidBehavior)
282282

283283
throw new ServiceNotFoundException($id, null, null, $alternatives);
284284
}
285+
286+
return null;
285287
}
286288

287289
/**

ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ private function doGet(string $id, int $invalidBehavior = ContainerInterface::EX
601601
$definition = $this->getDefinition($id);
602602
} catch (ServiceNotFoundException $e) {
603603
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $invalidBehavior) {
604-
return;
604+
return null;
605605
}
606606

607607
throw $e;

EnvVarProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function getEnv($prefix, $name, \Closure $getEnv)
120120

121121
if (false !== $i || 'string' !== $prefix) {
122122
if (null === $env = $getEnv($name)) {
123-
return;
123+
return null;
124124
}
125125
} elseif (isset($_ENV[$name])) {
126126
$env = $_ENV[$name];
@@ -132,7 +132,7 @@ public function getEnv($prefix, $name, \Closure $getEnv)
132132
}
133133

134134
if (null === $env = $this->container->getParameter("env($name)")) {
135-
return;
135+
return null;
136136
}
137137
}
138138

Extension/Extension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function getConfiguration(array $config, ContainerBuilder $container)
101101
return null;
102102
}
103103

104-
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
104+
final protected function processConfiguration(ConfigurationInterface $configuration, array $configs): array
105105
{
106106
$processor = new Processor();
107107

LazyProxy/ProxyHelper.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa
5050
if ('self' === $lcName) {
5151
return $prefix.$r->getDeclaringClass()->name;
5252
}
53-
if ($parent = $r->getDeclaringClass()->getParentClass()) {
54-
return $prefix.$parent->name;
55-
}
53+
54+
return ($parent = $r->getDeclaringClass()->getParentClass()) ? $prefix.$parent->name : null;
5655
}
5756
}

Tests/Compiler/ResolveClassPassTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\DependencyInjection\ChildDefinition;
1616
use Symfony\Component\DependencyInjection\Compiler\ResolveClassPass;
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
18-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1918
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
2019

2120
class ResolveClassPassTest extends TestCase
@@ -59,17 +58,6 @@ public function provideInvalidClassId()
5958
yield ['\DateTime'];
6059
}
6160

62-
public function testWontResolveClassFromClassIdWithLeadingBackslash()
63-
{
64-
$this->expectException(InvalidArgumentException::class);
65-
$this->expectExceptionMessage('Service definition "\App\Some\Service" has no class, and its name looks like a FQCN but it starts with a backslash; remove the leading backslash.');
66-
67-
$container = new ContainerBuilder();
68-
$container->register('\App\Some\Service');
69-
70-
(new ResolveClassPass())->process($container);
71-
}
72-
7361
public function testNonFqcnChildDefinition()
7462
{
7563
$container = new ContainerBuilder();

Tests/ContainerBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,8 +1288,8 @@ public function testNoClassFromGlobalNamespaceClassIdWithLeadingSlash()
12881288

12891289
public function testNoClassFromNamespaceClassIdWithLeadingSlash()
12901290
{
1291-
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
1292-
$this->expectExceptionMessage('Service definition "\Symfony\Component\DependencyInjection\Tests\FooClass" has no class, and its name looks like a FQCN but it starts with a backslash; remove the leading backslash.');
1291+
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
1292+
$this->expectExceptionMessage('The definition for "\Symfony\Component\DependencyInjection\Tests\FooClass" has no class attribute, and appears to reference a class or interface. Please specify the class attribute explicitly or remove the leading backslash by renaming the service to "Symfony\Component\DependencyInjection\Tests\FooClass" to get rid of this error.');
12931293
$container = new ContainerBuilder();
12941294

12951295
$container->register('\\'.FooClass::class);

0 commit comments

Comments
 (0)