note 116267 added to closure.bind

From: Date: Wed, 03 Dec 2014 20:22:42 +0000
Subject: note 116267 added to closure.bind
Groups: php.notes 
Request: Send a blank email to php-notes+get-201060@lists.php.net to get a copy of this message
If you need to validate whether or not a closure can be bound to a PHP object, you will have to resort to using reflection. <?php /** * @param \Closure $callable * * @return bool */ function isBindable(\Closure $callable) { $bindable = false; $reflectionFunction = new \ReflectionFunction($callable); if ( $reflectionFunction->getClosureScopeClass() === null || $reflectionFunction->getClosureThis() !== null ) { $bindable = true; } return $bindable; } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 37.0.85.243 ---- Manual Page -- http://php.net/manual/en/closure.bind.php Edit -- https://master.php.net/note/edit/116267 Del: integrated -- https://master.php.net/note/delete/116267/integrated Del: useless -- https://master.php.net/note/delete/116267/useless Del: bad code -- https://master.php.net/note/delete/116267/bad+code Del: spam -- https://master.php.net/note/delete/116267/spam Del: non-english -- https://master.php.net/note/delete/116267/non-english Del: in docs -- https://master.php.net/note/delete/116267/in+docs Del: other reasons-- https://master.php.net/note/delete/116267 Reject -- https://master.php.net/note/reject/116267 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201060) next »