Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43474 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53329 invoked from network); 25 Mar 2009 20:24:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Mar 2009 20:24:09 -0000 Authentication-Results: pb1.pair.com header.from=mapi@manuel-pichler.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=mapi@manuel-pichler.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain manuel-pichler.de from 87.230.77.219 cause and error) X-PHP-List-Original-Sender: mapi@manuel-pichler.de X-Host-Fingerprint: 87.230.77.219 xplib.de Linux 2.5 (sometimes 2.4) (4) Received: from [87.230.77.219] ([87.230.77.219:53977] helo=server.xplib.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2F/3D-30978-6E29AC94 for ; Wed, 25 Mar 2009 15:24:07 -0500 Received: from dslb-092-073-115-168.pools.arcor-ip.net ([92.73.115.168] helo=[192.168.13.23]) by server.xplib.de with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1LmZdj-0007t0-Nj; Wed, 25 Mar 2009 20:24:02 +0000 Reply-To: mapi@manuel-pichler.de To: Jeremy Cc: internals@lists.php.net In-Reply-To: <14.C2.30978.F466AC94@pb1.pair.com> References: <14.C2.30978.F466AC94@pb1.pair.com> Content-Type: text/plain Organization: private Date: Wed, 25 Mar 2009 21:23:54 +0100 Message-ID: <1238012634.28918.14.camel@arwen> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 Content-Transfer-Encoding: 7bit X-Spam-Score: -4.4 (----) X-Spam-Report: Spam detection software, running on the system "server.xplib.de", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 > } > } [...] Content analysis details: (-4.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] Subject: Re: [PHP-DEV] Access to syntax tree? From: mapi@manuel-pichler.de (Manuel Pichler) 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