Re: Inline typecasting / typehinting for classes and interfaces

From: Date: Wed, 15 Aug 2012 09:34:04 +0000
Subject: Re: Inline typecasting / typehinting for classes and interfaces
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  Groups: php.internals 
Request: Send a blank email to internals+get-62178@lists.php.net to get a copy of this message
Stas already pointed out that parameter typehints allow you to define the interface for your method. Return typehints would server a similar purpose and as such I'd consider them useful. But "variable" typehints don't serve any such purpose.
I gave an example validating an array of Foo instances, which the current system doesn't solve. Of course PHP could extend argument typehints to describe this, but Stas *just* said he doesn't want generics and so on in PHP. All right, I don't either. I just want a clean way to describe my expectation that a variable is what it is, and assuming that all function arguments are one single instance simply doesn't match the real world out there. People iterate arrays, they pass arrays around. And they have expectations for what's inside those arrays. Stan

« previous php.internals (#62178) next »