]> granicus.if.org Git - php/commitdiff
Fixed bug #45608 (closures don't work in static methods)
authorDmitry Stogov <dmitry@php.net>
Sat, 26 Jul 2008 14:15:19 +0000 (14:15 +0000)
committerDmitry Stogov <dmitry@php.net>
Sat, 26 Jul 2008 14:15:19 +0000 (14:15 +0000)
Zend/tests/closure_023.phpt [new file with mode: 0755]
Zend/zend_closures.c

diff --git a/Zend/tests/closure_023.phpt b/Zend/tests/closure_023.phpt
new file mode 100755 (executable)
index 0000000..634fb6d
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Closure 023: Closure declared in statically called method
+--FILE--
+<?php
+class foo {
+    public static function bar() {
+        $func = function() { echo "Done"; };
+        $func();
+    }
+}
+foo::bar();
+--EXPECT--
+Done
+
index c534c8838ac69f0e61a88452cadb6655da9ea831..2b5d1029d564b53497628c3a4fbc7c0fcc8aa5fa 100644 (file)
@@ -296,6 +296,7 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent
                        closure->this_ptr = this_ptr;
                        Z_ADDREF_P(this_ptr);
                } else {
+                       closure->func.common.fn_flags |= ZEND_ACC_STATIC;
                        closure->this_ptr = NULL;
                }
        } else {