Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74233 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17641 invoked from network); 15 May 2014 18:22:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 May 2014 18:22:53 -0000 Authentication-Results: pb1.pair.com header.from=php@marc-bennewitz.de; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@marc-bennewitz.de; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain marc-bennewitz.de does not designate 80.237.132.171 as permitted sender) X-PHP-List-Original-Sender: php@marc-bennewitz.de X-Host-Fingerprint: 80.237.132.171 wp164.webpack.hosteurope.de Received: from [80.237.132.171] ([80.237.132.171:52370] helo=wp164.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 08/60-14382-CF505735 for ; Thu, 15 May 2014 14:22:53 -0400 Received: from dslb-178-005-224-019.pools.arcor-ip.net ([178.5.224.19] helo=[192.168.178.27]); authenticated by wp164.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) id 1Wl0Ir-0001ZU-EQ; Thu, 15 May 2014 20:22:49 +0200 Message-ID: <537505E8.5090608@marc-bennewitz.de> Date: Thu, 15 May 2014 20:22:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Sebastian Krebs CC: PHP Internals References: <53750338.5070004@marc-bennewitz.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-bounce-key: webpack.hosteurope.de;php@marc-bennewitz.de;1400178173;36e85a8b; Subject: Re: [PHP-DEV] PR 659 / #60687: directly call a callable From: php@marc-bennewitz.de (Marc Bennewitz) On 15.05.2014 20:17, Sebastian Krebs wrote: > 2014-05-15 20:11 GMT+02:00 Marc Bennewitz >: > > Hi list > > Since the hype-hint "callable" is out it doesn't catch if the > callable argument is directly callable - so currently using > "call_user_func[_array]" is a requirement. > > @see http://3v4l.org/OYAgk > > class MyClass { > public static function test() { > var_dump(__METHOD__); > } > } > > function call(callable $f) { > $f(); > } > > call('MyClass::test'); > > I have created a PR to make this one possible and would very like to > see this one fixed from PHP-5.6 down to PHP-5.4 were the callable > type-hint was added. > > Is there something I have to do ? > (I'll be not available after the next week for 3 month) > > > > Hi > > I've fixed it :) > > http://3v4l.org/et7MX > > > class MyClass { > public static function test() { > var_dump(__METHOD__); > } > } > > function call(callable $f) { > $f(); > } > > call(['MyClass','test']); You missed the point here. The callable type-hint accepts static methods formed as string but you can't call it directly. As a API developer point of view you have to call it using "call_user_func[_array]" or to parse and normalize such arguments which reduces readability and performance a lot. > > > Regards, > Sebastian > > > > Marc > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > github.com/KingCrunch