php-src/Zend/tests/self_method_or_prop_outside_class.phpt
2020-07-10 21:05:28 +02:00

37 lines
797 B
PHP

--TEST--
Accessing self:: properties or methods outside a class
--FILE--
<?php
$fn = function() {
$str = "foo";
try {
self::${$str . "bar"};
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
unset(self::${$str . "bar"});
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
isset(self::${$str . "bar"});
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
self::{$str . "bar"}();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
};
$fn();
?>
--EXPECT--
Cannot access "self" when no class scope is active
Cannot access "self" when no class scope is active
Cannot access "self" when no class scope is active
Cannot access "self" when no class scope is active