I was thinking about creating a tool which would scan source code and check for constraints. Specifically, the end-user would place metadata throughout his class definition and the tool would work off that. One use case that I believe would be useful would be an @Override annotation (like that found in Java) which would signify that a method overrides a parent's implementation.
I wanted to raise the issue here to see if anyone knew of such a tool and to gauge interest. Additionally, I'd like to start a discussion on how to best design the tool in a manner which allows for future constraints to be checked (This last part will probably need a new thread in the appropriate forum later).
Thanks for any feedback!
Source code inspection tool
Moderator: General Moderators
-
ManUnderground
- Forum Newbie
- Posts: 4
- Joined: Mon Jan 21, 2008 8:47 pm
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Source code inspection tool
You'll likely have to use Reflection for something like this. The Reflection API does allow the parsing of documentation comments so you can do things like this.
I'm not overly sure of this usefulness of this in PHP however.
Code: Select all
class Foo extends Bar {
/**
* @Override
* @SupressWarnings
*/
public function doSomething() {
}
}-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Source code inspection tool
Nothing in PHP like is seems to ever take off...Java and C/C++ how a much larger community around such projects...
I've been working on a documentation project myself (but have put it on hold breifly) which would attempt to determine such constraints through syntactic/static analysis rather than reflection...
The problem with reflection (so I determined anyways) is that you need to actually include the class into the current executing context...my biggest concern was that of namespace collisions and that of possible performance issues. For that reason I started on a parser framework.
What other kind of inspections did you have in mind?
Personally, I fail to see why you would need to manually indicate whether a method overrides it's parent. Short of being easier for a parser to process, I see this, more as a short coming than a bonus. I'd rather see source code parsed completely and have those kind of constraints auto-detected.
Cheers
I've been working on a documentation project myself (but have put it on hold breifly) which would attempt to determine such constraints through syntactic/static analysis rather than reflection...
The problem with reflection (so I determined anyways) is that you need to actually include the class into the current executing context...my biggest concern was that of namespace collisions and that of possible performance issues. For that reason I started on a parser framework.
What other kind of inspections did you have in mind?
Personally, I fail to see why you would need to manually indicate whether a method overrides it's parent. Short of being easier for a parser to process, I see this, more as a short coming than a bonus. I'd rather see source code parsed completely and have those kind of constraints auto-detected.
Cheers