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) {
            $annotationsCollection = $property->getReflectionDocComment()->getAnnotationsCollection();
            if ($property->isPublic() && $annotationsCollection->hasAnnotationTag('var')) {
                $element = $this->dom->createElement('xsd:element');
                $element->setAttribute('name', $property->getName());
                $propertyVarAnnotation = $annotationsCollection->getAnnotation('var');
                $element->setAttribute('type', $this->getXSDType(reset($propertyVarAnnotation)->getVarType()));
                if ($annotationsCollection->hasAnnotationTag('nillable')) {
                    $element->setAttribute('nillable', 'true');
                }
                if ($annotationsCollection->hasAnnotationTag('minOccurs')) {
                    $minOccurs = intval($annotationsCollection->getAnnotation('minOccurs')[0]->getDescription());
                    $element->setAttribute('minOccurs', $minOccurs > 0 ? $minOccurs : 0);
                    if ($minOccurs > 1) {
                        $all = $this->changeAllToSequence($all);
                    }
                }
                if ($annotationsCollection->hasAnnotationTag('maxOccurs')) {
                    $maxOccurs = intval($annotationsCollection->getAnnotation('maxOccurs')[0]->getDescription());
                    $element->setAttribute('maxOccurs', $maxOccurs > 0 ? $maxOccurs : 'unbounded');
                    if ($maxOccurs !== 1) {
                        $all = $this->changeAllToSequence($all);
                    }
                }
                $all->appendChild($element);
            }
        }

        $complexType = $this->dom->createElement('xsd:complexType');
        $complexType->setAttribute('name', $soapTypeName);
        $complexType->appendChild($all);

        $this->schema->appendChild($complexType);

        return $soapType;
    }
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) {
            $annotationsCollection = $property->getReflectionDocComment()->getAnnotationsCollection();
            if ($property->isPublic() && $annotationsCollection->hasAnnotationTag('var')) {
                $element = $this->dom->createElement('xsd:element');
                $element->setAttribute('name', $property->getName());
                $propertyVarAnnotation = $annotationsCollection->getAnnotation('var');
                $element->setAttribute('type', $this->getXSDType(reset($propertyVarAnnotation)->getVarType()));
                if ($annotationsCollection->hasAnnotationTag('nillable')) {
                    $element->setAttribute('nillable', 'true');
                }
                if ($annotationsCollection->hasAnnotationTag('minOccurs')) {
                    $minOccurs = intval($annotationsCollection->getAnnotation('minOccurs')[0]->getDescription());
                    $element->setAttribute('minOccurs', $minOccurs > 0 ? $minOccurs : 0);
                    if ($minOccurs > 1) {
                        $all = $this->changeAllToSequence($all);
                    }
                }
                if ($annotationsCollection->hasAnnotationTag('maxOccurs')) {
                    $maxOccurs = intval($annotationsCollection->getAnnotation('maxOccurs')[0]->getDescription());
                    $element->setAttribute('maxOccurs', $maxOccurs > 0 ? $maxOccurs : 'unbounded');
                    if ($maxOccurs !== 1) {
                        $all = $this->changeAllToSequence($all);
                    }
                }
                $all->appendChild($element);
            }
        }

        $complexType = $this->dom->createElement('xsd:complexType');
        $complexType->setAttribute('name', $soapTypeName);
        $complexType->appendChild($all);

        $this->schema->appendChild($complexType);

        return $soapType;
    }
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 ) { $ annotationsCollection = $ property -> getReflectionDocComment ( ) -> getAnnotationsCollection ( ) ; if ( $ property -> isPublic ( ) && $ annotationsCollection -> hasAnnotationTag ( 'var' ) ) { $ element = $ this -> dom -> createElement ( 'xsd:element' ) ; $ element -> setAttribute ( 'name' , $ property -> getName ( ) ) ; $ propertyVarAnnotation = $ annotationsCollection -> getAnnotation ( 'var' ) ; $ element -> setAttribute ( 'type' , $ this -> getXSDType ( reset ( $ propertyVarAnnotation ) -> getVarType ( ) ) ) ; if ( $ annotationsCollection -> hasAnnotationTag ( 'nillable' ) ) { $ element -> setAttribute ( 'nillable' , 'true' ) ; } if ( $ annotationsCollection -> hasAnnotationTag ( 'minOccurs' ) ) { $ minOccurs = intval ( $ annotationsCollection -> getAnnotation ( 'minOccurs' ) [ 0 ] -> getDescription ( ) ) ; $ element -> setAttribute ( 'minOccurs' , $ minOccurs > 0 ? $ minOccurs : 0 ) ; if ( $ minOccurs > 1 ) { $ all = $ this -> changeAllToSequence ( $ all ) ; } } if ( $ annotationsCollection -> hasAnnotationTag ( 'maxOccurs' ) ) { $ maxOccurs = intval ( $ annotationsCollection -> getAnnotation ( 'maxOccurs' ) [ 0 ] -> getDescription ( ) ) ; $ element -> setAttribute ( 'maxOccurs' , $ maxOccurs > 0 ? $ maxOccurs : 'unbounded' ) ; if ( $ maxOccurs !== 1 ) { $ all = $ this -> changeAllToSequence ( $ all ) ; } } $ all -> appendChild ( $ element ) ; } } $ complexType = $ this -> dom -> createElement ( 'xsd:complexType' ) ; $ complexType -> setAttribute ( 'name' , $ soapTypeName ) ; $ complexType -> appendChild ( $ all ) ; $ this -> schema -> appendChild ( $ complexType ) ; return $ soapType ; }
Add a complex type.

@param string $type Name of the class.
@return string
Add a complex type .