[wp-hackers] Corrupt Plugin files

Austin Matzko austin at ilfilosofo.com
Tue Dec 7 14:39:46 UTC 2010

On Tue, Dec 7, 2010 at 7:02 AM, Ozh <ozh at ozh.org> wrote:
>> That's type hinting:
> <http://php.net/manual/en/language.oop5.typehinting.php>
> thanks for the reference link. I'm filing this to the "totally worthless
> additions of PHP5 I'll never use" basket though :)

Type hinting has its place.  I think it's especially helpful for an
API.  Suppose I have a method like so:

public function add( User $user )

It's immediately clear that the add method must receive a -User- object.

Type hinting also encourages good code design by preventing me, the
developer, from trying to make one method do too many things, which
among other problems makes the code hard to test and to debug.  For
example, that add() method will throw a fatal error if someone tries
to pass it a user's ID integer or login slug.

More information about the wp-hackers mailing list