php-src/Zend/tests/property_hooks/cpp.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

34 lines
530 B
PHP

--TEST--
Constructor property promotion
--FILE--
<?php
class Test {
public function __construct(
public $prop = 42 {
get => print("Getting\n");
set { print("Setting\n"); }
}
) {
echo "Constructor\n";
}
}
echo "Pre-test\n";
$test = new Test;
$test->prop;
$test->prop = 42;
$r = (new ReflectionProperty(Test::class, 'prop'));
var_dump($r->hasDefaultValue());
var_dump($r->getDefaultValue());
?>
--EXPECT--
Pre-test
Setting
Constructor
Getting
Setting
bool(false)
NULL