Re: Class and interface location

From: Date: Wed, 19 Jan 2011 22:20:40 +0000
Subject: Re: Class and interface location
References: 1 2 3 4 5 6 7 8  Groups: php.general 
Request: Send a blank email to php-general+get-310886@lists.php.net to get a copy of this message
On 1/19/11 3:44 PM, David Harkness wrote:
What about creating your own docblock tag such as @plugin-interface? While it still requires each plugin to explicitly define the interface(s) it implements, it won't be in the class declaration. This would be very easy to nab for a tree of files using grep, removing the need to do any static analysis or parse PHP code. David
I'm not sure I see the advantage of that over specifying the interface in the code: /** * Bob does stuff. * * @implements Foo */ class Bob implements Foo { } Either way developers need to explicitly define which interfaces (of those we care about) the class implements, and we'll have to string parse the file to find the string "Foo". As far as I know the extra implements in the class declaration doesn't hurt PHP, it's just redundant. And actually, thinking about it, I wonder if requiring the explicit declaration is a good thing anyway because then it's immediately obvious and greppable what the class does. :-) --Larry Garfield

« previous php.general (#310886) next »