CodeDoc/Data/Method.php
authorAlan Knowles <alan@roojs.com>
Tue, 25 Oct 2016 07:04:27 +0000 (15:04 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 25 Oct 2016 07:04:27 +0000 (15:04 +0800)
CodeDoc/Data/Method.php [new file with mode: 0644]

diff --git a/CodeDoc/Data/Method.php b/CodeDoc/Data/Method.php
new file mode 100644 (file)
index 0000000..cefa5f8
--- /dev/null
@@ -0,0 +1,163 @@
+<?php
+
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/2_02.txt.                                 |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Alan Knowles <alan@akbkhome.com>                      |
+// +----------------------------------------------------------------------+
+//
+require_once 'PHP/CodeDoc/Data.php';
+/**
+*   Method and Function Data Container
+*
+*   @package  PHP_CodeDoc
+*   @access   public
+*   @author   Alan Knowles <alan@akbkhome.com>
+*
+*/
+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',
+                        )
+                    )   
+                )
+            )
+        );
+                
+                
+        
+    }
+}