Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88781 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22298 invoked from network); 13 Oct 2015 15:41:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Oct 2015 15:41:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.169 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.212.169 mail-wi0-f169.google.com Received: from [209.85.212.169] ([209.85.212.169:34470] helo=mail-wi0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/E2-05441-F162D165 for ; Tue, 13 Oct 2015 11:41:19 -0400 Received: by wicgb1 with SMTP id gb1so94244878wic.1 for ; Tue, 13 Oct 2015 08:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=kXwL+qJlopx1WzgOvxJhYiNOSNPKO2tU1vQGBt4bDJM=; b=P/1BNmCvqNfNkdn3AiWkq1CDl7W8U9+ZqbZkrl9stasTK3DJABnIalLBRgdLasFSZf 5rlGYnCxXeZWVwURC60/0gw1CHQUmuKUhAO2FkV8zktmZtPVWhwIkbosKIp/C3bq82Eg +T+EhhblikaHSszQXgOuc/PyBznb+XmcVkKW3ZYk85hSwWCVMs/w3N6G3J0AfskmyKv/ DH6Wy6zwrz8MyJDR/vjDatww+Ykdh4aI1oS4s25L32cqbTo83D4lzxxbeeMy1xttGyoG MckDR17L8aL8RGsb1Rt8BkvwnvVF+2WqswDSHBIfbQ5uO6sGw69VoThWog75NE3Ceqeq vQEg== MIME-Version: 1.0 X-Received: by 10.194.201.130 with SMTP id ka2mr37663084wjc.123.1444750845539; Tue, 13 Oct 2015 08:40:45 -0700 (PDT) Received: by 10.28.55.18 with HTTP; Tue, 13 Oct 2015 08:40:45 -0700 (PDT) In-Reply-To: <561D0D81.2020306@gmail.com> References: <5C.21.16518.AA80C165@pb1.pair.com> <561CDFFA.8040207@php.net> <561D0D81.2020306@gmail.com> Date: Tue, 13 Oct 2015 11:40:45 -0400 Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Scalar type hints and scalar type name aliases causeconfuson From: ircmaxell@gmail.com (Anthony Ferrara) 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 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