xref: /php-src/ext/opcache/tests/jit/closure_001.phpt (revision 08b2ab22)
1--TEST--
2Closures should be always called with ZEND_ACC_CLOSURE flag set
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.file_update_protection=0
7opcache.protect_memory=1
8opcache.jit_hot_func=2
9--EXTENSIONS--
10opcache
11--FILE--
12<?php
13class Foo {
14}
15
16function bar() {
17    return function () {
18        return function () {
19            return function () {
20                return 42;
21            };
22        };
23    };
24}
25
26$foo = new Foo;
27$f = bar();
28
29var_dump($f->call($foo));
30var_dump($f->call($foo));
31var_dump($f());
32?>
33--EXPECTF--
34object(Closure)#3 (4) {
35  ["name"]=>
36  string(%d) "{closure:%s:%d}"
37  ["file"]=>
38  string(%d) "%s"
39  ["line"]=>
40  int(%d)
41  ["this"]=>
42  object(Foo)#1 (0) {
43  }
44}
45object(Closure)#3 (4) {
46  ["name"]=>
47  string(%d) "{closure:%s:%d}"
48  ["file"]=>
49  string(%d) "%s"
50  ["line"]=>
51  int(%d)
52  ["this"]=>
53  object(Foo)#1 (0) {
54  }
55}
56object(Closure)#3 (3) {
57  ["name"]=>
58  string(%d) "{closure:%s:%d}"
59  ["file"]=>
60  string(%d) "%s"
61  ["line"]=>
62  int(%d)
63}
64