2012-08-01 16:23:56 +00:00
|
|
|
<?php
|
2012-08-04 18:31:42 +00:00
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
2012-08-01 16:23:56 +00:00
|
|
|
|
2013-02-25 15:07:43 +00:00
|
|
|
if ( PHP_SAPI != 'cli' ) {
|
|
|
|
|
die( "This filter can only be run from the command line.\n" );
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-01 16:23:56 +00:00
|
|
|
$source = file_get_contents( $argv[1] );
|
2014-08-30 16:10:26 +00:00
|
|
|
$regexp = '#'
|
|
|
|
|
. '\@var'
|
|
|
|
|
. '\s+'
|
|
|
|
|
// Type hint
|
|
|
|
|
. '([^\s]+)'
|
2014-08-30 16:50:35 +00:00
|
|
|
. '\s+'
|
2014-08-30 16:10:26 +00:00
|
|
|
// Any text or line(s) between type hint and '/' closing the comment
|
2014-08-30 16:51:42 +00:00
|
|
|
// (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.
|
|
|
|
|
// */
|
2014-08-30 16:10:26 +00:00
|
|
|
. '([^/]+)'
|
|
|
|
|
. '/'
|
|
|
|
|
. '\s+'
|
|
|
|
|
. '(var|public|protected|private)'
|
|
|
|
|
. '\s+'
|
|
|
|
|
// Variable name
|
|
|
|
|
. '(\$[^\s;=]+)'
|
|
|
|
|
. '#';
|
|
|
|
|
$replac = '${2}/ ${3} ${1} ${4}';
|
2013-04-27 11:23:52 +00:00
|
|
|
$source = preg_replace( $regexp, $replac, $source );
|
2012-08-01 16:23:56 +00:00
|
|
|
|
|
|
|
|
echo $source;
|