Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92117 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82964 invoked from network); 7 Apr 2016 12:56:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Apr 2016 12:56:32 -0000 Authentication-Results: pb1.pair.com header.from=pjsturgeon@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pjsturgeon@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.47 as permitted sender) X-PHP-List-Original-Sender: pjsturgeon@gmail.com X-Host-Fingerprint: 209.85.215.47 mail-lf0-f47.google.com Received: from [209.85.215.47] ([209.85.215.47:33470] helo=mail-lf0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/57-48788-EF856075 for ; Thu, 07 Apr 2016 08:56:31 -0400 Received: by mail-lf0-f47.google.com with SMTP id e190so54494797lfe.0 for ; Thu, 07 Apr 2016 05:56:30 -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-transfer-encoding; bh=elJT+zurKSRw4DANVMOWZmXGAVJNNJ8Rd4blM9XT1xo=; b=QICjEe7CNw7VwaJXJ0t7RTwCDhPmCBOl8BE/l9VGkkacczkX1f8CLf+sb91k/6y/gM jmF0V87uVfqEsReRbNSc2dR3suNUYGAZsx86VolaUPij9iW77tdsKUs0nXBOlOX43Kko OSKIrrble8SxRT+hb6n/J9eoX1jFSgMk6LGS6tzK6uuqfBW6k8FYZKa+LMVqexIJQ0Ah LZcJzr3OVUWHB3DoxCNBNCGVyNFD36VkyxrFYbf4V40AIFFW2bCRDMUjd5b84IxKFGjw 8E5Yt6gARzQmmoV6tbXaCxb0pSmsYF9bL1KWpVp41oEwWx6e+QPWQriQHumhDqPq/lSK rSCQ== 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-transfer-encoding; bh=elJT+zurKSRw4DANVMOWZmXGAVJNNJ8Rd4blM9XT1xo=; b=jWfWWCGJicMMKnIQ//hrIja6PDjuPESvYlu17WvO+n6SeDbnDIxDToFPZqc/czzFOZ 4UDLddZmgv1HmiDBWDNvn5xcPVxPAE902FtT4D+ovvdRw1UHf6xIFZ7GPd3xQSDXB7rb NWnwAv2zkKCIGPH8ChkSNdvjj2cCIPYOKvBaUIua6vG6068IivoPlutSGejb3e2wImwo HUMHD3VY5eeDo4pkwzRBS4KyaV/8/Hvx6SOYgowWLhz9xxzyM8paf02ReiqkX7OEHk14 qz6cj8Jw+tvqpgnap1u8QiPPLGsWhkTWbh8U/YpXK5SKhL9BSKuhXOcHYYHLLlCJ4RUx /XBA== X-Gm-Message-State: AD7BkJIM6fM8Yb3a/xwmw576PJXqBakF4ivihZaq+HwWNzCbMQ+Un1YcoBd8uKvlyLM1gc5ycyquDIsHseHEKw== MIME-Version: 1.0 X-Received: by 10.25.83.8 with SMTP id h8mr7585992lfb.167.1459960428218; Wed, 06 Apr 2016 09:33:48 -0700 (PDT) Received: by 10.114.78.71 with HTTP; Wed, 6 Apr 2016 09:33:48 -0700 (PDT) In-Reply-To: <57001915.3030407@telia.com> References: <3F.70.02405.6803BE65@pb1.pair.com> <56F01545.8080008@gmail.com> <56F14572.701@gmail.com> <56F15EF5.80006@telia.com> <56F16023.1010002@gmail.com> <56FC4ED6.6050701@telia.com> <57001915.3030407@telia.com> Date: Wed, 6 Apr 2016 12:33:48 -0400 Message-ID: To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Cc: Joe Watkins , Dmitry Stogov , Krakjo , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: pjsturgeon@gmail.com (Phil Sturgeon) On Sat, Apr 2, 2016 at 3:10 PM, Bj=C3=B6rn Larsson wrote: > Good evening,Den 2016-03-31 kl. 10:34, skrev Joe Watkins: >> >> Morning, >> >>> Given that public is implied for all properties above there >>> is a value in having the same rule for type. >> >> public $bar, int $foo; >> >> What does this mean? >> >> If it's not an error, what does this mean ? >> >> public $bar, int $foo, $qux; >> >> If it's an error, why is it an error ? >> >> Both of these examples are just as ambiguous as >> >> public int $foo, $bar, $qux; >> >> Access modifiers are assumed to apply to all declarations in a group, >> because that's what grouping is actually for. >> >> We don't need to make grouping about types, we need to make type >> declarations unambiguous. > > I think by issuing an error on the two first one we make the > third one unambiguous. It also makes it a bit easier to explain > and remember rules for visibility and type keywords before > a list of properties, i.e. they are close to the same. > > Having the public keyword optional would be nice, but then > as you say it should be the same for untyped properties. > >>> Anyway, in Hack following syntax passes: https://3v4l.org/3tUu9 >> >> Hack does not consider types implicitly nullable. >> >> > class Foo { >> public int $int =3D null; >> public stdClass $std =3D null; >> } >> >> things.php:3:10,12: Wrong type hint (Typing[4110]) >> things.php:3:10,12: This is an int >> things.php:3:21,24: It is incompatible with a nullable type >> things.php:4:10,17: Wrong type hint (Typing[4110]) >> things.php:4:10,17: This is an object of type stdClass >> things.php:4:26,29: It is incompatible with a nullable type >> >> > function foo(int $int =3D null, stdClass $std =3D null) {} >> >> things.php:2:18,21: Wrong type hint (Typing[4110]) >> things.php:2:14,16: This is an int >> things.php:2:25,28: It is incompatible with a nullable type >> things.php:2:40,43: Wrong type hint (Typing[4110]) >> things.php:2:31,38: This is an object of type stdClass >> things.php:2:47,50: It is incompatible with a nullable type >> >> HHVM doesn't care about types ... we don't compare our type system to th= at >> ... > > I rest my case here :-) > > Regards //Bj=C3=B6rn > We polled pretty hard and had a bunch of discussions about how multiple declarations should work, and ended up siding with Zeev and Larry, and all those others saying that type declarations should work for all just as visibility does currently: public int $foo, $bar; $bar here will be int. Trying to specify another type will resolve in an error. RFC is updated to match. We have a few more implementation tweaks to make, then it's off to the races with this one.