mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

RFC: https://wiki.php.net/rfc/property-hooks Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
41 lines
484 B
PHP
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)
|
|
}
|