PHP dynamic Page-level DocBlocks

Posted by Obmerk Kronen on Stack Overflow See other posts from Stack Overflow or by Obmerk Kronen
Published on 2012-06-23T02:59:56Z Indexed on 2012/06/23 3:16 UTC
Read the original article Hit count: 158

I was wondering if there is a way to interact with the Page-level DocBlocks. My question is more specifically about wordpress plugin development, but this question has arised also in a non-wordpress environments.

The reason is mainly the possibility to easily change VERSIONS and names throughout a large project with maybe a constant definition - but that will reflect also in the docblock..

The following example Docblock is from a wordpress plugin I write -

/*
Plugin Name: o99 Auxilary Functions v0.4.7
Plugin URI: http://www.myurl.com
Description: some simple description that nobody reads.
Version: 0.4.7
Author: my cool name
Author URI: http://www.ok-alsouri.com
*/

Is there a way to transform it into :

$ver = '0.4.7';
$uri = 'http://www.myurl.com';
$desc = 'some simple description that nobody reads.';
$mcn = 'my cool name';
etc.. 
etc..

    /*
    Plugin Name: o99 Auxilary Functions ($ver)
    Plugin URI: ($uri)
    Description: ($desc)
    Version: ($ver)
    Author: ($mcn)
    Author URI: ($$uri)
    */

obviously for echo to work I would need to break the docblock itself, and I can not WRITE the docblock directly into it´s own file .

In shorts : can I "generate" a docblock with php itself somehow (I would think that the answer is - "no" for the page itself.. But maybe I am wrong and someone has some neat hack :-) )

Is that even possible ?

© Stack Overflow or respective owner

Related posts about php

Related posts about Wordpress