Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92072 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44101 invoked from network); 2 Apr 2016 19:10:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Apr 2016 19:10:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=bjorn.x.larsson@telia.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=bjorn.x.larsson@telia.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain telia.com from 81.236.60.155 cause and error) X-PHP-List-Original-Sender: bjorn.x.larsson@telia.com X-Host-Fingerprint: 81.236.60.155 v-smtpout2.han.skanova.net Received: from [81.236.60.155] ([81.236.60.155:57114] helo=v-smtpout2.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 69/34-29546-31910075 for ; Sat, 02 Apr 2016 14:10:12 -0500 Received: from [192.168.7.7] ([195.198.188.252]) by cmsmtp with SMTP id mQvwatitlGabYmQvwaUdnc; Sat, 02 Apr 2016 21:10:08 +0200 To: Joe Watkins 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> Cc: Dmitry Stogov , Phil Sturgeon , Krakjo , PHP internals Message-ID: <57001915.3030407@telia.com> Date: Sat, 2 Apr 2016 21:10:13 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfDJFOXoiYOKJADhWZcPaYts8u1Ni6GZpw1WunBvgYzKMSmLbBv7i5FRfNXYAM19dD7hdoipKp/ByHOZGz+LTMkr8EU6mrlJn4bHWF5dhytb/R3TnNpLM +GcBxmBAm9pZgDlzyunJjhO9wRRuAz2wwbiqa4oJ2uCfwJkoOnp+q/SYXcZ4i3zrHwfJC82w1s8skvMEJEIM5zqgkylRYJa6MwSDwrBiUqzk+y1lfvOXE8M8 56Pmxqz1a9LFcZvoh0Um1waoi4If7BAcYb686YqgpPtQ3svJuVWHL7OPzFpjOCOX2svbXbmPaDcENWvzz+3BdQ== Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties From: bjorn.x.larsson@telia.com (=?UTF-8?Q?Bj=c3=b6rn_Larsson?=) 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 = null; > public stdClass $std = 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 = null, stdClass $std = 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 that > ... I rest my case here :-) Regards //Björn