removeMethod() public method

public removeMethod ( string $methodName ) : self
$methodName string
return self
 /**
  * @param ContextInterface $context
  * @param ClassGenerator   $class
  * @param Property         $property
  *
  * @throws \Zend\Code\Generator\Exception\InvalidArgumentException
  */
 private function implementGetResult(ContextInterface $context, ClassGenerator $class, Property $property)
 {
     $useAssembler = new UseAssembler($this->wrapperClass ?: ResultInterface::class);
     if ($useAssembler->canAssemble($context)) {
         $useAssembler->assemble($context);
     }
     $methodName = 'getResult';
     $class->removeMethod($methodName);
     $class->addMethodFromGenerator(MethodGenerator::fromArray(['name' => $methodName, 'parameters' => [], 'visibility' => MethodGenerator::VISIBILITY_PUBLIC, 'body' => $this->generateGetResultBody($property), 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'return', 'description' => $this->generateGetResultReturnTag($property)]]])]));
 }
Example #2
0
 /**
  * @param ClassGenerator $class
  * @param Property       $firstProperty
  *
  * @throws \Zend\Code\Generator\Exception\InvalidArgumentException
  */
 private function implementGetIterator($class, $firstProperty)
 {
     $methodName = 'getIterator';
     $class->removeMethod($methodName);
     $class->addMethodFromGenerator(MethodGenerator::fromArray(['name' => $methodName, 'parameters' => [], 'visibility' => MethodGenerator::VISIBILITY_PUBLIC, 'body' => sprintf('return new \\ArrayIterator(is_array($this->%1$s) ? $this->%1$s : []);', $firstProperty->getName()), 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'return', 'description' => '\\ArrayIterator']]])]));
 }
 public function testRemoveMethod()
 {
     $classGenerator = new ClassGenerator();
     $classGenerator->addMethod('methodOne');
     $this->assertTrue($classGenerator->hasMethod('methodOne'));
     $classGenerator->removeMethod('methodOne');
     $this->assertFalse($classGenerator->hasMethod('methodOne'));
 }
Example #4
0
 public function testRemoveMethodInsensitive()
 {
     $classGenerator = new ClassGenerator();
     $classGenerator->addMethod('methodOne');
     $classGenerator->removeMethod('METHODONe');
     $this->assertFalse($classGenerator->hasMethod('methodOne'));
 }