Anonymous functions inside static methods.

From: Date: Thu, 08 May 2014 22:02:45 +0000
Subject: Anonymous functions inside static methods.
Groups: php.internals 
Request: Send a blank email to internals+get-74072@lists.php.net to get a copy of this message
See this 3v4l (contents at bottom of the message): http://3v4l.org/pHkf7 I think Bar::bar() should definitely return 'Bar' (currently returns 'Foo') but what about the Bar::Baz() call? Until today I didn't even know you could declare a static anonymous function, so I'm not really sure what the expected behavior is. Script contents: <?php class Foo { static function bar() { $foo = static function() { return get_called_class(); }; return $foo(); } static function baz() { $foo = function() { return get_called_class(); }; return $foo(); } } class Bar extends Foo { } assert(Bar::bar() === 'Bar'); assert(Bar::baz() === 'Bar');

« previous php.internals (#74072) next »