]> granicus.if.org Git - php/commitdiff
Observe fake closures
authorSammy Kaye Powers <sammyk@php.net>
Fri, 15 Jan 2021 18:07:40 +0000 (10:07 -0800)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 28 Jan 2021 09:03:41 +0000 (10:03 +0100)
Closes GH-6607.

Zend/zend_observer.c
ext/zend_test/tests/observer_closure_02.phpt [new file with mode: 0644]

index a60428ee04fa1f7a7c93b8cb11e30007e7366a3e..2bb7f9afa2a6910b01ab914a544e67d344f49e81 100644 (file)
@@ -29,7 +29,7 @@
 #define ZEND_OBSERVER_NOT_OBSERVED ((void *) 2)
 
 #define ZEND_OBSERVABLE_FN(fn_flags) \
-       (!(fn_flags & (ZEND_ACC_CALL_VIA_TRAMPOLINE | ZEND_ACC_FAKE_CLOSURE)))
+       (!(fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))
 
 typedef struct _zend_observer_fcall_data {
        // points after the last handler
diff --git a/ext/zend_test/tests/observer_closure_02.phpt b/ext/zend_test/tests/observer_closure_02.phpt
new file mode 100644 (file)
index 0000000..9d6cc90
--- /dev/null
@@ -0,0 +1,32 @@
+--TEST--
+Observer: Observability of fake closures
+--SKIPIF--
+<?php if (!extension_loaded('zend-test')) die('skip: zend_test extension required'); ?>
+--INI--
+zend_test.observer.enabled=1
+zend_test.observer.observe_all=1
+--FILE--
+<?php
+class Foo
+{
+    public function bar()
+    {
+        echo 'Called as fake closure.' . PHP_EOL;
+    }
+}
+
+$callable = [new Foo(), 'bar'];
+$closure = \Closure::fromCallable($callable);
+$closure();
+
+echo 'DONE' . PHP_EOL;
+?>
+--EXPECTF--
+<!-- init '%s%eobserver_closure_%d.php' -->
+<file '%s%eobserver_closure_%d.php'>
+  <!-- init Foo::bar() -->
+  <Foo::bar>
+Called as fake closure.
+  </Foo::bar>
+DONE
+</file '%s%eobserver_closure_%d.php'>