Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91435 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84801 invoked from network); 26 Feb 2016 11:47:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2016 11:47:32 -0000 Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.54 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.215.54 mail-lf0-f54.google.com Received: from [209.85.215.54] ([209.85.215.54:33565] helo=mail-lf0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/83-55238-35B30D65 for ; Fri, 26 Feb 2016 06:47:32 -0500 Received: by mail-lf0-f54.google.com with SMTP id m1so51882038lfg.0 for ; Fri, 26 Feb 2016 03:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:subject:references:date:mime-version:content-transfer-encoding :from:message-id:in-reply-to:user-agent; bh=HVD8+Exy8UHh2jZDD7nK+tflMoTkhOOZHRzD+SkirQM=; b=IIfoFtFTcMzx01EW+FiTHIIka0I44E7NBiJTjCgVuVM0pIeHfwvRWG/jmQ/c7cxR++ JWjgvaXuV0h9Zd0UROHFB0ypDmJNnd1Lt8yFBeazDtyO9z1muD/x4z+mISh02b4LMIbF sRRiSe6Eq3+4OVCeGjzFzq811/tLIMqsYi0O/4fEnaoiOCh0yiWu3S93fsWcwroYbGQo bbM4kAwxRwSWNNa8VklOGRvnOZBO8rpm7uojB05vrhBk5ECoiKp6ToAdg2aVQrEFHee1 +QhNYeEAN6xfM0ruZQxemicdF6w5nCQwFlPAzlCiFGC14SJuUmHUcZmhz2D4YCXFYj5r RvEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=HVD8+Exy8UHh2jZDD7nK+tflMoTkhOOZHRzD+SkirQM=; b=R3KoDk0lmgL4cRFOChvOo6P1NkEBC4k2uH9yv7SK/7u+gDwHLSoIYG4xbstlr+vr0c hZyC43oObsQV+U/JVIYJfCmu+CWhV2+YGPpwVpOnztUYHSRfKzZefM+n80+wSpBtSWFQ LGET5t7BzEW1x+gRnKh3eJr8MZilLlJslsMlClnzXtooMi03X4j4O9DDJqupPl7mL6KH Jh89qXGZiuSpwSMkvDC+ANZsmwTLTB3PMxNFpUW6PPQ9vU1js2E7yWCrG8AjaL0sg8eu bpAe0AHrgO8N2sgSV6gjx20ycsdaXVuHVCz+QKwfsZnb45ged5MvjMkEu+/vxF5sPAev cBNw== X-Gm-Message-State: AD7BkJJ77nskZBnnJ2Fg8RfwU7of7oYsT+odZkXrjQqyYv3OxX5AkuvGrRApTW0OiyMtrw== X-Received: by 10.25.77.130 with SMTP id a124mr484006lfb.4.1456487248196; Fri, 26 Feb 2016 03:47:28 -0800 (PST) Received: from nikita-work-box ([185.62.192.230]) by smtp.gmail.com with ESMTPSA id r191sm1776997lfe.28.2016.02.26.03.47.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 26 Feb 2016 03:47:27 -0800 (PST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: <97.82.11730.D8C3FC65@pb1.pair.com> <56CF63D8.8020005@gmail.com> Date: Fri, 26 Feb 2016 14:47:19 +0300 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: User-Agent: Opera Mail/12.16 (Linux) Subject: Re: [PHP-DEV] Re: [RFC] Callable constructors From: inefedor@gmail.com ("Nikita Nefedov") On Fri, 26 Feb 2016 14:28:19 +0300, Andrea Faulds wrote: > Hi Rowan, > > Rowan Collins wrote: >> On 25/02/2016 17:40, Andrea Faulds wrote: >> >> Snipped for brevity, but I agree with your sentiment here. Making >> __construct more magic seems like an imperfect solution to this. I'm not >> sure making a new magic method (new, __new, etc) is much better though, >> since it would serve such a limited purpose. > > Yeah, I do wonder if ::new would really be worth it. > >> >> Then we could add to that a special case for constructors: >> >> - Callable::forConstructor(string $class_name) >> > > Oh, that's quite a clean solution, I like that. Heck, no need for > Callable, we already have ->getClosure() in Reflection. A modified > version of that for constructors could work > (ReflectionClass::getConstructorClosure() ?). > > Thanks. Hey Andrea, This would still not solve Dan's problem though. Which is representing `new Class` as a serializeable callable. I really think ::new() makes the most sense here (and looks quite alright unlike `Class::__construct()`). Although making a special case for `new ...` is pretty simple, I too have felt the need for callable constructors plenty of times, that would be useful.