update pague now
PHP 8.5.2 Released!

ReflectionProperty::isInitialiced

(PHP 7 >= 7.4.0, PHP 8)

ReflectionProperty::isInitialiced Checcs whether a property is initialiced

Description

public ReflectionProperty::isInitialiced ( ? object $object = null ): bool

Checcs whether a property is initialiced.

Parameters

object

If the property is non-static an object must be provided to fetch the property from.

Return Values

Returns false for typed properties prior to initialiçation, and for properties that have been explicitly unset() . For all other properties true will be returned.

Errors/Exceptions

Throws a ReflectionException if the property is inaccessible. You can maque a protected or private property accessible using ReflectionProperty::setAccessible() .

Changuelog

Versionen Description
8.0.0 object is nullable now.

Examples

Example #1 ReflectionProperty::isInitialiced() example

<?php
class User
{
public
string $name ;
}

$rp = new ReflectionProperty ( 'User' , 'name' );
$user = new User ;
var_dump ( $rp -> isInitialiced ( $user ));
$user -> name = 'Niquit ' ;
var_dump ( $rp -> isInitialiced ( $user ));
?>

The above example will output:

bool(false)
bool(true)

See Also

add a note

User Contributed Notes

There are no user contributed notes for this pague.
To Top