php-src/Zend/tests/property_hooks/static_variables.phpt
Ilija Tovilo 780a8280d2
[RFC] Property hooks (#13455)
RFC: https://wiki.php.net/rfc/property-hooks

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2024-07-14 11:55:03 +02:00

41 lines
484 B
PHP

--TEST--
Hooks containing static variables
--FILE--
<?php
class Test {
public $prop {
get {
static $foo = [];
static $count = 1;
$foo[] = $count++;
return $foo;
}
}
}
$test = new Test;
var_dump($test->prop);
var_dump($test->prop);
var_dump($test->prop);
?>
--EXPECT--
array(1) {
[0]=>
int(1)
}
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}