Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109348 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68907 invoked from network); 26 Mar 2020 19:37:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Mar 2020 19:37:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E1CB918050B for ; Thu, 26 Mar 2020 11:02:06 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 ; Thu, 26 Mar 2020 11:02:06 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id q19so7365581ljp.9 for ; Thu, 26 Mar 2020 11:02:06 -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=c90ItTVgpUzvJEDMygw8NKkPuGqGN2jELOr9dIOF6XY=; b=TQpl1pqKxlw1moUqUROh312SPBR6tQSXuHt4xwLupWKt4dLT9Ll5ODgyM174DR3xpj 6AFm+Nkkv7TRLius0Mc8QsVfJnBPkFBkiHqxzW9/2xLfeO9EUuX3j4hlDZ/IUJdtKegm SY8kexNWyM/0PxRIsfPvFollCxMY1IYnfy9ICIu45jbBIqakkOIFt3oJ8trSEqgdYV9B O9aUu9DiTruM0BFCd8e6ZM3n8A3Nype1X4GRWdLLCrAwVmELhwP5Kcyrs/TRQEVRPjQN 46FOchkQqRkG0T1etY91q9e/4oE9Zwk/PaPZWtVHzq2nY/3DC2rSUuNcv9QGcUX3jPA+ ZVow== 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=c90ItTVgpUzvJEDMygw8NKkPuGqGN2jELOr9dIOF6XY=; b=JUNi9t0eb0cFjyBplqRVErCAq6BGpg132WoP96cRz7k3a72Tb4CX7SY/zZgHZovWcb sc7WR9AaYUq3XsZu4TtkCblBt4UH9sksEGROvon4C35uWHxUf06DpsFcSlj3GYBrXOll hluaABLTJxpDpnl///Sr9R18tvRUsLE+WFuGRmnbB8OnOruX8FZZ80fSlkd0YZPtBUfA R21fflPs/pV9mCE6/UhYiiaKqO3edpJepyATLRdDXscavESI61RUi/ncjuhU+6d8iUFZ PKe0/aSOe3BQ+5i+PL5brqTbYkXH6WTxU7YrKplsJdb3qW/B3RE9YmXeZXy5BiP7juGJ qf3w== X-Gm-Message-State: ANhLgQ0p6NyCFCRe1T+NNbO8EbM0MEEWg7ttS/cLaHUHlVfq7nhGhWxH JIKyel+9b06eJTi0ozAMmHi+IutULhqzqdm1PxQ= X-Google-Smtp-Source: ADFU+vtitQDaPha9CfVh6zo5xBJviU9LOlnrkPWSiv3RwItl4v5XBjkv48FuuzhRpFt1kqb0e5lCNdEwHIQBG6Ur7XY= X-Received: by 2002:a2e:88d9:: with SMTP id a25mr6182784ljk.267.1585245724017; Thu, 26 Mar 2020 11:02:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 26 Mar 2020 19:01:47 +0100 Message-ID: To: David Rodrigues Cc: PHP Internals Content-Type: multipart/alternative; boundary="0000000000004306ad05a1c5c88e" Subject: Re: [PHP-DEV] [RFC] Constructor Property Promotion From: nikita.ppv@gmail.com (Nikita Popov) --0000000000004306ad05a1c5c88e Content-Type: text/plain; charset="UTF-8" On Thu, Mar 26, 2020 at 5:02 PM David Rodrigues wrote: > Hello! > > With all respect, seems a bit confuses to me, without in fact offer a new > feature, just a shortcut. I hope it's me seeing it the wrong way. > > What happen if I rename the constructor parameters on a child class > constructor? > > Example (https://3v4l.org/VqQde): > > class A { > public function __construct(public int $x) { ... } > } > > class B extends A { > public function __construct(public int $y) { ...; > parent::__construct($y); } > } > Constructors (in general, independent of this feature) are per-class and do not participate in classical signature-based inheritance (the exception being abstract constructors, but those aren't relevant here). The notion of "renaming" a constructor parameter doesn't make sense in that regard, because the parameters of the child constructor have absolutely no relation to the parameters of the parent constructor. The way to write your example would be: class A { public function __construct(public int $x) {} } class B extends A { public function __construct(int $x) { parent::__construct($x); // Your extra logic here. } } Regards, Nikita --0000000000004306ad05a1c5c88e--