Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129613 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 C84F81A00BC for ; Tue, 16 Dec 2025 05:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1765864562; bh=gI0ndxV9s7Jl+Q8TWQhH3FFJmm31hrhD6e6PEk6o1NA=; h=From:Subject:Date:References:Cc:In-Reply-To:To:From; b=U0TF40b1P7P1qvu7Xf+/KRnCVBnsXqf2Sh05y9qZIT66W1LZzMNU7qBceyMD8h0VV he5QFnkXr6mfI4zD5wIuodI9WkYLsueAl8hIasDdaC0/NwLd/exaY8/oOKDY8hquYc w1uD8WV9YrujViMih4N+T7VOJfStjjZW6l2n5WSDdg/KSwFKHMESzw17lr4EtjUphh +Xhe2WZUjUQRGccH55VvCVJUeQzkLfKet4mU2g9gS4SfTGFrLgBC1K002zj5pCJKKk I8pzKiFfeBxzzf4b6otQGtgBAmjmZj2xQoTrgGgwtHbCpw+nQu5RiHB2Y9VSnsNUnX DPiEcQBP4lyaw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 774E0180041 for ; Tue, 16 Dec 2025 05:55:58 +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.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,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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, 16 Dec 2025 05:55:58 +0000 (UTC) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-47798ded6fcso26726195e9.1 for ; Mon, 15 Dec 2025 21:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765864552; x=1766469352; darn=lists.php.net; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=9RoN9lMux2I1KU2MoZHUuaxoPy5cA5J8ng/Xj0UdUnk=; b=SahRFylVrIsmCANeZrKsz4E17dIBZf+xmKLBsWoEYFjur3ecTHYNNNGE+SED5y/zIF hT3vYimMcaXfxiNbH+df6APkuWyaeGQqJowuhdMGFMqUtNkj0CjyLWB7ZNsIOnioHiCk 5fwuEr+tt6ZCVyBvEZJkrtNUH3ImcVeDH5zu/gzlP/x0KwyBJ9kdtc8unTk1x0Mi3P4X 5UTreXr8rOCbkegNhKtaUC+Ud1pDpqlE7PXMqGbU0RBYY6CazaiTae/OIaUpI6k7dKt+ IdFMxERARMjIKWlvJHpyRsKwp6vVCspUZ9tCsebE7OlGfqH0ga//ZR6sL4clv6nEv/oU y6aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765864552; x=1766469352; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :content-transfer-encoding:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=9RoN9lMux2I1KU2MoZHUuaxoPy5cA5J8ng/Xj0UdUnk=; b=TmroxIASF/KVNL0WiwVdD60Zjp1Oh4kmTTmm6CgalcX5vydqh703dIwcEFgczw6O4A JW6YHIekiQ6iyalQzD8j5iiBHKF+/HuNq2hpkZMBd9yx9U70RTWiKLAlVBzL2jpaqwwV i8iTAy2XGynt7RHqVKFPYo8Gh283nSDrY2X0CfeIDjlkfRAdqHk44Kicp7/z1ESzyHj7 2NlYIh4o1PG4yJBNszrg4cewQzE19niIXjiT3ip6Np0tEHD/isrEvbRdMS2UGIMF9b0o IJTsORPJDGxrEC03VjtbydthYx6NBCXs4l566U7nY+b0nbts+CVdHRAbKpb22paZ/E5f XWPA== X-Gm-Message-State: AOJu0Yx4pEzX5atwWs+VPt9dNvOA2r7i4En78p9DPzAP2bZfMJahKdiW zhPF4dZfkIybl1SCLXK7UD04txSeKYkn4h3gm6sP/wee1GjtOa1kYxWRZldibggo X-Gm-Gg: AY/fxX5sP8WNElRekRpQ2ZFUq1yMwRNQMlKN8VRyDe+aMoUDhftQ4fnKoincIpIOEn4 j9rfBrIXPxvAxg8uaCD0wf/USyZHv01cPAdDVi+Fv+atWNSVy929Ib1/efft9e/GkNXKudQnZm3 lQiG+zL8q5xcWQEEraq/A8Ys5/ZT8TQ47yJa6wPI1VztLcTX3k+4QghYFO2+JL2Wl/UL81KyA/o UfRPr5xG0y67ayiEwswUYLJ6UiuHEeHVjovvE5CUE1BkVxeVqf2mmHk9VUMvjYwMgRX+SN6GJsG Y+2f/yt7u107C3gcI8dfM/MWV3MxXzr4FuRY075nAesfXFcNYxG4uV4zWDUUh2556/+6+mYG8dq e9cgLNmwBVQU0zCIgcIY68bHh1nGzxoGIs/L5mbunYUDje7mVhJiBRt7Vpi1VshcQURXKCF+4/+ suj2V7dgjd8tSZ0Qx4q46mC5M81hdmHw== X-Google-Smtp-Source: AGHT+IGtg8++R7ztOW6WtJunVXQlZlzsdGAnwJl3W0HbtoPXwcG5WqMdy2jPPKtckST5a4c9lZUuEw== X-Received: by 2002:a05:600c:4451:b0:477:7b16:5f9f with SMTP id 5b1f17b1804b1-47a8f9145c1mr138550595e9.31.1765864551693; Mon, 15 Dec 2025 21:55:51 -0800 (PST) Received: from smtpclient.apple ([178.134.17.116]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a8f4a3e9fsm222287405e9.6.2025.12.15.21.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Dec 2025 21:55:51 -0800 (PST) X-Google-Original-From: Dmitry Derepko Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (1.0) Subject: Re: [PHP-DEV] [RFC] Context Managers Date: Tue, 16 Dec 2025 09:55:39 +0400 Message-ID: <1BB46A91-C7F4-4F9E-A3A8-24B9DFC3DB3A@gmail.com> References: Cc: php internals In-Reply-To: To: Larry Garfield X-Mailer: iPhone Mail (23B85) From: xepozzd@gmail.com (Dmitry Derepko) > On Dec 16, 2025, at 1:19=E2=80=AFAM, Larry Garfield wrote: >=20 > =EF=BB=BFOn Thu, Dec 4, 2025, at 10:46 AM, Larry Garfield wrote: >>> On Tue, Nov 4, 2025, at 2:13 PM, Larry Garfield wrote: >>> Arnaud and I would like to present another RFC for consideration: >>> Context Managers. >>>=20 >>> https://wiki.php.net/rfc/context-managers >>>=20 >>> You'll probably note that is very similar to the recent proposal from >>> Tim and Seifeddine. Both proposals grew out of casual discussion >>> several months ago; I don't believe either team was aware that the >>> other was also actively working on such a proposal, so we now have two. >>> C'est la vie. :-) >>>=20 >>> Naturally, Arnaud and I feel that our approach is the better one. In >>> particular, as Arnaud noted in an earlier reply, __destruct() is >>> unreliable if timing matters. It also does not allow differentiating >>> between a success or failure exit condition, which for many use cases >>> is absolutely mandatory (as shown in the examples in the context >>> manager RFC). >>>=20 >>> The Context Manager proposal is a near direct port of Python's >>> approach, which is generally very well thought-out. However, there are >>> a few open questions as listed in the RFC that we are seeking feedback >>> on. >>>=20 >>> Discuss. :-) >>=20 >> More updates to Context Managers: >>=20 >> * We have added "masking" for the context variable, using essentially >> the same technique as the block scope RFC. >> * We have added support for `try using`, as a shorthand for when you >> want to wrap a try-catch-finally around a using statement anyway. >>=20 >> More details of both are in the RFC. >>=20 >> As no one seems to have a strong opinion on `continue`, we will most >> likely proceed with the current approach of matching `switch` behavior. >>=20 >> There doesn't seem to be much interest in making `using` an expression, >> which I find unfortunate, but that means we'll probably drop that. =20 >> Fortunately it is probably possible to change in the future if the need >> arises (the way `throw` was changed). >>=20 >> --Larry Garfield >=20 > Since the only feedback on what to use for "as" was that =3D> makes sense,= we have changed the RFC to use =3D> instead. So the new syntax is >=20 > using (new CM() =3D> $cVar) { > // Do stuff here. > } >=20 > --Larry Garfield I=E2=80=99d ask you to get back to =E2=80=9Cuse=E2=80=9D keyword, despite of= it=E2=80=99s in use in Laravel or somewhere else.=20 As a developer I cannot even imagine what =E2=80=9Cuse=E2=80=9D could mean i= n web frameworks context, I hope it could have a better name and at the same= time we can advise to use namespaces if you don=E2=80=99t want to get somet= hing broken after upgrading language.=20 Just my 5 cents.=20 --=20 Best regards,=20 Dmitrii Derepko.=20 @xepozz=