mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Observe fake closures
Closes GH-6607.
This commit is contained in:
parent
e9b8b085a7
commit
17142eab22
2 changed files with 33 additions and 1 deletions
|
@ -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
|
||||
|
|
32
ext/zend_test/tests/observer_closure_02.phpt
Normal file
32
ext/zend_test/tests/observer_closure_02.phpt
Normal file
|
@ -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'>
|
Loading…
Add table
Add a link
Reference in a new issue