コード例 #1
0
ファイル: GetterAssembler.php プロジェクト: phpro/soap-client
 /**
  * @param ContextInterface|PropertyContext $context
  *
  * @throws AssemblerException
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $property = $context->getProperty();
     try {
         $methodName = Normalizer::generatePropertyMethod('get', $property->getName());
         $class->removeMethod($methodName);
         $class->addMethodFromGenerator(MethodGenerator::fromArray(['name' => $methodName, 'parameters' => [], 'visibility' => MethodGenerator::VISIBILITY_PUBLIC, 'body' => sprintf('return $this->%s;', $property->getName()), 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'return', 'description' => $property->getType()]]])]));
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
コード例 #2
0
 /**
  * @param ContextInterface|TypeContext $context
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $type = $context->getType();
     try {
         $class->removeMethod('__construct');
         $constructor = $this->assembleConstructor($type);
         $class->addMethodFromGenerator($constructor);
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
コード例 #3
0
ファイル: UseAssembler.php プロジェクト: phpro/soap-client
 /**
  * @param ContextInterface|TypeContext $context
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     try {
         $uses = $class->getUses();
         if (!in_array(Normalizer::getCompleteUseStatement($this->useName, $this->useAlias), $uses) && !in_array($this->useName, $uses)) {
             $class->addUse($this->useName, $this->useAlias);
         }
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
コード例 #4
0
 /**
  * @param ContextInterface|PropertyContext $context
  *
  * @throws AssemblerException
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $property = $context->getProperty();
     try {
         // It's not possible to overwrite a property in zend-code yet!
         if ($class->hasProperty($property->getName())) {
             return;
         }
         $class->addPropertyFromGenerator(PropertyGenerator::fromArray(['name' => $property->getName(), 'visibility' => PropertyGenerator::VISIBILITY_PROTECTED, 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'var', 'description' => $property->getType()]]])]));
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
コード例 #5
0
ファイル: TraitAssembler.php プロジェクト: phpro/soap-client
 /**
  * @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);
     }
 }
コード例 #6
0
 /**
  * @param ContextInterface|TypeContext $context
  *
  * @throws AssemblerException
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $properties = $context->getType()->getProperties();
     $firstProperty = count($properties) ? current($properties) : null;
     try {
         $interfaceAssembler = new InterfaceAssembler(\IteratorAggregate::class);
         if ($interfaceAssembler->canAssemble($context)) {
             $interfaceAssembler->assemble($context);
         }
         if ($firstProperty) {
             $this->implementGetIterator($class, $firstProperty);
         }
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
コード例 #7
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);
     }
 }
コード例 #8
0
 /**
  * @param ContextInterface|TypeContext $context
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $class->setFinal(true);
 }