Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123362 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 BC0F11A009C for ; Sun, 19 May 2024 08:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1716107478; bh=POZdvPaHf4UeHjgM5UHlkKnZ6BJfl2IkKBMDZmsvzK0=; h=From:Date:Subject:To:From; b=bLxkS9jQMu8G0zydNyWqaKdWPTlM4s2ziRizbYT4ikYutT+NPjI7kKKGTB9Bdmubm +d/Ak/vJat/SfV+6RL+yqsHTFFaoymijjijtFWoGLcIwNqXCHMuiHckieXYTYSNqgJ AuM4HNqwU7ifMLl/0ZLsYr07VJZiHE+E6id0FHG07CpUsHd1CE25RxhvaX3Q6OQ7J+ XsluPDadXyaxNTlqSmkAr4fpSGbsrNDmsSUGs6pR73Vyaf0aM8EoS2Avj4j/ARz3YE DhCzt3b3GaqdEjwjpXiAaHIXwXU4J1HcjqJL9hYP19THtsyWeysMPvlpb1ODRZXD/7 wcVGkjciTFkew== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CEB6418007A for ; Sun, 19 May 2024 08:31:17 +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_H3,RCVD_IN_MSPIKE_WL, 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-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.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 ; Sun, 19 May 2024 08:31:14 +0000 (UTC) Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6f0f7ec684cso939915a34.0 for ; Sun, 19 May 2024 01:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716107419; x=1716712219; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=5Mq9Yr3Osgoe7+TNmNQYemI6FrhuyAjolhneh6D4src=; b=CdXa7B53WymD8cjaQMF6sOERDk+NCGxJbdZ41Vbb2q1/wZKFMK+cCwsRv6LPPjrdfo AtiJrlZde1CEonZ2CSb3S//C6GmitGZiqHTBEGBKMhXGVrcn3Kj2BRow3F80Pf8VWzA1 aNOicw6YEVMDdvZaVyYjED2/UTe8TBfkGYxA27Bl6Di0BPuj37JB8/Y6tBjDqmPdLk7v P6aaTgQiWwTBzXldt+4yDcwwfxT4LJZVMCySPG3gLAHI9GPZxL3VnyQiCCxklPbXq38X moGRoSiKfiFltwSIi+sZ41zJPpq+90mXAF3dXlWX9Bc7x/ItCTkMIVUc2s6PrYLMj7Vs Ff6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716107419; x=1716712219; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5Mq9Yr3Osgoe7+TNmNQYemI6FrhuyAjolhneh6D4src=; b=dAI9dewH85xcea4UyGUUTtJ49YKERQZtyneTmwsBM3VVOE6XIuSgyWbkpKNYF8BR6c 9pFDrCiTJsdutnXHYUoOlmOb9D6ZIygkfrdkz5wICvjLtjL3wZVdDfY82wmfGOsX7dlT w1/W13Jl1jbshbi6LbgmgJKqweM91vTviIZVpDjmQ938vNExtTzjiVYCkqSNB2j0ls4S ad62eCTKHfDk180T/RGmo08DZrRQj/ZsAotRg4Qe2v1UqCoRkZzUBdv66gPYLVl2zQ/3 IdvcWCGWDu9vrOur8QxaopXhAmptpDTGG8a42OrNBk9rQaA2McyT7YiI64pRTi/p/YwT lU4g== X-Gm-Message-State: AOJu0Yzwas2gv2EZyPfeWaHu3SE+rN6bHAsdA1EjohR7ol8jOQpj3VGx FBpVILm4Tqn9PkOein4HX6O8eeHYF37GfWk4xP+DuPYqjCy9sEidZr0H9Iv732MTic3CvAMxV8i 3ilxzgizXN8nDP5eJekEhzL7fzuab9Tv/7SU= X-Google-Smtp-Source: AGHT+IH73OWoDW3WHWj552hCxzxHOpFVdATW9Fu2RB54OZmN+nnYaYdjIDZEJjwITs28a9wwhjJ1+aYRkfBRHx20U48= X-Received: by 2002:a9d:65d6:0:b0:6f0:3916:ab03 with SMTP id 46e09a7af769-6f0e910679bmr31553877a34.5.1716107418880; Sun, 19 May 2024 01:30:18 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Date: Sun, 19 May 2024 01:30:08 -0700 Message-ID: Subject: [PHP-DEV] [Discussion] Why can't I do "{$a::class}"? To: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000001954e80618ca653c" From: sarkedev@gmail.com (Peter Stalman) --0000000000001954e80618ca653c Content-Type: text/plain; charset="UTF-8" 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 $, which 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: ``` ``` 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 --0000000000001954e80618ca653c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Internals,

Obviously=C2=A0we 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 $, which = 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?=C2=A0 Consider:

```
<?php

$a =3D new A();

ech= o " {A::$static_property} \n"; // doesn't work (unless $stati= c_property is a variable)
echo " {$a::$static_property} \n"; /= / works

echo " {A::static_method()} \n"; // doesn't wo= rk (just text)
echo " {$a::static_method()} \n"; // works
<= br>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?=C2=A0 It seems like so= mething that would use `eval()`, but doesn't.=C2=A0 Take a look:
<= div>

I found it at the bottom of the manual e= ntry for Strings[1].=C2=A0 Not something I would use, but it's interest= ing to see.

Thanks,
Peter

=
--0000000000001954e80618ca653c--