]> granicus.if.org Git - php/commitdiff
Added test and possible fix for https://bugs.php.net/bug.php?id=67068
authorDanack <Danack@basereality.com>
Tue, 13 Jan 2015 01:24:19 +0000 (01:24 +0000)
committerStanislav Malyshev <stas@php.net>
Sun, 1 Feb 2015 07:13:55 +0000 (23:13 -0800)
Zend/zend_closures.c
ext/reflection/tests/bug67068.phpt [new file with mode: 0644]

index bc193df6f118da24662480049b026ce80441c079..24bc6da26bd92a2e69f32372b6dc2a00255d7df6 100644 (file)
@@ -449,6 +449,7 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent
 
        closure->func = *func;
        closure->func.common.prototype = NULL;
+       closure->func.common.fn_flags |= ZEND_ACC_CLOSURE;
 
        if ((scope == NULL) && (this_ptr != NULL)) {
                /* use dummy scope if we're binding an object without specifying a scope */
diff --git a/ext/reflection/tests/bug67068.phpt b/ext/reflection/tests/bug67068.phpt
new file mode 100644 (file)
index 0000000..35c1b16
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #67068 (ReflectionFunction::getClosure returns something that doesn't report as a closure)
+--FILE--
+<?php
+class MyClass {
+    public function method() {}
+}
+
+$object = new MyClass;
+$reflector = new \ReflectionMethod($object, 'method');
+$closure = $reflector->getClosure($object);
+
+$closureReflector = new \ReflectionFunction($closure);
+
+var_dump($closureReflector->isClosure());
+?>
+--EXPECT--
+bool(true)
\ No newline at end of file