Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109657 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6522 invoked from network); 15 Apr 2020 16:21:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Apr 2020 16:21:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D46D51804D0 for ; Wed, 15 Apr 2020 07:51:04 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 15 Apr 2020 07:51:04 -0700 (PDT) Received: by mail-il1-f180.google.com with SMTP id i2so3512620ils.12 for ; Wed, 15 Apr 2020 07:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cEliaVMjFvuBkVdDDup2p0l8RjXTyNYltaGYEQ1+GX4=; b=tTFap2qjNdzdOMkEXy/wYZUMfM2bwEM720YDl++5U9H+7xDZpXGCR9CC0gdMYY2UZl BBKyKc6bV3fQsM7qOmOyKTVUkh0AlHiE9XVeAzmTVObmfSVI3uYCoqpocx98xBmd0s6b KIJrk3QKAQKcwiJsDBPSQRlgL/02iwEkHy9EWYij7RdTn4l37BDCHwbaOOgdC5JhHPsT WjbSuXlLRQzTbBlF1BaKNVR6Vb69F6nylFhv67J5vk1EU6Qx7MMhLyWf1rliEUUAMw0K 89pRBqKLgq9RgZ2/Tg37rQDerwJOQrui+Deet3mr+mMmV/i4pKcMWSaSP9MRGXjmjmH2 jAoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cEliaVMjFvuBkVdDDup2p0l8RjXTyNYltaGYEQ1+GX4=; b=KsBjKZLRbx3S8Ls9NRPQQ6dkj/AYcCXGjV8+HhQLEm0aY54/E6nXIzTDeBvwXoaqvL WSy1JGXy6syPzBL3sYWJcmqAEzt4rKmydBbbMvORXT15wMyuQNnAOJM6jZazPa3wrOiZ Vj5/AcjrPHKIVf3c1xWhu2V1hnjfpa6MbiRPWFWaWN5qQAYFaV+isSkMFhpI9J5U77di vaY7RhtYKZ30JlJV+0gG/Mm6j6Rozm7BdrnAbWicLEwyJQRThN6FUthxg5Ndf4RRwln6 CS2gWkDHjG0JN7Qoz0MDpiFl6gsGG1IwDInFcWGdhnPHNiALdUCKn0ywUb8cFzw1kJa1 H/ow== X-Gm-Message-State: AGi0PuYs6hkpgKU3jgLFyg/Qw7it9c+3HFRKMYSK1H5Mvh5voBsF7YuC s5nM3IWmDQ3H4uA5KzL0hH0ukxkcwUH7hyr4IN0= X-Google-Smtp-Source: APiQypJQ2pSQo2m5ngaumcSEaaEQQYv/ZkXLOlUdDzwd8ixeNzkhUwoSHBpWu6OplDXszmBah6oFMwuVvu0Qphdl7CM= X-Received: by 2002:a92:4b11:: with SMTP id m17mr5982474ilg.42.1586962261404; Wed, 15 Apr 2020 07:51:01 -0700 (PDT) MIME-Version: 1.0 References: <90F4B395-F010-4196-9C40-7896D4F3F2F4@gmail.com> <0A374409-6FA6-4E02-A7E6-EACA3E42451C@gmail.com> <436FD800-A316-4C99-8793-C6EF4BD15BE3@gmail.com> In-Reply-To: Date: Wed, 15 Apr 2020 16:50:50 +0200 Message-ID: To: Nikita Popov Cc: Claude Pache , Nicolas Grekas , PHP Internals Content-Type: multipart/alternative; boundary="000000000000dcf31305a3557161" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed From: carusogabriel34@gmail.com (Gabriel Caruso) --000000000000dcf31305a3557161 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 15 Apr 2020 at 12:57, Nikita Popov wrote: > On Tue, Apr 14, 2020 at 7:45 PM Claude Pache > wrote: > >> >> >> Le 14 avr. 2020 =C3=A0 18:53, Nikita Popov a =C3= =A9crit : >> >> On Tue, Apr 14, 2020 at 6:07 PM Claude Pache >> wrote: >> >>> >>> >>> > Le 14 avr. 2020 =C3=A0 16:54, Nicolas Grekas >>> a =C3=A9crit : >>> > >>> > I'm just not sold on allowing "void" on __construct, because the very >>> concept of a return type on a constructor is ... void, and also because= of >>> the code style choices this will open (and the CS "wars" I mentioned). >>> > >>> >>> This issue is not specific to magic method like __construct(). It is th= e >>> whole concept of =E2=80=9Cvoid=E2=80=9D as return type which is, say, = =E2=80=9Cproblematic=E2=80=9D. >>> >>> In fact, =E2=80=9Cvoid=E2=80=9D is not really a return type. It is a wa= y to state that >>> the method is not supposed to return anything, which means, as you said >>> very well, that =E2=80=9Cthe very concept of return type on [this metho= d] is void=E2=80=9D. >>> >>> That might be a reason to reject the concept of =E2=80=9Cvoid=E2=80=9D = as return type. >>> Or to revive https://wiki.php.net/rfc/allow-void-variance < >>> https://wiki.php.net/rfc/allow-void-variance> . But again, the issue is >>> orthogonal to the fact that this particular method is magic, and we sho= uld >>> not cherry-pick and reject the concept of =E2=80=9Cvoid=E2=80=9D for __= construct() and >>> similar magic methods only. >> >> >> Constructors not having a return type is standard behavior across most >> (all?) languages. You can't specify a constructor return type in C++. Yo= u >> can't specify one in C#. You can't specify one in Java. Off-hand, I can'= t >> name a language that both has a first-class constructor concept (Rust's >> "new" idiom does not count) and specifies a return type on it. >> >> It would naturally follow that, yes, you can't specify a constructor >> return type in PHP either, just like we enforce right now. Unless we hav= e >> some strong reason to deviate from standard behavior that I do not see? >> >> Regards, >> Nikita >> >> >> Do those languages allow to return something from the constructor (as >> does PHP currently)? because I=E2=80=99m more interested in the semantic= s of `: >> void` than the exact way to have it. >> > > Ah, so that's what this is about! In that case, I'd be happy to simply > always enforce that __construct() cannot return a value, in the same way = we > do for ": void" functions. (If we have backwards compatibility concerns, = we > can add this as a warning instead of hard error.) > > Nikita > I'll change the RFC and remove the `: void` return allowance for `__construct()`. Should we do the same for `__destruct()`? Nikita, about your suggestion of checking the actual return value of `__construct()`, I've mentioned in the RFC that I want to do that for all the magic methods in a future RFC ( https://wiki.php.net/rfc/magic-methods-signature#future-scope). Do you think we can follow with that, or no, we should add this check to the current RFC? Nicolas, I've improved the RFC document. Let me know if there's anything else that I need to clarify. Thanks for the feedback y'all. Best regards, --000000000000dcf31305a3557161--