Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91416 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3124 invoked from network); 25 Feb 2016 18:27:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2016 18:27:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:38658] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/64-11730-E874FC65 for ; Thu, 25 Feb 2016 13:27:26 -0500 Received: by mail-wm0-f43.google.com with SMTP id a4so39843108wme.1 for ; Thu, 25 Feb 2016 10:27:26 -0800 (PST) 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=ZLtRmXtZ7njBIy0FN/rOKMBCFrfR/G6OFhDUAx3Ej24=; b=OlPabZmlXdfhloeouf9q1MCT5mCuW3wkpchUU/ltkVYCllSrblpvKLRGOvSIVH2dDD J8ZOtBOfDvdTUv/4XpyGH/ShMI7RELLYgJG4OlEBGwLBv2q+gIZcmGyeksxk4R+b9wub JFH88AmPfuhtVUq7R6QZcxA1kRAW2EZbcMvXPyKmsrm9Xx/N0RU4FG8adU3wxifXlcVQ qk5kgG51TOsGi7oJuP3h9M0Nly4m6iLtcSsWCLJjYf/5w5oZjAcgsmGQDKMEH89IQU1c p2BQB1ZCrU3CEw3RvhITgm/Fca6+9wlGm1d5n24comaX42jxRgECkj1/wAmd7qjFEMSq TjFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=ZLtRmXtZ7njBIy0FN/rOKMBCFrfR/G6OFhDUAx3Ej24=; b=Xvn4J2Hq0uWhp4pSPsZb8i2zCkNiLwQbfSTqbBIPK236GhAOZXd+MVL5ZIcbhZOUud gkIMWID9QIACFhWJ4Cy7Aic+RAJHMJ101XrdQeCVxOW1uKDNqo8vyXINJX0Vs7HGvIAC xBR3tnZFVmU367q817YythRniRl7zLmI9Ii17PJPbFt5cTT6iZjti2/ftVwYZG8AdbBe eUZ8OlyrqRTKg+6KCNbKqG0YmX8u35U5ABNG/Rjtq/x2lxbjl8jzxO9H3s4uyLsd/34f gJzMyjTY4tlfabDvL3KcACv1dnr9x9pLLW4vlPmPcT2U1kgFqVUYOB4iXV4gWQY0rWt0 weDA== X-Gm-Message-State: AG10YOS3GN613wnYhQZNTIkTxkz/Hyrd7Yucfajkcb6uD5fMei3IOPTMzXYZvi8Z81tVg7RZpZOI0tmtX/bSEQ== MIME-Version: 1.0 X-Received: by 10.194.192.36 with SMTP id hd4mr44072879wjc.85.1456424843230; Thu, 25 Feb 2016 10:27:23 -0800 (PST) Received: by 10.28.68.215 with HTTP; Thu, 25 Feb 2016 10:27:23 -0800 (PST) In-Reply-To: References: Date: Thu, 25 Feb 2016 11:27:23 -0700 Message-ID: To: Dan Ackroyd Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7bae44026c4724052c9c558c Subject: Re: [PHP-DEV] [RFC] Callable constructors From: derokorian@gmail.com (Ryan Pallas) --047d7bae44026c4724052c9c558c Content-Type: text/plain; charset=UTF-8 On Thu, Feb 25, 2016 at 9:44 AM, Dan Ackroyd wrote: > Hello internals, > > I've written a small RFC to make it possible to call constructors of > objects as a callable, rather than only being able to call them > through the 'new' language construct. > > https://wiki.php.net/rfc/callableconstructors > > After gathering informal feedback for the RFC, one person said that > they felt it needed more of an emphasis on why it should be > implemented. I wanted to keep the actual RFC short, in the hope that > more people would read it in it's entirety, and also wanted to leave > library specific code out of the RFC. So, as an addendum to the RFC > text: > > I use the Auryn* DIC library. What I've wanted to do, and should be > able to do in my opinion, is this: > > $injector->delegate('FooInterface', 'FooImplementation::__construct'); > Which tells the injector "Whenever something requests an object that > implements FooInterface as a dependency, just execute the > FooImplementation constructor to make that object". > How is this any better, or what benefit would it provide over the current implementation, which takes a class name and then calls new on it when the Interface is asked for? Moreover, if you want to pass in a callable that creates the class, why not just create a method on that class called create (or whatever) much the same way that singletons often work. --047d7bae44026c4724052c9c558c--