8000 Merge branch '2.7' into 2.8 · symfony/dependency-injection@9f4e9f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f4e9f0

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Locale] Add missing @group legacy annotations Fix security-acl deps Fix doctrine mapping validation type error Remove skipping of tests based on ICU data version whenever possible Fix the handling of null as locale in the stub intl classes do not dump leading backslashes in class names fix issue #15377 Skip ::class constant [Config] type specific check for emptiness Conflicts: src/Symfony/Bridge/Twig/composer.json src/Symfony/Bundle/SecurityBundle/composer.json src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
2 parents 12eedb8 + 319f1b3 commit 9f4e9f0

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

Dumper/GraphvizDumper.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,18 @@ private function findNodes()
166166
$container = $this->cloneContainer();
167167

168168
foreach ($container->getDefinitions() as $id => $definition) {
169-
$className = $definition->getClass();
169+
$class = $definition->getClass();
170+
171+
if ('\\' === substr($class, 0, 1)) {
172+
$class = substr($class, 1);
173+
}
170174

171175
try {
172-
$className = $this->container->getParameterBag()->resolveValue($className);
176+
$class = $this->container->getParameterBag()->resolveValue($class);
173177
} catch (ParameterNotFoundException $e) {
174178
}
175179

176-
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $className), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope(false) ? 'filled' : 'dotted')));
180+
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope(false) ? 'filled' : 'dotted')));
177181
$container->setDefinition($id, new Definition('stdClass'));
178182
}
179183

Dumper/PhpDumper.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,13 @@ private function addServiceReturn($id, $definition)
372372
*/
373373
private function addServiceInstance($id, $definition)
374374
{
375-
$class = $this->dumpValue($definition->getClass());
375+
$class = $definition->getClass();
376+
377+
if ('\\' === substr($class, 0, 1)) {
378+
$class = substr($class, 1);
379+
}
380+
381+
$class = $this->dumpValue($class);
376382

377383
if (0 === strpos($class, "'") && !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
378384
throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id));
@@ -560,7 +566,7 @@ private function addService($id, $definition)
560566
if ($definition->isSynthetic()) {
561567
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
562568
} elseif ($class = $definition->getClass()) {
563-
$return[] = sprintf('@return %s A %s instance.', 0 === strpos($class, '%') ? 'object' : '\\'.$class, $class);
569+
$return[] = sprintf('@return %s A %s instance.', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\'));
564570
} elseif ($definition->getFactory()) {
565571
$factory = $definition->getFactory();
566572
if (is_string($factory)) {

Dumper/XmlDumper.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ private function addService($definition, $id, \DOMElement $parent)
114114
if (null !== $id) {
115115
$service->setAttribute('id', $id);
116116
}
117-
if ($definition->getClass()) {
118-
$service->setAttribute('class', $definition->getClass());
117+
if ($class = $definition->getClass()) {
118+
if ('\\' === substr($class, 0, 1)) {
119+
$class = substr($class, 1);
120+
}
121+
122+
$service->setAttribute('class', $class);
119123
}
120124
if ($definition->getFactoryMethod(false)) {
121125
$service->setAttribute('factory-method', $definition->getFactoryMethod(false));

Dumper/YamlDumper.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
6464
private function addService($id, $definition)
6565
{
6666
$code = " $id:\n";
67-
if ($definition->getClass()) {
68-
$code .= sprintf(" class: %s\n", $definition->getClass());
67+
if ($class = $definition->getClass()) {
68+
if ('\\' === substr($class, 0, 1)) {
69+
$class = substr($class, 1);
70+
}
71+
72+
$code .= sprintf(" class: %s\n", $class);
6973
}
7074

7175
if (!$definition->isPublic()) {

Tests/Fixtures/containers/container9.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
$container = new ContainerBuilder();
1212
$container
13-
->register('foo', 'Bar\FooClass')
13+
->register('foo', '\Bar\FooClass')
1414
->addTag('foo', array('foo' => 'foo'))
1515
->addTag('foo', array('bar' => 'bar', 'baz' => 'baz'))
1616
->setFactory(array('Bar\\FooClass', 'getInstance'))

0 commit comments

Comments
 (0)
0