Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81622 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96211 invoked from network); 2 Feb 2015 17:55:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 17:55:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.172 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.172 mail-vc0-f172.google.com Received: from [209.85.220.172] ([209.85.220.172:51925] helo=mail-vc0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/2D-34915-D0ABFC45 for ; Mon, 02 Feb 2015 12:55:25 -0500 Received: by mail-vc0-f172.google.com with SMTP id le20so15188583vcb.3 for ; Mon, 02 Feb 2015 09:55:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=hQleAxOvSkD61nTbdQmKOQrctuWl+U2p/GeEUonE+ls=; b=WyAw1RD37HhfpAE3OZl17ZMAuBo3IudTAgDbR9n3Tle/cN9HENkRMzRc+3DnmnXZxh 2sN6qVUHqiSd67VjV4EWR10DvWgydZkmRHiXINz3jiO19asTq6ngaangxGXrp/IQ8WS5 Ky5uvQIPGG2IwBNrpkCQ7RXlWEzcX71YWxIBuLuHJjfYI0Dn1ExszhYW/Wnu1AZKnt31 7g+9sHzGHDWuUiwhCYFO5Xu+ZkJS8ttAn6LpgF6Qlrtxquns8O3eOOmrfo9OJIg3MmU3 jl2q7fNBAY9bFdw0xszOpC93o2C7G2z2YxxSUCEblLrkOeS0jExNpTlcz+mTl5zsZD3P p5BQ== X-Gm-Message-State: ALoCoQnmd66kPFvGOF2d+2/NHbeMyK7I/46asOHWnBeGbippVI7JwyFYMMR/0j2vBZg4T1U/kv/0+xtK5PXT0NzYfxJOf+ooK7tJ4JB8ERGNHdW4frIWD5WGSaDwRxfBcOqUB4RO3FKlYRl5spaJRhG3pyWeihg/qQ== MIME-Version: 1.0 X-Received: by 10.221.21.131 with SMTP id qs3mr12974063vcb.33.1422899722859; Mon, 02 Feb 2015 09:55:22 -0800 (PST) Received: by 10.52.74.73 with HTTP; Mon, 2 Feb 2015 09:55:22 -0800 (PST) In-Reply-To: References: Date: Mon, 2 Feb 2015 21:55:22 +0400 Message-ID: To: Paul Dragoonis Cc: PHP Internals , Andrea Faulds , Nikita Popov Content-Type: multipart/alternative; boundary=001a11339f8a884c17050e1ea86a Subject: Re: [PHP-DEV] What do we need strict scalar type hints for? From: dmitry@zend.com (Dmitry Stogov) --001a11339f8a884c17050e1ea86a Content-Type: text/plain; charset=UTF-8 On Mon, Feb 2, 2015 at 7:47 PM, Paul Dragoonis wrote: > Hi Dmitry, > > It's preferred to have flexible scalars, that way we can interchange > between a numerical string or an integer. > > Over defining on such things loses the powerfulness of PHP. So scalar > typehints are detrimental rather than useful. Saying something is a scalar > or not, is useful however! :) > > A use case would be where scalar type hints are detrimental are: > > I implement an API that returns integers for entity ids, like 2,3,4,5,6. > and my web-frontend handles this fine because it's a scalar. Then, you want > to convert entity ids to UUID. This would break your entire web frontend > application since it's no longer "integer" whereas the concept of $id is > good enough. > I don't think this is a good case where strict type hinting is really helpful. > > Did this make sense? > > TL;DR - I am against such proposals. > Now, I'm more interested in opinions of people who like strict type hinting. I prefer weak hints, that follow standard conversion rules, but may be good arguments may change my mind. Thanks. Dmitry. > > Many thanks, > Paul > > > > > > On Mon, Feb 2, 2015 at 9:12 AM, Dmitry Stogov wrote: > >> hi, >> >> could you please write down few use cases, when strict scalar type hints >> are really useful. >> >> Thanks. Dmitry. >> > > --001a11339f8a884c17050e1ea86a--