Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123031 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 3D7831A009C for ; Mon, 8 Apr 2024 06:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712556539; bh=llK0l8FYAD1Qzajnp7LcI5+ydj/eqji7qpEZB9ExEU4=; h=From:Date:Subject:To:From; b=cY/9Rj/jmXwDIG12dxFO8VIiDI/3NIp+WwEgYfNv/m7JsNRwuHfsWfPLTl6+tqHBU KANNlhhEu5Qd437ZMWODwTH/Rww5Xn3SjTyMG2m+RKWpAoThOLZZMq25OAnXoAkCvG Cthp4DRrM9GPbSRBl6ynCMjCuTHlBEcvr+ywgtGnAkEeW9WTQwdvdTxl+tsOC5Zxc0 tlS8t+FYm5iU9afhAFzvbbJFd67uUM0pQh92GqiD9TNJBpDUZBW+KS1j1EkiJZSdkk VRJzF7VXiwxwMLilRKxJt2a6zuI0SSlwG+IBXID48FNDCg9RWmSXul7yx/CVv7g83K eLlQcnXSpsMlA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 67AFA18006F for ; Mon, 8 Apr 2024 06:08:58 +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-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 06:08:55 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4165d03308fso7779675e9.2 for ; Sun, 07 Apr 2024 23:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712556502; x=1713161302; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=wXzz+uzjKuFBQ+fo0YMjiDRC8pjT5ShRXLS+3yFQTcQ=; b=ivqfmv4t8ph3JrHAQUE252ods9vyfYejw1R2QaLZ0HU/UxYcJgfRlEgtpmpbYSIttZ e+pDTNpZMg8m7L30Sk+VMboUotPjTRtMKN/iJkOvUL3LLe+1A6YTNWBHJ1jOofXIXsSt gghZNF4QNRZd7HC3FM1HX8PrYV+SxOR/pnMnhC1MLsYimwlaLOdi7Nj3HE4Z7CGDo9gk GEZml/CWZdcWvj6TOnCxYw3t11mdCj8ATzBZMvKEM4cxCFGYsBO6f8i4ApvO3w3G9TFP JQQFNxUesOqKdwb3eGG9aNcYvYI+K6/kIwqEnPi5aEjLwba/0CY7cYC1NR1HurHf3sk6 GJXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712556502; x=1713161302; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wXzz+uzjKuFBQ+fo0YMjiDRC8pjT5ShRXLS+3yFQTcQ=; b=nmk5pJFHaWcpbjhQpYYnTwLyxEjd+RBg6EiTB4Xxfs7uZS6XcmYPs6fBugLAu/LLOp khSHfxvkE656zrEzhPj7TBeMd614iL5+cyFkgyu08/tU8sUPeyh82Pr54JtfQ1X8VRp3 gLPTIFd0MTlfcV/fQPEmT/NPb0Iwe3oE8FKaotRgVYBaU6fDjguRflFUOUUJufwnt4k/ UxREd3AKW/aMz/qDo17gPh+yE1YEC/bZwWyoa5r9nN7s3B3Z22GmqHrYn5OiTY7Rx2Je HCDj5aU3cY2sODA8ALpgNpkFKF90vE5nWmdhF0jLlX+ZOKIsCbe5mM5mTnJFXvtbBqNS X74w== X-Gm-Message-State: AOJu0YyhRrWax6sYkaMGdN8SH9USsbZSfWwmSR/8/Zrn8EJZeRrs/r1B QHB7kMk2Oq5v76ylO0ZbOln1xX5H0blzPMQWFWZOYImV957KMowNd9s1yWv+gPW1Us9Mz/nzalE XKnT3yRnAPVq0+/iYzTw4rbsNTVUxcmCUMAG9 X-Google-Smtp-Source: AGHT+IH6K7J8fGK1/JN/Pb0nIsv1ZXeEP47xk9gRBygvE6+GPGNByB+iOGUsbqtTnCekDZXZieYv2aTVzY16KuZ4EUs= X-Received: by 2002:a05:600c:1c95:b0:416:7233:9d1e with SMTP id k21-20020a05600c1c9500b0041672339d1emr1501735wms.28.1712556502090; Sun, 07 Apr 2024 23:08:22 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Date: Mon, 8 Apr 2024 09:08:11 +0300 Message-ID: Subject: [PHP-DEV] [RFC] [Discussion] new MyClass()->method() without parentheses To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000f70afa06158fa101" From: udaltsov.valentin@gmail.com (Valentin Udaltsov) --000000000000f70afa06158fa101 Content-Type: text/plain; charset="UTF-8" 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=70549 - 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 = 'constant'; public static $staticProperty = 'staticProperty'; public static function staticMethod(): string { return 'staticMethod'; } public $property = '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 --000000000000f70afa06158fa101 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hello inte= rnals,


I would li= ke to propose a syntax change for PHP 8.4 that allows to immediately access= instantiated objects without wrapping the expression into parentheses.


This was r= equested and discussed several times, see:

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

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

- https://externals.io/message/10181= 1

- https://externals.io/message/11395= 3


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

```php

class MyCl= ass

{

=C2=A0 =C2=A0 const CONSTANT =3D &= #39;constant';

=C2=A0 =C2=A0 public static $stati= cProperty =3D 'staticProperty';

=C2=A0 =C2=A0 public static functi= on staticMethod(): string { return 'staticMethod'; }

=C2=A0 =C2=A0 public $property =3D= 'property';

=C2=A0 =C2=A0 public function meth= od(): string { return 'method'; }

=C2=A0 =C2=A0 public function __in= voke(): string { return '__invoke'; }

}


var_dump(<= /p>

=C2=A0 =C2=A0 new MyClass()::CONST= ANT,=C2=A0 =C2=A0 =C2=A0 =C2=A0= // string(8)=C2=A0 "constant"

=C2=A0 =C2=A0 new MyClass()::$stat= icProperty, // string(14) "staticProperty"

=C2=A0 =C2=A0 new MyClass()::stati= cMethod(),=C2=A0 // stri= ng(12) "staticMethod"

=C2=A0 =C2=A0 new MyClass()->pr= operty,=C2=A0 =C2=A0 =C2=A0 =C2= =A0 // string(8)=C2=A0 <= /span>"property"

=C2=A0 =C2=A0 new MyClass()->me= thod(),=C2=A0 =C2=A0 =C2=A0 =C2= =A0 // string(6)=C2=A0 <= /span>"method"

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

);

```


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

Implementa= tion: https://github.= com/php/php-src/pull/13029


--

Best regar= ds, Valentin

--000000000000f70afa06158fa101--