Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126240 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 EE87B1A00BC for ; Thu, 30 Jan 2025 15:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738252068; bh=loCk4d51ZHuqgTQmtYL9JIF91S6DZzbxzjEM0ZVFuAg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Q9FA5bunC5zxkJv3VzJKYhpwIHvWpwA/zxafciwUEx2l5X7RLjwz4DShA2FJYK8fu ja2p0U8oiHjdib0CBepufvV0RRJk+IfiABsYfRCJklfnXcQJt8kHQ2sqaGdwLVj2bt HHDtuCBoo1GmAl6fukfwLYNxBwC8/7Aw/hvah9rkla5MACFAKyVoqDBM8tumjo7b2V 7hbDxXk08XU6ooWiSwlqx4phfYLWk+8sUOW8GBQ9sDFmymJFKuxeM+ZipGOn4le5Xx mZPuLTjevDKqq7gOoR64pOJIVBH6gdYkMkGjM21yCamtiFBaZw0nG5LXjW33aJavTz C20fpGGVzX1RQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 30F27180047 for ; Thu, 30 Jan 2025 15:47:48 +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,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 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 ; Thu, 30 Jan 2025 15:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1738252230; bh=qDcIKCN/147P0p6crnzxAngWKSz9g9s0BLbb+UxRhm8=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=LJ0BRcY/lYAUL84kNpBDdmDue4qSzhEb0Tafcagk+fk1vfUrKnS6H1564LI8VKzxY 6p/80j1AJSEo6P6TqMXtY1KLkutISFmQu/enKkZzrDGfMFNdabXLbZEdFbZQqoZ5UA tRqsAK4Npm1AikigsmYBr+9eJKeGsIE1WnAANW489uPC1fGmJ7ti+iVJE1aFOV0PqJ wo0VzjB37rWj8/2+ZcVk4scdJ+CCVukVHTVOmNqDaNEqHWz4K5BEVuBt6z/CUePKVL vzdahUq8uHIwUHh0NVTnZFo0wD6WEER/s3GbeTvDOpLBHortmLXnuUbS/QhkxHH9o3 u/6YXeU4lHi0g== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 30 Jan 2025 16:50:30 +0100 To: Rob Landers Cc: Volker Dusch , php internals Subject: Re: [PHP-DEV] RFC: Marking return values as important (#[\NoDiscard]) In-Reply-To: <3b4d9be8-9255-44ab-95c5-ea3045212cf4@app.fastmail.com> References: <3f170549-cfd6-441e-b892-cf51d726dbe8@bastelstu.be> <3b4d9be8-9255-44ab-95c5-ea3045212cf4@app.fastmail.com> Message-ID: <412ea440edbfbfc10be2e39497648ad6@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-01-29 21:16, schrieb Rob Landers: > I understand what you are saying, but I can also just remove the > warning via: > > $_ = outer; Please note that `$_` is a regular variable and thus will increase the lifetimes of returned objects (and arrays that can contain objects), which might or might not be observable when implementing `__destruct()`. Also note that OPcache will actually optimize away dead stores if it can guarantee that the difference is not observable (i.e. if it knows that the function never returns an object and if `get_defined_vars()` is not called). Of course it would be possible to exclude `$_` from this dead-store optimization with PHP 8.5+ to allow for a smoother migration for libraries that require cross-version compatibility. We nevertheless wanted to offer an alternative that might be less confusing than a “special variable” that might also conflict with diagnostics like unused variable detection. > […] It also happens to make the diffs more natural looking when and if > the return value gets used during a code review. […] Can you clarify what you mean by “more natural looking”? Best regards Tim Düsterhus