Re: Access to syntax tree?
| From: | Manuel Pichler | Date: | Wed, 25 Mar 2009 20:23:54 +0000 |
| Subject: | Re: Access to syntax tree? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-43474@lists.php.net to get a copy of this message | ||
Hello Jeremy,
On Wed, 2009-03-25 at 10:13 -0700, Jeremy wrote:
> Is there any way to access the parse tree of a PHP file from within PHP?
>
> I'm trying to write a code-checking utility to find namespace-related
> problems in code and alert me to them. Specifically:
>
> namespace foo\bar;
>
> function foobar()
> {
> try
> {
> ...
> }
> catch(Exception $e)
> {
> //nothing will be caught
> //I forgot to qualify
> //code silently fails
> }
> }
a little bit off topic here, but PHP_Depend's[1] parser and source graph
in branches/0.9.0[2] can be used to detect such issues. It is aware of
namespaces and can detect most class/interface language constructs like
catch, new, type-hints, static calls etc.
Greetings
Manuel
[1] http://pdepend.org/
[2] http://svn.pdepend.org/branches/0.9.0/
--
Manuel Pichler http://manuel-pichler.de
GnuPG Key: 6A5D2258 / B4F9 AA42 925D A4AA 4733 4E39 F48B 809C 6A5D 2258