Skip to content

Commit

Permalink
Throw exceptions in case someone forgot to set method name in call.
Browse files Browse the repository at this point in the history
Bug fix: yes
Feature add: no
Symfony2 tests pass: yes
Symfony2 tests added: yes

In general without this exception generated by php dumper container class, will cause PHP fatal error, bacause method call will look like this: `$instance->(/* arguments*/);`.
  • Loading branch information
canni committed Nov 30, 2011
1 parent 001a25a commit 0a5240d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Definition.php
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\DependencyInjection;

use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;

/**
* Definition represents a service definition.
*
Expand Down Expand Up @@ -308,10 +310,15 @@ public function setMethodCalls(array $calls = array())
*
* @return Definition The current instance
*
* @throws InvalidArgumentException on empty $method param
*
* @api
*/
public function addMethodCall($method, array $arguments = array())
{
if (empty($method)) {
throw new InvalidArgumentException(sprintf('Method name cannot be empty.'));
}
$this->calls[] = array($method, $arguments);

return $this;
Expand Down

0 comments on commit 0a5240d

Please sign in to comment.