mirror of
https://github.com/php/php-src.git
synced 2024-12-15 12:54:57 +08:00
6cc53981e5
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.
36 lines
470 B
PHP
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) {
|
|
}
|