Bug #74558 [NEW]: Can't rebind closure which returns by Closure::fromCallable()
From: igorchernin at yahoo dot com
Operating system: Windows
PHP version: 7.1.4
Package: *General Issues
Bug Type: Bug
Bug description:Can't rebind closure which returns by Closure::fromCallable()
Description:
------------
---
From manual page: http://www.php.net/closure.fromcallable
---
Get error: Cannot rebind scope of closure created by
ReflectionFunctionAbstract::getClosure()
I am getting the error after converting function to Closure and after
rebind the Closure to some object.
I can't bind (and also bindTo) closure which returned by
Closure::fromCallable().
Test script:
---------------
<?php
class A {
private $name;
public function __construct($name)
{
$this->name = $name;
}
}
// test callable
function getName()
{
return $this->name;
}
$bob = new A("Bob");
$cl1 = Closure::fromCallable("getName");
$cl1 = $cl1->bindTo($bob, 'A');
$result = $cl1();
echo $result
Expected result:
----------------
Bob
Actual result:
--------------
Warning: Cannot rebind scope of closure created by
ReflectionFunctionAbstract::getClosure() on line 18
--
Edit bug report at https://bugs.php.net/bug.php?id=74558&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74558&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74558&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74558&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74558&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74558&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74558&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74558&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74558&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74558&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74558&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74558&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74558&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74558&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74558&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74558&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74558&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74558&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74558&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74558&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74558&r=mysqlcfg
Thread (5 messages)
- igorchernin at yahoo dot com