268ccdbcb5c0a910ba55d676e4277eb805994adf
[lhc/web/wiklou.git] / maintenance / mwdoc-filter.php
1 <?php
2 /**
3 * Doxygen filter to show correct member variable types in documentation.
4 *
5 * Should be filled in doxygen INPUT_FILTER as "php mwdoc-filter.php"
6 *
7 * Original source code by Goran Rakic
8 * http://blog.goranrakic.com/
9 * http://stackoverflow.com/questions/4325224
10 *
11 * @file
12 */
13
14 if ( PHP_SAPI != 'cli' ) {
15 die( "This filter can only be run from the command line.\n" );
16 }
17
18 $source = file_get_contents( $argv[1] );
19 $regexp = '#'
20 . '\@var'
21 . '\s+'
22 // Type hint
23 . '([^\s]+)'
24 // Any text or line(s) between type hint and '/' closing the comment
25 // (includes the star of "*/")
26 . '([^/]+)'
27 . '/'
28 . '\s+'
29 . '(var|public|protected|private)'
30 . '\s+'
31 // Variable name
32 . '(\$[^\s;=]+)'
33 . '#';
34 $replac = '${2}/ ${3} ${1} ${4}';
35 $source = preg_replace( $regexp, $replac, $source );
36
37 echo $source;