Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91425 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25974 invoked from network); 25 Feb 2016 22:19:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2016 22:19:36 -0000 Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 209.85.161.173 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 209.85.161.173 mail-yw0-f173.google.com Received: from [209.85.161.173] ([209.85.161.173:35361] helo=mail-yw0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/48-11730-7FD7FC65 for ; Thu, 25 Feb 2016 17:19:36 -0500 Received: by mail-yw0-f173.google.com with SMTP id g127so55051491ywf.2 for ; Thu, 25 Feb 2016 14:19:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+3MzJIt3v9d1yPnJq4y36VCTTsAyfm0xW6sAnjd+3go=; b=q0nHc6h08U/kh39H4LSSUaavK02tqIN929ZmjP3sZSyJfVf/U6v6dSUV7J85ayIuuU /yvaeG98A8YCM9hdRmzMRsFRafGVLaVd970PiGJB4loxi6eyVkK/EttFlZAKJczPF/Jy 69MKQSoDYkmAkxYwzQANOxiso3GT76g0vhyijtfeXm2sNNO1duZ7jaNSBTPsV3q6qVG+ Suk5ZvbN65Fevm+P6eb7zKKB1/4/ewfCL3xajWVUrRWkQaFKibiCW0yzUgW2KbOp1/SF PsFo23m25u/VF7F6g5p2P7kOyP4uOd9PZipF64kichBmurxdIKlHVw9c1ARYX9WY2TNr G9sg== 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=+3MzJIt3v9d1yPnJq4y36VCTTsAyfm0xW6sAnjd+3go=; b=YkYLCoci/Iff+yglju+48nxNMn0NX7gFFMOuSibCOf5gHUX9WopmbVMCLmt45wPEzY qLaPwTsmuoLHWBCQAmSmWMYSEOx956ojhuvEl0CagAMQb7OJLNoZNCQNYviOdaTp5Kie rz9kBKW3OdHJXPxOeVpZrTitkj16oocj3+/hsyhLAlIpwWBnGJX2NVGDyanxRIaL7g8v HzuUkR2hIXrhhhMnUqF8MzELhtYIDLjo2yoLwQXVhtczxz8bV0TSs/xEHSdPHv5dJn7T KNO5TiD56oiyQCruk2+LAZkE2u6osKWHjDTtDmhJhigpdRqJ7ElkmDA49PCH9OCZzKBJ AvwQ== X-Gm-Message-State: AD7BkJK/5IGJrS9bfQ+yuPoSYA8ph4M2oqpUSMwHACgM7NlJrJOssytgQWj/FR8ibdJUBnUnYhiCVXO+O+84vw== MIME-Version: 1.0 X-Received: by 10.129.134.133 with SMTP id w127mr73061ywf.252.1456438773614; Thu, 25 Feb 2016 14:19:33 -0800 (PST) Received: by 10.37.43.85 with HTTP; Thu, 25 Feb 2016 14:19:33 -0800 (PST) X-Originating-IP: [2.98.210.180] In-Reply-To: References: Date: Thu, 25 Feb 2016 22:19:33 +0000 Message-ID: To: Adam Harvey Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Callable constructors From: danack@basereality.com (Dan Ackroyd) On 25 February 2016 at 18:16, Adam Harvey wrote: > > am I right > that this is equivalent to the following? > >$injector->delegate('FooInterface', function (...$args) { return new FooImplementation(...$args); }); Nope. The vital part you missed is that with the original function, all of the parameters (aka dependencies of the class) can be found through reflection, and so can be created by the injector as needed. By using function (...$args){} - all of the parameter information is lost, and so isn't usable by an autowiring-injector. The only equivalent thing that would be to either create a dumb function by hand: function createFooImpl(Bar $bar, Quux $quux) { return new FooImplementation($bar, $quux); } for every possible constructor used in your app (and remember to keep it up to date of course!), or to use eval to create a function on the fly. > "I only skimmed the RFC" I find this very dissapointing. Conversations are far more productive if people have read the whole of a proposal before deciding how they feel about it and giving feedback. In particular reading the sections "Can't be used as strings in class properties" and "Can't be used in string based configuration" would give examples where the RFC is of benefit in a way that is not related to DIC libraries. cheers Dan