protected function addComplexType($type, $name = false, $parent = false)
    {
        if (!$parent) {
            //outline element
            //check if the complexType doesn't already exists
            if (isset($this->types[$name])) {
                return $this->types[$name];
            }
            //create the complexType tag beneath the xsd:schema tag
            $complexTypeTag = $this->addElement('xsd:complexType', $this->parentElement);
            if ($name) {
                //might be an anonymous element
                $complexTypeTag->setAttribute('name', $name);
                $this->types[$name] = $complexTypeTag;
            }
        } else {
            //inline element
            $complexTypeTag = $this->addElement('xsd:complexType', $parent);
        }

        $tag = $this->addElement('xsd:all', $complexTypeTag);
        //check if it has the name 'object()' (kind of a stdClass)
        if (strtolower(substr($type, 0, 6)) == 'object') {
            //stdClass
            $content = substr($type, 7, -1);
            $properties = explode(',', $content);//split the content into properties
            foreach ($properties as $property) {
                if (strpos($property, '=>') !== false) {
                    //array with keys (order is important, so use 'sequence' tag)
                    list($keyType, $valueType) = explode('=>', $property);
                    $el = $this->addTypeElement($valueType, $keyType, $tag);
                } else {
                    throw new WSDLException('Error creating WSDL: expected "=>". When using the object() as type, use it as object(paramname=>paramtype,paramname2=>paramtype2)', 100);
                }
            }
        } else { //should be a known class
            if (!class_exists($name)) {
                throw new WSDLException("Error creating WSDL: no class found with the name '$name' / $type : $parent, so how should we know the structure for this datatype?", 101);
            }
            $v = new IPReflectionClass($name);
            $properties = $v->getProperties(false, false, false);//not protected and private properties

            foreach ((array) $properties as $property) {
                if (!$property->isPrivate) {
                    $el = $this->addTypeElement($property->type, $property->name, $tag, $property->optional);
                }
            }
        }

        return $complexTypeTag;
    }