Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123551 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 9664E1A009C for ; Fri, 7 Jun 2024 21:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717796165; bh=6fzJUxT6wGAPgetLADkAUlhrpGiMXV2iwQMyU4BP2Bk=; h=References:In-Reply-To:From:Date:Subject:To:From; b=Quqdcls7IU8iwwVyQYeSw8pMLr8z8eWsTvQ1dX8Dyt70BYJZ0fVzkaVfKOkZ8ZEeB gikkOKXB8pXldt4G7DTFNC/LhQlOho1lYHuKbZRYTbKg+c27JFzWdI3MMFiB9iesYN SbLgBh7fAGY3zzNNiwlFtfZHJOigcJPILs6/tcdYKskCiDJMbLVLApn96yx+m22gqw QCNInpwpvglBDtmnbUkynKw/wkbvSzo271FUJ5wrU3OdxgYHma1Ir0dgEaJosMH3V0 DPdD5LQ51NUNRHTa7miVq6fRkVovxmaK2f+9nK7/COkzBw1DXStmtdegTZea3NdDhd FY0o8QsYl32Lw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6B832180050 for ; Fri, 7 Jun 2024 21:36:03 +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,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com [209.85.221.180]) (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 ; Fri, 7 Jun 2024 21:36:03 +0000 (UTC) Received: by mail-vk1-f180.google.com with SMTP id 71dfb90a1353d-4eb39c45a9aso790646e0c.1 for ; Fri, 07 Jun 2024 14:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717796096; x=1718400896; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=oxDmLiJaF3Do2KS61sJ3tTGp9ymuL2hUOHPnYvr3YnA=; b=g44y2uQ93vMgCbLXUpnYlq/dZi7dmpWyScfQBHsIMKUp2gand2Hc41yspi4MGu+n/C uavR6MtVpI20iygbBIRI3FJ8oHbSytvD2GJSFdAzX/gcBDui7mzQm3EI7HG1aIppTKUg xs30vGaKwvbRy+2qIGXfLCLxTWOScHI3mnp5dYdTDkvWbkNSMoaQ+Iimy2LrUVLFcDES J2GBhZyfeGK+1q1PSHOetCehc/2LArPbPrEZMvd4blPdxOFEy5407KGZxJ0C1swNcAgU uGToRufVQ16XzVjZdSyzn3+h8RODSRKeAlk4VKnGCLRGHkDSVjCKCtX+tIEOCpuaNENQ JYug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717796096; x=1718400896; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oxDmLiJaF3Do2KS61sJ3tTGp9ymuL2hUOHPnYvr3YnA=; b=lAlAiGl9vxY7+1JHdnsU70uc92tbK5ye1f9YfmVlmB5mJAFy65gGuBwb5p0CSE6SOu GA7jSH9VLSmDLVVqB82NU4g85aAy7hAoL9JahspZZuBYYr8PNd194yUv++VJzb4Idrd2 xALWmnU0yNk7OcVEeOJdy4gwJjtX3dn4CCGNxFBuixCkJlkz7RYKVot9ZdXoMEovx0wU 4Jmu0bc+M4n9VmF3wRkFgJLnAWu1Uc+NYDaPIaCXWVe10rQTNxIlhIEtyua3RkVS7d2p 0z/vOwtZFNVXuBwykFU8wWBE2rMVAn7yg5pQRoy0q1BMu4tefNANSxn1QHak4RFvmlyM evRQ== X-Gm-Message-State: AOJu0YzD+KaQ8MacR2O04uUj76obIB0IGGj1f5125UVxcQGRPw7SIzMY YcaZjbVXq9MPqqpSxOFWL4WLHU3RNmnKBGl/O3ZBTI9HCv+E9aiFfm9/2WRMHbJkV3lDEJ5VQki qH7CjKTnleOWI6Uhi6H5wN2TLoOyMfCxt1d4= X-Google-Smtp-Source: AGHT+IGZp3Q/MMrKE6uul7LTT3wsvdEZFs/kK0Hef/FSlR7krSw6St6Js+61v47EWVtklWQQ6zmIulawXxQ3BvYYMPo= X-Received: by 2002:ac5:cdb4:0:b0:4ea:f128:7adb with SMTP id 71dfb90a1353d-4eb562bba21mr3996273e0c.10.1717796095523; Fri, 07 Jun 2024 14:34:55 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <652c1a66-6702-4009-a4a0-d2221df00f69@app.fastmail.com> In-Reply-To: Date: Fri, 7 Jun 2024 18:34:19 -0300 Message-ID: Subject: Re: [PHP-DEV] RFC proposal : "new" keyword shorthand To: php internals Content-Type: multipart/alternative; boundary="00000000000012016e061a53928f" From: ericklima.comp@gmail.com (Erick de Azevedo Lima) --00000000000012016e061a53928f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi all. > Em sex., 7 de jun. de 2024 =C3=A0s 17:53, Pierre escreveu: > I do agree with you that when you use value objects, you need it a lot, > but I'd much prefer having a JS like value objects initializer syntax, > such as `Point {x: 1, y: 2}` syntax than creating another way to call > the constructor, which already has a mastered and comprehensive syntax > which is simply `new`. I also think that `new `(4 chars, if we count the blank space) is short enough. But a JS-like syntax that's already known for representing objects could be used. I'm sympathetic to something like this (changing the OP examples): class A { public function b() { echo "I'm B"; } } A::{}->b(); class Foo { public function __construct( public string $name ) {} } class Bar { public function __construct( public Foo $foo ) {} } $bar =3D Bar::{ Foo::{ "I'm foo in bar" } }; echo $bar->foo->name; #[AttributeOverrides([ AttributeOverride::{ name: "id", column: Column::{ name: "guest_id", type: "integer", length: 140 } }, AttributeOverride::{ name: "name", column: Column::{ name: "guest_name", nullable: false, unique: true, length: 240 } }] )] #[AttributeOverrides([ AttributeOverride::{ name: "id", column: Column::{ name: "guest_id", type: "integer", length: 140 } }, AttributeOverride::{ name: "name", column: Column::{ name: "guest_name", nullable: false, unique: true, length: 240 } }] )] -- Erick --00000000000012016e061a53928f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi all.

> Em sex., 7 de jun. de 2024 =C3=A0s 17:53, Pierre &= lt;pierre-php@processus.org= > escreveu:
> I do agree with you that when you use value objects,= you need it a lot,
> but I'd much prefer having a JS like value= objects initializer syntax,
> such as `Point {x: 1, y: 2}` syntax t= han creating another way to call
> the constructor, which already ha= s a mastered and comprehensive syntax
> which is simply `new`.
=
I also think that `new `(4 chars, if we coun= t the blank space) is short enough.
But a JS-like syntax that's alre= ady known for representing objects could be used.
I'm sympathetic to something like this (changing the OP exam= ples):

class A {
=C2=A0 =C2=A0 = =C2=A0public function b() {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo &quo= t;I'm B";
=C2=A0 =C2=A0 =C2=A0}
=C2=A0}

=C2=A0A::{}-&= gt;b();


class Foo {
=C2=A0 =C2=A0 public function __construct= (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public string $name
=C2=A0 =C2=A0 ) {}<= br>}

class Bar {
=C2=A0 =C2=A0public function __construct(
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 public Foo $foo
=C2=A0 =C2=A0) {}
}

= =C2=A0$bar =3D Bar::{ Foo::{ "I'm foo in bar" } };
=C2=A0e= cho $bar->foo->name;


#[AttributeOverrides([
=C2=A0 =C2= =A0 AttributeOverride::{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 name: "id"= ;,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 column: Column::{ name: "guest_id&qu= ot;, type: "integer", length: 140 }
=C2=A0 =C2=A0 },
=C2=A0= =C2=A0 AttributeOverride::{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 name: "nam= e",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 column: Column::{ name: "guest= _name", nullable: false, unique: true, length: 240 }
=C2=A0 =C2=A0 = }]
)]


#[AttributeOverrides([
=C2=A0 =C2=A0 AttributeOverri= de::{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 name: "id",
=C2=A0 =C2=A0= =C2=A0 =C2=A0 column: Column::{ name: "guest_id", type: "in= teger", length: 140 }
=C2=A0 =C2=A0 },
=C2=A0 =C2=A0 AttributeOv= erride::{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 name: "name",
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 column: Column::{ name: "guest_name", nullab= le: false, unique: true, length: 240 }
=C2=A0 =C2=A0 }]
)]

--
Erick<= br>
--00000000000012016e061a53928f--