Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110133 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72617 invoked from network); 11 May 2020 17:45:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 May 2020 17:45:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 15AAC1804D3 for ; Mon, 11 May 2020 09:21:56 -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-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 ; Mon, 11 May 2020 09:21:55 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id a21so10155380ljj.11 for ; Mon, 11 May 2020 09:21:55 -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=cu4QnRpgjpho2zzQIzoHVO9OWZKdKAIi25Q2akXjtR4=; b=NGcAylwScacY1XdIYWR6vFARaXR67eBKyjyKIwcwr381Yq87PwLKmtWwrFmg+u24MU ff2vsyqIrIAh0q2J7jt7OnfGiUiLJfCFepYsslWuQyczHWqSEjcevqYWuJrarxhYW4z2 Ft+SaUpJZD/xdUg8ldXXyWmui1GdOMxAz2DrO/8RZorXf7zaVbOsnMICOOpY44Hcqhe1 oLL8MwW43cyz2RwU790YW+WC4fHPvh9hXevAhH8OakyGb5T+qgWtn8B26xYmYlmSavSH cq4tTmW4gcaLTF5j/wL/Z9GN0rvBlEtv+6uBlaOCq+T3Ox5cKeseQn/3BG5WvP0qDIDB 37sQ== 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=cu4QnRpgjpho2zzQIzoHVO9OWZKdKAIi25Q2akXjtR4=; b=hk5SbbmrR+B+wOaAiN2OR10JuVRJFFimOdSLTtZPOJqarJRJChXZ5HDE20e3cX/DcZ QH4zfz0f67sd6Xw8OoM957VtEV85j2yAS6/KL86XIZdNP7CG1bjwFS2ZBhwtYxRZYy8C MNwLa6hQA2L338lS4EthzlLesVhLfEpIh9RxRDvsCtEB1SKph0xWzqTBDoLsBdaw+B05 IrMNxdmCmO8rIINDo7iNcbU2vlRjJHQPZl+DCtSG1+n+XxKpr/6zlrjySoIKfn26xdpR AmhxRg1nUKi9VePX094oBMVV0ac45DmPK5bO8Kl8B6ou4w44wC1GetrYdUM6G98I0A11 NKPg== X-Gm-Message-State: AOAM533XmjcMK23XUg9p4YraUGH66O9/MsTbHVeugUQLYG/lZNZXq7HE 9LKhXCgm+KFPePHR4O7NN0CxFNRS3dLvHZbtd301JRFS6cU= X-Google-Smtp-Source: ABdhPJzPSnpJbJgHpWRm6S0FXWtHPyFxiXPkXmZ/QN9hpA0lXiI2GcZVYsNSx0CLN8tGAni4Q/iTzlIB4dBHyhIiMx4= X-Received: by 2002:a2e:9a04:: with SMTP id o4mr10682609lji.117.1589214113896; Mon, 11 May 2020 09:21:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 11 May 2020 18:21:36 +0200 Message-ID: To: Dan Ackroyd Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000bb1acb05a561bea1" Subject: Re: [PHP-DEV] Re: [RFC] Constructor Property Promotion From: nikita.ppv@gmail.com (Nikita Popov) --000000000000bb1acb05a561bea1 Content-Type: text/plain; charset="UTF-8" On Mon, May 11, 2020 at 5:26 PM Dan Ackroyd wrote: > On Mon, 11 May 2020 at 10:52, Nikita Popov wrote: > > > > Please tell me if you have further concerns > > Question - as this is just sugar, presumably it doesn't add much > complexity to the PHP engine? > Yes, the implementation complexity for this feature is minimal, as these things go. > Vague concern - because it's a novel syntax, I find it hard to read, > particularly when there are comments* for the properties. Do you think > I'll just get used to it, or is it likely to be an ongoing issue? > Well, I can't really answer this with confidence, but given the number of people who told me how much they love this feature in TypeScript, I would hazard that you would indeed get used to it. > Also, in five years time, if we have structs**, people will be > wondering why we bothered with this. But I think it does make life > easier for developers in the meantime. > When we discussed this topic in chat last time, I got the feeling that the rough consensus was that introducing "structs" as a feature distinct from classes is a bad idea, and we should instead try to make relevant features available for classes. Constructor promotion is one of those :) > class UrlToPdfProcessor > { > public function __construct( > // The full url to reach the instance of chrome running in > headless mode. > public string $chromeUrl, > > // A path to a directory where the output PDF will be written to. > // It must already exist and be writeable by the process running > // the PDF processor. > public string $tmpPath, > > // The internal domain name for the site to be rendered. > // The domain name should not contain either protocol or path > // components > string $internalDomain > ) { > } > } > As suggested in https://wiki.php.net/rfc/constructor_promotion#coding_style_considerations, my recommendation is to use normal @param annotations for constructor arguments, as we do now. While interleaving parameters and comments is certainly possible (already), it's certainly not common style, and I don't think it will become common style with constructor promotion. Regards, Nikita --000000000000bb1acb05a561bea1--