Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64199 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49982 invoked from network); 8 Dec 2012 21:48:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Dec 2012 21:48:54 -0000 Authentication-Results: pb1.pair.com header.from=adamjonr@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=adamjonr@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: adamjonr@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qa0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:50511] helo=mail-qa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/15-13109-5C5B3C05 for ; Sat, 08 Dec 2012 16:48:53 -0500 Received: by mail-qa0-f42.google.com with SMTP id hg5so661248qab.8 for ; Sat, 08 Dec 2012 13:48:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=AHzKBOp7OLgX0J7VwkKpsy2lMnvymKGPDIibX8SPpZ4=; b=Y8b+kUUvMl1ddcb/l+q8LmDirvR22xNXH0awjdATvFQUBRgU+N7ePuiGPykq7RUEMP Sj7jDqtXXtYabT3kofdDkTfyZ3vhct6fc4e/qlXRetXBmpusty5px//n3y4uDSIkjTP2 bq1AxhFAWlUXv4PlkH+EI0bXeggGWv/dx2lbI1YUOQ6NmhjCeNjVswDCrUJ2sVihG+Oy nA+n+lHWpA2AzucxDmAexB7tbEyin5/m3uDjn6VO3yq2IRrJWCegyVJTrCJnXlfa/hRs M8VGJV5B36d3MUkIK7I8VGjdivqXeEieZzx82cItHF5mhxnq+ymjiuI+lHMQowfuXn8z hiHA== MIME-Version: 1.0 Received: by 10.224.78.148 with SMTP id l20mr18071586qak.27.1355003330708; Sat, 08 Dec 2012 13:48:50 -0800 (PST) Received: by 10.229.206.202 with HTTP; Sat, 8 Dec 2012 13:48:50 -0800 (PST) Date: Sat, 8 Dec 2012 16:48:50 -0500 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=20cf306f75143245f404d05e4c5f Subject: Call closure stored as object property directly without use of temporary variable From: adamjonr@gmail.com (Adam Jon Richardson) --20cf306f75143245f404d05e4c5f Content-Type: text/plain; charset=ISO-8859-1 First, thanks everyone for the hard work on the PHP 5.5 alpha. I just ran the tests and submitted some results, but from the little bit I've used it so far, things are looking really nice. Second, and to the main point of this email, I would like to be able to call closures that are stored as object properties directly without having to make use of a temporary variable. For example: func = function(){ return 'Yes!'; }; $o->func(); ?> The above code elicits the error: Call to undefined method stdClass:test() in... I realize I could create a class that implements __call() to intercept and redirect the call to the closure, but this adds much overhead for a simple approach and also precludes the use of stdClass (I like the option of being able to cast to an array, and then back with very little overhead.) It seems as though the parser could be updated to accommodate this intention, but I understand this could pose a backwards compatibility issue (current users could have closures stored as object properties and be expecting the magic method __call() to be invoked instead of the closure itself.) Has anyone else wanted this functionality? Has anyone else thought of ideas of addressing this (or come to the conclusion it really isn't safely addressable without causing disproportionate amounts of grief?) Thank you, Adam --20cf306f75143245f404d05e4c5f--