Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123461 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 C13331A009C for ; Wed, 29 May 2024 20:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717015497; bh=vQwa0kTZsXLO1cpYRNUb0MbUGVJnQ016ADexn3UW1/g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SOf4gz3u8njZTjEK1tHsMUVjjV2PsZqobIJNa8ND9VntIx+HS3FWoriGBYxpt2ur8 ztXmgznpVMdD+neRTKnatKYkq8uNcSUblzwZSmaeLbVVBCUz+046iI6P/KLEZAMaXF +xT2njkzh9OjCkiiYOKRFMPkB6XzE7yOgUDoQe4LZ06O/N8IGvhWQbvDdQjnVFjwLn Xj0r94w8Uzzmbntg1DAn6k+nhwKdI+DAML9TC/t5ugIsbcSRIfi3rG9N+Lb3oY7ng9 ciYHGRDfyD8LEJKdSLY4MR+wyp30kk9B9YvG0Z1hWXN6GkiNLOZ3TVj99N2p7ze0q/ teXBocj6JG3uw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 324E2180BE3 for ; Wed, 29 May 2024 20:44:55 +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-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 ; Wed, 29 May 2024 20:44:54 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-357f1c0b86fso139752f8f.0 for ; Wed, 29 May 2024 13:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717015433; x=1717620233; 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=XHzuj66c+0q5cik+Oi2lbK1H8ZqF+SwXWGgsIsA9PhI=; b=JmVeYq66KDK9GMQMzSJ7IIWEfIOMBdN7pIbqABPM3kShQVNHkHVnFMXTI/zoYbAvly z5PdXQl+IZwrLfADsLOkJVj5a88Jdce311jKdo+u2Wl7oqqXkTmjzv+wWAiu5g9koVhw laIlcqb/4Bs4xabCqVVGLJiZeXLv9T20hUSA0XElr60kwfQeg0aY1NzT41WEUjMsAC6Z 1dMYYNJa1lo2gFcYqWNOOyf3kWlMTMqHBPWpgdNRGYkOr0GXeIZBtTXW6maz2bD8CnMb VFxIm7+UnjbTsePxAIfPNiJq4QXd6sWUO2YrnSXIDNz5N/FB066OJHdtDGPe0RnwNtJ/ pyfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717015433; x=1717620233; 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=XHzuj66c+0q5cik+Oi2lbK1H8ZqF+SwXWGgsIsA9PhI=; b=o+g3V8uLMtMeiaSOMaTaTYy6VlH7+wksTXjBIesMiPnJaRIpK8uWFAjnKCjB2dYABq uMrF129bWtjxU0nCQeV8iFPB1yhfyjVuatkOch4TrhuYS1fIet/0xZxLvKv/+bKxWqp+ e+Wu/TwZfaKl8jT068JolJq+gcKwZwU1a8GvZQ4wSlu+JQTSySmKGt3F8eesbWoqaB1k xKGE1++95Ed+f6c8Zc2e5Pem0oEbqnpACqtuegYdU6n/+LJcZqJZtOJ4ZUHAYCVMrkYU WOe+GEYDZMuawIaxHdS2AhMSDrOC+v4DF696vCWd+fUC6yfy7xZDDnBJV9pDZRjCrQPl qZqQ== X-Gm-Message-State: AOJu0YxCxh8Ypvt9DTSe2P1zZ58NCJ5+8zSLNLJqr+v0HSmgGpXVVfZq 1wwY+unAmHuSRpMkEPWNdnZUV73ei2rLH/lRtG19/EoMjwnOT3H8SYQK3Qld+VmKfqOEiKtobSM yCbAp51nGdKEVaaHgzb2toSfdGQ== X-Google-Smtp-Source: AGHT+IEQZbiiiWnl9o2rdGz/faXLaqnOzOeGnLHb514fAgZfkpRjjgZN7KARXyv95GqiIgVBHIeT+O/tHgac2k3Vyww= X-Received: by 2002:a05:600c:3147:b0:41a:c170:701f with SMTP id 5b1f17b1804b1-4212792f8d6mr3030745e9.38.1717015432615; Wed, 29 May 2024 13:43:52 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 29 May 2024 23:43:40 +0300 Message-ID: Subject: Re: [PHP-DEV] [Discussion] Why can't I do "{$a::class}"? To: Peter Stalman Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000ef5c2806199dce60" From: udaltsov.valentin@gmail.com (Valentin Udaltsov) --000000000000ef5c2806199dce60 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, May 19, 2024 at 10:30=E2=80=AFAM Peter Stalman = wrote: > Hi Internals, > > Obviously we can't use constants or functions directly in strings using > variable parsing, I assume because it lacks the easily detectable $. > > However, we _can_ use methods because the object variable has the $, whic= h > I assume is the reason methods work and functions don't. > > I feel like it's something that _could_ have been added when dynamic > access of static members support was added in 5.3.0, but maybe it was > overlooked or decided against? Consider: > > ``` > > $a =3D new A(); > > echo " {A::$static_property} \n"; // doesn't work (unless $static_propert= y > is a variable) > echo " {$a::$static_property} \n"; // works > > echo " {A::static_method()} \n"; // doesn't work (just text) > echo " {$a::static_method()} \n"; // works > > echo " {A::constant} \n"; // doesn't work > echo " {$a::constant} \n"; // doesn't work either, but why? > > ?> > ``` > > > Also, as a side note, why does this hack below work? It seems like > something that would use `eval()`, but doesn't. Take a look: > > https://3v4l.org/aPCSD > > I found it at the bottom of the manual entry for Strings[1]. Not > something I would use, but it's interesting to see. > > Thanks, > Peter > > [1]: https://www.php.net/manual/en/language.types.string.php#91628 > Hi, Peter! > Also, as a side note, why does this hack below work? It's not a hack. Variables, including callable ones with any arguments are allowed to be interpolated. See another example: https://3v4l.org/BJUvL -- Regards, Valentin Udaltsov --000000000000ef5c2806199dce60 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, May 19, 2024 at 10:30=E2=80=AFAM = Peter Stalman <sarkedev@gmail.com<= /a>> wrote:

Hi, Peter!

> Also, as a side note, why = does this hack below work?

It's not a hack. Variables, in= cluding callable ones with=C2=A0any arguments are allowed to be interpolate= d. See another example:=C2=A0https://3v4l.org/BJUvL
<= font color=3D"#888888">--
=
Regards,
Val= entin Udaltsov
--000000000000ef5c2806199dce60--