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; }
/** * 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; }
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; }