Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124466 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 91D001A00B7 for ; Thu, 18 Jul 2024 09:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721294602; bh=m97diQbOlFjDGrD7L77akHv9mlYrz2I5dmkTIu7sQko=; h=From:Date:Subject:To:From; b=KEFuxQCGo99QqjV/LDrXERauK4w7TfW1vdM4FA4CWN5sKGtf4F7gqFwoaowRPwCJf ogK8wxhI7vtak1L+BTVLiJ3a77Bo+TXpjS3MJfbjhIWxhm6GxlTlVKBMU6RsIagsYl PWEO1Qxht7fS19OciXNaBBHWT8u2ZHfUYONz976XUvVc2GJYaZfFQGR75OIpXwIsA/ FLeVpX6P/3YKP2kzc2CRJp+pDPM8M3TvlFZ1fqfcNGEzUBk8ChoJ1ox/EQmHIG8KRu yENDErhE3iTVLCTZpBSBatef/pafzqnsdQTqqihrVDB4MSwaO9N7sAi9d7CK9zUOAN jnYSR0sHcGKGg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3CA6F18004B for ; Thu, 18 Jul 2024 09:23:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 18 Jul 2024 09:23:21 +0000 (UTC) Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-e03a17a50a9so667313276.1 for ; Thu, 18 Jul 2024 02:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721294510; x=1721899310; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=7G4RphRAbrep5wzJY7MW3gSJmVCII5yqxUQCM5xv9Kk=; b=KFAcWFX1VMD/twgVUowIJvuRBOwcqXWo6//oOqD4hefQtmjhYsZrTtaLJ++EQQiLJ+ G6IQxcOPI1lZxHPAjTboXg3Oo7PdnhZwINhkAQaZ8UqvqC2Dx/xzrM3jlONwrWtv9Ohy noOoVfu3RdueBbASLx185VYruK91urm/vIZ8/Dq3PEWSRg97kMrpuAFHby9AZV+272eE Ci7bX9sWFZLQqr4MVgTX+yxHeSY8SD7Sff/5ugEQ+O+TCQ4UFDov2x3+QV0EdArooJI8 6YXTCQNjfQYERip8Qee0ZKgFxAIuPwhSQHE1fLrOEYE9puadr5uEV/51DJ2NDm7ZiFuj 7Nyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721294510; x=1721899310; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7G4RphRAbrep5wzJY7MW3gSJmVCII5yqxUQCM5xv9Kk=; b=XvLje3MWPTLPivc+TT7YDXmt7g1pe9Lctcsb3Mig3Wk3OEwsmSZnYvp+61WMrv4F8q vZXXdpNkeYgsc+3YtLf86eJrlh5GQxMzsoLhSH3f9ufxLifLNcgfuyXp1pGBrwHh+vtK 6gQ0fA8WuDBuiKckUN3oAm4yFPXwBUsIF4G6XAGaDhmkEmPnrE5Bsx4caKduc1yGXUo7 sT5urR0oRusZ6oxEGnmTpj2/SpoUYKzLMCSYP7B+qOatNWnpowJ3smPFixxKVDG31Swj Y56AUZfViqvEGU7FazruyRQudC/1BjqxFkzmz5suJDszZJR2upVkhJvKRw8eLI115jhH Lnxg== X-Gm-Message-State: AOJu0YzVRpu3bjR5pvyRxqHOfBp4OV/0xAVCDidUpXrNpMvsd0IFNhw5 pRLZwGtPRU1hqdvZpqw7VxoWgGRotFNynfY2yA/JDdmVQtNHYUNzFFl9YJU91oTSD4ypGnp2Zde D6XhHsgxw7qTbBQGUbw+vRYxYdFMajtDy X-Google-Smtp-Source: AGHT+IHIT8LjQ/mbnLNSJuorg3s+woO28cb7iutUcBUsGJRfX63JhaeoO42daV4G2eGtOTNHtvy11KtsiLa05NbBSeA= X-Received: by 2002:a05:6902:1022:b0:e08:54fc:96a with SMTP id 3f1490d57ef6-e0854fc0dbamr508687276.26.1721294510282; Thu, 18 Jul 2024 02:21:50 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 18 Jul 2024 11:21:39 +0200 Message-ID: Subject: [PHP-DEV] Optional constructor body To: PHP internals Content-Type: multipart/alternative; boundary="000000000000d6e16c061d821b15" From: olivernybroe@gmail.com (Oliver Nybroe) --000000000000d6e16c061d821b15 Content-Type: text/plain; charset="UTF-8" Hello internals. I am looking into making the constructor body optional in classes, essentially allowing you to write ``` class User { public function __construct( private string $name, ) } ``` Currently to make this code valid, it would have to be written the following way ``` class User { public function __construct( public string $name, ) {} } ``` With the introduction or constructor property promotion in 8.0, we often see classes where the constructor has an empty body, and my guess would be that this will only increase with the introduction of property access hooks in 8.4 which is allowed to be defined in the constructor also. This change would only be a cosmetic change and simplify the userland code by removing two redundant characters. This would be my first RFC and I am willing to try and implement it myself. Best regards Oliver Nybroe (he/him) --000000000000d6e16c061d821b15 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello internals.=C2=A0

I am looking into makin= g the constructor body optional in classes, essentially allowing you to wri= te

```
class User {
=C2=A0 =C2=A0 pub= lic function __construct(
=C2=A0 =C2=A0 =C2=A0 =C2=A0 private string $na= me,
=C2=A0 =C2=A0 )
}
```

Currently to ma= ke this code valid, it would have to be written the following way

``= `
class User {
=C2=A0 =C2=A0 public function __construct(
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 public string $name,
=C2=A0 =C2=A0 ) {}
}
```=

With the introduction or constructor property pro= motion in 8.0, we often see classes where the constructor has an empty body= , and my guess would be that this will only increase with the introduction = of property access hooks in 8.4 which is allowed to be defined in the const= ructor also.=C2=A0

This change would only be a cosmetic change and s= implify the userland code by removing two redundant characters.=C2=A0


This would be my first RFC and I= am willing to try and implement it myself.=C2=A0


Best regards
Oliver Nybroe (he/hi= m)
--000000000000d6e16c061d821b15--