Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127438 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 lists.php.net (Postfix) with ESMTPS id 93AD51A00BC for ; Sat, 24 May 2025 09:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748077613; bh=3zPVYLkPT5Zco25E1zJIxgEfc7ziI9CQGzDsADmV2HA=; h=From:Date:Subject:To:From; b=QKlLeZBRMyF122QZrcAbebBaeKVeG96FAlw7Rd08JQ0lScx0PnerVXsA0BTz6gkwN 6yTZky81Dn644JkEQuIQsSj/E493MW6Y8OQe7nAaCzFig2nOHuQ1Ya1Qf7rV1OFuKJ iZkynbh3dKKncLllVGDwoLprWg+GpibeWkqr7s1lRfZLELsYmGkxjZYOWiwJpffZQt CbuM7Cd0o3DHgaeGci0gqFFXipE8Y1fBYRfka/6vWHqdvDNn8NhuCiILUtGzaDMvQl tPs5lX5namVZmYurrzcbsMO9qvDXQvKhVlrSuvSCPDqIY/SWvs9Brg/qTFGwcHREPX QvjFkE3Vdr9OA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 04B1D180057 for ; Sat, 24 May 2025 09:06:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) (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 ; Sat, 24 May 2025 09:06:52 +0000 (UTC) Received: by mail-ed1-f67.google.com with SMTP id 4fb4d7f45d1cf-6019b564d0bso1226573a12.2 for ; Sat, 24 May 2025 02:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748077739; x=1748682539; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=cqZoZ1SCLmHWQgCwmF5LET7su0zun/hv7SM5EsiPBFQ=; b=cKO/Elr/ZDGipaX5bWwq3Pewqv1Ivk7OkVce8EYm0jDiK39f666YqNMaoRS3cC1S68 GKF03xZ0h+7cTIF5I6psZqLQNFuFUYvxo75UIuXAxmjrZdPvTEwiQZ+u5u3xQVxHakAi h83wAcdrOvJ+utEzDiD/medcHDkmplL4xBy2NkB5pi0qK3LgL2BRGr1w8+aSQ2ieTkZ8 7bBoZvRYTW+TMpGQmwPt1TxzKND+/8oDVHfqL5rKF9owepSYpVeMmOzRCXk/lwFWOZNU RHjaO1zPQumyis8eGMjbYYcqOVo5G++0XwxAqkn0qkKgTsuXVMOL0rR2rTdtEOzzqMZZ cR0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748077739; x=1748682539; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cqZoZ1SCLmHWQgCwmF5LET7su0zun/hv7SM5EsiPBFQ=; b=WW9erUbWXEqXSocqzqCD7horg9u8SFyfkMYR2lcBTSDIZLzJOsjJkYe0WPswOUoHhT wHpa01ucIpwfaxvswrTOum41nwnlhuGWIfZP1z3xXVs15AMlzGZZsaxBwK88OrubO0jS 2Amh5hQMFXvaYEgNyc0fdYFhg1LG64nJtivGm9MeC+Wkap8a8KvSADd/WJkqMG6p/03t 73yJoLVciTmyR5pTXPgjAyaTuMGxVxzJ1IUFQC6bdT9VtsZ4BLkfAfM8ChE+p8bEyd6r vCaQFXeI+3nG3wORMwi2pnuDa5NIh+7Vrqw2/9U1H8tOCXcScbRf5jnQqe07RTPiBl+8 o1CA== X-Gm-Message-State: AOJu0YzlNncZZ609NZQ7OfUYroRYx3IMDYPoyrn0pA3DRTyvmfF49Qin ER3wVDfbqJ2JPVIDz+C+oIG97kY3fYbWMsa5QXoJ40GQnPjTj0GHc+3OoVKkE9Jojft5Ntf/WZi MSRSRYLBnfrISr6cq7H3cY6MAR91bKwuSVbDJsyc= X-Gm-Gg: ASbGncu6EDBSrc4ak3IDoWsIZq75qaJJ174YyisdphDeJ6bE2bIY6Vbl3i29miv/55V GLU+NqmVmwjY2iKt34g5HfUBA/O8M+jSNkHvW9GEq6+zyAZEpRKFFnitYgn2e6y/ugwSxtQwAWb unyuMpgG5uI1Iz6N8eMXTLe9Z4IbmD5kNYQg== X-Google-Smtp-Source: AGHT+IHHeWfAkABV2w7JpzbWO6xxL+a57UU+R3DbUEbmjKqbEOd4k3CtK7yIYzgbWz5Ce+ehE1M8JllnWHIDHSDTFII= X-Received: by 2002:a17:907:3d93:b0:ad5:42bd:dfab with SMTP id a640c23a62f3a-ad85b1300e6mr187799466b.30.1748077738870; Sat, 24 May 2025 02:08:58 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Sat, 24 May 2025 17:08:46 +0800 X-Gm-Features: AX0GCFtlkD1C0TKfWqu2rFjX_TEGnYYeE-gr3U_wFckmXclIiFuk-1sMylbUa_o Message-ID: Subject: [PHP-DEV] [RFC Draft] Introduce with as an alias for namespace use keyword To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000aa4c970635de1069" From: a766650827@gmail.com (=?UTF-8?B?6ams5q2j5by6?=) --000000000000aa4c970635de1069 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello internals, I=E2=80=99d like to propose adding with as a full alias for the namespace-r= elated use keyword in PHP. This is a purely syntactic improvement aimed at: 1. Clarifying semantics: with better conveys "reference/borrow" intent (e.g., with Foo\Bar vs. use Foo\Bar). 2. Reducing beginner confusion: use currently serves dual roles (namespaces and closure captures), which can be misleading. 3. Aligning with modern languages: Similar keywords exist in Dart/Kotlin (with/import). Key points: - Zero-cost: Lexer-level alias, no runtime impact. - Fully backward compatible: use remains permanently supported. Example: php // Current syntax use Vendor\Package\ClassName; use function Vendor\Package\functionName; // Proposed syntax with Vendor\Package\ClassName; with function Vendor\Package\functionName; Question to the list: - Does this improvement warrant an RFC? - Are there objections to the concept or keyword choice? I=E2=80=99ll proceed with a formal RFC if feedback is non-negative. Appreci= ate your thoughts! ------------------------------ Proposed by: [xiaoma] GitHub: [https://github.com/15892951523] --000000000000aa4c970635de1069 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello internals,

I=E2=80=99d like to propose adding=C2= =A0with=C2=A0as a full al= ias for the namespace-related=C2=A0use=C2=A0keyword in PHP. This is a purely syntactic improvement a= imed at:

  1. Clarifying semantics:=C2=A0with=C2=A0bet= ter conveys "reference/borrow" intent (e.g.,=C2=A0with Foo\Bar=C2=A0vs.=C2=A0use Foo\Bar).
  2. Reducing beginner confus= ion:=C2=A0use=C2= =A0currently serves dual roles (namespaces and closure captures), which can= be misleading.
  3. Aligning with modern languages: Similar keywords exist in D= art/Kotlin (with/import).

Key points:

  • Zero-cost: Lexer-level alias, no = runtime impact.
  • Fully backward compatible:=C2= =A0use=C2=A0remains perma= nently supported.

Example:

<= div style=3D"margin:0px;padding:0px;border:0px rgb(224,224,224);font-style:= inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-= size:inherit;line-height:inherit;font-size-adjust:inherit;font-kerning:inhe= rit;font-feature-settings:inherit;vertical-align:baseline;display:flex;back= ground-image:initial;background-position:initial;background-size:initial;ba= ckground-repeat:initial;background-origin:initial;background-clip:initial;h= eight:2.5rem;white-space:unset;word-break:break-word">
php
=


// Current syntax  
use Vendor\Package\ClassName; =20
use function=
 Vendor\Package\functionName; =20

// Proposed syntax  
with Vendor\Package\ClassName; =20
with function Vendor\Package\functionName;  

Question to the list:<= /p>

  • Does this i= mprovement warrant an RFC?
  • Are there objections to= the concept or keyword choice?

I=E2=80=99ll proceed with a formal RFC = if feedback is non-negative. Appreciate your thoughts!


Proposed by: [xi= aoma]
GitHub: [https://github.com/15892951523= ]

--000000000000aa4c970635de1069--