php-src/Zend/tests/bug66811.phpt
Nikita Popov ab97606b8a Fix compiler assumptions about self/etc wrt closures
* 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.
2015-05-06 18:13:19 +02:00

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"