Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62134 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20493 invoked from network); 14 Aug 2012 00:16:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2012 00:16:23 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qc0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:44389] helo=mail-qc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3D/BE-00812-6D899205 for ; Mon, 13 Aug 2012 20:16:22 -0400 Received: by qcmt36 with SMTP id t36so3163443qcm.29 for ; Mon, 13 Aug 2012 17:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=uTpELwCnD/NNo0KBzBCmnPsorpO+VhVXO7RVxsTSSqg=; b=bJSh4IPPn895JIpdJ8WQVe9w2fI3bMSqUTHtFMdOOk+BfUHjPz2VpPg8cWAkNS8q7n iga+96ogwlON6VTFxa4dtaHDNPMGSyGp1MbEOYccn7DQ2J22sUM1xBVSVQvA2ROdoWAS Bq46Ks//XnT3zCViPEgbtRqSpwchPPaLAIcCSFrGM5kNBmS1MJ12knsY107er7WlCJVl EZyNyeHylY9F8FGzkz8w0JBgftpv1BKOzDKRhA4hWmnh4EoOtvy7NOY0uovgcgiN8+AP 9rEJLDmurCjuG24QBrcXlO7M/n+1Dt76l1ikE4cDFh445a5Ra1EMwMFtQdLubJJW411l BViA== MIME-Version: 1.0 Received: by 10.224.188.76 with SMTP id cz12mr18151295qab.12.1344903379645; Mon, 13 Aug 2012 17:16:19 -0700 (PDT) Received: by 10.229.54.213 with HTTP; Mon, 13 Aug 2012 17:16:19 -0700 (PDT) In-Reply-To: References: <50298AC9.4070302@naderman.de> Date: Mon, 13 Aug 2012 20:16:19 -0400 Message-ID: To: Nicholas Curtis Cc: Nils Adermann , internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf303640cf33761604c72eb8cd Subject: Re: [PHP-DEV] Decorators Revisited From: ircmaxell@gmail.com (Anthony Ferrara) --20cf303640cf33761604c72eb8cd Content-Type: text/plain; charset=ISO-8859-1 All, As promised, here's a link to the proof-of-concept implementation: https://github.com/ircmaxell/php-src/blob/spl_decorator/ext/spl/spl_decorator.c#L77 I'm not really looking for feedback about whether or not we should implement a decorator helper, but more for this exact method of doing it (having a "magic" base class which would be extended)... The interface addition is mainly a quick tool to test it with. I would think that's too dirty to go with in an official proposal. In the official proposal I could foresee two main ways of solving it: 1. Add an additional pointer to the zend_class_entry for the wrapped class. Then change instanceof and the like to check for that pointer as well. 2. Move instanceof to a handler from the current standalone function. Then each (pecl level) class could choose its own implementation if it is needed. The function could still exist for BC reasons, but would proxy to the handler method if it existed... Then, the wrapped class (the additional pointer) would only need to live on the objects internal store... Thanks, Anthony On Mon, Aug 13, 2012 at 7:50 PM, Nicholas Curtis wrote: > I agree great idea. Would really help to simplify benchmarking code also. > > On Mon, Aug 13, 2012 at 4:16 PM, Nils Adermann > wrote: > > > On 08/12/2012 08:17 PM, Anthony Ferrara wrote: > > > Thoughts? > > Yes, please. I think this would be a great simplification for all kinds > > of extensibility / plugin mechanisms implemented in various PHP projects. > > > > Typically these either end up with the boilerplate you described or try > > to come up with some kind of hack (e.g. dynamic code generation) to > > circumvent the problem of having to explicitly define parent classes if > > one wants to dynamically decorate objects multiple times while maintaing > > interfaces. > > > > Cheers, > > Nils > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > --20cf303640cf33761604c72eb8cd--