Skip to content

Commit 0e2a51e

Browse files
committed
Merge pull request #57 from tetsuo13/331e331aca
Treat global constant declared using const keyword as global and not class constant
2 parents 67c1af0 + 331e331 commit 0e2a51e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

classes/phpDoctor.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,18 @@ function &parse()
807807
break;
808808

809809
case T_STRING:
810+
$constOutsideOfClass = (isset($tokens[$key - 2][1]) && $tokens[$key - 2][1] == 'const');
811+
810812
// read global constant
811-
if ($token[1] == 'define') {// && $tokens[$key + 2][0] == T_CONSTANT_ENCAPSED_STRING) {
812-
$const =& new fieldDoc($this->_getNext($tokens, $key, T_CONSTANT_ENCAPSED_STRING), $ce, $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create constant object
813+
if ($token[1] == 'define' || $constOutsideOfClass) {// && $tokens[$key + 2][0] == T_CONSTANT_ENCAPSED_STRING) {
814+
if (!$constOutsideOfClass) {
815+
// Current token is define() function.
816+
$constantName = $this->_getNext($tokens, $key, T_CONSTANT_ENCAPSED_STRING);
817+
} else {
818+
// Current token is constant's name.
819+
$constantName = $token[1];
820+
}
821+
$const =& new fieldDoc($constantName, $ce, $rootDoc, $filename, $lineNumber, $this->sourcePath()); // create constant object
813822
$this->verbose('Found '.get_class($const).': global constant '.$const->name());
814823
$const->set('final', TRUE); // is constant
815824
$value = '';

0 commit comments

Comments
 (0)