blob: 0cc7bde8a406ec79c27951082df662b3dad78e0c (
plain)
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
|
<?php
/**
* Doxygen filter to show correct member variable types in documentation.
*
* Should be filled in doxygen INPUT_FILTER as "php mwdoc-filter.php"
*
* Original source code by Goran Rakic
* http://blog.goranrakic.com/
* http://stackoverflow.com/questions/4325224
*
* @file
*/
if ( PHP_SAPI != 'cli' ) {
die( "This filter can only be run from the command line.\n" );
}
$source = file_get_contents( $argv[1] );
$regexp = '#'
. '\@var'
. '\s+'
// Type hint
. '([^\s]+)'
. '\s+'
// Any text or line(s) between type hint and '/' closing the comment
// (includes the star of "*/"). Descriptions containing a slash
// are not supported. Those will have to to be rewritten to have their
// description *before* the @var:
// /**
// * Description with / in it.
// * @var array
// */
// instead of:
// /**
// * @var array Description with / in it.
// */
. '([^/]+)'
. '/'
. '\s+'
. '(var|public|protected|private)'
. '\s+'
// Variable name
. '(\$[^\s;=]+)'
. '#';
$replac = '${2}/ ${3} ${1} ${4}';
$source = preg_replace( $regexp, $replac, $source );
echo $source;
|