Skip to content

Commit 2dc012e

Browse files
committed
[DependencyInjection] fixed ? position in some exception messages (refs symfony#7861)
1 parent 38f9cf3 commit 2dc012e

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ public function updateRepr()
5757
if ($this->alternatives) {
5858
if (1 == count($this->alternatives)) {
5959
$this->message .= ' Did you mean this: "';
60-
} elseif (1 < count($this->alternatives)) {
60+
} else {
6161
$this->message .= ' Did you mean one of these: "';
6262
}
63-
$this->message .= implode('", "', $this->alternatives);
64-
$this->message .= '" ?';
63+
$this->message .= implode('", "', $this->alternatives).'"?';
6564
}
6665
}
6766

src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ public function __construct($id, $sourceId = null, \Exception $previous = null,
3232
if ($alternatives) {
3333
if (1 == count($alternatives)) {
3434
$msg .= ' Did you mean this: "';
35-
} elseif (1 < count($alternatives)) {
35+
} else {
3636
$msg .= ' Did you mean one of these: "';
3737
}
38-
$msg .= implode('", "', $alternatives);
39-
$msg .= '" ?';
38+
$msg .= implode('", "', $alternatives).'"?';
4039
}
4140

4241
parent::__construct($msg, 0, $previous);

src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,15 @@ public function testGetThrowServiceNotFoundException()
179179
$this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist');
180180
} catch (\Exception $e) {
181181
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist');
182-
$this->assertEquals('You have requested a non-existent service "foo1". Did you mean this: "foo" ?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException with some advices');
182+
$this->assertEquals('You have requested a non-existent service "foo1". Did you mean this: "foo"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException with some advices');
183183
}
184184

185185
try {
186186
$sc->get('bag');
187187
$this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist');
188188
} catch (\Exception $e) {
189189
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException if the key does not exist');
190-
$this->assertEquals('You have requested a non-existent service "bag". Did you mean one of these: "bar", "baz" ?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException with some advices');
190+
$this->assertEquals('You have requested a non-existent service "bag". Did you mean one of these: "bar", "baz"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException with some advices');
191191
}
192192
}
193193

src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ public function testGetThrowParameterNotFoundException()
9797
$this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist');
9898
} catch (\Exception $e) {
9999
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist');
100-
$this->assertEquals('You have requested a non-existent parameter "foo1". Did you mean this: "foo" ?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices');
100+
$this->assertEquals('You have requested a non-existent parameter "foo1". Did you mean this: "foo"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices');
101101
}
102102

103103
try {
104104
$bag->get('bag');
105105
$this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist');
106106
} catch (\Exception $e) {
107107
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException', $e, '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist');
108-
$this->assertEquals('You have requested a non-existent parameter "bag". Did you mean one of these: "bar", "baz" ?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices');
108+
$this->assertEquals('You have requested a non-existent parameter "bag". Did you mean one of these: "bar", "baz"?', $e->getMessage(), '->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException with some advices');
109109
}
110110

111111
try {

0 commit comments

Comments
 (0)