Re: Object Type Casting

From: Date: Wed, 24 Apr 2013 19:22:23 +0000
Subject: Re: Object Type Casting
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-67137@lists.php.net to get a copy of this message
Hi, I guess it would work like an inline type-hint. Something along the lines of: $circle = ShapeFactory::createShape('circle'); if (!$circle instanceof Circle) { throw …; } I would like something like this, since it saves quite some code. Cheers Jannik Am Mittwoch, 24. April 2013 um 19:19 schrieb Stas Malyshev: > Hi! > > > Are there any plans to add object type casting support in PHP? > > > > For example: > > $circle = (Circle) ShapeFactory::createShape('circle'); > > $circle->radius = 10; > > echo $circle->getArea(); > > > > > What is this supposed to do? I.e. what createShape returns and what > (Circle) operator is doing to it? > > > It would be great if this feature could be added to 5.5 :) > > 5.5 is in feature freeze, so it won't happen in any case. > > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#67137) next »