]> granicus.if.org Git - php/commitdiff
Closure::fromCallable(): Fix late static binding
authorNikita Popov <nikic@php.net>
Tue, 5 Jul 2016 13:22:13 +0000 (15:22 +0200)
committerNikita Popov <nikic@php.net>
Tue, 5 Jul 2016 13:31:11 +0000 (15:31 +0200)
Zend/tests/closures/closure_from_callable_lsb.phpt [new file with mode: 0644]
Zend/zend_closures.c

diff --git a/Zend/tests/closures/closure_from_callable_lsb.phpt b/Zend/tests/closures/closure_from_callable_lsb.phpt
new file mode 100644 (file)
index 0000000..bd57fba
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Testing Closure::fromCallable() functionality: Late static binding
+--FILE--
+<?php
+
+class Foo {
+    const BAR = 1;
+    public static function method() {
+        return static::BAR;
+    }
+}
+var_dump(Closure::fromCallable(['Foo', 'method'])());
+
+?>
+--EXPECT--
+int(1)
index 6185c212a887c00233ceafbc8c6e6faa6011d826..ef321e7cbf9fa2e5293573f1bb08b7bca7d8562d 100644 (file)
@@ -297,7 +297,7 @@ static int zend_create_closure_from_callable(zval *return_value, zval *callable,
                ZVAL_OBJ(&instance, fcc.object);
                zend_create_fake_closure(return_value, mptr, mptr->common.scope, fcc.object->ce, &instance);
        } else {
-               zend_create_fake_closure(return_value, mptr, mptr->common.scope, NULL, NULL);
+               zend_create_fake_closure(return_value, mptr, mptr->common.scope, mptr->common.scope, NULL);
        }
 
        return SUCCESS;