From 2920ae4987fb9ffa78ff85ebc26b194630f3c07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Gamaliel?= Date: Fri, 6 May 2016 17:35:47 -0300 Subject: [PATCH 01/11] Criado gerador do arquivo Phar, arquivo Phar, e composer.json --- bin/docblock | Bin 0 -> 9075 bytes bin/docblock.phar | Bin 0 -> 9075 bytes bin/docblock.phar.php | 9 + bin/docblock.phar.php~ | 9 + composer.json | 13 + composer.json~ | 8 + docblock.phar.php | 9 + docblock.phar.php~ | 9 + src/DocBlockGenerator.class.php | 493 ++++++++++++++++++++++++ src/DocBlockGenerator.class.php~ | 492 +++++++++++++++++++++++ src/docblock.php | 74 ++++ docblock.php => src/docblock.php~ | 0 src/new file~ | 0 vendor/autoload.php | 7 + vendor/composer/ClassLoader.php | 413 ++++++++++++++++++++ vendor/composer/LICENSE | 21 + vendor/composer/autoload_classmap.php | 9 + vendor/composer/autoload_namespaces.php | 9 + vendor/composer/autoload_psr4.php | 9 + vendor/composer/autoload_real.php | 45 +++ vendor/composer/installed.json | 1 + 21 files changed, 1630 insertions(+) create mode 100755 bin/docblock create mode 100644 bin/docblock.phar create mode 100644 bin/docblock.phar.php create mode 100644 bin/docblock.phar.php~ create mode 100644 composer.json create mode 100644 composer.json~ create mode 100644 docblock.phar.php create mode 100644 docblock.phar.php~ create mode 100644 src/DocBlockGenerator.class.php create mode 100644 src/DocBlockGenerator.class.php~ create mode 100644 src/docblock.php rename docblock.php => src/docblock.php~ (100%) create mode 100644 src/new file~ create mode 100644 vendor/autoload.php create mode 100644 vendor/composer/ClassLoader.php create mode 100644 vendor/composer/LICENSE create mode 100644 vendor/composer/autoload_classmap.php create mode 100644 vendor/composer/autoload_namespaces.php create mode 100644 vendor/composer/autoload_psr4.php create mode 100644 vendor/composer/autoload_real.php create mode 100644 vendor/composer/installed.json diff --git a/bin/docblock b/bin/docblock new file mode 100755 index 0000000000000000000000000000000000000000..7b1baf9cd4752957a75cdd6aacc08f2ece63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ne3R^1pi^R*K}!WYKzqC|v5 zUtH@5fnPB@ltwqgb-GEwkr!6BxAXCfYoHa*lT0%=a)4)~qvn@HU8d%>q(vIe^hc)5T2WM*z<<7{Fs4~!O{jKfK6GFl25rCpa_^wm-#>hP zgs(2g0Es6%KWrS{x^?S&`28{erGM!YQf=n;3&3vu2){Rn@xTAz)~&z(XZ;uS_mBT} zKmQZ)!H@pzA1EO<)O`wN-M!bi&tAi;ZM3|;zm;WCP2lxkj=!ipBzM8UI? zM=f${=?$|O7pP_1u=oTW(6Go7fyoI2X($-Ih0CSFPs%NlLUe`6yTPO=qYD{d!&0!dowo2pa71k6 z1ukuh%69XvB3Y7{%{HzU6uv$R&LB}bVqI|-t>IvT_A0!_q(_u3lD z_2;B7y;5=~&Rn3+dC=IfFbl`9rm{G@#J3wwLN~om3$wl29H$ABr)?FMpjdVsZ8-mZz8S~=uwjZT zf-RMo^QYULhUQE(q2I0~&6!$XtOYcB365h5_ysDoc6hR&mgD_sxHX-`%HmZ$xh10O z=9M=o_X*~H))%_NB@?KIBTV!y+?$jV8&RTNo#AA-9N{tsSr5sbzAsa$zR7}8wy#?U tTp|>j<5!K}{_3B_zjpre`#=BT>)(C-o4>v4tp4NI-$#%0;_2(B{{=5$;EVtO literal 0 HcmV?d00001 diff --git a/bin/docblock.phar b/bin/docblock.phar new file mode 100644 index 0000000000000000000000000000000000000000..7b1baf9cd4752957a75cdd6aacc08f2ece63f300 GIT binary patch literal 9075 zcmcIqTW=f36?Xen5Gc_8gR#nZSC+^XWyek>Tb3--7gUZ^iBZwW2D{uHk{j(UyF*=^ z1br=vKIOT8pbvfRTVMKCw11&b1^Oon6#dSbndMR>odjqV$l5(~?sMi`X7iKV-lQzN zL6mwjy%7007mY_x@TbveUdn-ZESx9}mehQf`~zF!pnwd>?#zi`$?sS4>Q z{gG7t%fiodS(NVTs|UwD4^&_CIqB^k_qH2_RFfjzZhWPEvg<}Aw04_N z=lHaHeC8Z?fBs4Lq}TuC_?7dPov{q#b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ih0CSFPs%NlLUe`6yTPO=qYD{d!&0!dowo2pa71k6 z1ukuh%69XvB3Y7{%{HzU6uv$R&LB}bVqI|-t>IvT_A0!_q(_u3lD z_2;B7y;5=~&Rn3+dC=IfFbl`9rm{G@#J3wwLN~om3$wl29H$ABr)?FMpjdVsZ8-mZz8S~=uwjZT zf-RMo^QYULhUQE(q2I0~&6!$XtOYcB365h5_ysDoc6hR&mgD_sxHX-`%HmZ$xh10O z=9M=o_X*~H))%_NB@?KIBTV!y+?$jV8&RTNo#AA-9N{tsSr5sbzAsa$zR7}8wy#?U tTp|>j<5!K}{_3B_zjpre`#=BT>)(C-o4>v4tp4NI-$#%0;_2(B{{=5$;EVtO literal 0 HcmV?d00001 diff --git a/bin/docblock.phar.php b/bin/docblock.phar.php new file mode 100644 index 0000000..97c5ffb --- /dev/null +++ b/bin/docblock.phar.php @@ -0,0 +1,9 @@ +addFile('src/docblock.php'); +$defaultStub = $app->createDefaultStub("src/docblock.php"); +$stub = "#!/usr/bin/env php \n".$defaultStub; +$app->setStub($stub); +$app->stopBuffering(); +?> + diff --git a/bin/docblock.phar.php~ b/bin/docblock.phar.php~ new file mode 100644 index 0000000..8502d8b --- /dev/null +++ b/bin/docblock.phar.php~ @@ -0,0 +1,9 @@ +addFile('docblock.php'); +$defaultStub = $app->createDefaultStub("docblock.php"); +$stub = "#!/usr/bin/php \n".$defaultStub; +$app->setStub($stub); +$app->stopBuffering(); +?> + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a93d5c9 --- /dev/null +++ b/composer.json @@ -0,0 +1,13 @@ +{ + "name": "agentile/php-docblock-generator", + "description": "Generate PHPDoc Blocks in files and Folders", + "require": {}, + "autoload": { + "psr-0": { + "DocBlockGenerator\\": "src" + } + }, + "bin": [ + "bin/docblock" + ], +} diff --git a/composer.json~ b/composer.json~ new file mode 100644 index 0000000..32223d9 --- /dev/null +++ b/composer.json~ @@ -0,0 +1,8 @@ +{ + "name": "agentile/php-docblock-generator", + "description": "Generate PHPDoc Blocks in files and Folders", + "require": {}, + "bin": [ + "bin/docblock" + ], +} diff --git a/docblock.phar.php b/docblock.phar.php new file mode 100644 index 0000000..97c5ffb --- /dev/null +++ b/docblock.phar.php @@ -0,0 +1,9 @@ +addFile('src/docblock.php'); +$defaultStub = $app->createDefaultStub("src/docblock.php"); +$stub = "#!/usr/bin/env php \n".$defaultStub; +$app->setStub($stub); +$app->stopBuffering(); +?> + diff --git a/docblock.phar.php~ b/docblock.phar.php~ new file mode 100644 index 0000000..9223c36 --- /dev/null +++ b/docblock.phar.php~ @@ -0,0 +1,9 @@ +addFile(dirname(__FILE__).'/../src/docblock.php'); +$defaultStub = $app->createDefaultStub(dirname(__FILE__)."/../src/docblock.php"); +$stub = "#!/usr/bin/env php \n".$defaultStub; +$app->setStub($stub); +$app->stopBuffering(); +?> + diff --git a/src/DocBlockGenerator.class.php b/src/DocBlockGenerator.class.php new file mode 100644 index 0000000..e039410 --- /dev/null +++ b/src/DocBlockGenerator.class.php @@ -0,0 +1,493 @@ +target = $target; + $this->target_function = $target_function; + $this->recursive = $recursive; + } + + /** + * result + * Print output to command line + * + * + * @return string + * + * @access public + * @static + * @since 0.85 + */ + public function result() + { + $str = ''; + foreach ($this->log as $log_item) { + $str .= "{$log_item}\n"; + } + echo $str; + } + + /** + * start + * Begin the docblocking process, determine if a file or folder was given + * + * @return void + * + * @access public + * @static + * @since 0.85 + */ + public function start() + { + if (is_file($this->target)) { + $valid_file = $this->fileCheck($this->target); + if ($valid_file == false) { + return; + } + $this->fileDocBlock(); + } elseif (is_dir($this->target)) { + if ($this->recursive == true) { + $files = $this->scanDirectories($this->target, true); + } else { + $files = $this->scanDirectories($this->target); + } + foreach ($files as $file) { + $this->target = $file; + $this->fileDocBlock(); + } + } else { + $this->log[] = 'This is not a file or folder.'; + return; + } + } + + /** + * fileCheck + * Make sure we can deal with the target file + * + * @param $target + * + * @return bool + * + * @access public + * @static + * @since 0.85 + */ + public function fileCheck($target) + { + $file_ext = strtolower(substr($target, strrpos($target, '.'))); + $bool = true; + if (!in_array($file_ext, $this->exts)) { + $this->log[] = "{$target} is not a PHP file."; + $bool = false; + } + if (!is_readable($target)) { + $this->log[] = "{$target} is not readable."; + $bool = false; + } + if (!is_writable($target)) { + $this->log[] = "{$target} is not writeable.\nCheck file permissions"; + $bool = false; + } + return $bool; + } + + /** + * fileDocBlock + * Shell method for docblock operations, explodes file, performs docblock methods, impodes. + * + * @return void + * + * @access public + * @static + * @since 0.85 + */ + public function fileDocBlock() + { + $this->file_contents = file_get_contents($this->target); + list($funcs, $classes) = $this->getProtos(); + $handle = fopen($this->target, 'r'); + if ($contents = fread($handle, filesize($this->target))) { + $contents = explode("\n", $contents); + $contents = $this->docBlock($contents, $funcs, $classes, $this->target_function); + $contents = implode("\n", $contents); + fclose($handle); + $handle = fopen($this->target, 'w'); + if (fwrite($handle, $contents)) { + $this->log[] = "{$this->target} Doc Blocked!"; + fclose($handle); + return; + } else { + fclose($handle); + $this->log[] = "Could not write new content.\nCheck Permissions"; + return; + } + } else { + fclose($handle); + $this->log[] = "Could not get file contents.\nCheck Permissions"; + return; + } + } + + /** + * getProtos + * This function goes through the tokens to gather the arrays of information we need + * + * @return array + * + * @access public + * @static + * @since 0.85 + */ + public function getProtos() + { + $tokens = token_get_all($this->file_contents); + $funcs = array(); + $classes = array(); + $curr_class = ''; + $class_depth = 0; + $count = count($tokens); + for ($i = 0; $i < $count; $i++) { + if (is_array($tokens[$i]) && $tokens[$i][0] == T_CLASS) { + $line = $tokens[$i][2]; + ++$i; // whitespace; + $curr_class = $tokens[++$i][1]; + if (!in_array(array('line' => $line, 'name' => $curr_class), $classes)) { + $classes[] = array('line' => $line, 'name' => $curr_class); + } + while ($tokens[++$i] != '{') {} + ++$i; + $class_depth = 1; + continue; + } elseif (is_array($tokens[$i]) && $tokens[$i][0] == T_FUNCTION) { + $next_by_ref = FALSE; + $this_func = array(); + + while ($tokens[++$i] != ')') { + if (is_array($tokens[$i]) && $tokens[$i][0] != T_WHITESPACE) { + if (!$this_func) { + $this_func = array( + 'name' => $tokens[$i][1], + 'class' => $curr_class, + 'line' => $tokens[$i][2], + ); + } else { + $this_func['params'][] = array( + 'byRef' => $next_by_ref, + 'name' => $tokens[$i][1], + ); + $next_by_ref = FALSE; + } + } elseif ($tokens[$i] == '&') { + $next_by_ref = TRUE; + } elseif ($tokens[$i] == '=') { + while (!in_array($tokens[++$i], array(')', ','))) { + if ($tokens[$i][0] != T_WHITESPACE) { + break; + } + } + $this_func['params'][count($this_func['params']) - 1]['default'] = $tokens[$i][1]; + } + } + $funcs[] = $this_func; + } elseif ($tokens[$i] == '{' || $tokens[$i] == 'T_CURLY_OPEN' || $tokens[$i] == 'T_DOLLAR_OPEN_CURLY_BRACES') { + ++$class_depth; + } elseif ($tokens[$i] == '}') { + --$class_depth; + } + + if ($class_depth == 0) { + $curr_class = ''; + } + } + + return array($funcs, $classes); + } + + /** + * docBlock + * Main docblock function, determines if class or function docblocking is need and calls + * appropriate subfunction. + * + * @param $arr + * @param $funcs + * @param $classes + * @param $target_function + * + * @return array + * + * @access public + * @static + * @since 0.85 + */ + public function docBlock($arr, $funcs, $classes, $target_function) + { + $func_lines = array(); + foreach ($funcs as $func) { + $func_lines[] = $func['line']; + } + $class_lines = array(); + foreach ($classes as $class) { + $class_lines[] = $class['line']; + } + $class_or_func = ''; + $count = count($arr); + for($i = 0; $i < $count; $i++) { + $line = $i + 1; + $code = $arr[$i]; + + if (in_array($line, $class_lines) && !$this->docBlockExists($arr[($i - 1)])) { + $class_or_func = 'class'; + } elseif (in_array($line, $func_lines) && !$this->docBlockExists($arr[($i - 1)])) { + $class_or_func = 'func'; + } else { + continue; + } + + if ($class_or_func === 'func') { + $data = $this->getData($line, $funcs); + } elseif ($class_or_func === 'class') { + $data = $this->getData($line, $classes); + } + if ($target_function !== null && $target_function !== '') { + if ($data['name'] !== $target_function) { + continue; + } + } + $indent_count = $this->getStrIndent($code); + $indent = ''; + for($indt = 0; $indt < $indent_count; $indt++) { + $indent .= ' '; + } + if ($class_or_func === 'func') { + $doc_block = $this->functionDocBlock($indent, $data); + } elseif ($class_or_func === 'class') { + $doc_block = $this->classDocBlock($indent, $data); + } + $arr[$i] = $doc_block . $arr[$i]; + } + return $arr; + } + + /** + * scanDirectories + * Get all specific files from a directory and if recursive, subdirectories + * + * @param $dir + * @param $recursive + * @param $data + * + * @return array + * + * @access public + * @static + * @since 0.85 + */ + public function scanDirectories($dir, $recursive = false, $data = array()) + { + // set filenames invisible if you want + $invisible = array('.', '..', '.htaccess', '.htpasswd'); + // run through content of root directory + $dir_content = scandir($dir); + foreach ($dir_content as $key => $content) { + // filter all files not accessible + $path = $dir . '/' . $content; + if (!in_array($content, $invisible)) { + // if content is file & readable, add to array + if (is_file($path) && is_readable($path)) { + // what is the ext of this file + $file_ext = strtolower(substr($path, strrpos($path, "."))); + // if this file ext matches the ones from our array + if (in_array($file_ext, $this->exts)) { + // save file name with path + $data[] = $path; + } + // if content is a directory and readable, add path and name + } elseif (is_dir($path) && is_readable($path)) { + // recursive callback to open new directory + if ($recursive == true) { + $data = $this->scanDirectories($path, true, $data); + } + } + } + } + return $data; + } + + /** + * getData + * Retrieve method or class information from our arrays + * + * @param $line + * @param $arr + * + * @return mixed + * + * @access public + * @static + * @since 0.85 + */ + public function getData($line, $arr) + { + foreach ($arr as $k => $v) { + if ($line == $v['line']) { + return $arr[$k]; + } + } + return false; + } + + /** + * docBlockExists + * Primitive check to see if docblock already exists + * + * @param $line + * + * @return bool + * + * @access public + * @static + * @since 0.85 + */ + public function docBlockExists($line) + { + // ok we are simply going to check the line above the function and look for */ + // TODO: make this a more accurate check. + $indent = $this->getStrIndent($line); + if ($indent > 0) { + $line = substr($line, ($indent - 1)); + } + $len = strlen($line); + if ($len == 0) { + return false; + } + $asterik = false; + for ($i = 0; $i < $len; $i++) { + if ($line[$i] == '*') { + $asterik = true; + } elseif ($line[$i] == '/' && $asterik == true) { + return true; + } else { + $asterik = false; + } + } + return false; + } + + /** + * functionDocBlock + * Docblock for function + * + * @param $indent + * @param $data + * + * @return string + * + * @access public + * @static + * @since 0.85 + */ + public function functionDocBlock($indent, $data) + { + $doc_block = "{$indent}/**\n"; + $doc_block .= "{$indent} * {$data['name']}\n"; + $doc_block .= "{$indent} * Insert description here\n"; + $doc_block .= "{$indent} *\n"; + if (isset($data['params'])) { + foreach($data['params'] as $func_param) { + $doc_block .= "{$indent} * @param {$func_param['name']}\n"; + } + } + $doc_block .= "{$indent} *\n"; + $doc_block .= "{$indent} * @return\n"; + $doc_block .= "{$indent} *\n"; + $doc_block .= "{$indent} * @access\n"; + $doc_block .= "{$indent} * @static\n"; + $doc_block .= "{$indent} * @see\n"; + $doc_block .= "{$indent} * @since\n"; + $doc_block .= "{$indent} */\n"; + + return $doc_block; + } + + /** + * classDocBlock + * Docblock for class + * + * @param $indent + * @param $data + * + * @return string + * + * @access public + * @static + * @since 0.85 + */ + public function classDocBlock($indent, $data) + { + $doc_block = "{$indent}/**\n"; + $doc_block .= "{$indent} * {$data['name']}\n"; + $doc_block .= "{$indent} * Insert description here\n"; + $doc_block .= "{$indent} *\n"; + $doc_block .= "{$indent} * @category\n"; + $doc_block .= "{$indent} * @package\n"; + $doc_block .= "{$indent} * @author\n"; + $doc_block .= "{$indent} * @copyright\n"; + $doc_block .= "{$indent} * @license\n"; + $doc_block .= "{$indent} * @version\n"; + $doc_block .= "{$indent} * @link\n"; + $doc_block .= "{$indent} * @see\n"; + $doc_block .= "{$indent} * @since\n"; + $doc_block .= "{$indent} */\n"; + + return $doc_block; + } + + /** + * getStrIndent + * Returns indentation count of a string + * + * @param $str + * @param $count + * + * @return int + * + * @access public + * @static + * @since 0.85 + */ + public function getStrIndent($str, $count = 0) + { + if (isset($str[0])) { + return ($str[0] == ' ') ? $this->getStrIndent(substr($str, 1), ($count + 1)) : $count; + } else { + return $count; + } + } + +} +?> diff --git a/src/DocBlockGenerator.class.php~ b/src/DocBlockGenerator.class.php~ new file mode 100644 index 0000000..bb795df --- /dev/null +++ b/src/DocBlockGenerator.class.php~ @@ -0,0 +1,492 @@ +use namespace DocBlockGenerator + +class DocBlockGenerator { + + public $exts = array('.php', '.php4', '.php5', '.phps', '.inc'); + public $target; + public $target_function; + public $recursive; + public $file_contents; + public $log = array(); + + + /** + * __construct + * + * @param $target + * @param $target_function + * @param $recursive + * + * @return void + * + * @access public + * @static + * @since 0.85 + */ + public function __construct($target, $target_function = null, $recursive = false) + { + $this->target = $target; + $this->target_function = $target_function; + $this->recursive = $recursive; + } + + /** + * result + * Print output to command line + * + * + * @return string + * + * @access public + * @static + * @since 0.85 + */ + public function result() + { + $str = ''; + foreach ($this->log as $log_item) { + $str .= "{$log_item}\n"; + } + echo $str; + } + + /** + * start + * Begin the docblocking process, determine if a file or folder was given + * + * @return void + * + * @access public + * @static + * @since 0.85 + */ + public function start() + { + if (is_file($this->target)) { + $valid_file = $this->fileCheck($this->target); + if ($valid_file == false) { + return; + } + $this->fileDocBlock(); + } elseif (is_dir($this->target)) { + if ($this->recursive == true) { + $files = $this->scanDirectories($this->target, true); + } else { + $files = $this->scanDirectories($this->target); + } + foreach ($files as $file) { + $this->target = $file; + $this->fileDocBlock(); + } + } else { + $this->log[] = 'This is not a file or folder.'; + return; + } + } + + /** + * fileCheck + * Make sure we can deal with the target file + * + * @param $target + * + * @return bool + * + * @access public + * @static + * @since 0.85 + */ + public function fileCheck($target) + { + $file_ext = strtolower(substr($target, strrpos($target, '.'))); + $bool = true; + if (!in_array($file_ext, $this->exts)) { + $this->log[] = "{$target} is not a PHP file."; + $bool = false; + } + if (!is_readable($target)) { + $this->log[] = "{$target} is not readable."; + $bool = false; + } + if (!is_writable($target)) { + $this->log[] = "{$target} is not writeable.\nCheck file permissions"; + $bool = false; + } + return $bool; + } + + /** + * fileDocBlock + * Shell method for docblock operations, explodes file, performs docblock methods, impodes. + * + * @return void + * + * @access public + * @static + * @since 0.85 + */ + public function fileDocBlock() + { + $this->file_contents = file_get_contents($this->target); + list($funcs, $classes) = $this->getProtos(); + $handle = fopen($this->target, 'r'); + if ($contents = fread($handle, filesize($this->target))) { + $contents = explode("\n", $contents); + $contents = $this->docBlock($contents, $funcs, $classes, $this->target_function); + $contents = implode("\n", $contents); + fclose($handle); + $handle = fopen($this->target, 'w'); + if (fwrite($handle, $contents)) { + $this->log[] = "{$this->target} Doc Blocked!"; + fclose($handle); + return; + } else { + fclose($handle); + $this->log[] = "Could not write new content.\nCheck Permissions"; + return; + } + } else { + fclose($handle); + $this->log[] = "Could not get file contents.\nCheck Permissions"; + return; + } + } + + /** + * getProtos + * This function goes through the tokens to gather the arrays of information we need + * + * @return array + * + * @access public + * @static + * @since 0.85 + */ + public function getProtos() + { + $tokens = token_get_all($this->file_contents); + $funcs = array(); + $classes = array(); + $curr_class = ''; + $class_depth = 0; + $count = count($tokens); + for ($i = 0; $i < $count; $i++) { + if (is_array($tokens[$i]) && $tokens[$i][0] == T_CLASS) { + $line = $tokens[$i][2]; + ++$i; // whitespace; + $curr_class = $tokens[++$i][1]; + if (!in_array(array('line' => $line, 'name' => $curr_class), $classes)) { + $classes[] = array('line' => $line, 'name' => $curr_class); + } + while ($tokens[++$i] != '{') {} + ++$i; + $class_depth = 1; + continue; + } elseif (is_array($tokens[$i]) && $tokens[$i][0] == T_FUNCTION) { + $next_by_ref = FALSE; + $this_func = array(); + + while ($tokens[++$i] != ')') { + if (is_array($tokens[$i]) && $tokens[$i][0] != T_WHITESPACE) { + if (!$this_func) { + $this_func = array( + 'name' => $tokens[$i][1], + 'class' => $curr_class, + 'line' => $tokens[$i][2], + ); + } else { + $this_func['params'][] = array( + 'byRef' => $next_by_ref, + 'name' => $tokens[$i][1], + ); + $next_by_ref = FALSE; + } + } elseif ($tokens[$i] == '&') { + $next_by_ref = TRUE; + } elseif ($tokens[$i] == '=') { + while (!in_array($tokens[++$i], array(')', ','))) { + if ($tokens[$i][0] != T_WHITESPACE) { + break; + } + } + $this_func['params'][count($this_func['params']) - 1]['default'] = $tokens[$i][1]; + } + } + $funcs[] = $this_func; + } elseif ($tokens[$i] == '{' || $tokens[$i] == 'T_CURLY_OPEN' || $tokens[$i] == 'T_DOLLAR_OPEN_CURLY_BRACES') { + ++$class_depth; + } elseif ($tokens[$i] == '}') { + --$class_depth; + } + + if ($class_depth == 0) { + $curr_class = ''; + } + } + + return array($funcs, $classes); + } + + /** + * docBlock + * Main docblock function, determines if class or function docblocking is need and calls + * appropriate subfunction. + * + * @param $arr + * @param $funcs + * @param $classes + * @param $target_function + * + * @return array + * + * @access public + * @static + * @since 0.85 + */ + public function docBlock($arr, $funcs, $classes, $target_function) + { + $func_lines = array(); + foreach ($funcs as $func) { + $func_lines[] = $func['line']; + } + $class_lines = array(); + foreach ($classes as $class) { + $class_lines[] = $class['line']; + } + $class_or_func = ''; + $count = count($arr); + for($i = 0; $i < $count; $i++) { + $line = $i + 1; + $code = $arr[$i]; + + if (in_array($line, $class_lines) && !$this->docBlockExists($arr[($i - 1)])) { + $class_or_func = 'class'; + } elseif (in_array($line, $func_lines) && !$this->docBlockExists($arr[($i - 1)])) { + $class_or_func = 'func'; + } else { + continue; + } + + if ($class_or_func === 'func') { + $data = $this->getData($line, $funcs); + } elseif ($class_or_func === 'class') { + $data = $this->getData($line, $classes); + } + if ($target_function !== null && $target_function !== '') { + if ($data['name'] !== $target_function) { + continue; + } + } + $indent_count = $this->getStrIndent($code); + $indent = ''; + for($indt = 0; $indt < $indent_count; $indt++) { + $indent .= ' '; + } + if ($class_or_func === 'func') { + $doc_block = $this->functionDocBlock($indent, $data); + } elseif ($class_or_func === 'class') { + $doc_block = $this->classDocBlock($indent, $data); + } + $arr[$i] = $doc_block . $arr[$i]; + } + return $arr; + } + + /** + * scanDirectories + * Get all specific files from a directory and if recursive, subdirectories + * + * @param $dir + * @param $recursive + * @param $data + * + * @return array + * + * @access public + * @static + * @since 0.85 + */ + public function scanDirectories($dir, $recursive = false, $data = array()) + { + // set filenames invisible if you want + $invisible = array('.', '..', '.htaccess', '.htpasswd'); + // run through content of root directory + $dir_content = scandir($dir); + foreach ($dir_content as $key => $content) { + // filter all files not accessible + $path = $dir . '/' . $content; + if (!in_array($content, $invisible)) { + // if content is file & readable, add to array + if (is_file($path) && is_readable($path)) { + // what is the ext of this file + $file_ext = strtolower(substr($path, strrpos($path, "."))); + // if this file ext matches the ones from our array + if (in_array($file_ext, $this->exts)) { + // save file name with path + $data[] = $path; + } + // if content is a directory and readable, add path and name + } elseif (is_dir($path) && is_readable($path)) { + // recursive callback to open new directory + if ($recursive == true) { + $data = $this->scanDirectories($path, true, $data); + } + } + } + } + return $data; + } + + /** + * getData + * Retrieve method or class information from our arrays + * + * @param $line + * @param $arr + * + * @return mixed + * + * @access public + * @static + * @since 0.85 + */ + public function getData($line, $arr) + { + foreach ($arr as $k => $v) { + if ($line == $v['line']) { + return $arr[$k]; + } + } + return false; + } + + /** + * docBlockExists + * Primitive check to see if docblock already exists + * + * @param $line + * + * @return bool + * + * @access public + * @static + * @since 0.85 + */ + public function docBlockExists($line) + { + // ok we are simply going to check the line above the function and look for */ + // TODO: make this a more accurate check. + $indent = $this->getStrIndent($line); + if ($indent > 0) { + $line = substr($line, ($indent - 1)); + } + $len = strlen($line); + if ($len == 0) { + return false; + } + $asterik = false; + for ($i = 0; $i < $len; $i++) { + if ($line[$i] == '*') { + $asterik = true; + } elseif ($line[$i] == '/' && $asterik == true) { + return true; + } else { + $asterik = false; + } + } + return false; + } + + /** + * functionDocBlock + * Docblock for function + * + * @param $indent + * @param $data + * + * @return string + * + * @access public + * @static + * @since 0.85 + */ + public function functionDocBlock($indent, $data) + { + $doc_block = "{$indent}/**\n"; + $doc_block .= "{$indent} * {$data['name']}\n"; + $doc_block .= "{$indent} * Insert description here\n"; + $doc_block .= "{$indent} *\n"; + if (isset($data['params'])) { + foreach($data['params'] as $func_param) { + $doc_block .= "{$indent} * @param {$func_param['name']}\n"; + } + } + $doc_block .= "{$indent} *\n"; + $doc_block .= "{$indent} * @return\n"; + $doc_block .= "{$indent} *\n"; + $doc_block .= "{$indent} * @access\n"; + $doc_block .= "{$indent} * @static\n"; + $doc_block .= "{$indent} * @see\n"; + $doc_block .= "{$indent} * @since\n"; + $doc_block .= "{$indent} */\n"; + + return $doc_block; + } + + /** + * classDocBlock + * Docblock for class + * + * @param $indent + * @param $data + * + * @return string + * + * @access public + * @static + * @since 0.85 + */ + public function classDocBlock($indent, $data) + { + $doc_block = "{$indent}/**\n"; + $doc_block .= "{$indent} * {$data['name']}\n"; + $doc_block .= "{$indent} * Insert description here\n"; + $doc_block .= "{$indent} *\n"; + $doc_block .= "{$indent} * @category\n"; + $doc_block .= "{$indent} * @package\n"; + $doc_block .= "{$indent} * @author\n"; + $doc_block .= "{$indent} * @copyright\n"; + $doc_block .= "{$indent} * @license\n"; + $doc_block .= "{$indent} * @version\n"; + $doc_block .= "{$indent} * @link\n"; + $doc_block .= "{$indent} * @see\n"; + $doc_block .= "{$indent} * @since\n"; + $doc_block .= "{$indent} */\n"; + + return $doc_block; + } + + /** + * getStrIndent + * Returns indentation count of a string + * + * @param $str + * @param $count + * + * @return int + * + * @access public + * @static + * @since 0.85 + */ + public function getStrIndent($str, $count = 0) + { + if (isset($str[0])) { + return ($str[0] == ' ') ? $this->getStrIndent(substr($str, 1), ($count + 1)) : $count; + } else { + return $count; + } + } + +} + diff --git a/src/docblock.php b/src/docblock.php new file mode 100644 index 0000000..8cde822 --- /dev/null +++ b/src/docblock.php @@ -0,0 +1,74 @@ + '') : $_SERVER['argv']; + +$current_dir = getcwd(); + +$options = array( + 'file_folder' => '', + 'target_function' => '', + 'recursive' => false +); + +foreach ($argv as $k => $arg) { + if ($k !== 0) { + if (strtolower($arg) === '-r') { + $options['recursive'] = true; + } elseif (is_file($arg)) { + $options['file_folder'] = $arg; + } elseif (is_file($current_dir . '/' . $arg)) { + $options['file_folder'] = $current_dir . '/' . $arg; + } elseif (is_dir($arg)) { + $options['file_folder'] = $arg; + } elseif (is_dir($current_dir . '/' . $arg)) { + $options['file_folder'] = $current_dir . '/' . $arg; + } else { + $options['target_function'] = $arg; + } + } +} + +if (isset($argv[1])) { + if (is_file($options['file_folder']) || is_dir($options['file_folder'])) { + $doc_block_generator = new DocBlockGenerator($options['file_folder'], $options['target_function'], $options['recursive']); + $doc_block_generator->start(); + $doc_block_generator->result(); + } else { + die("\nThis is not a valid file or directory\n"); + } + +} else { + die("\nPlease provide a file or directory as a parameter\n"); +} diff --git a/docblock.php b/src/docblock.php~ similarity index 100% rename from docblock.php rename to src/docblock.php~ diff --git a/src/new file~ b/src/new file~ new file mode 100644 index 0000000..e69de29 diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..98cb3b2 --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + private $classMapAuthoritative = false; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative) { + return false; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..1a28124 --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) 2016 Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + return $loader; + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1 @@ +[] From 63c2deb650a7953fc7680c976c40b90c8bc3b615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Gamaliel?= Date: Fri, 6 May 2016 17:42:04 -0300 Subject: [PATCH 02/11] Removendo Vendor --- vendor/autoload.php | 7 - vendor/composer/ClassLoader.php | 413 ------------------------ vendor/composer/LICENSE | 21 -- vendor/composer/autoload_classmap.php | 9 - vendor/composer/autoload_namespaces.php | 9 - vendor/composer/autoload_psr4.php | 9 - vendor/composer/autoload_real.php | 45 --- vendor/composer/installed.json | 1 - 8 files changed, 514 deletions(-) delete mode 100644 vendor/autoload.php delete mode 100644 vendor/composer/ClassLoader.php delete mode 100644 vendor/composer/LICENSE delete mode 100644 vendor/composer/autoload_classmap.php delete mode 100644 vendor/composer/autoload_namespaces.php delete mode 100644 vendor/composer/autoload_psr4.php delete mode 100644 vendor/composer/autoload_real.php delete mode 100644 vendor/composer/installed.json diff --git a/vendor/autoload.php b/vendor/autoload.php deleted file mode 100644 index 98cb3b2..0000000 --- a/vendor/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - * @see http://www.php-fig.org/psr/psr-0/ - * @see http://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - // PSR-4 - private $prefixLengthsPsr4 = array(); - private $prefixDirsPsr4 = array(); - private $fallbackDirsPsr4 = array(); - - // PSR-0 - private $prefixesPsr0 = array(); - private $fallbackDirsPsr0 = array(); - - private $useIncludePath = false; - private $classMap = array(); - - private $classMapAuthoritative = false; - - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); - } - - return array(); - } - - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative) { - return false; - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if ($file === null && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if ($file === null) { - // Remember that this class does not exist. - return $this->classMap[$class] = false; - } - - return $file; - } - - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { - if (0 === strpos($class, $prefix)) { - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; -} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE deleted file mode 100644 index 1a28124..0000000 --- a/vendor/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) 2016 Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php deleted file mode 100644 index 7a91153..0000000 --- a/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,9 +0,0 @@ - $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - - $loader->register(true); - - return $loader; - } -} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json deleted file mode 100644 index fe51488..0000000 --- a/vendor/composer/installed.json +++ /dev/null @@ -1 +0,0 @@ -[] From d1bda55f6d26b3fd514e7f9497fc1979269e1652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Gamaliel?= Date: Fri, 6 May 2016 17:44:17 -0300 Subject: [PATCH 03/11] Removed temporary files --- bin/docblock.phar.php~ | 9 - composer.json~ | 8 - docblock.phar.php~ | 9 - src/DocBlockGenerator.class.php~ | 492 --------------------------- src/docblock.php~ | 559 ------------------------------- src/new file~ | 0 6 files changed, 1077 deletions(-) delete mode 100644 bin/docblock.phar.php~ delete mode 100644 composer.json~ delete mode 100644 docblock.phar.php~ delete mode 100644 src/DocBlockGenerator.class.php~ delete mode 100644 src/docblock.php~ delete mode 100644 src/new file~ diff --git a/bin/docblock.phar.php~ b/bin/docblock.phar.php~ deleted file mode 100644 index 8502d8b..0000000 --- a/bin/docblock.phar.php~ +++ /dev/null @@ -1,9 +0,0 @@ -addFile('docblock.php'); -$defaultStub = $app->createDefaultStub("docblock.php"); -$stub = "#!/usr/bin/php \n".$defaultStub; -$app->setStub($stub); -$app->stopBuffering(); -?> - diff --git a/composer.json~ b/composer.json~ deleted file mode 100644 index 32223d9..0000000 --- a/composer.json~ +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "agentile/php-docblock-generator", - "description": "Generate PHPDoc Blocks in files and Folders", - "require": {}, - "bin": [ - "bin/docblock" - ], -} diff --git a/docblock.phar.php~ b/docblock.phar.php~ deleted file mode 100644 index 9223c36..0000000 --- a/docblock.phar.php~ +++ /dev/null @@ -1,9 +0,0 @@ -addFile(dirname(__FILE__).'/../src/docblock.php'); -$defaultStub = $app->createDefaultStub(dirname(__FILE__)."/../src/docblock.php"); -$stub = "#!/usr/bin/env php \n".$defaultStub; -$app->setStub($stub); -$app->stopBuffering(); -?> - diff --git a/src/DocBlockGenerator.class.php~ b/src/DocBlockGenerator.class.php~ deleted file mode 100644 index bb795df..0000000 --- a/src/DocBlockGenerator.class.php~ +++ /dev/null @@ -1,492 +0,0 @@ -use namespace DocBlockGenerator - -class DocBlockGenerator { - - public $exts = array('.php', '.php4', '.php5', '.phps', '.inc'); - public $target; - public $target_function; - public $recursive; - public $file_contents; - public $log = array(); - - - /** - * __construct - * - * @param $target - * @param $target_function - * @param $recursive - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function __construct($target, $target_function = null, $recursive = false) - { - $this->target = $target; - $this->target_function = $target_function; - $this->recursive = $recursive; - } - - /** - * result - * Print output to command line - * - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function result() - { - $str = ''; - foreach ($this->log as $log_item) { - $str .= "{$log_item}\n"; - } - echo $str; - } - - /** - * start - * Begin the docblocking process, determine if a file or folder was given - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function start() - { - if (is_file($this->target)) { - $valid_file = $this->fileCheck($this->target); - if ($valid_file == false) { - return; - } - $this->fileDocBlock(); - } elseif (is_dir($this->target)) { - if ($this->recursive == true) { - $files = $this->scanDirectories($this->target, true); - } else { - $files = $this->scanDirectories($this->target); - } - foreach ($files as $file) { - $this->target = $file; - $this->fileDocBlock(); - } - } else { - $this->log[] = 'This is not a file or folder.'; - return; - } - } - - /** - * fileCheck - * Make sure we can deal with the target file - * - * @param $target - * - * @return bool - * - * @access public - * @static - * @since 0.85 - */ - public function fileCheck($target) - { - $file_ext = strtolower(substr($target, strrpos($target, '.'))); - $bool = true; - if (!in_array($file_ext, $this->exts)) { - $this->log[] = "{$target} is not a PHP file."; - $bool = false; - } - if (!is_readable($target)) { - $this->log[] = "{$target} is not readable."; - $bool = false; - } - if (!is_writable($target)) { - $this->log[] = "{$target} is not writeable.\nCheck file permissions"; - $bool = false; - } - return $bool; - } - - /** - * fileDocBlock - * Shell method for docblock operations, explodes file, performs docblock methods, impodes. - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function fileDocBlock() - { - $this->file_contents = file_get_contents($this->target); - list($funcs, $classes) = $this->getProtos(); - $handle = fopen($this->target, 'r'); - if ($contents = fread($handle, filesize($this->target))) { - $contents = explode("\n", $contents); - $contents = $this->docBlock($contents, $funcs, $classes, $this->target_function); - $contents = implode("\n", $contents); - fclose($handle); - $handle = fopen($this->target, 'w'); - if (fwrite($handle, $contents)) { - $this->log[] = "{$this->target} Doc Blocked!"; - fclose($handle); - return; - } else { - fclose($handle); - $this->log[] = "Could not write new content.\nCheck Permissions"; - return; - } - } else { - fclose($handle); - $this->log[] = "Could not get file contents.\nCheck Permissions"; - return; - } - } - - /** - * getProtos - * This function goes through the tokens to gather the arrays of information we need - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function getProtos() - { - $tokens = token_get_all($this->file_contents); - $funcs = array(); - $classes = array(); - $curr_class = ''; - $class_depth = 0; - $count = count($tokens); - for ($i = 0; $i < $count; $i++) { - if (is_array($tokens[$i]) && $tokens[$i][0] == T_CLASS) { - $line = $tokens[$i][2]; - ++$i; // whitespace; - $curr_class = $tokens[++$i][1]; - if (!in_array(array('line' => $line, 'name' => $curr_class), $classes)) { - $classes[] = array('line' => $line, 'name' => $curr_class); - } - while ($tokens[++$i] != '{') {} - ++$i; - $class_depth = 1; - continue; - } elseif (is_array($tokens[$i]) && $tokens[$i][0] == T_FUNCTION) { - $next_by_ref = FALSE; - $this_func = array(); - - while ($tokens[++$i] != ')') { - if (is_array($tokens[$i]) && $tokens[$i][0] != T_WHITESPACE) { - if (!$this_func) { - $this_func = array( - 'name' => $tokens[$i][1], - 'class' => $curr_class, - 'line' => $tokens[$i][2], - ); - } else { - $this_func['params'][] = array( - 'byRef' => $next_by_ref, - 'name' => $tokens[$i][1], - ); - $next_by_ref = FALSE; - } - } elseif ($tokens[$i] == '&') { - $next_by_ref = TRUE; - } elseif ($tokens[$i] == '=') { - while (!in_array($tokens[++$i], array(')', ','))) { - if ($tokens[$i][0] != T_WHITESPACE) { - break; - } - } - $this_func['params'][count($this_func['params']) - 1]['default'] = $tokens[$i][1]; - } - } - $funcs[] = $this_func; - } elseif ($tokens[$i] == '{' || $tokens[$i] == 'T_CURLY_OPEN' || $tokens[$i] == 'T_DOLLAR_OPEN_CURLY_BRACES') { - ++$class_depth; - } elseif ($tokens[$i] == '}') { - --$class_depth; - } - - if ($class_depth == 0) { - $curr_class = ''; - } - } - - return array($funcs, $classes); - } - - /** - * docBlock - * Main docblock function, determines if class or function docblocking is need and calls - * appropriate subfunction. - * - * @param $arr - * @param $funcs - * @param $classes - * @param $target_function - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function docBlock($arr, $funcs, $classes, $target_function) - { - $func_lines = array(); - foreach ($funcs as $func) { - $func_lines[] = $func['line']; - } - $class_lines = array(); - foreach ($classes as $class) { - $class_lines[] = $class['line']; - } - $class_or_func = ''; - $count = count($arr); - for($i = 0; $i < $count; $i++) { - $line = $i + 1; - $code = $arr[$i]; - - if (in_array($line, $class_lines) && !$this->docBlockExists($arr[($i - 1)])) { - $class_or_func = 'class'; - } elseif (in_array($line, $func_lines) && !$this->docBlockExists($arr[($i - 1)])) { - $class_or_func = 'func'; - } else { - continue; - } - - if ($class_or_func === 'func') { - $data = $this->getData($line, $funcs); - } elseif ($class_or_func === 'class') { - $data = $this->getData($line, $classes); - } - if ($target_function !== null && $target_function !== '') { - if ($data['name'] !== $target_function) { - continue; - } - } - $indent_count = $this->getStrIndent($code); - $indent = ''; - for($indt = 0; $indt < $indent_count; $indt++) { - $indent .= ' '; - } - if ($class_or_func === 'func') { - $doc_block = $this->functionDocBlock($indent, $data); - } elseif ($class_or_func === 'class') { - $doc_block = $this->classDocBlock($indent, $data); - } - $arr[$i] = $doc_block . $arr[$i]; - } - return $arr; - } - - /** - * scanDirectories - * Get all specific files from a directory and if recursive, subdirectories - * - * @param $dir - * @param $recursive - * @param $data - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function scanDirectories($dir, $recursive = false, $data = array()) - { - // set filenames invisible if you want - $invisible = array('.', '..', '.htaccess', '.htpasswd'); - // run through content of root directory - $dir_content = scandir($dir); - foreach ($dir_content as $key => $content) { - // filter all files not accessible - $path = $dir . '/' . $content; - if (!in_array($content, $invisible)) { - // if content is file & readable, add to array - if (is_file($path) && is_readable($path)) { - // what is the ext of this file - $file_ext = strtolower(substr($path, strrpos($path, "."))); - // if this file ext matches the ones from our array - if (in_array($file_ext, $this->exts)) { - // save file name with path - $data[] = $path; - } - // if content is a directory and readable, add path and name - } elseif (is_dir($path) && is_readable($path)) { - // recursive callback to open new directory - if ($recursive == true) { - $data = $this->scanDirectories($path, true, $data); - } - } - } - } - return $data; - } - - /** - * getData - * Retrieve method or class information from our arrays - * - * @param $line - * @param $arr - * - * @return mixed - * - * @access public - * @static - * @since 0.85 - */ - public function getData($line, $arr) - { - foreach ($arr as $k => $v) { - if ($line == $v['line']) { - return $arr[$k]; - } - } - return false; - } - - /** - * docBlockExists - * Primitive check to see if docblock already exists - * - * @param $line - * - * @return bool - * - * @access public - * @static - * @since 0.85 - */ - public function docBlockExists($line) - { - // ok we are simply going to check the line above the function and look for */ - // TODO: make this a more accurate check. - $indent = $this->getStrIndent($line); - if ($indent > 0) { - $line = substr($line, ($indent - 1)); - } - $len = strlen($line); - if ($len == 0) { - return false; - } - $asterik = false; - for ($i = 0; $i < $len; $i++) { - if ($line[$i] == '*') { - $asterik = true; - } elseif ($line[$i] == '/' && $asterik == true) { - return true; - } else { - $asterik = false; - } - } - return false; - } - - /** - * functionDocBlock - * Docblock for function - * - * @param $indent - * @param $data - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function functionDocBlock($indent, $data) - { - $doc_block = "{$indent}/**\n"; - $doc_block .= "{$indent} * {$data['name']}\n"; - $doc_block .= "{$indent} * Insert description here\n"; - $doc_block .= "{$indent} *\n"; - if (isset($data['params'])) { - foreach($data['params'] as $func_param) { - $doc_block .= "{$indent} * @param {$func_param['name']}\n"; - } - } - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @return\n"; - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @access\n"; - $doc_block .= "{$indent} * @static\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; - $doc_block .= "{$indent} */\n"; - - return $doc_block; - } - - /** - * classDocBlock - * Docblock for class - * - * @param $indent - * @param $data - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function classDocBlock($indent, $data) - { - $doc_block = "{$indent}/**\n"; - $doc_block .= "{$indent} * {$data['name']}\n"; - $doc_block .= "{$indent} * Insert description here\n"; - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @category\n"; - $doc_block .= "{$indent} * @package\n"; - $doc_block .= "{$indent} * @author\n"; - $doc_block .= "{$indent} * @copyright\n"; - $doc_block .= "{$indent} * @license\n"; - $doc_block .= "{$indent} * @version\n"; - $doc_block .= "{$indent} * @link\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; - $doc_block .= "{$indent} */\n"; - - return $doc_block; - } - - /** - * getStrIndent - * Returns indentation count of a string - * - * @param $str - * @param $count - * - * @return int - * - * @access public - * @static - * @since 0.85 - */ - public function getStrIndent($str, $count = 0) - { - if (isset($str[0])) { - return ($str[0] == ' ') ? $this->getStrIndent(substr($str, 1), ($count + 1)) : $count; - } else { - return $count; - } - } - -} - diff --git a/src/docblock.php~ b/src/docblock.php~ deleted file mode 100644 index ec6e263..0000000 --- a/src/docblock.php~ +++ /dev/null @@ -1,559 +0,0 @@ -target = $target; - $this->target_function = $target_function; - $this->recursive = $recursive; - } - - /** - * result - * Print output to command line - * - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function result() - { - $str = ''; - foreach ($this->log as $log_item) { - $str .= "{$log_item}\n"; - } - echo $str; - } - - /** - * start - * Begin the docblocking process, determine if a file or folder was given - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function start() - { - if (is_file($this->target)) { - $valid_file = $this->fileCheck($this->target); - if ($valid_file == false) { - return; - } - $this->fileDocBlock(); - } elseif (is_dir($this->target)) { - if ($this->recursive == true) { - $files = $this->scanDirectories($this->target, true); - } else { - $files = $this->scanDirectories($this->target); - } - foreach ($files as $file) { - $this->target = $file; - $this->fileDocBlock(); - } - } else { - $this->log[] = 'This is not a file or folder.'; - return; - } - } - - /** - * fileCheck - * Make sure we can deal with the target file - * - * @param $target - * - * @return bool - * - * @access public - * @static - * @since 0.85 - */ - public function fileCheck($target) - { - $file_ext = strtolower(substr($target, strrpos($target, '.'))); - $bool = true; - if (!in_array($file_ext, $this->exts)) { - $this->log[] = "{$target} is not a PHP file."; - $bool = false; - } - if (!is_readable($target)) { - $this->log[] = "{$target} is not readable."; - $bool = false; - } - if (!is_writable($target)) { - $this->log[] = "{$target} is not writeable.\nCheck file permissions"; - $bool = false; - } - return $bool; - } - - /** - * fileDocBlock - * Shell method for docblock operations, explodes file, performs docblock methods, impodes. - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function fileDocBlock() - { - $this->file_contents = file_get_contents($this->target); - list($funcs, $classes) = $this->getProtos(); - $handle = fopen($this->target, 'r'); - if ($contents = fread($handle, filesize($this->target))) { - $contents = explode("\n", $contents); - $contents = $this->docBlock($contents, $funcs, $classes, $this->target_function); - $contents = implode("\n", $contents); - fclose($handle); - $handle = fopen($this->target, 'w'); - if (fwrite($handle, $contents)) { - $this->log[] = "{$this->target} Doc Blocked!"; - fclose($handle); - return; - } else { - fclose($handle); - $this->log[] = "Could not write new content.\nCheck Permissions"; - return; - } - } else { - fclose($handle); - $this->log[] = "Could not get file contents.\nCheck Permissions"; - return; - } - } - - /** - * getProtos - * This function goes through the tokens to gather the arrays of information we need - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function getProtos() - { - $tokens = token_get_all($this->file_contents); - $funcs = array(); - $classes = array(); - $curr_class = ''; - $class_depth = 0; - $count = count($tokens); - for ($i = 0; $i < $count; $i++) { - if (is_array($tokens[$i]) && $tokens[$i][0] == T_CLASS) { - $line = $tokens[$i][2]; - ++$i; // whitespace; - $curr_class = $tokens[++$i][1]; - if (!in_array(array('line' => $line, 'name' => $curr_class), $classes)) { - $classes[] = array('line' => $line, 'name' => $curr_class); - } - while ($tokens[++$i] != '{') {} - ++$i; - $class_depth = 1; - continue; - } elseif (is_array($tokens[$i]) && $tokens[$i][0] == T_FUNCTION) { - $next_by_ref = FALSE; - $this_func = array(); - - while ($tokens[++$i] != ')') { - if (is_array($tokens[$i]) && $tokens[$i][0] != T_WHITESPACE) { - if (!$this_func) { - $this_func = array( - 'name' => $tokens[$i][1], - 'class' => $curr_class, - 'line' => $tokens[$i][2], - ); - } else { - $this_func['params'][] = array( - 'byRef' => $next_by_ref, - 'name' => $tokens[$i][1], - ); - $next_by_ref = FALSE; - } - } elseif ($tokens[$i] == '&') { - $next_by_ref = TRUE; - } elseif ($tokens[$i] == '=') { - while (!in_array($tokens[++$i], array(')', ','))) { - if ($tokens[$i][0] != T_WHITESPACE) { - break; - } - } - $this_func['params'][count($this_func['params']) - 1]['default'] = $tokens[$i][1]; - } - } - $funcs[] = $this_func; - } elseif ($tokens[$i] == '{' || $tokens[$i] == 'T_CURLY_OPEN' || $tokens[$i] == 'T_DOLLAR_OPEN_CURLY_BRACES') { - ++$class_depth; - } elseif ($tokens[$i] == '}') { - --$class_depth; - } - - if ($class_depth == 0) { - $curr_class = ''; - } - } - - return array($funcs, $classes); - } - - /** - * docBlock - * Main docblock function, determines if class or function docblocking is need and calls - * appropriate subfunction. - * - * @param $arr - * @param $funcs - * @param $classes - * @param $target_function - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function docBlock($arr, $funcs, $classes, $target_function) - { - $func_lines = array(); - foreach ($funcs as $func) { - $func_lines[] = $func['line']; - } - $class_lines = array(); - foreach ($classes as $class) { - $class_lines[] = $class['line']; - } - $class_or_func = ''; - $count = count($arr); - for($i = 0; $i < $count; $i++) { - $line = $i + 1; - $code = $arr[$i]; - - if (in_array($line, $class_lines) && !$this->docBlockExists($arr[($i - 1)])) { - $class_or_func = 'class'; - } elseif (in_array($line, $func_lines) && !$this->docBlockExists($arr[($i - 1)])) { - $class_or_func = 'func'; - } else { - continue; - } - - if ($class_or_func === 'func') { - $data = $this->getData($line, $funcs); - } elseif ($class_or_func === 'class') { - $data = $this->getData($line, $classes); - } - if ($target_function !== null && $target_function !== '') { - if ($data['name'] !== $target_function) { - continue; - } - } - $indent_count = $this->getStrIndent($code); - $indent = ''; - for($indt = 0; $indt < $indent_count; $indt++) { - $indent .= ' '; - } - if ($class_or_func === 'func') { - $doc_block = $this->functionDocBlock($indent, $data); - } elseif ($class_or_func === 'class') { - $doc_block = $this->classDocBlock($indent, $data); - } - $arr[$i] = $doc_block . $arr[$i]; - } - return $arr; - } - - /** - * scanDirectories - * Get all specific files from a directory and if recursive, subdirectories - * - * @param $dir - * @param $recursive - * @param $data - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function scanDirectories($dir, $recursive = false, $data = array()) - { - // set filenames invisible if you want - $invisible = array('.', '..', '.htaccess', '.htpasswd'); - // run through content of root directory - $dir_content = scandir($dir); - foreach ($dir_content as $key => $content) { - // filter all files not accessible - $path = $dir . '/' . $content; - if (!in_array($content, $invisible)) { - // if content is file & readable, add to array - if (is_file($path) && is_readable($path)) { - // what is the ext of this file - $file_ext = strtolower(substr($path, strrpos($path, "."))); - // if this file ext matches the ones from our array - if (in_array($file_ext, $this->exts)) { - // save file name with path - $data[] = $path; - } - // if content is a directory and readable, add path and name - } elseif (is_dir($path) && is_readable($path)) { - // recursive callback to open new directory - if ($recursive == true) { - $data = $this->scanDirectories($path, true, $data); - } - } - } - } - return $data; - } - - /** - * getData - * Retrieve method or class information from our arrays - * - * @param $line - * @param $arr - * - * @return mixed - * - * @access public - * @static - * @since 0.85 - */ - public function getData($line, $arr) - { - foreach ($arr as $k => $v) { - if ($line == $v['line']) { - return $arr[$k]; - } - } - return false; - } - - /** - * docBlockExists - * Primitive check to see if docblock already exists - * - * @param $line - * - * @return bool - * - * @access public - * @static - * @since 0.85 - */ - public function docBlockExists($line) - { - // ok we are simply going to check the line above the function and look for */ - // TODO: make this a more accurate check. - $indent = $this->getStrIndent($line); - if ($indent > 0) { - $line = substr($line, ($indent - 1)); - } - $len = strlen($line); - if ($len == 0) { - return false; - } - $asterik = false; - for ($i = 0; $i < $len; $i++) { - if ($line[$i] == '*') { - $asterik = true; - } elseif ($line[$i] == '/' && $asterik == true) { - return true; - } else { - $asterik = false; - } - } - return false; - } - - /** - * functionDocBlock - * Docblock for function - * - * @param $indent - * @param $data - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function functionDocBlock($indent, $data) - { - $doc_block = "{$indent}/**\n"; - $doc_block .= "{$indent} * {$data['name']}\n"; - $doc_block .= "{$indent} * Insert description here\n"; - $doc_block .= "{$indent} *\n"; - if (isset($data['params'])) { - foreach($data['params'] as $func_param) { - $doc_block .= "{$indent} * @param {$func_param['name']}\n"; - } - } - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @return\n"; - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @access\n"; - $doc_block .= "{$indent} * @static\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; - $doc_block .= "{$indent} */\n"; - - return $doc_block; - } - - /** - * classDocBlock - * Docblock for class - * - * @param $indent - * @param $data - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function classDocBlock($indent, $data) - { - $doc_block = "{$indent}/**\n"; - $doc_block .= "{$indent} * {$data['name']}\n"; - $doc_block .= "{$indent} * Insert description here\n"; - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @category\n"; - $doc_block .= "{$indent} * @package\n"; - $doc_block .= "{$indent} * @author\n"; - $doc_block .= "{$indent} * @copyright\n"; - $doc_block .= "{$indent} * @license\n"; - $doc_block .= "{$indent} * @version\n"; - $doc_block .= "{$indent} * @link\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; - $doc_block .= "{$indent} */\n"; - - return $doc_block; - } - - /** - * getStrIndent - * Returns indentation count of a string - * - * @param $str - * @param $count - * - * @return int - * - * @access public - * @static - * @since 0.85 - */ - public function getStrIndent($str, $count = 0) - { - if (isset($str[0])) { - return ($str[0] == ' ') ? $this->getStrIndent(substr($str, 1), ($count + 1)) : $count; - } else { - return $count; - } - } - -} - -$argv = empty($_SERVER['argv']) ? array(0 => '') : $_SERVER['argv']; - -$current_dir = getcwd(); - -$options = array( - 'file_folder' => '', - 'target_function' => '', - 'recursive' => false -); - -foreach ($argv as $k => $arg) { - if ($k !== 0) { - if (strtolower($arg) === '-r') { - $options['recursive'] = true; - } elseif (is_file($arg)) { - $options['file_folder'] = $arg; - } elseif (is_file($current_dir . '/' . $arg)) { - $options['file_folder'] = $current_dir . '/' . $arg; - } elseif (is_dir($arg)) { - $options['file_folder'] = $arg; - } elseif (is_dir($current_dir . '/' . $arg)) { - $options['file_folder'] = $current_dir . '/' . $arg; - } else { - $options['target_function'] = $arg; - } - } -} - -if (isset($argv[1])) { - if (is_file($options['file_folder']) || is_dir($options['file_folder'])) { - $doc_block_generator = new DocBlockGenerator($options['file_folder'], $options['target_function'], $options['recursive']); - $doc_block_generator->start(); - $doc_block_generator->result(); - } else { - die("\nThis is not a valid file or directory\n"); - } - -} else { - die("\nPlease provide a file or directory as a parameter\n"); -} \ No newline at end of file diff --git a/src/new file~ b/src/new file~ deleted file mode 100644 index e69de29..0000000 From 41018f4a7d492310c1f0051b0665721b17c1014f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Gamaliel?= Date: Fri, 6 May 2016 17:44:17 -0300 Subject: [PATCH 04/11] README.md updated --- README | 4 +- bin/docblock.phar.php~ | 9 - composer.json~ | 8 - docblock.phar.php~ | 9 - src/DocBlockGenerator.class.php~ | 492 --------------------------- src/docblock.php~ | 559 ------------------------------- src/new file~ | 0 7 files changed, 2 insertions(+), 1079 deletions(-) delete mode 100644 bin/docblock.phar.php~ delete mode 100644 composer.json~ delete mode 100644 docblock.phar.php~ delete mode 100644 src/DocBlockGenerator.class.php~ delete mode 100644 src/docblock.php~ delete mode 100644 src/new file~ diff --git a/README b/README index c63f592..6cc6eae 100644 --- a/README +++ b/README @@ -6,9 +6,9 @@ file/folder - the file or folder you want to docblock (php files) target function - to docblock only a specific method/function name Example: -php docblock.php target.php targetFunction +bin/docblock target.php targetFunction or -php docblock.php target/dir -r targetFunction +bin/docblock target/dir -r targetFunction Credit to Sean Coates for the getProtos function, modified a little. http://seancoates.com/fun-with-the-tokenizer diff --git a/bin/docblock.phar.php~ b/bin/docblock.phar.php~ deleted file mode 100644 index 8502d8b..0000000 --- a/bin/docblock.phar.php~ +++ /dev/null @@ -1,9 +0,0 @@ -addFile('docblock.php'); -$defaultStub = $app->createDefaultStub("docblock.php"); -$stub = "#!/usr/bin/php \n".$defaultStub; -$app->setStub($stub); -$app->stopBuffering(); -?> - diff --git a/composer.json~ b/composer.json~ deleted file mode 100644 index 32223d9..0000000 --- a/composer.json~ +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "agentile/php-docblock-generator", - "description": "Generate PHPDoc Blocks in files and Folders", - "require": {}, - "bin": [ - "bin/docblock" - ], -} diff --git a/docblock.phar.php~ b/docblock.phar.php~ deleted file mode 100644 index 9223c36..0000000 --- a/docblock.phar.php~ +++ /dev/null @@ -1,9 +0,0 @@ -addFile(dirname(__FILE__).'/../src/docblock.php'); -$defaultStub = $app->createDefaultStub(dirname(__FILE__)."/../src/docblock.php"); -$stub = "#!/usr/bin/env php \n".$defaultStub; -$app->setStub($stub); -$app->stopBuffering(); -?> - diff --git a/src/DocBlockGenerator.class.php~ b/src/DocBlockGenerator.class.php~ deleted file mode 100644 index bb795df..0000000 --- a/src/DocBlockGenerator.class.php~ +++ /dev/null @@ -1,492 +0,0 @@ -use namespace DocBlockGenerator - -class DocBlockGenerator { - - public $exts = array('.php', '.php4', '.php5', '.phps', '.inc'); - public $target; - public $target_function; - public $recursive; - public $file_contents; - public $log = array(); - - - /** - * __construct - * - * @param $target - * @param $target_function - * @param $recursive - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function __construct($target, $target_function = null, $recursive = false) - { - $this->target = $target; - $this->target_function = $target_function; - $this->recursive = $recursive; - } - - /** - * result - * Print output to command line - * - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function result() - { - $str = ''; - foreach ($this->log as $log_item) { - $str .= "{$log_item}\n"; - } - echo $str; - } - - /** - * start - * Begin the docblocking process, determine if a file or folder was given - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function start() - { - if (is_file($this->target)) { - $valid_file = $this->fileCheck($this->target); - if ($valid_file == false) { - return; - } - $this->fileDocBlock(); - } elseif (is_dir($this->target)) { - if ($this->recursive == true) { - $files = $this->scanDirectories($this->target, true); - } else { - $files = $this->scanDirectories($this->target); - } - foreach ($files as $file) { - $this->target = $file; - $this->fileDocBlock(); - } - } else { - $this->log[] = 'This is not a file or folder.'; - return; - } - } - - /** - * fileCheck - * Make sure we can deal with the target file - * - * @param $target - * - * @return bool - * - * @access public - * @static - * @since 0.85 - */ - public function fileCheck($target) - { - $file_ext = strtolower(substr($target, strrpos($target, '.'))); - $bool = true; - if (!in_array($file_ext, $this->exts)) { - $this->log[] = "{$target} is not a PHP file."; - $bool = false; - } - if (!is_readable($target)) { - $this->log[] = "{$target} is not readable."; - $bool = false; - } - if (!is_writable($target)) { - $this->log[] = "{$target} is not writeable.\nCheck file permissions"; - $bool = false; - } - return $bool; - } - - /** - * fileDocBlock - * Shell method for docblock operations, explodes file, performs docblock methods, impodes. - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function fileDocBlock() - { - $this->file_contents = file_get_contents($this->target); - list($funcs, $classes) = $this->getProtos(); - $handle = fopen($this->target, 'r'); - if ($contents = fread($handle, filesize($this->target))) { - $contents = explode("\n", $contents); - $contents = $this->docBlock($contents, $funcs, $classes, $this->target_function); - $contents = implode("\n", $contents); - fclose($handle); - $handle = fopen($this->target, 'w'); - if (fwrite($handle, $contents)) { - $this->log[] = "{$this->target} Doc Blocked!"; - fclose($handle); - return; - } else { - fclose($handle); - $this->log[] = "Could not write new content.\nCheck Permissions"; - return; - } - } else { - fclose($handle); - $this->log[] = "Could not get file contents.\nCheck Permissions"; - return; - } - } - - /** - * getProtos - * This function goes through the tokens to gather the arrays of information we need - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function getProtos() - { - $tokens = token_get_all($this->file_contents); - $funcs = array(); - $classes = array(); - $curr_class = ''; - $class_depth = 0; - $count = count($tokens); - for ($i = 0; $i < $count; $i++) { - if (is_array($tokens[$i]) && $tokens[$i][0] == T_CLASS) { - $line = $tokens[$i][2]; - ++$i; // whitespace; - $curr_class = $tokens[++$i][1]; - if (!in_array(array('line' => $line, 'name' => $curr_class), $classes)) { - $classes[] = array('line' => $line, 'name' => $curr_class); - } - while ($tokens[++$i] != '{') {} - ++$i; - $class_depth = 1; - continue; - } elseif (is_array($tokens[$i]) && $tokens[$i][0] == T_FUNCTION) { - $next_by_ref = FALSE; - $this_func = array(); - - while ($tokens[++$i] != ')') { - if (is_array($tokens[$i]) && $tokens[$i][0] != T_WHITESPACE) { - if (!$this_func) { - $this_func = array( - 'name' => $tokens[$i][1], - 'class' => $curr_class, - 'line' => $tokens[$i][2], - ); - } else { - $this_func['params'][] = array( - 'byRef' => $next_by_ref, - 'name' => $tokens[$i][1], - ); - $next_by_ref = FALSE; - } - } elseif ($tokens[$i] == '&') { - $next_by_ref = TRUE; - } elseif ($tokens[$i] == '=') { - while (!in_array($tokens[++$i], array(')', ','))) { - if ($tokens[$i][0] != T_WHITESPACE) { - break; - } - } - $this_func['params'][count($this_func['params']) - 1]['default'] = $tokens[$i][1]; - } - } - $funcs[] = $this_func; - } elseif ($tokens[$i] == '{' || $tokens[$i] == 'T_CURLY_OPEN' || $tokens[$i] == 'T_DOLLAR_OPEN_CURLY_BRACES') { - ++$class_depth; - } elseif ($tokens[$i] == '}') { - --$class_depth; - } - - if ($class_depth == 0) { - $curr_class = ''; - } - } - - return array($funcs, $classes); - } - - /** - * docBlock - * Main docblock function, determines if class or function docblocking is need and calls - * appropriate subfunction. - * - * @param $arr - * @param $funcs - * @param $classes - * @param $target_function - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function docBlock($arr, $funcs, $classes, $target_function) - { - $func_lines = array(); - foreach ($funcs as $func) { - $func_lines[] = $func['line']; - } - $class_lines = array(); - foreach ($classes as $class) { - $class_lines[] = $class['line']; - } - $class_or_func = ''; - $count = count($arr); - for($i = 0; $i < $count; $i++) { - $line = $i + 1; - $code = $arr[$i]; - - if (in_array($line, $class_lines) && !$this->docBlockExists($arr[($i - 1)])) { - $class_or_func = 'class'; - } elseif (in_array($line, $func_lines) && !$this->docBlockExists($arr[($i - 1)])) { - $class_or_func = 'func'; - } else { - continue; - } - - if ($class_or_func === 'func') { - $data = $this->getData($line, $funcs); - } elseif ($class_or_func === 'class') { - $data = $this->getData($line, $classes); - } - if ($target_function !== null && $target_function !== '') { - if ($data['name'] !== $target_function) { - continue; - } - } - $indent_count = $this->getStrIndent($code); - $indent = ''; - for($indt = 0; $indt < $indent_count; $indt++) { - $indent .= ' '; - } - if ($class_or_func === 'func') { - $doc_block = $this->functionDocBlock($indent, $data); - } elseif ($class_or_func === 'class') { - $doc_block = $this->classDocBlock($indent, $data); - } - $arr[$i] = $doc_block . $arr[$i]; - } - return $arr; - } - - /** - * scanDirectories - * Get all specific files from a directory and if recursive, subdirectories - * - * @param $dir - * @param $recursive - * @param $data - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function scanDirectories($dir, $recursive = false, $data = array()) - { - // set filenames invisible if you want - $invisible = array('.', '..', '.htaccess', '.htpasswd'); - // run through content of root directory - $dir_content = scandir($dir); - foreach ($dir_content as $key => $content) { - // filter all files not accessible - $path = $dir . '/' . $content; - if (!in_array($content, $invisible)) { - // if content is file & readable, add to array - if (is_file($path) && is_readable($path)) { - // what is the ext of this file - $file_ext = strtolower(substr($path, strrpos($path, "."))); - // if this file ext matches the ones from our array - if (in_array($file_ext, $this->exts)) { - // save file name with path - $data[] = $path; - } - // if content is a directory and readable, add path and name - } elseif (is_dir($path) && is_readable($path)) { - // recursive callback to open new directory - if ($recursive == true) { - $data = $this->scanDirectories($path, true, $data); - } - } - } - } - return $data; - } - - /** - * getData - * Retrieve method or class information from our arrays - * - * @param $line - * @param $arr - * - * @return mixed - * - * @access public - * @static - * @since 0.85 - */ - public function getData($line, $arr) - { - foreach ($arr as $k => $v) { - if ($line == $v['line']) { - return $arr[$k]; - } - } - return false; - } - - /** - * docBlockExists - * Primitive check to see if docblock already exists - * - * @param $line - * - * @return bool - * - * @access public - * @static - * @since 0.85 - */ - public function docBlockExists($line) - { - // ok we are simply going to check the line above the function and look for */ - // TODO: make this a more accurate check. - $indent = $this->getStrIndent($line); - if ($indent > 0) { - $line = substr($line, ($indent - 1)); - } - $len = strlen($line); - if ($len == 0) { - return false; - } - $asterik = false; - for ($i = 0; $i < $len; $i++) { - if ($line[$i] == '*') { - $asterik = true; - } elseif ($line[$i] == '/' && $asterik == true) { - return true; - } else { - $asterik = false; - } - } - return false; - } - - /** - * functionDocBlock - * Docblock for function - * - * @param $indent - * @param $data - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function functionDocBlock($indent, $data) - { - $doc_block = "{$indent}/**\n"; - $doc_block .= "{$indent} * {$data['name']}\n"; - $doc_block .= "{$indent} * Insert description here\n"; - $doc_block .= "{$indent} *\n"; - if (isset($data['params'])) { - foreach($data['params'] as $func_param) { - $doc_block .= "{$indent} * @param {$func_param['name']}\n"; - } - } - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @return\n"; - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @access\n"; - $doc_block .= "{$indent} * @static\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; - $doc_block .= "{$indent} */\n"; - - return $doc_block; - } - - /** - * classDocBlock - * Docblock for class - * - * @param $indent - * @param $data - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function classDocBlock($indent, $data) - { - $doc_block = "{$indent}/**\n"; - $doc_block .= "{$indent} * {$data['name']}\n"; - $doc_block .= "{$indent} * Insert description here\n"; - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @category\n"; - $doc_block .= "{$indent} * @package\n"; - $doc_block .= "{$indent} * @author\n"; - $doc_block .= "{$indent} * @copyright\n"; - $doc_block .= "{$indent} * @license\n"; - $doc_block .= "{$indent} * @version\n"; - $doc_block .= "{$indent} * @link\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; - $doc_block .= "{$indent} */\n"; - - return $doc_block; - } - - /** - * getStrIndent - * Returns indentation count of a string - * - * @param $str - * @param $count - * - * @return int - * - * @access public - * @static - * @since 0.85 - */ - public function getStrIndent($str, $count = 0) - { - if (isset($str[0])) { - return ($str[0] == ' ') ? $this->getStrIndent(substr($str, 1), ($count + 1)) : $count; - } else { - return $count; - } - } - -} - diff --git a/src/docblock.php~ b/src/docblock.php~ deleted file mode 100644 index ec6e263..0000000 --- a/src/docblock.php~ +++ /dev/null @@ -1,559 +0,0 @@ -target = $target; - $this->target_function = $target_function; - $this->recursive = $recursive; - } - - /** - * result - * Print output to command line - * - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function result() - { - $str = ''; - foreach ($this->log as $log_item) { - $str .= "{$log_item}\n"; - } - echo $str; - } - - /** - * start - * Begin the docblocking process, determine if a file or folder was given - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function start() - { - if (is_file($this->target)) { - $valid_file = $this->fileCheck($this->target); - if ($valid_file == false) { - return; - } - $this->fileDocBlock(); - } elseif (is_dir($this->target)) { - if ($this->recursive == true) { - $files = $this->scanDirectories($this->target, true); - } else { - $files = $this->scanDirectories($this->target); - } - foreach ($files as $file) { - $this->target = $file; - $this->fileDocBlock(); - } - } else { - $this->log[] = 'This is not a file or folder.'; - return; - } - } - - /** - * fileCheck - * Make sure we can deal with the target file - * - * @param $target - * - * @return bool - * - * @access public - * @static - * @since 0.85 - */ - public function fileCheck($target) - { - $file_ext = strtolower(substr($target, strrpos($target, '.'))); - $bool = true; - if (!in_array($file_ext, $this->exts)) { - $this->log[] = "{$target} is not a PHP file."; - $bool = false; - } - if (!is_readable($target)) { - $this->log[] = "{$target} is not readable."; - $bool = false; - } - if (!is_writable($target)) { - $this->log[] = "{$target} is not writeable.\nCheck file permissions"; - $bool = false; - } - return $bool; - } - - /** - * fileDocBlock - * Shell method for docblock operations, explodes file, performs docblock methods, impodes. - * - * @return void - * - * @access public - * @static - * @since 0.85 - */ - public function fileDocBlock() - { - $this->file_contents = file_get_contents($this->target); - list($funcs, $classes) = $this->getProtos(); - $handle = fopen($this->target, 'r'); - if ($contents = fread($handle, filesize($this->target))) { - $contents = explode("\n", $contents); - $contents = $this->docBlock($contents, $funcs, $classes, $this->target_function); - $contents = implode("\n", $contents); - fclose($handle); - $handle = fopen($this->target, 'w'); - if (fwrite($handle, $contents)) { - $this->log[] = "{$this->target} Doc Blocked!"; - fclose($handle); - return; - } else { - fclose($handle); - $this->log[] = "Could not write new content.\nCheck Permissions"; - return; - } - } else { - fclose($handle); - $this->log[] = "Could not get file contents.\nCheck Permissions"; - return; - } - } - - /** - * getProtos - * This function goes through the tokens to gather the arrays of information we need - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function getProtos() - { - $tokens = token_get_all($this->file_contents); - $funcs = array(); - $classes = array(); - $curr_class = ''; - $class_depth = 0; - $count = count($tokens); - for ($i = 0; $i < $count; $i++) { - if (is_array($tokens[$i]) && $tokens[$i][0] == T_CLASS) { - $line = $tokens[$i][2]; - ++$i; // whitespace; - $curr_class = $tokens[++$i][1]; - if (!in_array(array('line' => $line, 'name' => $curr_class), $classes)) { - $classes[] = array('line' => $line, 'name' => $curr_class); - } - while ($tokens[++$i] != '{') {} - ++$i; - $class_depth = 1; - continue; - } elseif (is_array($tokens[$i]) && $tokens[$i][0] == T_FUNCTION) { - $next_by_ref = FALSE; - $this_func = array(); - - while ($tokens[++$i] != ')') { - if (is_array($tokens[$i]) && $tokens[$i][0] != T_WHITESPACE) { - if (!$this_func) { - $this_func = array( - 'name' => $tokens[$i][1], - 'class' => $curr_class, - 'line' => $tokens[$i][2], - ); - } else { - $this_func['params'][] = array( - 'byRef' => $next_by_ref, - 'name' => $tokens[$i][1], - ); - $next_by_ref = FALSE; - } - } elseif ($tokens[$i] == '&') { - $next_by_ref = TRUE; - } elseif ($tokens[$i] == '=') { - while (!in_array($tokens[++$i], array(')', ','))) { - if ($tokens[$i][0] != T_WHITESPACE) { - break; - } - } - $this_func['params'][count($this_func['params']) - 1]['default'] = $tokens[$i][1]; - } - } - $funcs[] = $this_func; - } elseif ($tokens[$i] == '{' || $tokens[$i] == 'T_CURLY_OPEN' || $tokens[$i] == 'T_DOLLAR_OPEN_CURLY_BRACES') { - ++$class_depth; - } elseif ($tokens[$i] == '}') { - --$class_depth; - } - - if ($class_depth == 0) { - $curr_class = ''; - } - } - - return array($funcs, $classes); - } - - /** - * docBlock - * Main docblock function, determines if class or function docblocking is need and calls - * appropriate subfunction. - * - * @param $arr - * @param $funcs - * @param $classes - * @param $target_function - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function docBlock($arr, $funcs, $classes, $target_function) - { - $func_lines = array(); - foreach ($funcs as $func) { - $func_lines[] = $func['line']; - } - $class_lines = array(); - foreach ($classes as $class) { - $class_lines[] = $class['line']; - } - $class_or_func = ''; - $count = count($arr); - for($i = 0; $i < $count; $i++) { - $line = $i + 1; - $code = $arr[$i]; - - if (in_array($line, $class_lines) && !$this->docBlockExists($arr[($i - 1)])) { - $class_or_func = 'class'; - } elseif (in_array($line, $func_lines) && !$this->docBlockExists($arr[($i - 1)])) { - $class_or_func = 'func'; - } else { - continue; - } - - if ($class_or_func === 'func') { - $data = $this->getData($line, $funcs); - } elseif ($class_or_func === 'class') { - $data = $this->getData($line, $classes); - } - if ($target_function !== null && $target_function !== '') { - if ($data['name'] !== $target_function) { - continue; - } - } - $indent_count = $this->getStrIndent($code); - $indent = ''; - for($indt = 0; $indt < $indent_count; $indt++) { - $indent .= ' '; - } - if ($class_or_func === 'func') { - $doc_block = $this->functionDocBlock($indent, $data); - } elseif ($class_or_func === 'class') { - $doc_block = $this->classDocBlock($indent, $data); - } - $arr[$i] = $doc_block . $arr[$i]; - } - return $arr; - } - - /** - * scanDirectories - * Get all specific files from a directory and if recursive, subdirectories - * - * @param $dir - * @param $recursive - * @param $data - * - * @return array - * - * @access public - * @static - * @since 0.85 - */ - public function scanDirectories($dir, $recursive = false, $data = array()) - { - // set filenames invisible if you want - $invisible = array('.', '..', '.htaccess', '.htpasswd'); - // run through content of root directory - $dir_content = scandir($dir); - foreach ($dir_content as $key => $content) { - // filter all files not accessible - $path = $dir . '/' . $content; - if (!in_array($content, $invisible)) { - // if content is file & readable, add to array - if (is_file($path) && is_readable($path)) { - // what is the ext of this file - $file_ext = strtolower(substr($path, strrpos($path, "."))); - // if this file ext matches the ones from our array - if (in_array($file_ext, $this->exts)) { - // save file name with path - $data[] = $path; - } - // if content is a directory and readable, add path and name - } elseif (is_dir($path) && is_readable($path)) { - // recursive callback to open new directory - if ($recursive == true) { - $data = $this->scanDirectories($path, true, $data); - } - } - } - } - return $data; - } - - /** - * getData - * Retrieve method or class information from our arrays - * - * @param $line - * @param $arr - * - * @return mixed - * - * @access public - * @static - * @since 0.85 - */ - public function getData($line, $arr) - { - foreach ($arr as $k => $v) { - if ($line == $v['line']) { - return $arr[$k]; - } - } - return false; - } - - /** - * docBlockExists - * Primitive check to see if docblock already exists - * - * @param $line - * - * @return bool - * - * @access public - * @static - * @since 0.85 - */ - public function docBlockExists($line) - { - // ok we are simply going to check the line above the function and look for */ - // TODO: make this a more accurate check. - $indent = $this->getStrIndent($line); - if ($indent > 0) { - $line = substr($line, ($indent - 1)); - } - $len = strlen($line); - if ($len == 0) { - return false; - } - $asterik = false; - for ($i = 0; $i < $len; $i++) { - if ($line[$i] == '*') { - $asterik = true; - } elseif ($line[$i] == '/' && $asterik == true) { - return true; - } else { - $asterik = false; - } - } - return false; - } - - /** - * functionDocBlock - * Docblock for function - * - * @param $indent - * @param $data - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function functionDocBlock($indent, $data) - { - $doc_block = "{$indent}/**\n"; - $doc_block .= "{$indent} * {$data['name']}\n"; - $doc_block .= "{$indent} * Insert description here\n"; - $doc_block .= "{$indent} *\n"; - if (isset($data['params'])) { - foreach($data['params'] as $func_param) { - $doc_block .= "{$indent} * @param {$func_param['name']}\n"; - } - } - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @return\n"; - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @access\n"; - $doc_block .= "{$indent} * @static\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; - $doc_block .= "{$indent} */\n"; - - return $doc_block; - } - - /** - * classDocBlock - * Docblock for class - * - * @param $indent - * @param $data - * - * @return string - * - * @access public - * @static - * @since 0.85 - */ - public function classDocBlock($indent, $data) - { - $doc_block = "{$indent}/**\n"; - $doc_block .= "{$indent} * {$data['name']}\n"; - $doc_block .= "{$indent} * Insert description here\n"; - $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @category\n"; - $doc_block .= "{$indent} * @package\n"; - $doc_block .= "{$indent} * @author\n"; - $doc_block .= "{$indent} * @copyright\n"; - $doc_block .= "{$indent} * @license\n"; - $doc_block .= "{$indent} * @version\n"; - $doc_block .= "{$indent} * @link\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; - $doc_block .= "{$indent} */\n"; - - return $doc_block; - } - - /** - * getStrIndent - * Returns indentation count of a string - * - * @param $str - * @param $count - * - * @return int - * - * @access public - * @static - * @since 0.85 - */ - public function getStrIndent($str, $count = 0) - { - if (isset($str[0])) { - return ($str[0] == ' ') ? $this->getStrIndent(substr($str, 1), ($count + 1)) : $count; - } else { - return $count; - } - } - -} - -$argv = empty($_SERVER['argv']) ? array(0 => '') : $_SERVER['argv']; - -$current_dir = getcwd(); - -$options = array( - 'file_folder' => '', - 'target_function' => '', - 'recursive' => false -); - -foreach ($argv as $k => $arg) { - if ($k !== 0) { - if (strtolower($arg) === '-r') { - $options['recursive'] = true; - } elseif (is_file($arg)) { - $options['file_folder'] = $arg; - } elseif (is_file($current_dir . '/' . $arg)) { - $options['file_folder'] = $current_dir . '/' . $arg; - } elseif (is_dir($arg)) { - $options['file_folder'] = $arg; - } elseif (is_dir($current_dir . '/' . $arg)) { - $options['file_folder'] = $current_dir . '/' . $arg; - } else { - $options['target_function'] = $arg; - } - } -} - -if (isset($argv[1])) { - if (is_file($options['file_folder']) || is_dir($options['file_folder'])) { - $doc_block_generator = new DocBlockGenerator($options['file_folder'], $options['target_function'], $options['recursive']); - $doc_block_generator->start(); - $doc_block_generator->result(); - } else { - die("\nThis is not a valid file or directory\n"); - } - -} else { - die("\nPlease provide a file or directory as a parameter\n"); -} \ No newline at end of file diff --git a/src/new file~ b/src/new file~ deleted file mode 100644 index e69de29..0000000 From 830e163786e882c2762eebe25b20e43d3039fe1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Gamaliel?= Date: Fri, 6 May 2016 18:46:26 -0300 Subject: [PATCH 05/11] composer.json fixed --- composer.json~ | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 composer.json~ diff --git a/composer.json~ b/composer.json~ new file mode 100644 index 0000000..a93d5c9 --- /dev/null +++ b/composer.json~ @@ -0,0 +1,13 @@ +{ + "name": "agentile/php-docblock-generator", + "description": "Generate PHPDoc Blocks in files and Folders", + "require": {}, + "autoload": { + "psr-0": { + "DocBlockGenerator\\": "src" + } + }, + "bin": [ + "bin/docblock" + ], +} From 8ecb3f5a421f5b3bb93e51417db925f35bcc796d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Gamaliel?= Date: Mon, 9 May 2016 08:46:13 -0300 Subject: [PATCH 06/11] Binary working --- bin/docblock | Bin 9075 -> 23681 bytes bin/docblock.phar | Bin 9075 -> 23681 bytes bin/docblock.phar.php | 9 --------- docblock.phar.php | 3 ++- 4 files changed, 2 insertions(+), 10 deletions(-) mode change 100644 => 100755 bin/docblock.phar delete mode 100644 bin/docblock.phar.php diff --git a/bin/docblock b/bin/docblock index 7b1baf9cd4752957a75cdd6aacc08f2ece63f300..2157f9a51b5dfa2273b05df007789117a9ef8d74 100755 GIT binary patch literal 23681 zcmd^H&2t;aa+h;Tn0i&oDaVZX@C;BQ36hpSLRk`JiLzCZEQX}zdZtyVC9oj&5y0Z@ zF8E~0-W_O+@-Q#H54X0;jHkz5G&mZ7pX{mJ{9-Din9Zd(}#X6eWcbAr;q3J}^ zUXUcgWv4wG1xb6=q*)RMlio>~_0E%EHVc!qv$A47{Lu8rL7Mi$izv;~PJ2(mH_-Qb zi4WV`(KHK_emKjXMC0(ueA>szyGtoBMbrLxJ_viWARFmS+ud&4teal%$?XEwm=OST)(-8)%bGvux)9)kDQB$|XNR#+Ev z2{M?aZFBFw*;-v{_vKqV3oo+nY#c<>HXEB;XR}7&+qavV2ic&hdDPT6j!&AJlWAjf zc9AtfU!;u_QlZK0CisFHYBUR*p1Qu*{m>e?~b=Z23!a&c^RK}p~vTcHwyLNtU=t4lD`rBN6R z!lbkODCm#EwMX$ZOXBginZ|29befzJPPE%*1X2PR337q8zdAhJ>u#=ZnvXU% z&GYyy9GJZ@nFP~tnvE~pg=pK)Vl|O%!=O}m$08^6Xbizz7>hudF=Vs?aE_Qcmf+SP zHjI1xbbt2|qS`M@0Z#GA3IPdNvMfXVT+vP|zz zp**u})hv7Cy8w~Vb`a2T=4DT0%ta`!XgZ9^rd?SZRF99^h*aS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3?iE+$c+9k-9F%U1D=Fn7aypP4H`ixwizb4X*DuTpv8V?rNKzlkJC%sr#&Zgi@)(8Fk4W2!!o%0RNYLL5ZXP2acdvWBW=);iY!?`${MHJ*8_Z5#J8# zpW?OFYs2eHwATjj$FocPp4}+B_6WSJg)36mC&<3H`wsZ0r`HBXMtgnO--7Y_DW5aV zeR)3!hklZ}=@mGw0i*PQ*W4R}v8~vl)1h$|E<>xB0S_Kl<0-`)vJh{`{~0;-4P==YL)P`#*dT|K0EN$0NS{ I;`tZ<1K0!Oy#N3J delta 82 zcmZqN$@tlAgN2lsKLY~;BM=LMX%Lx|nWsP5OG=aHaddFile('src/docblock.php'); -$defaultStub = $app->createDefaultStub("src/docblock.php"); -$stub = "#!/usr/bin/env php \n".$defaultStub; -$app->setStub($stub); -$app->stopBuffering(); -?> - diff --git a/docblock.phar.php b/docblock.phar.php index 97c5ffb..a6847b3 100644 --- a/docblock.phar.php +++ b/docblock.phar.php @@ -1,6 +1,7 @@ addFile('src/docblock.php'); +$app->addFile('src/DocBlockGenerator.class.php'); $defaultStub = $app->createDefaultStub("src/docblock.php"); $stub = "#!/usr/bin/env php \n".$defaultStub; $app->setStub($stub); From 418777362fe51191087eca236ff0061ec9ecfdfc Mon Sep 17 00:00:00 2001 From: Chris Coleman Date: Mon, 17 Apr 2017 10:21:20 -0400 Subject: [PATCH 07/11] Attempt to guess param types based on defaults --- src/DocBlockGenerator.class.php | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/DocBlockGenerator.class.php b/src/DocBlockGenerator.class.php index e039410..ba4ae07 100644 --- a/src/DocBlockGenerator.class.php +++ b/src/DocBlockGenerator.class.php @@ -66,7 +66,7 @@ public function start() if (is_file($this->target)) { $valid_file = $this->fileCheck($this->target); if ($valid_file == false) { - return; + return false; } $this->fileDocBlock(); } elseif (is_dir($this->target)) { @@ -81,7 +81,7 @@ public function start() } } else { $this->log[] = 'This is not a file or folder.'; - return; + return false; } } @@ -419,7 +419,7 @@ public function functionDocBlock($indent, $data) $doc_block .= "{$indent} *\n"; if (isset($data['params'])) { foreach($data['params'] as $func_param) { - $doc_block .= "{$indent} * @param {$func_param['name']}\n"; + $doc_block .= "{$indent} * @param {$func_param['name']} ". (isset($func_param['default'])?$this->decodeType($func_param['default']):'type') . "\n"; } } $doc_block .= "{$indent} *\n"; @@ -434,6 +434,32 @@ public function functionDocBlock($indent, $data) return $doc_block; } + /** + * Decode the parameter type + * @param type $type + * @return string + */ + public function decodeType($type) { + $typeToReturn = $type; + + if ($type == "''") { + $typeToReturn = 'string'; + } + + if (is_int($type)) { + $typeToReturn = 'int'; + } + + if ($type === false) { + $typeToReturn = 'bool'; + } + + if ($type === true) { + $typeToReturn = 'bool'; + } + return $typeToReturn; + } + /** * classDocBlock * Docblock for class From 4a4c0a84d6c576c4b1d6a1101cf647922a68d6f9 Mon Sep 17 00:00:00 2001 From: Chris Coleman Date: Mon, 17 Apr 2017 11:24:23 -0400 Subject: [PATCH 08/11] Fix bug where it skipped params if there was a close parenthesis as part of the default value. --- src/DocBlockGenerator.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DocBlockGenerator.class.php b/src/DocBlockGenerator.class.php index ba4ae07..594cbe8 100644 --- a/src/DocBlockGenerator.class.php +++ b/src/DocBlockGenerator.class.php @@ -187,7 +187,7 @@ public function getProtos() $next_by_ref = FALSE; $this_func = array(); - while ($tokens[++$i] != ')') { + while ($tokens[++$i] != '{') { if (is_array($tokens[$i]) && $tokens[$i][0] != T_WHITESPACE) { if (!$this_func) { $this_func = array( From f47a7f5e8f0d932097bd69db3ff6ae6b43105ce3 Mon Sep 17 00:00:00 2001 From: Chris Coleman Date: Mon, 17 Apr 2017 11:53:27 -0400 Subject: [PATCH 09/11] Detect @access type and @static status. --- src/DocBlockGenerator.class.php | 35 ++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/DocBlockGenerator.class.php b/src/DocBlockGenerator.class.php index 594cbe8..4e5bcf3 100644 --- a/src/DocBlockGenerator.class.php +++ b/src/DocBlockGenerator.class.php @@ -186,6 +186,25 @@ public function getProtos() } elseif (is_array($tokens[$i]) && $tokens[$i][0] == T_FUNCTION) { $next_by_ref = FALSE; $this_func = array(); + $func_status = array(); + + if ($tokens[$i-2][1] == 'static') { + $func_status['static'] = true; + } else { + $func_status['static'] = false; + } + + if ($tokens[$i-2][1] != 'static') { + if ($tokens[$i-2][1] == 'public' || $tokens[$i-2][1] == 'private'|| $tokens[$i-2][1] == 'protected') { + $func_status['access'] = $tokens[$i-2][1]; + } + } + if ($tokens[$i-2][1] == 'static') { + if ($tokens[$i-4][1] == 'public' || $tokens[$i-4][1] == 'private'|| $tokens[$i-4][1] == 'protected') { + $func_status['access'] = $tokens[$i-4][1]; + } + + } while ($tokens[++$i] != '{') { if (is_array($tokens[$i]) && $tokens[$i][0] != T_WHITESPACE) { @@ -213,7 +232,8 @@ public function getProtos() $this_func['params'][count($this_func['params']) - 1]['default'] = $tokens[$i][1]; } } - $funcs[] = $this_func; + + $funcs[] = $this_func + $func_status; } elseif ($tokens[$i] == '{' || $tokens[$i] == 'T_CURLY_OPEN' || $tokens[$i] == 'T_DOLLAR_OPEN_CURLY_BRACES') { ++$class_depth; } elseif ($tokens[$i] == '}') { @@ -425,10 +445,15 @@ public function functionDocBlock($indent, $data) $doc_block .= "{$indent} *\n"; $doc_block .= "{$indent} * @return\n"; $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @access\n"; - $doc_block .= "{$indent} * @static\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; + if (!empty($data['access'])) { + $doc_block .= "{$indent} * @access {$data['access']}\n"; + } + if ($data['static']) { + $doc_block .= "{$indent} * @static\n"; + } + // We can't determine these automatically yet. + //$doc_block .= "{$indent} * @see\n"; + //$doc_block .= "{$indent} * @since\n"; $doc_block .= "{$indent} */\n"; return $doc_block; From e086f6ba8d290925a54b258be37feb1dff44056e Mon Sep 17 00:00:00 2001 From: Chris Coleman Date: Mon, 17 Apr 2017 12:36:54 -0400 Subject: [PATCH 10/11] Detect if we actually return anything and only add @return if we do. --- src/DocBlockGenerator.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/DocBlockGenerator.class.php b/src/DocBlockGenerator.class.php index 4e5bcf3..03c6edd 100644 --- a/src/DocBlockGenerator.class.php +++ b/src/DocBlockGenerator.class.php @@ -169,9 +169,13 @@ public function getProtos() $funcs = array(); $classes = array(); $curr_class = ''; + $curr_func = ''; $class_depth = 0; $count = count($tokens); for ($i = 0; $i < $count; $i++) { + if (is_array($tokens[$i]) && $tokens[$i][0] == T_RETURN) { + $funcs[$curr_func]['return'] = 'returns'; + } if (is_array($tokens[$i]) && $tokens[$i][0] == T_CLASS) { $line = $tokens[$i][2]; ++$i; // whitespace; @@ -209,6 +213,7 @@ public function getProtos() while ($tokens[++$i] != '{') { if (is_array($tokens[$i]) && $tokens[$i][0] != T_WHITESPACE) { if (!$this_func) { + $curr_func = $tokens[$i][1]; $this_func = array( 'name' => $tokens[$i][1], 'class' => $curr_class, @@ -233,7 +238,7 @@ public function getProtos() } } - $funcs[] = $this_func + $func_status; + $funcs[$curr_func] = $this_func + $func_status; } elseif ($tokens[$i] == '{' || $tokens[$i] == 'T_CURLY_OPEN' || $tokens[$i] == 'T_DOLLAR_OPEN_CURLY_BRACES') { ++$class_depth; } elseif ($tokens[$i] == '}') { @@ -443,7 +448,9 @@ public function functionDocBlock($indent, $data) } } $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @return\n"; + if (isset($data['return'])) { + $doc_block .= "{$indent} * @return type\n"; + } $doc_block .= "{$indent} *\n"; if (!empty($data['access'])) { $doc_block .= "{$indent} * @access {$data['access']}\n"; From 92bd668a64f61e5ce7597b2586c8daad15d52971 Mon Sep 17 00:00:00 2001 From: Chris Coleman Date: Tue, 18 Apr 2017 10:31:19 -0400 Subject: [PATCH 11/11] Fix bug where it tried to add params that were not variables. Fix a bug where it put the type on the wrong side of the param name. Trim down the class doc block Remove some whitespace to make it more compact. --- src/DocBlockGenerator.class.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/DocBlockGenerator.class.php b/src/DocBlockGenerator.class.php index 03c6edd..38b2f52 100644 --- a/src/DocBlockGenerator.class.php +++ b/src/DocBlockGenerator.class.php @@ -219,7 +219,7 @@ public function getProtos() 'class' => $curr_class, 'line' => $tokens[$i][2], ); - } else { + } elseif ($tokens[$i][0] == T_VARIABLE) { $this_func['params'][] = array( 'byRef' => $next_by_ref, 'name' => $tokens[$i][1], @@ -444,14 +444,13 @@ public function functionDocBlock($indent, $data) $doc_block .= "{$indent} *\n"; if (isset($data['params'])) { foreach($data['params'] as $func_param) { - $doc_block .= "{$indent} * @param {$func_param['name']} ". (isset($func_param['default'])?$this->decodeType($func_param['default']):'type') . "\n"; + $doc_block .= "{$indent} * @param ". (isset($func_param['default'])?$this->decodeType($func_param['default']):'type') . " {$func_param['name']}\n"; } + $doc_block .= "{$indent} *\n"; } - $doc_block .= "{$indent} *\n"; if (isset($data['return'])) { $doc_block .= "{$indent} * @return type\n"; } - $doc_block .= "{$indent} *\n"; if (!empty($data['access'])) { $doc_block .= "{$indent} * @access {$data['access']}\n"; } @@ -511,15 +510,15 @@ public function classDocBlock($indent, $data) $doc_block .= "{$indent} * {$data['name']}\n"; $doc_block .= "{$indent} * Insert description here\n"; $doc_block .= "{$indent} *\n"; - $doc_block .= "{$indent} * @category\n"; - $doc_block .= "{$indent} * @package\n"; - $doc_block .= "{$indent} * @author\n"; - $doc_block .= "{$indent} * @copyright\n"; - $doc_block .= "{$indent} * @license\n"; - $doc_block .= "{$indent} * @version\n"; - $doc_block .= "{$indent} * @link\n"; - $doc_block .= "{$indent} * @see\n"; - $doc_block .= "{$indent} * @since\n"; + //$doc_block .= "{$indent} * @category\n"; + //$doc_block .= "{$indent} * @package\n"; + //$doc_block .= "{$indent} * @author\n"; + //$doc_block .= "{$indent} * @copyright\n"; + //$doc_block .= "{$indent} * @license\n"; + //$doc_block .= "{$indent} * @version\n"; + //$doc_block .= "{$indent} * @link\n"; + //$doc_block .= "{$indent} * @see\n"; + //$doc_block .= "{$indent} * @since\n"; $doc_block .= "{$indent} */\n"; return $doc_block;