Re: Inline typecasting / typehinting for classes and interfaces

From: Date: Wed, 15 Aug 2012 08:06:30 +0000
Subject: Re: Inline typecasting / typehinting for classes and interfaces
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-62166@lists.php.net to get a copy of this message
I'd like to also ask people to read what the intended effect of the proposal is instead of going into abstract discussions about how casting one class to another doesn't make sense (this is not what's being proposed). Just like PHP typehints look like static typing but *aren't*, the same way the fact this looks like a static cast *doesn't* make it so. A dynamic language can't have static casts, and I'd think this is obvious to everybody. Instead, I'm adapting the principle so it fits with existing PHP behaviors and patterns. Syntax which looks like static typing is fine by me as well. Examples: ClassName $foo = expression(); foreach ($list as InterfaceName $item) { ... } etc. The only operation done here is validating the variable is a valid instance of this type. No transformation is happening. Stan

« previous php.internals (#62166) next »