php8.5
Home/ Manual/ reflection / reflectionproperty/ ReflectionProperty::isPromoted

ReflectionProperty::isPromoted

PHP function Edit on GitHub ✎

(PHP 8)

Checks if property is promoted

Description

ReflectionProperty::isPromoted(): bool

Checks whether the property is promoted

Parameters Parameters

Return Values

true if the property is promoted, false otherwise.

Examples

ReflectionProperty::isPromoted example

php
<?php
class Foo {
    public $baz;

    public function __construct(public $bar) {}
}

$o = new Foo(42);
$o->baz = 42;

$ro = new ReflectionObject($o);
var_dump($ro->getProperty('bar')->isPromoted());
var_dump($ro->getProperty('baz')->isPromoted());
?>

The above example will output:

output
bool(true)
bool(false)

See Also

  • ReflectionProperty::isDefault
  • ReflectionProperty::isInitialized
  • ReflectionProperty::getValue

Source: reference/reflection/reflectionproperty/ispromoted.xml · from the official PHP manual (php/doc-en)