Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88784 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40692 invoked from network); 13 Oct 2015 20:16:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Oct 2015 20:16:14 -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.213.182 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.213.182 mail-ig0-f182.google.com Received: from [209.85.213.182] ([209.85.213.182:37113] helo=mail-ig0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/15-05441-C866D165 for ; Tue, 13 Oct 2015 16:16:13 -0400 Received: by igbhv6 with SMTP id hv6so2078462igb.0 for ; Tue, 13 Oct 2015 13:16:08 -0700 (PDT) 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=3EZgylS051mshBAZcnRseoEhBbvaH5UCOrklvs/0v30=; b=jR9C7iiZQr1h6V5zIMBk9csiryo+g+zfeOcFdOjMhqKtOwGneGBikKrfFVeC6tsAuF 7w9nS15s36Er34d4OodF/+HXKwVAqoJhmzpl/YFFX1VeSNmi5Du65hx3GOea4rYcFixp r6TOuZvkhaOzz0l8UVgLSnPalD/6yatgH741ppbiUa/WYMnTTffHLrkjUbzzrsbw9IGR 1nt+D9tjkP/aYO8u9rch7yhHLFL7hJxRmmt7vgmxlB/7doWV32uLT44ugdHKkOK+zy6C WIFIAb2a47r3Anmr4KddkKOhGo6ZrKqlVjjHi4nEbclnVb+eiBPF9/F+4hesQe0084Y4 i31g== X-Gm-Message-State: ALoCoQmudQnmsc+UjTeNRRdX2ncYSMr2fOdrmGuwtnQM2Dnk2DFZa6ucP/9GxT1KCVr3O/wzxw9+FGoZkNOAh6KURJf20p8fMWZedGVQTdv7AKoa/EPsASKJH7psyJOzg7GuearPZOYrhh8Dyc+4E8RfN1/84WfkQJoYw/PirK3tCpnver+X1+0= MIME-Version: 1.0 X-Received: by 10.50.23.80 with SMTP id k16mr21432126igf.62.1444767368179; Tue, 13 Oct 2015 13:16:08 -0700 (PDT) Received: by 10.50.73.166 with HTTP; Tue, 13 Oct 2015 13:16:07 -0700 (PDT) In-Reply-To: References: <5C.21.16518.AA80C165@pb1.pair.com> <561CDFFA.8040207@php.net> <561D0D81.2020306@gmail.com> Date: Tue, 13 Oct 2015 23:16:07 +0300 Message-ID: To: Anthony Ferrara Cc: Rowan Collins , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e01538ca0c399f70522021de6 Subject: Re: [PHP-DEV] Scalar type hints and scalar type name aliases causeconfuson From: dmitry@zend.com (Dmitry Stogov) --089e01538ca0c399f70522021de6 Content-Type: text/plain; charset=UTF-8 On Tue, Oct 13, 2015 at 6:40 PM, Anthony Ferrara wrote: > All, > > On Tue, Oct 13, 2015 at 9:56 AM, Rowan Collins > wrote: > > Andrea Faulds wrote on 13/10/2015 12:00: > >> > >> Hi Michael, > >> > >> Michael Wallner wrote: > >>> > >>> On 12/10/15 21:23, Andrea Faulds wrote: > >>>> > >>>> Even if we can't reserve the names, I hope we can do the two other > >>>> suggestions in time for release. > >>> > >>> > >>> Additionally, we could say "instance of class ...". > >>> > >> > >> We could do that, though it's already 'instance of'. Not sure on this > one. > > > > > > > > It's not necessarily a class you're requiring an instance of, it could > (and > > according to some design disciplines "should") be an interface. I think > the > > "did you mean..." is more useful if we don't make everything alias. > > > > Regards, > > -- > > Rowan Collins > > [IMSoP] > > > > > I think it's important to clean up these error messages and make it > easier to find the root problem. > > With that said, I strongly believe that adding new reserved classes is > the wrong way to do that. Part of the problem is inconsistency around > what we call types in the first place. This leads to confusion around > what types people expect and how they expect them. > > An example is the fact that types are different all over the place. > Cast tokens, the return of gettype(), documentation, etc. > > Everything is inconsistent. And reserving extra types because of this > inconsistency does nothing to actually fix the problem. > > Instead, my suggestion would be to double-down on clarifying that > "int"/"float"/"bool"/etc are the canonical correct versions, and > everything else is an alias. In future versions (likely 8, but > possibly earlier) we could deprecate the aliases, to keep things far > more consistent. > > Reserving more classes now (both 7.0 and this late in the RC process) > is IMHO not a great idea. Either side sucks (whichever we do we're > wrong), but at least not reserving gives us a path towards cleaning it > up rather than making it worse. > > I like Derick's suggestion (though removing "class"): > > Fatal error: Uncaught TypeError: Return value of foo() must be an > instance of boolean, scalar boolean returned > I also don't like reserving new class names or limiting their use. The message above looks clear and it shouldn't be a big problem to implement the fix. This fix shouldn't change anything except error message, so it'll make minimal risk for 7.0 release process. Thanks. Dmitry. > > The "instance" says it's an object. > > The rest of it becomes a documentation problem. We're already mostly > consistent in the docs (all of the signatures use the correct tokens), > so it shouldn't be hard to finish that off... > > My $0.02 at least. > > Anthony > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --089e01538ca0c399f70522021de6--