Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109644 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65226 invoked from network); 15 Apr 2020 12:27:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Apr 2020 12:27:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5984C1804CC for ; Wed, 15 Apr 2020 03:57:13 -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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 03:57:12 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id h6so2305735lfc.0 for ; Wed, 15 Apr 2020 03:57:12 -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=zXVq80PMZTLlYjGKfQEOy5M36xOcpU08ldMJSqG8S24=; b=pI9Y+r40yadq5YhTfQ6JzYgvhrNLtuf/8Vrm3mm7AqRh+DASAIUuQOOXJSpVG4c6Vx 2Yo0Yg8jnP00aN0cy7J/vVObTzSxE6RXUMLPWvAEET7jfPb8tD88P3dRjUV6butNcMjp jhfJIU1Glivs1oTa2WTj+5m7rqdmmgXaaieusVhDxdsFVofxpA1S44g6xzxLuhDI+Fus x3GsUQ+QtoRUpo2yRZjCkQ6dqg9vSq+uWn6sYJJZJ1OvqgRVh+iuPt6BI+MWFuIyUarD JjkZzf3l1VMw3tJiWg7LbOFxmUg2j85AO/uXXhufSArgCiFDJ64+9OMFFeUkPl0O/hXu Fw1A== 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=zXVq80PMZTLlYjGKfQEOy5M36xOcpU08ldMJSqG8S24=; b=fe1tw2YN3ABfYsUwPU40dznmf2z1anbRKY4oSq2icNxbDAbW3zy5+eCQ9I/RJNaybA xTKN0eYzuKEiKiRNm1VNCTlTkc6drhQh9Lsxtdq4IaluoU3RtIbAUBCfvJtAz4LODCds z2aKLcWjehqaSZ4x9Zi3iAEgtCcC+yQbh61BzyBH4unsBWaE71/kJwERliTafyphBjfT jVc18lLYfngpPALb2WMjUJfFZX6DcCFR1rJHdDvVC+4Yyv8870aCAtezTz+94L7CNRb8 v/Q4bsCs3SHQNG4HiPfYhJWSiDXozkztS4ibggADl5xwWkWqU071Xa4q+9uKJbl9pKpJ nwDQ== X-Gm-Message-State: AGi0PuZScAS7dyg9ct8ZPACrRgg9x8+NN3NETJm3y0z6AnD2OaZXkZD1 KfLvgw7HD9RkIaBoHaVW7wST5cl1ln4CmES1qZg= X-Google-Smtp-Source: APiQypJxI9dL2a5GyINuJ896sv3k+0MX85TypOW6LVJ3laMvCmsGbG//LronQstZ7tc2c4VX3xdzoKzckWOtJzidNpA= X-Received: by 2002:ac2:47f0:: with SMTP id b16mr2829052lfp.81.1586948230509; Wed, 15 Apr 2020 03:57:10 -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: <436FD800-A316-4C99-8793-C6EF4BD15BE3@gmail.com> Date: Wed, 15 Apr 2020 12:56:54 +0200 Message-ID: To: Claude Pache Cc: Nicolas Grekas , Gabriel Caruso , PHP Internals Content-Type: multipart/alternative; boundary="0000000000008e778505a3522d04" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed From: nikita.ppv@gmail.com (Nikita Popov) --0000000000008e778505a3522d04 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 the >> 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 way= 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 method= ] is void=E2=80=9D. >> >> That might be a reason to reject the concept of =E2=80=9Cvoid=E2=80=9D a= s 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 shou= ld >> not cherry-pick and reject the concept of =E2=80=9Cvoid=E2=80=9D for __c= onstruct() 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++. You > 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 have > 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 doe= s > PHP currently)? because I=E2=80=99m more interested in the semantics 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 --0000000000008e778505a3522d04--