Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46100 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37384 invoked from network); 19 Nov 2009 11:51:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2009 11:51:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=ametaireau@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ametaireau@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.78.27 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ametaireau@gmail.com X-Host-Fingerprint: 74.125.78.27 ey-out-2122.google.com Received: from [74.125.78.27] ([74.125.78.27:14816] helo=ey-out-2122.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 34/36-01102-A21350B4 for ; Thu, 19 Nov 2009 06:51:07 -0500 Received: by ey-out-2122.google.com with SMTP id 9so463021eyd.39 for ; Thu, 19 Nov 2009 03:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=q9QHhMnRL9kWiFLW65MC+HeLSrqPIlZGzWm6lbXBuoA=; b=vRqaDTvF8gFYmshOSusaMyDSvEfKRYtsn+zQ8hZg7RrfKCnPYwKrGioFr8usUP+bUv nzcRxosRxNMZ7Qret4ex8fsC+49SKnox2r9qLU6F4Kcfa40eUr7k+xw/29Cbx/SQ5Zq8 rFV0l4GllVFZyoHNvmnWcYvkctI242BSlmPzI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:cc:content-type; b=WxJtZu8B4bFUXLLDcM6gEXEIF55G9TOKwJ7taH4Bwdkz69ioC/OVGdcCZhRwj1rjWY aII/UR7ggU7BEBHpOmUUExzFB9Rapz5i7txPXoaKNMfsInUKPG9+71zaG7JPjMWZkO3b MdnTfd33CjQaMDMPH3Z7DiNyTbGuW3xQeDHHs= MIME-Version: 1.0 Sender: ametaireau@gmail.com Received: by 10.213.25.78 with SMTP id y14mr1377284ebb.42.1258631462215; Thu, 19 Nov 2009 03:51:02 -0800 (PST) Date: Thu, 19 Nov 2009 12:50:42 +0100 X-Google-Sender-Auth: fcf1293693f3d3dc Message-ID: <2229b0db0911190350j6d0bde4cgcb57675778b55d0b@mail.gmail.com> To: internals@lists.php.net Cc: fred@spiral-project.org Content-Type: multipart/alternative; boundary=00151744790e3561660478b7f9e3 Subject: RFC: Custom Factories (SPL) From: alexis@spiral-project.org (=?UTF-8?Q?Alexis_M=C3=A9taireau?=) --00151744790e3561660478b7f9e3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello here! I'm a big fan of IoC too, and I think that PHP devs really need to have a look into Inversion of control. Adding this feature to PHP can be useful fo= r providing a simple way to detect and manage the object creation process. The "spl_factory_register" function allows to specify a manner to catch whe= n a "new" occurs, and to add an alternative way to manage the creation of objects, by calling custom factories instead of using the built in "new" process. In fact, this method allow us to branch our objects managers (or dependency injection containers) on classes that don't implement inversion of control (like the widely used singleton pattern). This is huge ! However it's important to note that* this behavior can encourage some people to continue writing hard coupled classes*, and use don't us or think about inversion of control, letting the (service/object) container do the stuff for us. It can be really *dangerous*, and maybe attack the problem by the wrong side ? On a pragmatic point of view, *this is an actual need*, for sure. At least Richard and me have encountered theses problems (and I think many other people). This "spl_factory_register" would solve them in an elegant way. About what Eloy Bote said, I think that traits and IoC are two different concepts, both talking about code re-usability and good practices, and both needed. And, about the signature of the function itself, why not use a callback lik= e in "spl_autoload_register" function ? Best regards --=20 Alexis M=C3=A9taireau 06 20 15 55 24 | 35 rue L=C3=A9o Lagrange, 31400 Toulouse | http://www.notmyidea.org --00151744790e3561660478b7f9e3--