Bug #69811 [NEW]: Cannot bind closure to scope of internal class stdClass
| From: | olivier dot laviale at gmail dot com | Date: | Fri, 12 Jun 2015 12:55:13 +0000 |
| Subject: | Bug #69811 [NEW]: Cannot bind closure to scope of internal class stdClass | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-193357@lists.php.net to get a copy of this message | ||
From: olivier dot laviale at gmail dot com
Operating system: Linux
PHP version: 7.0.0alpha1
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Cannot bind closure to scope of internal class stdClass
Description:
------------
Hi,
Looks like the following code is no longer possible with PHP7.
The following error is raised: "Cannot bind closure to scope of internal
class stdClass".
I understand that PHP7 may introduce BC changes, but there's no mention
about it in the documentation: http://php.net/manual/en/closure.bind.php
Test script:
---------------
<?php
class A
{
private $a = 1;
protected $b = 2;
public $c = 3;
static public function get_public_vars()
{
$get_public_vars = Closure::bind(function($object) {
return get_object_vars($object);
}, null, 'stdClass');
return $get_public_vars($this);
}
}
var_dump(A::get_public_vars(new A));
Expected result:
----------------
[ 'c' => 3 ]
Actual result:
--------------
Error: Cannot bind closure to scope of internal class stdClass
--
Edit bug report at https://bugs.php.net/bug.php?id=69811&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69811&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69811&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69811&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69811&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69811&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69811&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69811&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69811&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69811&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69811&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69811&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69811&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69811&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69811&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69811&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69811&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69811&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69811&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69811&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69811&r=mysqlcfg