Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129467 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 E2F561A00BC for ; Fri, 28 Nov 2025 08:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764319536; bh=fzjC9OZv3bewDXlYeMq4FNDo7gWK4+Rwiw7GIFcNO5I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IQE0vUZdj8FAy+E6IEDTH/+MBZOBlrtGS2DUc0baav4ULUsjKt8SegJlEJSPKZJr4 EI/68f4ffiERP2Wh1V4fDeqg/qGm6LI19jBwbhYp6c+Nb1wySK5r02icyGAkqRVGAg AZe9843oWnuU7kxn4g6i1whIhupJ4h5bPny7r/oWzQx2YOMB7jILJkNSLsiSSrqN3N OtFOsmZZQiLb9VOjMwLYrdGkZYWW2CnMs9K6fd4uMug1BpMR+ATEubcZ9Z4aVU2FxA m1AST1HJ0OdMEhuovgtkHoO2Lcdj1eN11ZCDStosCcjysrt2M+QisdLeLwjLvJDmOI G9uirYTP9CRbA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 59A0118007E for ; Fri, 28 Nov 2025 08:45:35 +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.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Fri, 28 Nov 2025 08:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1764319528; bh=63p75yWpK8bJyDQicC4jAC+w9AjKegdmPgh4DSeT5/s=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=By4IUIywRhDB2zrZFbVSNFuHyXTT5eHPhVPJiuef8SYdVLfR6a7mUmlCrZulW75jA 9hbEepN/qZP7vzcXcFr8cSTWmX1Er4Ib+Jy034jB3IdaZ1196/HNAXpI4IqEO3y8Dh zOoDs50U/Yvrnq+yaC+nUJAYv2Jhfc4RbvDBaZOL/jLDzKYa1bJAd8pxQo8iQ2m7Hf 84tW66S4UUeUkrfuhJiIJ123kJghy0ubSY7J8oCbTt26nvUvX95/heTlER+VikaB8E uO4Fky7fTBKHiF2hr47CGdwVnKKc09Klsj27eL09Z9sBZ2lKOQ99fQE6uI4JND09Ff jVd4Jon39dzvA== Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 28 Nov 2025 09:45:28 +0100 To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Context Managers In-Reply-To: References: Message-ID: <4cd2ddbea516f91bf258b9f223c62296@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-11-06 00:27, schrieb Rowan Tommins [IMSoP]: > I think you may have missed the key distinction between a "Context > Manager" (as designed by Python) and a "Disposable" (as used in C# and > others): the Context Manager is not the resource itself, it exists only > to meet the protocol/interface. > > In this code: > > with ( $dbConnection->transaction() as $handle ) { >    $handle->execute('I am in the transaction'); > } > > $handle is *not* the value returned by $dbConnection->transaction(), > it's the value returned > by $dbConnection->transaction()->enterContext(). For reference: This topic was/is also discussed in your sibling thread starting at https://news-web.php.net/php.internals/129464. I also stumbled upon this being completely unexpected from just looking at the code. If multiple participants on this list with a above-average knowledge of PHP (or even engine knowledge) find this unclear, I am really concerned about the clarity for “regular PHP developers”. Best regards Tim Düsterhus