Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78630 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13660 invoked from network); 4 Nov 2014 12:17:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Nov 2014 12:17:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:48290] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/21-06676-3E3C8545 for ; Tue, 04 Nov 2014 07:17:40 -0500 Received: (qmail 23134 invoked from network); 4 Nov 2014 13:17:33 +0100 Received: from cm56-129-238.liwest.at (HELO RoLaptop) (86.56.129.238) by ns73.kreativmedia.ch with ESMTPSA (AES128-SHA encrypted, authenticated); 4 Nov 2014 13:17:33 +0100 To: "'Chris Wright'" , "'Andrea Faulds'" Cc: "'Stas Malyshev'" , "'PHP Internals'" References: <002601cff777$eb923430$c2b69c90$@tutteli.ch> <000601cff80a$972e0250$c58a06f0$@tutteli.ch> <5458937F.9020304@sugarcrm.com> <0776A65F-D49A-4E8C-9771-6B5E5C4EA77E@ajf.me> In-Reply-To: Date: Tue, 4 Nov 2014 13:17:32 +0100 Message-ID: <001d01cff829$5010a750$f031f5f0$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHFXQsvCqySdhOS5hZldA9wwvCKZAF9M3/mAYp5CtcBNMNzSAEoQBf0AT4q8RqcMH654A== Content-Language: de-ch Subject: AW: AW: [PHP-DEV] Types on the right or on the left From: php@tutteli.ch ("Robert Stoll") > -----Urspr=C3=BCngliche Nachricht----- > Von: are.you.winning@gmail.com [mailto:are.you.winning@gmail.com] Im = Auftrag von Chris Wright > Gesendet: Dienstag, 4. November 2014 12:51 > An: Andrea Faulds > Cc: Stas Malyshev; Robert Stoll; PHP Internals > Betreff: Re: AW: [PHP-DEV] Types on the right or on the left >=20 > On 4 November 2014 10:32, Andrea Faulds wrote: >=20 > > > > > On 4 Nov 2014, at 08:51, Stas Malyshev = wrote: > > > > > > I agree, this is not a very good situation. It would be much = better > > > to take a systematic approach to this, but this is impossible = since > > > there is no systematic approach to strict typing in PHP, just some > > > pieces here and there. I think this is not right, but obviously = many > > > people here disagree and are happy to have the inconsistent = syntax. > > > I don't see why "public Foo function bar()" would be so much worse > > > than "public function > > > bar() : Foo" but for some reason this possibility wasn't even > > > considered as far as I can see. > > > I thought it was inconsistent, but after discussions on StackOverflow, = I > > don't think it actually is. Return types describe the return type of = a > > function, not the type of a function. So there's no reason they have > > to go before the function name like parameter types do. > > > > > So, in a sentence: >=20 > In PHP, input types go on the left and output types go on the right. >=20 > This sounds like a convention that could be established and followed, = and no-one could reasonably call it inconsistent if it > was adhered to. That is an interesting thought. Yet, where would you put the type of an = out parameter then? Nevertheless, you could phrase your convention = differently so it makes more sense and well.. in the end we can do = whatever we like in PHP and call it xy-convention and the user will have = to pick it up and learn it (quite similar to array functions where = usually the first argument is array and suddenly it is not the first = parameter as with array_key_exists, array_map or array_search). Sure it = is no big deal, the user should be able to pick up the convention = quickly but we could facilitate it, make it easier for the user, more = intuitive, in order that the user has a steeper learning curve. And the = time to decide what direction PHP should take is now with PHP 7.