From cac90ea6547fe194ab6ab101dfe11a0b751823ca Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 3 Jan 2007 15:52:55 +0000 Subject: Updated generator to use DocComment for generating class properties. --- framework/3rdParty/WsdlGen/WsdlGenerator.php | 39 +++++++++++++--------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'framework') diff --git a/framework/3rdParty/WsdlGen/WsdlGenerator.php b/framework/3rdParty/WsdlGen/WsdlGenerator.php index b7ab544d..cc18595e 100644 --- a/framework/3rdParty/WsdlGen/WsdlGenerator.php +++ b/framework/3rdParty/WsdlGen/WsdlGenerator.php @@ -259,29 +259,26 @@ class WsdlGenerator */ private function extractClassProperties($className) { - // Lets get the class' file so we can read the full contents of it. - $classReflect = new ReflectionClass($className); - - if (!file_exists($classReflect->getFileName())) { - throw new Exception('Could not find class file for '.$className); - } - - $file = file_get_contents($classReflect->getFileName()); - if ($file == '') { - throw new Exception("File {$classReflect->getFileName()} could not be opened"); - } - - $pos = strpos($file, 'class ' . $className); - $pos = strpos($file, '@var', $pos) + 5; - for($t = 0; $pos > 5; $t++) + /** + * modified by Qiang Xue, Jan. 2, 2007 + * Using Reflection's DocComment to obtain property definitions + * DocComment is available since PHP 5.1 + */ + $reflection = new ReflectionClass($className); + $properties = $reflection->getProperties(); + foreach($properties as $property) { - $type = $this->convertType(substr($file, $pos, strpos($file, ' ', $pos) - $pos)); - $pos = strpos($file, '$', $pos) + 1; - $name = substr($file, $pos, strpos($file, ';', $pos) - $pos); - $this->types[$className][$t] = array('type' => $type, 'name' => $name); - $pos = strpos($file, '@var', $pos) + 5; + $comment = $property->getDocComment(); + if($property->isPublic() && strpos($comment, '@soapproperty') !== false) + { + if (preg_match('/@var\s+(\w+(\[\])?)\s+\$(\w+)/mi', $comment, $match)) { + $param = array(); + $param['type'] = $this->convertType($match[1]); + $param['name'] = $match[3]; + $this->types[$className][] = $param; + } + } } } - } ?> \ No newline at end of file -- cgit v1.2.3