xref: /PHP-8.2/Zend/tests/closure_037.phpt (revision f8d79582)
1--TEST--
2Closure 037: self:: and static:: within closures
3--FILE--
4<?php
5class A {
6    private $x = 0;
7
8    function getClosure () {
9            return function () {
10                $this->x++;
11                self::printX();
12                self::print42();
13                static::print42();
14            };
15    }
16
17    function printX () {
18        echo $this->x."\n";
19    }
20
21    function print42() {
22        echo "42\n";
23    }
24}
25
26class B extends A {
27    function print42() {
28        echo "forty two\n";
29    }
30}
31
32$a = new A;
33$closure = $a->getClosure();
34$closure();
35$b = new B;
36$closure = $b->getClosure();
37$closure();
38?>
39Done.
40--EXPECT--
411
4242
4342
441
4542
46forty two
47Done.
48