1
0
mirror of https://github.com/php/php-src.git synced 2026-04-16 12:31:06 +02:00
Files
archived-php-src/Zend/tests/method_static_var.phpt
Nikita Popov 5d160e309e Fix static variable behavior with inheritance
When a method is inherited, the static variables will now always
use the initial values, rather than the values at the time of
inheritance. As such, behavior no longer depends on whether
inheritance happens before or after a method has been called.

This is implemented by always keeping static_variables as the
original values, and static_variables_ptr as the modified copy.

Closes GH-6705.
2021-02-18 11:18:19 +01:00

25 lines
348 B
PHP

--TEST--
Initial value of static var in method depends on the include time of the class definition
--FILE--
<?php
class Foo {
public static function test() {
static $i = 0;
var_dump(++$i);
}
}
Foo::test();
eval("class Bar extends Foo {}");
Foo::test();
Bar::test();
Bar::test();
?>
--EXPECT--
int(1)
int(2)
int(1)
int(2)