(PHP 5, PHP 7, PHP 8)
Introduction
La classe ReflectionProperty rapporte
des informations sur les propriétés des classes.
Synopsis de la classe
class
ReflectionProperty
implements
Reflector {
/* Constantes */
public
const
int
IS_STATIC;
public
const
int
IS_READONLY;
public
const
int
IS_PUBLIC;
public
const
int
IS_PROTECTED;
public
const
int
IS_PRIVATE;
/* Propriétés */
public
string
$name;
public
string
$class;
/* Méthodes */
public __construct(object|string
$class, string
$property)
private __clone(): void
public static export(mixed
$class, string
$name, bool
$return = ?): string
public getAttributes(?string
$name =
null, int
$flags = 0): array
public
getDeclaringClass(): ReflectionClass
public getDefaultValue(): mixed
public
getDocComment(): string|false
public
getModifiers(): int
public
getName(): string
public
gettype(): ?ReflectionType
public getValue(?object
$object =
null): mixed
public hasDefaultValue(): bool
public hasType(): bool
public
isDefault(): bool
public isInitialized(?object
$object =
null): bool
public
isPrivate(): bool
public isPromoted(): bool
public
isProtected(): bool
public
isPublic(): bool
public isReadOnly(): bool
public
isStatic(): bool
public setAccessible(bool
$accessible): void
public setValue(object
$object, mixed
$value): void
public
__toString(): string
}
Propriétés
- name
-
Nom de la propriété. En lecture seule, lance une
ReflectionException lors d'une tentative d'écriture.
- class
-
Nom de la classe où la propriété a été définie. En lecture seule, lance une
ReflectionException lors d'une tentative d'écriture.
Constantes pré-définies
Modificateurs de ReflectionProperty
ReflectionProperty::IS_STATIC
-
Indique que la propriété est
static
Antérieur à PHP 7.4.0, la valeur était 1.
ReflectionProperty::IS_READONLY
-
Indique que la propriété est
readonly
Disponible à partir de PHP 8.1.0.
ReflectionProperty::IS_PUBLIC
-
Indique que la propriété est
publique.
Antérieur à PHP 7.4.0, la valeur était 256.
ReflectionProperty::IS_PROTECTED
-
Indique que la propriété est
protégée.
Antérieur à PHP 7.4.0, la valeur était 512.
ReflectionProperty::IS_PRIVATE
-
Indique que la propriété est
privée.
Antérieur à PHP 7.4.0, la valeur était 1024.
Note:
La valeur de ces constantes peut changer entre les versions de PHP.
Il est recommandé de toujours utiliser les constantes
et de ne pas dépendre sur les valeurs directement.
Historique
Sommaire
- ReflectionProperty::__clone — Clonage
- ReflectionProperty::__construct — Construit un nouvel objet ReflectionProperty
- ReflectionProperty::export — Exporte
- ReflectionProperty::getAttributes — Gets Attributes
- ReflectionProperty::getDeclaringClass — Récupère la classe déclarante
- ReflectionProperty::getDefaultValue — Returns the default value declared for a property
- ReflectionProperty::getDocComment — Récupère le commentaire de documentation d'une propriété
- ReflectionProperty::getModifiers — Récupère les modificateurs de propriété
- ReflectionProperty::getName — Récupère le nom de la propriété
- ReflectionProperty::getType — Récupère le type d'une propriété
- ReflectionProperty::getValue — Récupère la valeur de la propriété
- ReflectionProperty::hasDefaultValue — Checks if property has a default value declared
- ReflectionProperty::hasType — Vérifie si la propriété à un type
- ReflectionProperty::isDefault — Vérifie si la propriété est celle par défaut
- ReflectionProperty::isInitialized — Vérifie si une propriété est initialisée
- ReflectionProperty::isPrivate — Vérifie si la propriété est privée
- ReflectionProperty::isPromoted — Checks if property is promoted
- ReflectionProperty::isProtected — Vérifie si la propriété est protégée
- ReflectionProperty::isPublic — Vérifie si la propriété est publique
- ReflectionProperty::isReadOnly — Checks if property is readonly
- ReflectionProperty::isStatic — Vérifie si la propriété est statique
- ReflectionProperty::setAccessible — Définit l'accessibilité d'une propriété
- ReflectionProperty::setValue — Définit la valeur de la propriété
- ReflectionProperty::__toString — Récupère une représentation textuelle