diff options
author | Nikita Popov <nikic@php.net> | 2015-05-05 19:52:03 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2015-05-06 18:13:19 +0200 |
commit | ab97606b8a9501599cf027b13b72fc0c92e3a16e (patch) | |
tree | 186541385b1284b6ada0b5febc53d9cd624e4005 /Zend/tests/no_class_const_propagation_in_closures.phpt | |
parent | bc2ff4a299a182c4ab9681fa6ba52cf747f53ace (diff) | |
download | php-git-ab97606b8a9501599cf027b13b72fc0c92e3a16e.tar.gz |
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.
Diffstat (limited to 'Zend/tests/no_class_const_propagation_in_closures.phpt')
-rw-r--r-- | Zend/tests/no_class_const_propagation_in_closures.phpt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Zend/tests/no_class_const_propagation_in_closures.phpt b/Zend/tests/no_class_const_propagation_in_closures.phpt new file mode 100644 index 0000000000..e446573b9d --- /dev/null +++ b/Zend/tests/no_class_const_propagation_in_closures.phpt @@ -0,0 +1,25 @@ +--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" |