Inheritance: implements Phpro\SoapClient\CodeGenerator\Assembler\AssemblerInterface
 /**
  * @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)]]])]));
 }
Esempio n. 2
0
 /**
  * @param ContextInterface|TypeContext $context
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     try {
         $useAssembler = new UseAssembler($this->traitName, $this->traitAlias);
         if ($useAssembler->canAssemble($context)) {
             $useAssembler->assemble($context);
         }
         $traitAlias = $this->traitAlias ?: Normalizer::getClassNameFromFQN($this->traitName);
         $class->addTrait($traitAlias);
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
Esempio n. 3
0
 /**
  * @param ContextInterface|TypeContext $context
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $interface = $this->interfaceName;
     try {
         $useAssembler = new UseAssembler($interface);
         if ($useAssembler->canAssemble($context)) {
             $useAssembler->assemble($context);
         }
         $interfaces = $class->getImplementedInterfaces();
         if (!in_array($interface, $interfaces)) {
             $interfaces[] = $interface;
             $class->setImplementedInterfaces($interfaces);
         }
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
Esempio n. 4
0
    /**
     * @test
     */
    function it_assembles_an_existing_use_with_alias()
    {
        $assembler = new UseAssembler('MyUsedClass', 'Alias');
        $context = $this->createContext();
        $context->getClass()->addUse('MyUsedClass');
        $assembler->assemble($context);
        $code = $context->getClass()->generate();
        $expected = <<<CODE
namespace MyNamespace;

use MyUsedClass;

class MyType
{


}

CODE;
        $this->assertEquals($expected, $code);
    }