From f549e3f82834399f1f249a2d4f8099dd2de891b0 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 25 Oct 2016 15:04:27 +0800 Subject: [PATCH] CodeDoc/Data/Method.php --- CodeDoc/Data/Method.php | 163 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 CodeDoc/Data/Method.php diff --git a/CodeDoc/Data/Method.php b/CodeDoc/Data/Method.php new file mode 100644 index 0000000..cefa5f8 --- /dev/null +++ b/CodeDoc/Data/Method.php @@ -0,0 +1,163 @@ + | +// +----------------------------------------------------------------------+ +// +require_once 'PHP/CodeDoc/Data.php'; +/** +* Method and Function Data Container +* +* @package PHP_CodeDoc +* @access public +* @author Alan Knowles +* +*/ +class PHP_CodeDoc_Data_Method extends PHP_CodeDoc_Data { + var $id; // id in the Classes Operations array (not used yet) + var $name; // the name of the method + var $type; // Private | Public + var $class; // what class it is defined in + var $visibility; // Not used (always 1) + var $Param; // Array of Methods Parameters. + + var $description; // phpdoc class + var $isPublic = 1; + var $isStatic = 0; + var $isFinal = 0; + + function __construct() + { + $this->description = new PHP_CodeDoc_Data_PhpDoc(); + } + + function mergePhpDoc() { + $isOptional = FALSE; + foreach (array_keys($this->Param) as $i) { + if (@$this->description->param[$i]) { + $this->Param[$i]->type = @$this->description->param[$i]->type; + $this->Param[$i]->desc = @$this->description->param[$i]->desc; + } + $this->Param[$i]->shortname = substr($this->Param[$i]->name,1); + + if (isset($this->Param[$i]->Value)) { + $isOptional =TRUE; + } + if (!isset($this->Param[$i]->Value) && $isOptional) { + PHP_CodeDoc_Error::log("Missing optional value in method",$this); + } + $this->Param[$i]->isOptional=$isOptional ; + } + + + } + function toJs() + { + if ($this->type == 'Private') { + return false; + } + + $def_param = array( + 'desc' => '', + 'is_optional' => false, + 'name' => '', + 'type' => '', + '|xns' => 'Roo.doc', + 'xtype' => 'Param', + + ); + $params = array(); + foreach($this->Param as $i=>$obj) { + if (!isset($params[$i])) { + $params[$i] = $def_param; + } + $params[$i]['name'] = $obj->name; + } + foreach($this->description->param as $i=>$obj) { + if (!isset($params[$i])) { + $params[$i] = $def_param; + } + $params[$i]['desc'] = $obj->desc; + $params[$i]['type'] = $obj->type; + // fixme - is_optional and default values... + } + + + return + + array( + "name" => $this->name, + "parent" => "", + "title" => "", + "permname" => "", + "modOrder" => "001", + "items" => array( + + + + array( + 'name' => $this->name, + 'purpose' => $this->description->short, + 'stype' => 'function', + '|xns' => 'Roo.doc', + 'xtype' => 'Entry', + 'items' => array( + array( + 'name' => $this->name, + 'is_static' => $this->isStatic ? true:false, + 'memberof' => $this->class, + 'returndesc' => $this->name == '_construct' ? '' : $this->description->return->desc, + 'returntype' => $this->name == '_construct' ? '' : $this->description->return->type, + + '|xns' => 'Roo.doc', + 'xtype' => 'Synopsis', + 'items' => $params + ), + array( + 'stype' => 'desc', + '|xns' => 'Roo.doc', + 'xtype' => 'Section', + 'items' => array( + array( + 'html' => $this->description->longToHTML(), + '|xns' => 'Roo.doc', + 'xtype' => 'Para', + ) + ) + ), + array( + 'stype' => 'parameter', + '|xns' => 'Roo.doc', + 'xtype' => 'Section', + ), + array( + 'stype' => 'return', + '|xns' => 'Roo.doc', + 'xtype' => 'Section', + ), + array( + 'stype' => 'example', + '|xns' => 'Roo.doc', + 'xtype' => 'Section', + ) + ) + ) + ) + ); + + + + } +} -- 2.39.2