Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129136 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 1F8D81A00BC for ; Fri, 7 Nov 2025 19:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1762542749; bh=pVcoaW54rrP9Xgw9K6NGfsOG6H0EfG7Na6kL2xsWS7M=; h=Date:From:To:In-Reply-To:References:Subject:From; b=Ujgl2mL8uZvsEJ2vgtjrZw85PknNvvMA52y99nz0k2wdSdmmV/cfXmmvPodheS8jv 9y+O/3dVtBUFUJ1S1M6Hcf5VucGEBd9Z9UZWPeV48Q3S/iUg3Sj2AOl69B5gCsID7x CMK/OWyUDHYa4e0YiTJLTvi4MgHmePwkggrd4gp1gMpOKl7Vgwr4OoqPIueMsKbvE2 uFiBnR6dgJwxABzeEo8a7wJc0whdCNaC7NqVrS0nWnd6mEkLgbJ0o1jKbIWEUQzS9l AMKDGgjvE21615sjDHng5M44Fs6fPZ9JM72hnJEztw1qNMYzeZG+w/VcCqV2m9qyb6 k3K+xwIEKfQVg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DD3A01801D9 for ; Fri, 7 Nov 2025 19:12:28 +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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b2-smtp.messagingengine.com (fout-b2-smtp.messagingengine.com [202.12.124.145]) (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, 7 Nov 2025 19:12:28 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 56A911D000D1 for ; Fri, 7 Nov 2025 14:12:23 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Fri, 07 Nov 2025 14:12:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1762542743; x=1762629143; bh=sdMCkOwp4nWTV44FOrlDT 6Wnd0GpACHiOI7rb7jlM34=; b=MaZzfhxpOisUS4pnoeBIKkwAgE6LpsrpCS1c9 aQmj/HxSdKpEfJvPFLI32l88SKbnDZbhKwVTgCSNlHF/fpOfAUnBM4y+d7dOkrtr Ze/+82foZ3ixr7Q26JDYXancfFDzItVMQwBXEfv+v53TzR5LQylCI/5lre7nJUxI cFIzhnU2a2CzhuGX6shusBkU8QmzoBBFCGEutaPxRfaMkMqX8zuCLDMls2NTfLby dPumCGjN5B5KLdjNulb6bQmFmTZIapgwarjonrBPgNuyFsF7XH1UyZFRIZrpp4uV 59c2TbJQzkoWCp/X4otj4onOqC/kHxan0u2vwCcPyJPWOHSNQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1762542743; x=1762629143; bh=s dMCkOwp4nWTV44FOrlDT6Wnd0GpACHiOI7rb7jlM34=; b=JVNIr0UrrgllqK2aS qhgWpR+1YN3O7/vQFJ1Zd3dgrnUMFksUWM3zEMscwlZeTNWzvbBsVV1QxwTtEhJe z/b3yb5Gnt8oEiefTqJQuFDaTsHEK1fmN6wMSiEbOEnrlVkmjvngcL7hUEwKYgxr m9Krr0W7FQBDe3jBR36jUcrqm1+H8T6IaIVTxV0ma22pbPTrujDftAmKuzfYUH0j RNuBvCdCdYmeX9hKQzxRsa6dgP+hxHUW5wiagKC/Oi3unN6MsPHvRFZiAO+Tcxlk K4jfNLkAI7ziY0GgFyOwgHCXoKBcZVOnAqcHLCvihlHqXulPtvyeSbIh01qemFiy WkgKQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduledtgeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeeugfetieejueevffdulefhhfethfekvedtueevgfffvdef iedvtefgheevteelffenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghl ughtvggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C9F17700063; Fri, 7 Nov 2025 14:12:22 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: AboHCY4z1pNF Date: Fri, 07 Nov 2025 13:12:02 -0600 To: "php internals" Message-ID: In-Reply-To: <76553cea80282c4b6d71c4ead501415e@bastelstu.be> References: <76553cea80282c4b6d71c4ead501415e@bastelstu.be> Subject: Re: [PHP-DEV] [RFC] isReadable/isWriteable property reflection Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Fri, Nov 7, 2025, at 5:03 AM, Tim D=C3=BCsterhus wrote: > Hi > > Am 2025-11-06 00:24, schrieb Larry Garfield: >> In other news, Ilija and I said a year ago that we'd take a swing at=20 >> adding isReadable/isWriteable methods to ReflectionProperty. Took a=20 >> while, but here we are. A strangely small RFC from us: >>=20 >> https://wiki.php.net/rfc/isreadable-iswriteable > > I dislike implicitly =E2=80=9Cscope-dependent=E2=80=9D functions, sinc= e they effectively=20 > act like magic. This probably makes it harder to understand for humans=20 > and static analysis tools alike. I would therefore suggest making the=20 > `$scope` parameter required. A user can just pass `static::class`=20 > themselves and static analysis tools can use `class-string|null` inste= ad=20 > of `class-string|"static"|null` as their expected parameter type. Given that the 90% or more case is likely to be "from my current context= ", making that the default seems the most ergonomic. (The counter argum= ent, I suppose, is that this is hardly going to be a super-common routin= e to call so ergonomics don't matter.) stack-inspection isn't new. `Closure::getCurrent()` is the most recent = example, so we don't think it's especially problematic. If there's a preference for avoiding magic strings, it would be easy eno= ugh to use an enum instead. Something like: enum CallerScope { case Caller; case Global; } function isReadable(string|CallerScope $scope =3D CallerScope::Caller, ?= object $objecg =3D null) { ... } `Caller` would still do the same stack inspection, but it makes the type= more tightly controlled and eliminates a nullable. > As for the magic method logic: I would suggest to ignore the presence = of=20 > __get() and __set(). This more closely aligns with the direction PHP=20 > goes towards and is also easy to work around by checking with=20 > `method_exists()` whether any such a method exists - the reverse is no= t=20 > true. thumbs-up.gif --Larry Garfield