Beispiel #1
0
 /**
  * Generate the WSDL DOMDocument.
  *
  * @param boolean $withAnnotation Flag if only the methods with '@soap' annotation should be added.
  */
 public function generateWSDL($withAnnotation = false)
 {
     $qNameClassName = WSDL::typeToQName($this->class);
     $this->wsdl = new WSDL($qNameClassName, $this->uri);
     $port = $this->wsdl->addPortType($qNameClassName . 'Port');
     $binding = $this->wsdl->addBinding($qNameClassName . 'Binding', 'tns:' . $qNameClassName . 'Port');
     $this->wsdl->addSoapBinding($binding, $this->bindingStyle['style'], $this->bindingStyle['transport']);
     $this->wsdl->addService($qNameClassName . 'Service', $qNameClassName . 'Port', 'tns:' . $qNameClassName . 'Binding', $this->uri);
     $ref = new ReflectionClass($this->class);
     foreach ($ref->getMethods() as $method) {
         if ($withAnnotation === false || $method->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('soap')) {
             $this->addMethodToWsdl($method, $port, $binding);
         }
     }
 }
 /**
  * Check if the found trait name is the one that we need to reflect.
  *
  * @param string $name The name of the trait found.
  * @return boolean
  */
 private function isSearchedTrait($name)
 {
     if ($this->name === $name) {
         return true;
     }
     if (strpos($name, '\\') === 0) {
         return $this->name === $name || '\\' . $this->name === $name;
     }
     $name = $this->declaringClass->getNamespaceName() . '\\' . $name;
     return $this->name === $name || $this->name === '\\' . $name;
 }
Beispiel #3
0
 private function lookProperties(ReflectionClass $reflect, $obj)
 {
     $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PRIVATE);
     $item = array();
     $parent = $reflect->getParentClass();
     if ($parent) {
         $item = array_merge($item, $this->lookProperties($parent, $obj));
     }
     foreach ($props as $prop) {
         $prop->setAccessible(true);
         $property = $prop->getValue($obj);
         //                    if(!is_object($property))
         //                       $item[$prop->getName()]=  '';
         //                    else
         $item[$prop->getName()] = $property;
         //                       print_r($property);
         //                       echo '<br>';
     }
     //                die;
     return $item;
 }
Beispiel #4
0
 /**
  * Add a complex type.
  *
  * @param string $type Name of the class.
  * @return string
  */
 public function addComplexType($type)
 {
     if (isset($this->includedTypes[$type])) {
         return $this->includedTypes[$type];
     }
     if (strpos($type, '[]') !== false) {
         return $this->addComplexTypeArray(str_replace('[]', '', $type), $type);
     }
     $class = new ReflectionClass($type);
     $soapTypeName = static::typeToQName($type);
     $soapType = 'tns:' . $soapTypeName;
     $this->addType($type, $soapType);
     $all = $this->dom->createElement('xsd:all');
     foreach ($class->getProperties() as $property) {
         if ($property->isPublic() && $property->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('var')) {
             $element = $this->dom->createElement('xsd:element');
             $element->setAttribute('name', $property->getName());
             $propertyVarAnnotation = $property->getReflectionDocComment()->getAnnotationsCollection()->getAnnotation('var');
             $element->setAttribute('type', $this->getXSDType(reset($propertyVarAnnotation)->getVarType()));
             if ($property->getReflectionDocComment()->getAnnotationsCollection()->hasAnnotationTag('nillable')) {
                 $element->setAttribute('nillable', 'true');
             }
             $all->appendChild($element);
         }
     }
     $complexType = $this->dom->createElement('xsd:complexType');
     $complexType->setAttribute('name', $soapTypeName);
     $complexType->appendChild($all);
     $this->schema->appendChild($complexType);
     return $soapType;
 }
Beispiel #5
0
 private function lookProperties(ReflectionClass $reflect, $obj)
 {
     $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PRIVATE);
     $item = array();
     $parent = $reflect->getParentClass();
     if ($parent) {
         $item = array_merge($item, $this->lookProperties($parent, $obj));
     }
     foreach ($props as $prop) {
         $prop->setAccessible(true);
         $property = $prop->getValue($obj);
         $item[$prop->getName()] = $property;
     }
     return $item;
 }
 /**
  * Generates a trait class
  *
  * @param ReflectionClass $reflectionClass
  *
  * @return string
  */
 protected function generateTrait(ReflectionClass $reflectionClass) : string
 {
     $generator = new TraitGenerator($reflectionClass->getShortName(), $reflectionClass->getNamespaceName());
     $this->getTraitGeneratorEnhancerTraverser()->traverse($generator);
     return '<?php' . str_repeat(PHP_EOL, 2) . $generator->generate();
 }
 /**
  * Constructor.
  *
  * @param string $class The name of the class where the constant has been declared.
  * @param string $name The name of the constant to reflect.
  */
 public function __construct($class, $name)
 {
     $this->declaringClass = new ReflectionClass($class);
     $this->name = $name;
     $this->value = $this->declaringClass->getConstant($name);
 }
 /**
  * Returns an array of traits used by this class.
  *
  * @return \Wingu\OctopusCore\Reflection\ReflectionClass[]
  */
 public function getTraits()
 {
     $return = parent::getTraits();
     if ($return !== null) {
         foreach ($return as $key => $val) {
             $return[$key] = new static($val->getName());
         }
     }
     return $return;
 }