I got my IDE to properly recognize the include references made from nested includes (e.g. the line require_once './includes/module.inc'; when placed in /includes/bootstrap.inc, confuses the IDE when it checks if module.inc exists. From a static-code analysis point of view, it looks like the require_once tries to access /includes/./includes/module.inc).

The way I succeeded to "fool" the static path analysis in my IDE was by adding a project-level include search path pointing to my Drupal root.

However, I noticed that some files were still marked as missing. Specifically, those without a dot-slash prefix, e.g. include_once 'includes/install.inc';.

With a quick grep-search through the Drupal 6 core, I noticed that the syntax './includes/...' was used 76 times and 'includes/...' syntax 10 times. Sometimes, there were inconsistencies within the same source file.

If there is no actual functional reason for using the non-dot-slashed variant, I suggest changing the remaining ones to follow the ./includes/ convention. This would solve some IDE issues and make the code a little bit cleaner.

(This issue might be more general and could apply to other Drupal paths too. In this case I specifically looked at the includes-path. The same recommendation could be applied to templates etc. Maybe there should exist a "coding style" recommendation for this?)

Comments

htalvitie’s picture

gpk’s picture

Status: Active » Closed (duplicate)