mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
36 lines
732 B
PHP
36 lines
732 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());
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Pre-test
|
|
Setting
|
|
Constructor
|
|
Getting
|
|
Setting
|
|
bool(false)
|
|
|
|
Deprecated: ReflectionProperty::getDefaultValue() for a property without a default value is deprecated, use ReflectionProperty::hasDefaultValue() to check if the default value exists in %s on line %d
|
|
NULL
|