note 119159 added to language.types.callable

From: Date: Tue, 12 Apr 2016 14:11:09 +0000
Subject: note 119159 added to language.types.callable
Groups: php.notes 
Request: Send a blank email to php-notes+get-205215@lists.php.net to get a copy of this message
@edanschwartz at gmail dot com You can use ::class property to always indicate the class you're in when using static methods: <?php class Foo { public static function doAwesomeThings() { FunctionCaller::callIt(self::class . '::someAwesomeMethod'); } public static function someAwesomeMethod() { // fantastic code goes here. } } class FunctionCaller { public static function callIt(callable $func) { call_user_func($func); } } Foo::doAwesomeThings(); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 83.142.190.62 ---- Manual Page -- http://php.net/manual/en/language.types.callable.php Edit -- https://master.php.net/note/edit/119159 Del: integrated -- https://master.php.net/note/delete/119159/integrated Del: useless -- https://master.php.net/note/delete/119159/useless Del: bad code -- https://master.php.net/note/delete/119159/bad+code Del: spam -- https://master.php.net/note/delete/119159/spam Del: non-english -- https://master.php.net/note/delete/119159/non-english Del: in docs -- https://master.php.net/note/delete/119159/in+docs Del: other reasons-- https://master.php.net/note/delete/119159 Reject -- https://master.php.net/note/reject/119159 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205215) next »