mirror of
https://github.com/php/php-src.git
synced 2024-10-17 14:32:37 +00:00
e6bd5368ad
#Please review this change, I moved the routine which copies statics from the closure code to zend_variables.c #Please also have a look to check whether the TSRMLS_DC is correct, and whether it fits with the rest in zend_variables, because there you are using some macro magic and I am not exactly sure what the reason is for that.
38 lines
422 B
PHP
38 lines
422 B
PHP
--TEST--
|
|
Statics work like expected for language-based copy'n'paste. No link between methods from the same trait.
|
|
--FILE--
|
|
<?php
|
|
error_reporting(E_ALL);
|
|
|
|
trait Counter {
|
|
public function inc() {
|
|
static $c = 0;
|
|
$c = $c + 1;
|
|
echo "$c\n";
|
|
}
|
|
}
|
|
|
|
|
|
class C1 {
|
|
use Counter;
|
|
}
|
|
|
|
class C2 {
|
|
use Counter;
|
|
}
|
|
|
|
$o = new C1();
|
|
$o->inc();
|
|
$o->inc();
|
|
|
|
$p = new C2();
|
|
$p->inc();
|
|
$p->inc();
|
|
|
|
?>
|
|
--EXPECTF--
|
|
1
|
|
2
|
|
1
|
|
2
|