Ticket #150 (closed defect: fixed)

Opened 8 months ago

Last modified 1 month ago

unable to include phpdocumentor.ini in PHPDoc-Task

Reported by: dirk.thomas@4wdmedia Assigned to: 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

10/17/07 01:05:26 changed by hans

  • status changed from new to assigned.

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

10/17/07 01:12:52 changed by hans

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed in r150 (2.3) and r151 (trunk)

11/14/07 14:07:11 changed by felixdv

  • status changed from closed to reopened.
  • resolution 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.

12/10/07 06:36:36 changed by jamest@brennanit.com.au

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.

12/10/07 12:12:24 changed 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.

12/12/07 02:39:47 changed by jamest@brennanit.com.au

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.

02/06/08 20:29:32 changed by hans

  • milestone changed from 2.3.0 to 2.3.1.

02/06/08 20:32:47 changed by hans

(In [354]) Refs #150 - Added some redundant looking lines which seem to clear up the issue of being unable to find config file.

02/06/08 20:33:14 changed by hans

  • status changed from reopened to closed.
  • resolution set to fixed.

Ok -- these lines were added in r354. Please let me know if I interpreted those instructions correctly & if this fixes the issue. Thanks!


Add/Change #150 (unable to include phpdocumentor.ini in PHPDoc-Task)




Action