Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127871 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 D50C81A00BC for ; Thu, 3 Jul 2025 21:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751578925; bh=4yHKdXXH6ghXOkWGA6tanizVUhWAUu1qZ7pvkvFeKTE=; h=Date:From:To:In-Reply-To:References:Subject:From; b=VK3muxhd1Gb68LzAM9m28dZjHloSYKwwr2EraUzLyb5XWlfyqf86e0YNttowqc13E gHiuP/wA0W/wtQV+gnm+fBVT+s90QV8jRIsNvoxbQjVrYL3PHi4B5IN76KYaVL23uI OsK94ugThbvudnOqawBA9fTmqoK0+dj0gduLmLn5Vcfb7JB0eMCs4PMZitrhaSioIW RLrvJzJ7yW+jMjQMGZnwPc4gfNSV4tOjjkNJEShHP7200Nir1zrlsacEvMpbG8QErU ClnUI8FGpSKR96pK5Ts2RVCpjBmI4Ifg1x/G93bCN85y6KGKjxKisJQ7IoodIgF4FL 3+A5/8rAFs+MQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BE611180570 for ; Thu, 3 Jul 2025 21:42:04 +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: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 3 Jul 2025 21:42:04 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id A7A34EC1B27 for ; Thu, 3 Jul 2025 17:43:56 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Thu, 03 Jul 2025 17:43:56 -0400 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=fm2; t=1751579036; x=1751665436; bh=gNmF/0quzN1NJSVfSoLyI S//vHzxx7hY1QmAjKSUMrs=; b=pU5/V36MwAUav0HlzYu/XUEeuwM5Ru/kFWYxG am/HgbtJyreyjmUVbGwfYTLriB7YZ0vkj9Z4ksws7aKf3vfulAcM/J8m6jDS4sh6 eI1tcVIl2Gyx3657vZsP0almTtVpkGR8l2+xN0pYTnbus/uVfovPh57ICTiqsw4o 0Feh8kuE7/jytcS6i8d0hkESxsVfFeZYBi8vOn5XPSeNej6wv8aSC+k4/4VhfEpB mZeueBg9owrv82/J5CIZdyd1XqCP7zBRAkNI+tWs3VDPeupfTX6r1a9sFi58Np2V GL6wEup1E8pGF5Qj3hRYasdnakRnX4ayPl84oYSTfkC6uxLiw== 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=fm2; t=1751579036; x=1751665436; bh=g NmF/0quzN1NJSVfSoLyIS//vHzxx7hY1QmAjKSUMrs=; b=O3PkTI0yVPBiN8ViP ZyuO5EIwfg72405O7T61rM5ls5BofpxOg5bzM2TrX//15jcgtCrw7HxdNk6/RfBa X8Liml4FNa1r9mb90Zm/tJJZg+TOB74JcfdkOHRSMpCWWPNmMNqVcLmgqfgamEk2 RmGZNCveSJ/9g3hASfbrlqH+4gZdVlDJAT2kM2AICzllwu4spZoXSQt+x6jRHoYl a5uQu4sSVTQZoCIp3PEg1MHzqph878os5d4JuoO8Ia8p/C5iPG1NPp/cmR+Qt4e2 psyOAptY6muWtn6M3KoRkouPDDh8/vYdyIYcq39MFOs5zfVJZSBAurEYGoVCaCxI 152mQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddvudefkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepudegvdelgfeugeehfeejteffudevleethfefgeejffffleeg tddtveekgeekudfgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphht thhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhsse hlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 62C19700068; Thu, 3 Jul 2025 17:43:56 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T13a9b6ebd1dfd435 Date: Thu, 03 Jul 2025 16:43:36 -0500 To: "php internals" Message-ID: <926ca0e2-13f4-47fc-aec3-f7fa265cfdb5@app.fastmail.com> In-Reply-To: References: <1cfc477a-781f-40e9-9e37-dd748ef261be@app.fastmail.com> Subject: Re: [PHP-DEV] [RFC idea] Target-aware attributes Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jul 3, 2025, at 12:49 PM, Andreas Hennings wrote: >> A setter method injection is what I did in AttributeUtils, because it was the only real option. > > In my experience, this alternative leads to more complexity in > attribute classes. > The constructor needs to populate the attribute with temporary values, > which are then replaced in that separate method. > (I call that a "setter", but only because it behaves like one from the > outside, internally we usually don't want to store the reflector). > > Also, we can never be fully sure whether an attribute instance is > "complete" or not. > If the attribute instance is coming from > $reflection_attribute->newInstance(), we can be confident that the > ->injectReflector() or has been called. > But if the attribute was instantiated manually with "new ...", it > could as well be incomplete. > With ReflectionAttribute::getCurrentTargetReflector(), we can fail > early in the attribute constructor, by throwing on NULL. I ran into the "completeness problem" in AttributeUtils as well. In my case, it's not just reflection; there's a whole bunch of other things that can be passed back to the attribute to give it more context. My eventual solution was to also have a `Finalizable` interface that is guaranteed to be the last thing called, so the attribute can handle any last-minute defaults. I don't love it, but given the severe limitations of `readonly` it was the best I could do. (With aviz today, I could likely do better.) Basically, any time you have multi-step construction you will have a period where the state is potentially incomplete. While passing the reflection target in is one such multi-step case, there are lots of others, so in advanced cases (most of what I do) the object will always have an incomplete phase, and that's unavoidable. So I'm not *that* worried about there being a brief incomplete-gap in time in core, because I'll always have one anyway, and I've already figured out how to handle it. --Larry Garfield