Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/3965' into develop
Browse files Browse the repository at this point in the history
Close #3965
  • Loading branch information
weierophinney committed Mar 12, 2013
2 parents a21a096 + 466269d commit f3a579b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
18 changes: 17 additions & 1 deletion library/Zend/Code/Generator/ClassGenerator.php
Expand Up @@ -617,7 +617,7 @@ public function getMethods()
*/
public function getMethod($methodName)
{
foreach ($this->getMethods() as $method) {
foreach ($this->methods as $method) {
if ($method->getName() == $methodName) {
return $method;
}
Expand All @@ -626,6 +626,22 @@ public function getMethod($methodName)
return false;
}

/**
* @param string $methodName
* @return ClassGenerator
*/
public function removeMethod($methodName)
{
foreach ($this->methods as $key => $method) {
if ($method->getName() == $methodName) {
unset($this->methods[$key]);
break;
}
}

return $this;
}

/**
* @param string $methodName
* @return bool
Expand Down
10 changes: 10 additions & 0 deletions tests/ZendTest/Code/Generator/ClassGeneratorTest.php
Expand Up @@ -173,6 +173,16 @@ public function testHasMethod()
$this->assertTrue($classGenerator->hasMethod('methodOne'));
}

public function testRemoveMethod()
{
$classGenerator = new ClassGenerator();
$classGenerator->addMethod('methodOne');
$this->assertTrue($classGenerator->hasMethod('methodOne'));

$classGenerator->removeMethod('methodOne');
$this->assertFalse($classGenerator->hasMethod('methodOne'));
}

/**
* @group ZF-7361
*/
Expand Down

0 comments on commit f3a579b

Please sign in to comment.