Re: Inline typecasting / typehinting for classes and interfaces

From: Date: Wed, 15 Aug 2012 10:15:41 +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 15  Groups: php.internals 
Request: Send a blank email to internals+get-62180@lists.php.net to get a copy of this message
On Wed, Aug 15, 2012 at 12:01 PM, Stan Vass <sv_forums@fmethod.com> wrote: > Just like with argument typehints. > Point me to an argument typehint that is required for your code to run. > > You and Stas keep giving arguments against argument typehints, which is > really awkward. As already pointed out repeatedly, argument typehints serve the purpose of defining an interface. No, they are not required to run the code, that's true. But they still serve an important purpose for object oriented programming (and, just to make sure that you don't miss it again: That purpose is defining the interface). Variable typehints do not, as far as I can see. > I gave an example validating an array of Foo instances, which the current system doesn't > solve. Yes, and your system doesn't solve it either, or does it? As the validation does not happen through a parameter typehint it does not help defining the public interface. It only helps the IDE know the type (which doc comments can also do). Nikita

« previous php.internals (#62180) next »