Assuming I have a docblock like so :
* @since 0.0.1
* @subpackage my-package
* @todo too much
* @var int $myvar
* @version 0.0.99
or :
* Name: my app name
* URI: http://www.someurl.com
* Description: A Simple description.
* Version: 0.0.99
* Author: Obmerk99
* Author URI: http://www.someuri.com
* Text Domain: for get_text
* Domain Path: /lang
*
How can I parse the docblock to use those strings on the same file ?
My goal is to simply use the @version
number from the docblock thorough the whole document every time I change it ,without having to add another $version = 'myversion'
I know there are docblock parser classes, but I could not find how to read own file . ( my own question - from long ago, offers somewhat of a solution but only for external files and at any rate is not ideal because it involves opening and writing the file each time)
Also , in the pear example page , it appears they are somehow using ( as far as my understanding ) the version number as a variable - But I can not understand How ...
example Version I
* @version SVN: $Id$
example Version II :
* @version CVS: <?php
$
?> Id:$
( I do not know why the two sample pages are different ( URLs en
and zh
) - maybe it is just a small webug. ) but at any case I do not understand how to apply it .
The point is this : how can I use the docblock as strings in the file itself - or alternatively reversing the logic and use variables from the document in the docblock so I will always need to declare the version number ( and potentially other vars ) only ONCE
.
I think the only thing you can do is use a parser, or perform search/replace (with regexes)
One other way would be to implement it with Reflection: http://www.phpriot.com/articles/reflection-api Seems to me that that would be the way to go, if you have PHP5 available :)