Ticket #150 (closed defect: fixed)
unable to include phpdocumentor.ini in PHPDoc-Task
| Reported by: | dirk.thomas@… | Owned by: | hans |
|---|---|---|---|
| Priority: | major | Milestone: | 2.3.1 |
| Component: | phing-tasks-ext | Version: | 2.3.0RC1 |
| Keywords: | phpdoc | Cc: |
Description
When using the PHPDoc-task i have the problem that phpdoc is unable to find the configuration file phpdocumentor.ini.
I wrote a message to the dev-mailinglist, which contains an example "patch" how to make this work: http://phing.tigris.org/servlets/ReadMsg?list=dev&msgNo=523
Attachments
Change History
comment:2 Changed 4 years ago by hans
- Status changed from assigned to closed
- Resolution set to fixed
comment:3 Changed 4 years ago by felixdv
- Status changed from closed to reopened
- Resolution fixed deleted
I still have a problem with this, and I'm using 2.3.0 with the above patches definitely applied.
Phing reports an error using the phpDocumentor task, stating the following:
Reading file /project/source/Validate/handlers/length.php [PHP Error] in_array(): Wrong datatype for second argument [line 630 of /usr/local/php-5.2.5/lib/php/PhpDocumentor/phpDocumentor/Io.inc] [PHP Error] in_array(): Wrong datatype for second argument [line 641 of /usr/local/php-5.2.5/lib/php/PhpDocumentor/phpDocumentor/Io.inc]
Problem appears to be that the globals _phpDocumentor_cvsphpfile_exts and _phpDocumentor_phpfile_exts aren't loaded, which is strange because Phing lists this:
Parsing configuration file phpDocumentor.ini... (found in /usr/local/php-5.2.5/lib/php/data/PhpDocumentor/)
a phpDocumentor.ini is there with all information that should be in it.
comment:4 Changed 4 years ago by jamest@…
I've been experiencing this problem as well (Windows, latest stables of Phing, PhpDocumentor).
The first error occurs on line 635 of Io.inc in PHPDoc.
The key bits of code are this:
global $_phpDocumentor_phpfile_exts; $ext = $_phpDocumentor_phpfile_exts; if (in_array(array_pop($tmp),$ext)) { ... }
With a couple of debug statements, I found something strange going on. Notice that the assignment to $ext is from the $_phpDocumentor_phpfile_exts variable, rather than the $GLOBALS_phpDocumentor_phpfile_exts?.
On my box:
var_dump($GLOBALS_phpDocumentor_phpfile_exts?);
array(5) {
[0]=> string(3) "php" [1]=> string(4) "php3" [2]=> string(4) "php4" [3]=> string(5) "phtml" [4]=> string(3) "inc"
}
var_dump($_phpDocumentor_phpfile_exts);
NULL
Hmm. Looks like it might be a scoping problem associated with using the global var instead of the superglobal $GLOBALS var. I don't fully understand the context from which it is being called yet, though. Hopefully this at least gives a pointer to understands Phing a bit more thoroughly!
I wondered if it might be to do with register_globals, but the problem is the same both turned on or off...
Cheers,
Jamie.
comment:5 Changed 4 years ago by hans
That's interesting; perhaps we should change the way we're setting this value in Phing ... to use global rather than the superglobals array.
comment:6 Changed 4 years ago by jamest@…
I'm not sure why or how the problem exactly happens - I can't reproduce it in any test code:
<?php
function main() {
global $myglobalvar;
set_my_global_var();
var_dump($myglobalvar);
}
function set_my_global_var() {
$GLOBALS['myglobalvar'] = "Hello World";
}
main();
?>
Outputs the information as expected. Inheritance doesn't seem to cause it. Splitting the classes across 2 files doesn't cause it. I even made copies of the two source files and tested that, and in every case the global var is set as expected. Truly mysterious. Maybe I'm missing something really obvious.
Having said that, I did find a fix. In
PhingPhpDocumentorSetup::__construct()
, after
$this->parseIni();
add the following two (totally redundant, it would seem) lines. Sorted it out for me.
$_phpDocumentor_phpfile_exts = $GLOBALS['_phpDocumentor_phpfile_exts']; $_phpDocumentor_cvsphpfile_exts = $GLOBALS['_phpDocumentor_cvsphpfile_exts'];
You'll also need to add $_phpDocumentor_phpfile_exts as a global in the same function.
Cheers,
Jamie.

Thank you for the patch. This fix makes sense to me.