xref: /PHP-8.0/Zend/tests/closure_033.phpt (revision d30cd7d7)
1--TEST--
2Closure 033: Dynamic closure property and private function
3--FILE--
4<?php
5
6class Test {
7    public $func;
8    function __construct() {
9        $this->func = function() {
10            echo __METHOD__ . "()\n";
11        };
12    }
13    private function func() {
14        echo __METHOD__ . "()\n";
15    }
16}
17
18$o = new Test;
19$f = $o->func;
20$f();
21$o->func();
22
23?>
24===DONE===
25--EXPECTF--
26{closure}()
27
28Fatal error: Uncaught Error: Call to private method Test::func() from global scope in %s:%d
29Stack trace:
30#0 {main}
31  thrown in %sclosure_033.php on line %d
32