extending PHP_Beautifier

From: Date: Fri, 09 Mar 2007 13:12:07 +0000
Subject: extending PHP_Beautifier
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-45855@lists.php.net to get a copy of this message
Hi, I'm trying to write a filter for PHP_Beautifier that automatically adds the 'require' statements for lazy-loading files. Yes, autoloading classes would prob be easier, but the filter should handle defines and functions as well as work on PHP4 code. I've run into a couple of gotchas, and am wondering if anyone can help. If my filter runs into a structure like: class foo { function bar($param = DEFINED_ELSEWHERE) {
      ...
} } it's got to know to place the require for the file containing 'DEFINED_ELSEWHERE' before the 'class' structure. I tried use PHP_Beautifier::getMode('class') to see if I'm inside a class structure, but it appears that the mode is not cleared on leaving the structure. So if I run into: class foo {
    ...
} function bar($param = DEFINED_ELSEWHERE) { ... } my code will still think it's inside a class. Is this intentional? Or is that not what getMode() is intended for? Is there any other way of doing it (the class doesn't seem to get popped of the getControlSeq() stack either), or should I write my own extension to track this stuff? If I get my filter cleaned up, would Pear be interested in it? Regards, Matt

« previous php.pear.dev (#45855) next »