After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 528815 - Missing first PHP constant defined after an if block
Missing first PHP constant defined after an if block
Status: RESOLVED OBSOLETE
Product: doxygen
Classification: Other
Component: general
1.5.5
Other All
: Normal normal
: ---
Assigned To: Dimitri van Heesch
Dimitri van Heesch
[moved_to_github]
Depends on:
Blocks:
 
 
Reported: 2008-04-18 20:21 UTC by Thomas
Modified: 2018-07-30 10:33 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Thomas 2008-04-18 20:21:32 UTC
Please describe the problem:
If constants are defined using PHP's define(...) syntax, the first constant is missing if its definition is preceeded by an if or switch statement.

Steps to reproduce:
1. Create a new config file using the wizard.
2. Select to include all entities and cross-ref'd source code
3. Output HTML only
4. Leave all other settings at their defaults.
5. Have the following script documented:
<?php
if ( true ) {}
define( 'CONST1', 'Constant 1' );
define( 'CONST2', 'Constant 2' );
define( 'CONST3', 'Constant 3' );
?>

Actual results:
The documentation reads:
    * CONST2 : doxytest.php
    * CONST3 : doxytest.php 
(CONST1 is missing from the documentation) 

Expected results:
The documentation reads:
    * CONST1 : doxytest.php
    * CONST2 : doxytest.php
    * CONST3 : doxytest.php  

Does this happen every time?
This seems to happen whenever the define statements are preceeded by an if or switch statement. It also happens if the define statements are inside an if-block.

Other information:
Comment 1 Dimitri van Heesch 2008-04-27 11:09:20 UTC
Confirmed. Should be fixed in the next subversion update.
Comment 2 Dimitri van Heesch 2008-05-18 13:31:25 UTC
This bug was marked as assigned, which means it should be fixed in doxygen release 1.5.6. Please verify if the bug is indeed fixed. If not then reopen it and provide additional information if possible.
Comment 3 Thomas 2008-05-19 18:22:15 UTC
Sorry, but the bug is only partly fixed:
---
<?php
if ( true )
{	
    define( 'CONST1', 1 );
    define( 'CONST2', 2 );
}
else
{
}	

define( 'CONST3', 3 );
define( 'CONST4', 4 );
?>
---
(Config as in my original report, this time using version 1.5.6)

The above will document only CONST4. Removing the "else {}" causes CONST3 and CONST4 to be documented. In either case, CONST1 and CONST2 are not documented. While "else {}" was not explicitly mentioned in my original bug report (hadn't noticed then), I assumed that the fix would cover it as well. 

Contrary to version 1.5.5, the constants defined inside the if(){} are now completely ignored. I would expect them to be documented as well. 

Greetings,
Thomas
Comment 4 Steve 2011-10-26 04:46:51 UTC
     I'm using Doxygen version 1.7.4 on Ubuntu 11.10.  I'm having the same sort of problems reported here (in Doxygen bug #528815).  Basically, Doxygen's PHP parser seems blind to conditional PHP logic (although this may be true only outside of enclosing class/method or function contexts - TBD).  

     This problem is easy to reproduce.  Below is a small test.php file.  After that I'll append my latest, all-too exhaustive doxyfile.  I've been trying and trying and trying ... to get Doxygen to see either of the conditionally defined, alternative class definitions below.  So far, no luck.  

     I certainly would appreciate any help (or any clues/tips) - from any quarters.  Up to this point, I've used Doxygen with so many languages, that I more-than-hate the thought of giving up on Doxygen for PHP.  I really appreciate Doxygen.  Of course, just now, I just happen to be stuck with the psychedelic hypertext pulverizer (PHP ;-) - so I'm major bummed:
=======================================
=======================================
<?php
/** @file test.php
    This is a PHP test file.  It is used for experiments 
*/
/** @brief define(ALL_IMPORTANT_TOGGLE_VARIABLE)
    This will sweep in loads of development-time instrumentation, 
    that depends upon a fat, rich run-time environment or
    or exlcude it, say for production, on a slim and trim run-time 
    environment.   
*/  
define('VMD_THASA', true, true);
if (defined('VMD_THASA')) {
  require_once('Log.php');  // Pear Log:  http://pear.php.net/package/Log 
                            // Doxygen just won't seem to do anything with this URL :-(
  /** @brief Instrumentation Manager Class.  
      Do this and that to centrally manage development instrumentation  
  */
  class instrumentation_mgr  
  {
    private static $instance; //!<@brief A singleton's static self-reference
    private static $logger;   //!<@brief The user record logger

    private function __construct(){ //constructor
    }
    public static function singleton(){
      if (!isset(self::$instance)){
        $className = __CLASS__;
        self::$instance = new $className();
      }
      return self::$instance;
    }
    public function __clone(){
      trigger_error( 'Clone is not allowed for singletons.', E_USER_ERROR);
    }
    public function __wakeup(){
      trigger_error('Unserializing is not allowed for singletons.', E_USER_ERROR);
    }
    public function __destruct(){ // destructor
    }
    public function log($msg){ // end-user oriented logging.
      error_log("This is the rich logging function: ".$msg);
    }
    public function diag(){
    }
  }
} else {
  class instrumentation_mgr
  {
    private static $instance;

    private function __construct(){ // constructor
    }
    public static function singleton(){
      if (!isset(self::$instance)){
        $className = __CLASS__;
        self::$instance = new $className;
      }
      return self::$instance;
    }
    public function __clone(){
      trigger_error( 'Clone is not allowed for singletons.', E_USER_ERROR);
    }
    public function __wakeup(){
      trigger_error('Unserializing is not allowed for singletons.', E_USER_ERROR);
    }
    public function __destruct(){ // destructor
    }
    public function log($log_string){
      error_log($log_string);
    }
  }
}	
$logMgr = instrumentation_mgr::singleton(); 
$t = 'Foobarsky' ; 
$logMgr->log($t);
?>
====================================================
====================================================
# test.doxyfile
#
# Project specific options
#################################
PROJECT_NAME             = test
PROJECT_NUMBER           = 0.1
OUTPUT_DIRECTORY         = /var/www/dox/test
INPUT                    = /home/shulegaa/public_html
FILE_PATTERNS            = *.php *.inc
EXTENSION_MAPPING        = inc=PHP
INCLUDE_PATH             = 
INCLUDE_FILE_PATTERNS    = 
DOT_GRAPH_MAX_NODES      = 80
DOTFILE_DIRS             = 
# WARN_IF_UNDOCUMENTED should be YES, but ... 
# So sometimes, you just have to ingore the obvious ;-)
WARN_IF_UNDOCUMENTED     = YES

################################
# Project specific preprocessing options
# Many of these may not apply (much if, at all?) to PHP source
################################
# Bizarre to enable propreprocessing in PHP 
# but Drupal did this ... hmm ... what gives?
ENABLE_PREPROCESSING     = YES 
#EXPAND_AS_DEFINED        = 
EXPAND_AS_DEFINED        = VMD_THASA
#EXPAND_ONLY_PREDEF       = NO
EXPAND_ONLY_PREDEF       = YES
#PREDEFINED               = 
#PREDEFINED               = VMD_THASA = 1
PREDEFINED               = VMD_THASA = true
# MACRO_EXPANSION tends to complement ENABLE_PREPROCESSING
MACRO_EXPANSION          = YES

################################
# Generally peferred, non-project-specific options
# Many of these may not apply (much if at all) to PHP source
################################
ALPHABETICAL_INDEX       = YES
BRIEF_MEMBER_DESC        = YES
CALL_GRAPH               = YES
CALLER_GRAPH             = YES
CLASS_DIAGRAMS           = YES
COLLABORATION_GRAPH      = YES
COLS_IN_ALPHA_INDEX      = 4
CREATE_SUBDIRS           = YES
DIRECTORY_GRAPH          = YES
# Others suggest that this is a source of problems.  See
# http://sourceforge.net/mailarchive/forum.php?thread_name=4E81DADA.4000805%40caris.com&forum_name=doxygen-users
# So, be sure to set DOT_CLEANUP = NO.  I've confirmed that this is 
# a source of problems - that can crash Doxygen after long runs!
DOT_CLEANUP              = NO
DOT_FONTSIZE             = 12
DOT_IMAGE_FORMAT         = png
# Let DOT choose the number of threads based on # CPUs/cores
DOT_MULTI_TARGETS        = YES 
DOT_NUM_THREADS          = 0
DOT_PATH                 = 
DOT_TRANSPARENT          = NO
ENABLED_SECTIONS         = YES
ENUM_VALUES_PER_LINE     = 1
# merge_* files are often left around by emacs ediff
EXCLUDE_PATTERNS         = merge_* 
EXCLUDE_SYMLINKS         = NO
EXTRACT_ALL              = YES
EXTRACT_PRIVATE          = YES
EXTRACT_STATIC           = YES
EXTRACT_LOCAL_CLASSES    = YES
#FILE_VERSION_FILTER     = <some appropriate git command?>
FILTER_SOURCE_FILES      = NO
FULL_PATH_NAMES          = NO
GENERATE_AUTOGEN_DEF     = NO
GENERATE_BUGLIST         = YES
GENERATE_CHI             = NO
GENERATE_DEPRECATEDLIST  = YES
GENERATE_DOCSET          = NO
GENERATE_ECLIPSEHELP     = NO
GENERATE_HTML            = YES
GENERATE_HTMLHELP        = NO
GENERATE_LATEX           = NO
GENERATE_LEGEND          = YES
GENERATE_MAN             = NO
GENERATE_PERLMOD         = NO
GENERATE_RTF             = NO
GENERATE_TESTLIST        = YES
GENERATE_TODOLIST        = YES
GENERATE_TREEVIEW        = YES
GENERATE_XML             = NO
GRAPHICAL_HIERARCHY      = YES
GROUP_GRAPHS             = YES
HAVE_DOT                 = YES
HIDE_FRIEND_COMPOUNDS    = NO
HIDE_IN_BODY_DOCS        = NO
HIDE_SCOPE_NAMES         = NO
HIDE_UNDOC_CLASSES       = NO
HIDE_UNDOC_MEMBERS       = NO
HIDE_UNDOC_RELATIONS     = NO
HTML_ALIGN_MEMBERS       = YES
HTML_DYNAMIC_SECTIONS    = YES
HTML_FILE_EXTENSION      = .html
HTML_FOOTER              = 
HTML_HEADER              =
HTML_OUTPUT              = html
HTML_STYLESHEET          =
HTML_TIMESTAMP           = YES
INCLUDE_GRAPH            = YES
INCLUDED_BY_GRAPH        = YES
INHERIT_DOCS             = YES
INLINE_INFO              = YES
INLINE_SOURCES           = NO
INTERNAL_DOCS            = NO
# Unlimited max dot graph depth ... 
MAX_DOT_GRAPH_DEPTH      = 0
# Use a zero value for MAX_INITIALIZER_LINES to hide all initializers
MAX_INITIALIZER_LINES    = 8
OUTPUT_LANGUAGE          = English
QUIET                    = NO
RECURSIVE                = YES
REFERENCED_BY_RELATION   = YES
REFERENCES_RELATION      = YES
REFERENCES_LINK_SOURCE   = NO
REPEAT_BRIEF             = NO
SEARCHENGINE             = YES
SERVER_BASED_SEARCH      = YES      
SHORT_NAMES              = NO
SHOW_DIRECTORIES         = YES
SHOW_FILES               = YES
SHOW_INCLUDE_FILES       = YES
SHOW_NAMESPACES          = YES
SHOW_USED_FILES          = YES
SKIP_FUNCTION_MACROS     = NO
SORT_MEMBER_DOCS         = YES
SOURCE_BROWSER           = YES
STRIP_CODE_COMMENTS      = YES
TEMPLATE_RELATIONS       = YES
TREEVIEW_WIDTH           = 250
# Try UML_LOOK = YES at some point
UML_LOOK                 = NO
USE_HTAGS                = NO
USE_INLINE_TREES         = YES
VERBATIM_HEADERS         = YES
WARN_FORMAT              = "$file:$line: $text"
WARN_IF_DOC_ERROR        = YES
# Leave WARN_LOGFILE blank for stderr usage
WARN_LOGFILE             =
WARN_NO_PARAMDOC         = YES
WARNINGS                 = YES
====================================
====================================
Comment 5 André Klapper 2018-07-30 10:33:07 UTC
As discussed in https://github.com/doxygen/doxygen/pull/734 , Doxygen has moved its issue tracking to 

   https://github.com/doxygen/doxygen/issues

All Doxygen tickets in GNOME Bugzilla have been migrated to Github. You can subscribe and participate in the new ticket in Github. You can find the corresponding Github ticket by searching for its Bugzilla ID (number) in Github.

Hence I am closing this GNOME Bugzilla ticket.
Please use the corresponding ticket in Github instead. Thanks a lot!