Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64943 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32554 invoked from network); 14 Jan 2013 19:03:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2013 19:03:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=lisachenko.it@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=lisachenko.it@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.51 as permitted sender) X-PHP-List-Original-Sender: lisachenko.it@gmail.com X-Host-Fingerprint: 209.85.212.51 mail-vb0-f51.google.com Received: from [209.85.212.51] ([209.85.212.51:58976] helo=mail-vb0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/07-22727-46654F05 for ; Mon, 14 Jan 2013 14:03:00 -0500 Received: by mail-vb0-f51.google.com with SMTP id fq11so3822095vbb.38 for ; Mon, 14 Jan 2013 11:02:57 -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=Em6YmZfceBCr0NiUTei5Qc5jHm/4V6t62JAMUYPuH10=; b=ZvWplIH+oHDA6w0Qp16/MxrxFager1PljSy1yOynUs990cuY23wgRwmoE0l3ee/ZZG iuXdnI/kUuI6U5/Ae+paeaO7IPlA9XP54xep8SIT6Rt1KYhhokyWkwZn71Vc/DUGXF+/ pDWi/uuFyXeiNZ/lVwalV4Orm9h/9z8XOavgPkj6EIO2zANiUulSCVSiFCRG9jg3TGoV jxwqCX6xXi9gSQ/K56ouSddOBstwdzvIvCAvTQik8Ch4/efERheEvzR+K+Z8VpUvqXTj 16ZCkePr5S1ucor0yBL0+f8isEuwDVystPwGR0kB/l4YdmgNQ9VMrFsiWq5+TrwXIjD8 3W/g== MIME-Version: 1.0 Received: by 10.52.66.51 with SMTP id c19mr66002713vdt.123.1358190177449; Mon, 14 Jan 2013 11:02:57 -0800 (PST) Received: by 10.59.6.42 with HTTP; Mon, 14 Jan 2013 11:02:57 -0800 (PST) Date: Mon, 14 Jan 2013 23:02:57 +0400 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: [Reflection] Improve logic of ReflectionMethod->invokeArgs() for static methods From: lisachenko.it@gmail.com (Alexander Lissachenko) Hi! It's my first letter here ) I want to suggest a small improvement for ReflectionMethod->invoke() and ReflectionMethod->invokeArgs() methods to support LSB for overridden static methods. Currently, for invoking static methods first argument should be null, information about class (scope) is taken from the reflection class. However, there is one issue that can not be solved at the current time. Suppose, we have two classes: class First { public static function foo() { echo get_called_class(); } } class Second extends First { public static function foo() { echo "Do not call me, please"; } } Now I want to invoke the First::foo() method with Reflection from the Second class scope for using LSB. Currently this is impossible: $class = new ReflectionClass('First'); $class->getMethod('foo')->invokeArgs(null, array()); // Outputs 'First' as no scope information is passed $class = new ReflectionClass('Second'); $class->getMethod('foo')->invokeArgs(null, array()); // Outputs 'Do not call me, please' as method is redefined So, there is no way now to invoke the static First::foo() method from the child scope because it was redefined. However, this can be easily implemented by adding the scope for static methods invocation (like Closure::bindTo()): $class = new ReflectionClass('First'); $class->getMethod('foo')->invokeArgs('Second', array()); // Outputs 'Second' This improvement can be very useful for building proxies for static methods, that use LSB. Can it be implemented for PHP 5.3-5.5? Thanks!