Skip to content

Commit 1dfbf6a

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: always check for all fields to be mapped clarify exception when no args are configured [PropertyAccess] Handle interfaces in the invalid argument exception [Debug] Workaround "null" $context [Debug] Remove $context arg from handleError(), preparing for PHP 7.2 [Routing] Fix BC break in AnnotationClassLoader defaults attributes handling Fix tests with ICU 57.1 Fix the condition checking the minimum ICU version
2 parents 089275e + 0dd7e22 commit 1dfbf6a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Definition.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ public function addArgument($argument)
308308
*/
309309
public function replaceArgument($index, $argument)
310310
{
311+
if (0 === count($this->arguments)) {
312+
throw new OutOfBoundsException('Cannot replace arguments if none have been configured yet.');
313+
}
314+
311315
if ($index < 0 || $index > count($this->arguments) - 1) {
312316
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
313317
}

Tests/DefinitionTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ public function testGetArgumentShouldCheckBounds()
292292

293293
/**
294294
* @expectedException \OutOfBoundsException
295+
* @expectedExceptionMessage The index "1" is not in the range [0, 0].
295296
*/
296297
public function testReplaceArgumentShouldCheckBounds()
297298
{
@@ -301,6 +302,16 @@ public function testReplaceArgumentShouldCheckBounds()
301302
$def->replaceArgument(1, 'bar');
302303
}
303304

305+
/**
306+
* @expectedException \OutOfBoundsException
307+
* @expectedExceptionMessage Cannot replace arguments if none have been configured yet.
308+
*/
309+
public function testReplaceArgumentWithoutExistingArgumentsShouldCheckBounds()
310+
{
311+
$def = new Definition('stdClass');
312+
$def->replaceArgument(0, 'bar');
313+
}
314+
304315
public function testSetGetProperties()
305316
{
306317
$def = new Definition('stdClass');

0 commit comments

Comments
 (0)