Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85219 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94631 invoked from network); 19 Mar 2015 16:27:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2015 16:27:52 -0000 Authentication-Results: pb1.pair.com header.from=sbj.ml.read@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=sbj.ml.read@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.173 as permitted sender) X-PHP-List-Original-Sender: sbj.ml.read@gmail.com X-Host-Fingerprint: 209.85.213.173 mail-ig0-f173.google.com Received: from [209.85.213.173] ([209.85.213.173:33427] helo=mail-ig0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/C0-25408-709FA055 for ; Thu, 19 Mar 2015 11:27:51 -0500 Received: by ignm3 with SMTP id m3so13931759ign.0 for ; Thu, 19 Mar 2015 09:27:49 -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=JTJt+6ynUgOU1n05XuXqq9i83Dg6gcsoiKT2UxvE0gQ=; b=eW7mZbGdPAMhZgc4H5PcAJFqlpZe7eEe4bDI4KrLrOYQPodpSAPYQApe4jR0SyThR3 3d5Rr1CUxDNQ+YAxHMbkxqP8xcKcrPL6r0svugixzqPhnaYE53evwkl15YKXeh+H9cM1 QgeaeTcbBIRd01AXVSD2FymNNLI4HL5VIOG/G7L0SNtD07UCgVbxSJIMMilwl72d8umz hEeMYhs3qVzs9XpQpZQRQm+v/iBq6nZ3c0AClRxziWJ/ZtctccIMYrYNLw2EQhme48X0 /zq0M5So9kXjES8rypKSxwj4LYF0Kbpuv/h8hmHMvABnZvnj34JiQD7GJMTe5AqEO2XY 9fKQ== MIME-Version: 1.0 X-Received: by 10.107.170.33 with SMTP id t33mr124248683ioe.7.1426782468900; Thu, 19 Mar 2015 09:27:48 -0700 (PDT) Received: by 10.107.132.5 with HTTP; Thu, 19 Mar 2015 09:27:48 -0700 (PDT) In-Reply-To: References: <54BEC072.5000507@mabe.berlin> <54C28B63.1040506@gmail.com> <54C2E405.4090204@gmail.com> Date: Thu, 19 Mar 2015 17:27:48 +0100 Message-ID: To: "S.A.N" Cc: Yasuo Ohgaki , Nicolas Grekas , "internals@lists.php.net" , Stanislav Malyshev , Rowan Collins Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Inconsistencies in callable, call_user_func and direct variable calls From: sbj.ml.read@gmail.com ("Sebastian B.-Hagensen") Hi, 2015-03-19 17:17 GMT+01:00 S.A.N : >> Then how would you write an callback containing an already constructed object? >> $a = [$object, 'method']; >> >> The alternative is unnecessarily cumbersome: >> $a = function($methodArg1, $methodArg2) use($object) { return >> $object->method($methodArg1, $methodArg2); }; > > $object->$methodName(...$args); You would still need an array to pass the information about the callback to another context. The syntax you detailed is not usable by the callable typehint and internal functions requiring a callback. No improvement made. The better alternative may be to deprecate strings as callbacks (if one should be deprecated at all) and always require a closure or or an array with one of the following signatures array(string); array(string, string); array(object, string) Another way to unify array and string callback may be to use the callable syntax and have it return a closure: callable('strlen'); callable($object, $methodName); callable('class', 'staticMethod')