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)]]])]));
 }
示例#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']]])]));
 }
示例#3
0
 public function testRemoveMethod()
 {
     $classGenerator = new ClassGenerator();
     $classGenerator->addMethod('methodOne');
     $this->assertTrue($classGenerator->hasMethod('methodOne'));
     $classGenerator->removeMethod('methodOne');
     $this->assertFalse($classGenerator->hasMethod('methodOne'));
 }
示例#4
0
 public function testRemoveMethodInsensitive()
 {
     $classGenerator = new ClassGenerator();
     $classGenerator->addMethod('methodOne');
     $classGenerator->removeMethod('METHODONe');
     $this->assertFalse($classGenerator->hasMethod('methodOne'));
 }