Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaad1d09

Browse files
committed
bug#40167 [DependencyInjection] Definition::removeMethodCall should remove all matching calls (ruudk)
This PR was submitted for the 5.x branch but it was merged into the 4.4 branch instead.Discussion----------[DependencyInjection] Definition::removeMethodCall should remove all matching callsIt would only remove the first match, leaving the other method call(s) there to exist. This leads to unexpected situations.| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets | None| License | MIT| Doc PR |I found out that `Definition::removeMethodCall` only removes the first method call and stops. It should remove all method calls named `$method`.Commits-------944ba23 Definition::removeMethodCall should remove all matching calls
2 parents4a32fd0 +944ba23 commitaad1d09

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

‎src/Symfony/Component/DependencyInjection/Definition.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ public function removeMethodCall($method)
392392
foreach ($this->callsas$i =>$call) {
393393
if ($call[0] ===$method) {
394394
unset($this->calls[$i]);
395-
break;
396395
}
397396
}
398397

‎src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,4 +425,20 @@ public function testAddError()
425425
$def->addError('Second error');
426426
$this->assertSame(['First error','Second error'],$def->getErrors());
427427
}
428+
429+
publicfunctiontestMultipleMethodCalls()
430+
{
431+
$def =newDefinition('stdClass');
432+
433+
$def->addMethodCall('configure', ['arg1']);
434+
$this->assertTrue($def->hasMethodCall('configure'));
435+
$this->assertCount(1,$def->getMethodCalls());
436+
437+
$def->addMethodCall('configure', ['arg2']);
438+
$this->assertTrue($def->hasMethodCall('configure'));
439+
$this->assertCount(2,$def->getMethodCalls());
440+
441+
$def->removeMethodCall('configure');
442+
$this->assertFalse($def->hasMethodCall('configure'));
443+
}
428444
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp