mirror of
https://github.com/php/php-src.git
synced 2024-12-18 14:30:35 +08:00
ab97606b8a
* Don't throw an error if self/parent/static are used in a closure (outside a class). * Don't propagate self:: constants into closures * Use runtime fetch for self::class in closures Fixes bug #66811.
38 lines
572 B
PHP
38 lines
572 B
PHP
--TEST--
|
|
Bug #66811: Cannot access static::class in lambda, writen outside of a class
|
|
--FILE--
|
|
<?php
|
|
class A {
|
|
public static function f() {
|
|
return function () {
|
|
var_dump(self::class);
|
|
var_dump(static::class);
|
|
};
|
|
}
|
|
}
|
|
|
|
class B extends A {}
|
|
|
|
$f = B::f();
|
|
$f();
|
|
|
|
$g = $f->bindTo(null, A::class);
|
|
$g();
|
|
|
|
$foo = function () {
|
|
var_dump(self::class);
|
|
var_dump(static::class);
|
|
};
|
|
|
|
$bar = $foo->bindTo(null, A::class);
|
|
$bar();
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(1) "A"
|
|
string(1) "B"
|
|
string(1) "A"
|
|
string(1) "A"
|
|
string(1) "A"
|
|
string(1) "A"
|