Bug #64761 [NEW]: rebinding of closures doesn't work when they are declared in a static method
From: netmosfera at gmail dot com
Operating system: any
PHP version: 5.5.0beta4
Package: *General Issues
Bug Type: Bug
Bug description:rebinding of closures doesn't work when they are declared in a static method
Description:
------------
<?
class Test
{
public $clos;
public $bobo = 22;
static function blah(){
return new static(function(){ echo $this->bobo; });
}
function __construct(\Closure $c)
{
$this->clos = $c->bindTo($this, $this);
}
}
// perfectly fine when closure is declared in global space
$a = new Test(function(){ echo $this->bobo; });
$clos = $a->clos;
$clos();
// binding doesn't work when closure is declared in a static method
$a = Test::blah();
$clos = $a->clos;
$clos();
// results in: Warning: Cannot bind an instance to a static closure
--
Edit bug report at https://bugs.php.net/bug.php?id=64761&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64761&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64761&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64761&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64761&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64761&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64761&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64761&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64761&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64761&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64761&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64761&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64761&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64761&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64761&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64761&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64761&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64761&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64761&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64761&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64761&r=mysqlcfg
Thread (15 messages)
- netmosfera at gmail dot com
- laruence@php.netBug #64761 [Opn->Wfx]: rebinding of closures doesn't work when they are declared in a static method
- netmosfera at gmail dot comBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- hanskrentel at yahoo dot deBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- laruence@php.netBug #64761 [Wfx]: rebinding of closures doesn't work when they are declared in a static method
- wanwizard at fuelphp dot comBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- wanwizard at fuelphp dot comBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- wanwizard at fuelphp dot comBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- agita at live dot deBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- php at maisqi dot comBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- sjaillet at gmail dot comBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- dave at shax dot comBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- Cpuidle at gmx dot deBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method
- nikic@php.netBug #64761 [Wfx]: rebinding of closures doesn't work when they are declared in a static method
- kelunik@php.netBug #64761 [Com]: rebinding of closures doesn't work when they are declared in a static method