Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129162 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 B723B1A00BC for ; Sun, 9 Nov 2025 14:27:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762698432; bh=lwHiMmnJJBEbjwy8TgGnLF+byODwbyKvCNTFhESNoms=; h=Date:Subject:To:References:From:In-Reply-To:From; b=kLLRw/dOITHJAJ64ch2WgZsIyCyO+OXREfNqSLLe+lk4zbafbjiPNe6eDUO06LFXW YgQtZPpngHqomu5Q8mI9d/18btj9wmVDpHkTMjOHetFRndREdz1dKscJ2FnLiXYFe7 qUtrz1zGCVyB9l5x9DTYh+FusqUyPeaKdoVnw3YpsoYSZ7rnC/ZcP1XQb3dphLBV4W A8veOWuUO7tJOb5+nAJQ3awscR41fp56RomN6Ypme89XaTNDVBnk2SO6kvzeq3krS+ t7eNRPFAGmS9+gWAfYndHYMEPHqoJyTN6sLmFH2hrzMxXEEMnmkCv8WuTpz73ER1l0 VsgdxPopZwETw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 53DB218002E for ; Sun, 9 Nov 2025 14:27:11 +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_40,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 ; Sun, 9 Nov 2025 14:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1762698424; bh=tTuqajr6f3EEn2GY3tQKvbPr0ZyM1Oap9YxBXXN4104=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=moFmbzZlfdwGswLSV3heQsgALJ0UsNHSBx9PA78uKXsRiKCzE5/J4QVLw++5tldqw spqEM7HmJzayQDr0r4JpHKwdJ82H+ipgftW/kFTuIze1HRlzcQRac9DH+VAGH9HLQR Nzzt7LU5hkCwT1hNwOzf9oeYLiLAn/c/Twjma0Uta+Td5NYThY8mhfTWeEWOWteW2g ehP9QI2wKHR2fuRjY9R+upyEDdxS/bER6CUBpk/OcO3v6k0PIsxKYm2FYOPNmFT/q0 lJDwrSErYApWZEkb/2CBlnlqtrXNt12sLUwPcKHusiShdxll5hLqWgg18gUI1s5+KD KHXFQEY7tOiGw== Message-ID: <86cff497-f2ea-4335-9cf0-d4b08336acc5@bastelstu.be> Date: Sun, 9 Nov 2025 15:27:02 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] isReadable/isWriteable property reflection To: Larry Garfield , php internals References: <76553cea80282c4b6d71c4ead501415e@bastelstu.be> Content-Language: en-US In-Reply-To: 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 On 11/7/25 20:12, Larry Garfield wrote: > (The counter argument, I suppose, is that this is hardly going to be a super-common routine to call so ergonomics don't matter.) Yes. I expect this to mostly be useful deep within frameworks or specialized libraries. The type of code where these functions are likely to be used are very likely to be functions with an above-average complexity and having explicit code there will help keep the complexity low. Also it's not like `static::class` is particularly complicated to use. One issue I'm seeing with the “magic context” logic is that the code will suddenly break when the call to `->isReadable()` is moved into a helper function. Particularly when you consider the __get() use case that I mentioned below: Folks that are interested in wanting to learn whether there's a property that is actually readable *or* a magic getter might want to put this combined logic into a helper - and then the implicit scope will no longer work. > stack-inspection isn't new. `Closure::getCurrent()` is the most recent example, so we don't think it's especially problematic. The difference is that `Closure::getCurrent()` is a single-purpose function that is explicitly defined to operate on the current scope. It specifically throws an Error when misused. `->isReadable()` OTOH will silently misbehave. AFAICT it would also be the first reflection function that has dynamic behavior. > If there's a preference for avoiding magic strings, it would be easy enough to use an enum instead. Something like: My issue is not primarily with the “magic string”, but with the quite significant behavioral difference depending on the parameter value. Best regards Tim Düsterhus