xref: /PHP-5.6/Zend/tests/closure_bug66622.phpt (revision f47976dd)
1--TEST--
2Bug 66622: Closures do not correctly capture the late bound class (static::) in some cases
3
4--FILE--
5<?php
6class A {
7    static function name() { return 'A'; }
8    function foo() {
9        $fn = function() { return static::name(); };
10        echo static::name() . ' vs ' . $fn() . "\n";
11    }
12    function bar() {
13        $fn = static function() { return static::name(); };
14        echo static::name() . ' vs ' . $fn() . "\n";
15    }
16    static function baz() {
17        $fn = function() { return static::name(); };
18        echo static::name() . ' vs ' . $fn() . "\n";
19    }
20}
21class B extends A {
22    static function name() { return 'B'; }
23}
24
25function test() {
26    (new B)->foo();
27    (new B)->bar();
28    (new B)->baz();
29    B::baz();
30}
31test();
32
33--EXPECT--
34B vs B
35B vs B
36B vs B
37B vs B
38