php-src/Zend/tests/static_variable_in_private_trait_method.phpt
Nikita Popov 6cc53981e5 Addref static vars when not copying private method
While we don't need to give this method separate static vars, we
do still need to perform an addref, as there will be a corresponding
delref in the dtor.
2019-08-29 14:47:09 +02:00

36 lines
470 B
PHP

--TEST--
Behavior of static variable in private trait method
--FILE--
<?php
trait T {
private static function method() {
static $x;
if ($x === null) $x = new stdClass;
return $x;
}
public static function method2() {
return self::method();
}
}
class C {
use T;
}
var_dump(C::method2());
class D extends C {
use T;
}
var_dump(D::method2());
?>
--EXPECT--
object(stdClass)#1 (0) {
}
object(stdClass)#2 (0) {
}