> -----Original Message----- > From: Andrea Faulds [mailto:a...@ajf.me] > Sent: Monday, July 14, 2014 8:59 PM > To: Zeev Suraski > Cc: Rowan Collins; internals@lists.php.net > Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) > > > On 14 Jul 2014, at 18:52, Zeev Suraski <z...@zend.com> wrote: > > > Type hints were first and foremost introduced for object oriented > > safety, as a part of the major OO model shift Andi and I pushed for in > > PHP 5.0. What you may be alluding to - type hints for arrays and > > objects - were added at later time and introduced that small inconsistency > you're talking about. > > Still, type juggling for scalars has been the fundamental nature of > > PHP since the get go; Type jugging for arrays/objects was always more > > of an edge case and perhaps even a misfeature. > > I'm not sure we actually do "juggle" arrays and objects much, do we? You can > cast to them, sure, because PHP as a rule allows you to cast anything to > anything explicitly (bar resources), but I can't, for example, do a loose > comparison between an array and a string.
Exactly, that's my point. While you can explicitly cast scalars to arrays and even objects, it's an edge case and arguably a misfeature, and (IIRC) never happens implicitly. And of course there's no way to turn a scalar into a specific type of object or a resource. Zeev -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php