Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123179 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 BEDCA1A009C for ; Tue, 23 Apr 2024 11:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1713871149; bh=aXgO+I0/w7OE8RG+HFnH/qwjGdORdbqhnHEcEMz1tRk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=WiQSUEzU5jLbmCS+H707CY/G0b9qBOEw1o2qi2ftut6mL7ejJgRpx+o0R13yLKc0N nR4bymCFsaS4SiKhuResOabVgDTY9jzwOQRp5wUNSYmvjUFwCA+EQ20GiuUxsLi4fU Hs6vM0gqrlZTKLDgI8VPrht3EMTnZrnZblrHIAJTREC8C8a6o48ifqrjsGXu0Zxkm3 Wulazv1olVN74L8IVldzOR3Z1SvLIe//EEn40IBDERT7EaJQkb+x2cGShHLTNxJjBQ k6bMe0FjOnEeZ5c7TqHx8l4kv5XpLKMqa/civDFED0P0zE+kX1+poiUAxm/KHmUqcp 7W90aq75WM0Dg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 83BB8180546 for ; Tue, 23 Apr 2024 11:19:08 +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, 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-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.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 ; Tue, 23 Apr 2024 11:19:08 +0000 (UTC) Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-51b09c3a111so3487561e87.1 for ; Tue, 23 Apr 2024 04:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713871106; x=1714475906; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nouhOaR6XblOmC1wvHCV9Htvo2cfvySb+QN47qE5Occ=; b=bMG+ipukBSTQSS6zohDRjN4AgTi3MVd6+rIpW3x55vbKfLDLSd2GqYIJMbLe32rPd0 ac3drahcCLSe/SvdFHOB7QgntjnEAZTvmrly5ntXMxcVN2kfHyJpkKiWosa7t6q8f8n2 t8FJdOGe7wjJkZClRe6GaqKeLef4wt8d8mEL1tOMx94HfSZ79yxlSGohJLdvLdk7PQj0 BQvGW1DQVTpGygsIli6prIG0WbkU/F0YARIwvu5x5ILhyb1gpQ1MhVlUjTclKJ+TMrAu FRKVnTBvR5HoSKzVubEyIUqGbNhoUj5uruLa/too8F4IYaWrIOVhnDde9HvGVoW8kElU QITw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713871106; x=1714475906; h=content-transfer-encoding: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=nouhOaR6XblOmC1wvHCV9Htvo2cfvySb+QN47qE5Occ=; b=pkAtSnO2woG4UBi3owx6AhqJwKHyE4xMCXYvk1Oc16nogaffJgv1uKof3eJ2A0WI79 O12IWbPB5D5TBxPT+9kha461Cr+5euP9FTxZUBSvruivLPScqxnD10H0Gqp6Y4O4FQK2 4/Fie1cwnFR5O89dxPAl24f+1hQThVE7bI5cGNiSSaGzjAuN3hQirB5YqFI34ehqxxUP yx03Thpm4kurIk4Q+C/NX7NylrLGFADiHwZ34UEyNtX8PUQndnFA+apN4hMbt2JTnF5H aeg7hlpeI6y/iUQwmXmzlfJoQFHGZS8HfBFcgjvQT3jeVPddjjK26F/XjFlxg3VjpBTW B6hg== X-Forwarded-Encrypted: i=1; AJvYcCXcdX4pj2YJiKjkscDTu5x5bPHQ6ZIcUr6PuxcvSWR3oYy/aJbr7LC8/ovs+NcNj9w3RmEGCtxqRfjM0uiAIN4UfamHcxdTXQ== X-Gm-Message-State: AOJu0YxK7TMAV9nESyUyJS4amhHzBW+LftsssBTgcpMSVFHLtBmKZw1B P/qKwIW+gV9gblRHJkFVszMqtjxIB9jNCFIh+lXBO8EnUEj8NBWE2a8FIVU4w7Kp3O7XRMcteS3 lBdZfc7Z3zT9tWB9D5RKEcLoevRc= X-Google-Smtp-Source: AGHT+IEO1kIBJTZvY93Sg5gw/QuZL6Q8GzPFOot9u25OiqG51JEKGjfxVLKX5IoqVqorLdqq5w5S+EHseXwPh00RCWM= X-Received: by 2002:a05:6512:3281:b0:516:dd4f:d9ea with SMTP id p1-20020a056512328100b00516dd4fd9eamr7500851lfe.5.1713871106305; Tue, 23 Apr 2024 04:18:26 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <0466054f-bbec-47fd-8452-e848ebec7ec9@app.fastmail.com> In-Reply-To: Date: Tue, 23 Apr 2024 13:18:14 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] new MyClass()->method() without parentheses To: Valentin Udaltsov Cc: Larry Garfield , php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Tue, Apr 23, 2024 at 11:10=E2=80=AFAM Valentin Udaltsov wrote: > > =D0=B2=D1=82, 9 =D0=B0=D0=BF=D1=80. 2024=E2=80=AF=D0=B3. =D0=B2 19:41, La= rry Garfield : >> >> On Mon, Apr 8, 2024, at 6:08 AM, Valentin Udaltsov 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 expressio= n >> > 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 'staticMeth= od'; } >> > >> > 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_par= entheses >> > >> > Implementation: https://github.com/php/php-src/pull/13029 >> >> I always thought there was some technical parser reason why this wasn't = possible. Maybe that was true in 5.x but isn't anymore? >> >> I cannot speak to the implementation, but I'm all for the change itself. >> >> --Larry Garfield > > > Does anyone have additional feedback? I'd like to start voting on Thursda= y, April 25th. > I've also added a section on other syntax ideas that have been expressed = on Twitter and in the PR: https://wiki.php.net/rfc/new_without_parentheses#= other_syntax_ideas > -- > Valentin I suspect this will break (badly written) reflection in interesting ways: https://3v4l.org/mcSNH This basically breaks dereferencing order of operations and makes it inconsistent. Robert Landers Software Engineer Utrecht NL