Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123040 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 1F04E1ADA78 for ; Mon, 8 Apr 2024 11:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712575996; bh=B8nUHtVkXoWlLMIo1KmB3imK54lDdYzlcivpSUD6kXE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=M6KC4SW9PepK/bImod809H3LeG3pDz6rx/jEAFT9gMgz6btamZfug52bKkFvrTcIU Hr1jpUKqcnEyjdcd0q4FJPgts1gbHW0E0OTng/NeU0NBA41Iwvbjia+dIDYAnemuUY ctFK8ap0mTlepweiOcqYQ9HumDo5YfJslr8UyUziugDvDO3vRL25qA9P6Jsi1f8GsI 2XGX8JOrTS5K2acNBnW1gxq1Kxa6UKRUTS7zlxtF+3oO/Uk34JMdoa++4w78eNZMpQ 6hrMzgoBjg2QKBOS76lid0021qpfom/CgV7IgJoShhhpzW0hYSTFKDveyNTVCJLruz BuzKvb7CZ+ftA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 45F021807BF for ; Mon, 8 Apr 2024 11:33:13 +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: No X-Envelope-From: Received: from mail-ua1-f42.google.com (mail-ua1-f42.google.com [209.85.222.42]) (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 ; Mon, 8 Apr 2024 11:33:11 +0000 (UTC) Received: by mail-ua1-f42.google.com with SMTP id a1e0cc1a2514c-7e70cf0c2b5so59009241.0 for ; Mon, 08 Apr 2024 04:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712575959; x=1713180759; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3ppu1RYPh38TXUd/C5TtiJgFw3346Xec8bj0z/Y9u5o=; b=MaOWbAdJ+pvgoAQdJW/lTgDXmf/4HgbFHTABAKCheb86CEPJLB13NuneAdgc2GM45p p5lBBlhczeaKjvt1gxxvz/t6W+MgV+NefmJpW9JBc7XQHHmlc8+sCJXuwfcVT8E4zKfj ITXPIQWDTSA7lOrttL1r2weBX4flraCGoVPwaolz/GaEVgcjetB/X1DZu/UxELA2wRvb idVA1ROPjDZMUyakXqlIMv06Bhmm6EAt97k/k9a0PuzUOdfZNIRYN4iLURbzy8PpZRkW M2V0R0JdmcTV2G31+6OZUojlqtrTBj4f5xPpVJxjhglSi5gaDu38cijXXF6YoVGfSkKO +syA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712575959; x=1713180759; h=cc: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=3ppu1RYPh38TXUd/C5TtiJgFw3346Xec8bj0z/Y9u5o=; b=XxukAe70GQrGNpCSMKA/B+q28MGbCI/G8ugerZhkQXQjhYNywfw7emrdG53WtbYr/8 lkBnJJ8N4RpErQzPdwrowE+kg5FbH3qoVaNFlBFT0gP6Eal9BPKKG0vGW+kBILoD18gv CHAYVv4Zrfb3TSK0PA3C3gkwbwRfkGGgPv4FZXqsBYuA8w8dDz985dFdCuO/2yzEhktn CTktBtV/i9LB7vlWlBFQSe8XxNjFizlD2X4VcB+Sa3W5P+EtV7E1XxD3lYymAmHm1yvt vjRq9n+W4x+F7RqB8q36vgnE3R9r1tjgK/N60zepvJY0zBfigNJ/d4ogO1AwL/yMG83f qoYg== X-Gm-Message-State: AOJu0YxR0gaHg+z5/3yeTWbPMm13AFcBNI2dv21KN4B/QXIZvRCz8Hju O4gicZIZgMl//8XZVl9WZSKxUYMHQHnKdqbqZADlhOudrw5i9P2UkmmAHE9WPV+WS39KKjj/OI2 uxKkZ2GN0PpzFQxZ9/sxLQBL40aSFyZwndZo= X-Google-Smtp-Source: AGHT+IGgoRT5ulzvWaKT3WqmpvvdaGqEASXnKn9Z+kmtHde5tsw2QPttRihD9wrTJG34H78IAg1CTCTUF9i1W4zYioE= X-Received: by 2002:a05:6122:3d05:b0:4d3:3a78:60e2 with SMTP id ga5-20020a0561223d0500b004d33a7860e2mr4965514vkb.1.1712575958996; Mon, 08 Apr 2024 04:32:38 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 8 Apr 2024 08:32:02 -0300 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] new MyClass()->method() without parentheses To: Valentin Udaltsov Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000afe4fd06159429c8" From: deleugyn@gmail.com (Deleu) --000000000000afe4fd06159429c8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 8, 2024 at 3:11=E2=80=AFAM Valentin Udaltsov < udaltsov.valentin@gmail.com> wrote: > Hello internals, > > > I would like to propose a syntax change for PHP 8.4 that allows to > immediately access instantiated objects without wrapping the expression > into parentheses. > > > This was requested and discussed several times, see: > > - https://externals.io/message/66197 > > - https://bugs.php.net/bug.php?id=3D70549 > > - https://externals.io/message/101811 > > - https://externals.io/message/113953 > > > Here's what you will be able to write after this change: > > ```php > > class MyClass > > { > > const CONSTANT =3D 'constant'; > > public static $staticProperty =3D 'staticProperty'; > > public static function staticMethod(): string { return > 'staticMethod'; } > > public $property =3D 'property'; > > public function method(): string { return 'method'; } > > public function __invoke(): string { return '__invoke'; } > > } > > > var_dump( > > new MyClass()::CONSTANT, // string(8) "constant" > > new MyClass()::$staticProperty, // string(14) "staticProperty" > > new MyClass()::staticMethod(), // string(12) "staticMethod" > > new MyClass()->property, // string(8) "property" > > new MyClass()->method(), // string(6) "method" > > new MyClass()(), // string(8) "__invoke" > > ); > > ``` > > > For more details see the RFC: > https://wiki.php.net/rfc/new_without_parentheses > > Implementation: https://github.com/php/php-src/pull/13029 > > > -- > > Best regards, Valentin > Yes, please! --=20 Marco Deleu --000000000000afe4fd06159429c8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Mon, Apr 8, 2024 at 3:11=E2=80=AFA= M Valentin Udaltsov <udal= tsov.valentin@gmail.com> wrote:

Hello internals,


I would like to propose a syn= tax change for PHP 8.4 that allows to immediately access instantiated objec= ts without wrapping the expression into parentheses.


This was requested and discus= sed several times, see:

- https://externals.io/message/66197

- https://bugs.php.net/bug.php?id= =3D70549

- https://externals.io/message/101811<= /a>

- https://externals.io/message/113953<= /a>


Here's what you will be a= ble to write after this change:

```php

class MyClass

{

=C2=A0 =C2=A0 co= nst CONSTANT =3D 'constant';

=C2=A0 =C2=A0 pu= blic static $staticProperty =3D 'staticProperty';

=C2=A0 =C2=A0 pu= blic static function staticMethod(): string { return 'staticMethod'= ; }

=C2=A0 =C2=A0 pu= blic $property =3D 'property';

=C2=A0 =C2=A0 pu= blic function method(): string { return 'method'; }

=C2=A0 =C2=A0 pu= blic function __invoke(): string { return '__invoke'; }

}


var_dump(

=C2=A0 =C2=A0 ne= w MyClass()::CONSTANT,=C2=A0 =C2=A0 =C2=A0 =C2=A0 // string(8)= =C2=A0 "constant"

=C2=A0 =C2=A0 ne= w MyClass()::$staticProperty, // string(14) "staticProperty"

=C2=A0 =C2=A0 ne= w MyClass()::staticMethod(),=C2=A0 // string(12) "staticM= ethod"

=C2=A0 =C2=A0 ne= w MyClass()->property,=C2=A0 =C2=A0 =C2=A0 =C2=A0 // string= (8)=C2=A0 "property"

=C2=A0 =C2=A0 ne= w MyClass()->method(),=C2=A0 =C2=A0 =C2=A0 =C2=A0 // string= (6)=C2=A0 "method"

=C2=A0 =C2=A0 ne= w MyClass()(),=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= // string(8)=C2=A0 "__invoke"

);

```


For more details see the RFC:= https://wiki.php.net/rfc/new_without_parentheses

Implementation: https://github.c= om/php/php-src/pull/13029


--

Best regards, Valentin


Yes, please!

=

--
Marco Deleu
--000000000000afe4fd06159429c8--