php-src/Zend/tests/no_class_const_propagation_in_closures.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

26 lines
367 B
PHP

--TEST--
self:: class constants should not be propagated into closures, due to scope rebinding
--FILE--
<?php
class A {
const C = 'A::C';
public function f() {
return function() {
return self::C;
};
}
}
class B {
const C = 'B::C';
}
$f = (new A)->f();
var_dump($f->bindTo(null, 'B')());
?>
--EXPECT--
string(4) "B::C"