[Sungrazr-svn] [111] Sungrazr_Docs_Phpdoc: [NEW] added support for @ subparam definitions

0 views
Skip to first unread message

cl...@killersoft.com

unread,
Feb 9, 2008, 10:27:28 PM2/9/08
to Sungra...@googlegroups.com
Revision
111
Author
clay
Date
2008-02-09 19:27:27 -0800 (Sat, 09 Feb 2008)

Log Message

Sungrazr_Docs_Phpdoc: [NEW] added support for @subparam definitions

Modified Paths

Diff

Modified: trunk/Sungrazr/Docs/Phpdoc.php (110 => 111)


--- trunk/Sungrazr/Docs/Phpdoc.php	2007-12-31 05:34:48 UTC (rev 110)
+++ trunk/Sungrazr/Docs/Phpdoc.php	2008-02-10 03:27:27 UTC (rev 111)
@@ -38,4 +38,73 @@
         }
         $this->_info['supports'] = $methods;
     }   
+    
+    /**
+     * 
+     * Parses one or more @subparam lines into $this->_info.
+     * 
+     * A subparam may be:
+     * 
+     *  $param->property
+     *  $param::static
+     *  $param[key]
+     * 
+     * Intended to document expected keys/properties of parameters.
+     * 
+     * @param string $line The block line.
+     * 
+     * @return void
+     * 
+     */
+    public function parseSubparam($line)
+    {
+        // string|array $param->varname Summary or description.
+        preg_match('/(\S+)?(?:(?:\s+\&?\$)(\S+)((?:[^a-z]+)\S+))?((\s+)(.*))?/', $line, $matches);
+
+        if (! $matches) {
+            return;
+        }
+
+        // split subparam
+        $param = null;
+        $subparam = null;
+        if (strpos($matches[2], '::') !== false) {
+            $tmp = explode('::', $matches[2]);
+        } elseif (strpos($matches[2], '->') !== false) {
+            $tmp = explode('->', $matches[2]);
+        } elseif (strpos($matches[2], '[') !== false) {
+            $tmp = explode('[', $matches[2]);
+            $tmp[1] = str_replace(']', '', $tmp[1]);
+        }
+        $param = @$tmp[0];
+        $subparam = @$tmp[1];        
+
+
+        if (empty($param)) {
+            return;
+        }
+        
+        // param needs to be defined first
+        if (empty($this->_info['param'][$param])) {
+            return;
+        }
+        
+        // do we have a subparams array?
+        if (empty($this->_info['subparam'])) {
+            $this->_info['subparam'][$param] = array();
+        }
+                
+        // variable type
+        $type = $matches[1];
+                
+        // always need a summary element
+        $summ = trim($matches[3]);
+        
+        // save the param
+        $this->_info['subparam'][$param][$subparam] = array(
+            'type' => $type,
+            'summ' => $summ,
+        );
+    }
+    
 }
\ No newline at end of file
Reply all
Reply to author
Forward
0 new messages