Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75504 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57825 invoked from network); 14 Jul 2014 18:04:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 18:04:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.220.171 mail-vc0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:42305] helo=mail-vc0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/B2-45205-6CB14C35 for ; Mon, 14 Jul 2014 14:04:55 -0400 Received: by mail-vc0-f171.google.com with SMTP id id10so7963255vcb.16 for ; Mon, 14 Jul 2014 11:04:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc:content-type; bh=J0zumo1T75QhUkGcV3ZsoMB+GbTOOSUYrfORFvG5+1s=; b=KJToaEuvIYtocdDUSYfTgcy58NDbPGv7+Bqui42haQJvM05ZlRaEMoiM3VQS560o24 Q/VCtBzaJauoW1U/Zcy7wzGfdwJckaMDxoC68ffdI9CCoLrg9WxCbMeytBoCUY93hym6 z9Y4GwPGuxgjdp4QkFfk2KuRoQ6VP55F3XnXALRQ3874exZkl1mV5zWGrgmKpJWdx36H +61AFp5x3DH5BsRhhvvR6pBC9N5I1xlyyWYAjQRlyU3XgWs+VjTegXF6B7H8dFqOup+1 l0i+ynsPedboiI5BN9+IW+c7qXP0nn9zFNx8UK8+ihU7jd7I7GjvJ393Cy1owrznLRGp iGBw== X-Gm-Message-State: ALoCoQnehFSYsTgQFO4W29XvrCZYbRsVOd+JnFDUyJwazzaHtRGjJCewgBz1uDWsC3DLA22AjtyKP370NhKCOrFUdU0C198cjrcl41EQqwkKojGw8h0Nsn68V0e+EESe/13SJ3M8atFo X-Received: by 10.220.68.140 with SMTP id v12mr17398390vci.13.1405361091815; Mon, 14 Jul 2014 11:04:51 -0700 (PDT) References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <53C3F70A.7010706@gmail.com> <3aa29e080d70c843713e19a952dfbad6@mail.gmail.com> <3b06c592b0b88bb95d3ae7ea7a93d86f@mail.gmail.com> <6AF150D1-1398-43CA-977A-3CF3D51719F4@ajf.me> <5b53012f7b5437d85cdf9972194aa34f@mail.gmail.com> <53C408EC.7080104@gmail.com> <5f491f470e902489f036102ae0f437f8@mail.gmail.com> <53C41244.5010505@gmail.com> <8177fae7c5a1a21ab2bc2b98d7e29d17@mail.gmail.com> <3F4D195C-256C-443D-A92A-E130776C4E88@ajf.me> In-Reply-To: <3F4D195C-256C-443D-A92A-E130776C4E88@ajf.me> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJuUFVOlGiX172RfpkkW7aXwqSXwwHleMkPAd/qfJcBzHP03AGqtGtJAmKS0moBHXfO1gIOC4puAaFwLqQB3IH0cgJS+6QEAQ6G0gACRy0FgQJgp+hTAV4eWsOZlPrmMA== Date: Mon, 14 Jul 2014 21:04:50 +0300 Message-ID: To: Andrea Faulds Cc: Rowan Collins , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: RE: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: zeev@zend.com (Zeev Suraski) > -----Original Message----- > From: Andrea Faulds [mailto:ajf@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 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