-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdocblock.php
More file actions
74 lines (66 loc) · 2.2 KB
/
docblock.php
File metadata and controls
74 lines (66 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* DocBlockGenerator
*
* This class will generate docblock outline for files/folders.
*
* Use from command line - params:
* file/folder - the file or folder you want to docblock (php files)
* -r - to have it recursively go through a folder
* target function - to docblock only a specific method/function name
*
* Example:
* php docblock.php target.php targetFunction
* or
* php docblock.php target/dir -r targetFunction
*
* Credit to Sean Coates for the getProtos function, modified a little.
* http://seancoates.com/fun-with-the-tokenizer
*
* TODOs :
* 1. add all proper docblock properties
* 2. better checking for if docblock already exists
* 3. docblocking for class properties
* 4. try to gather more data for automatic insertion such as for @access
*
* @author Anthony Gentile
* @version 0.85
* @link http://agentile.com/docblock/
*/
include("DocBlockGenerator.class.php");
use DocBlockGenerator\DocBlockGenerator ;
$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");
}