(PHP 5, PHP 7, PHP 8)
Introduction
La classe ReflectionMethod rapporte
des informations sur une méthode.
Synopsis de la classe
class
ReflectionMethod
extends
ReflectionFunctionAbstract
{
/* Constantes */
public
const
int
IS_STATIC;
public
const
int
IS_PUBLIC;
public
const
int
IS_PROTECTED;
public
const
int
IS_PRIVATE;
public
const
int
IS_ABSTRACT;
public
const
int
IS_FINAL;
/* Propriétés */
public
string
$class;
/* Propriétés héritées */
public
string
$name;
/* Méthodes */
public __construct(object|string
$objectOrMethod, string
$method)
public __construct(string
$classMethod)
public static export(string
$class, string
$name, bool
$return =
false): string
public getClosure(?object
$object =
null): Closure
public
getDeclaringClass(): ReflectionClass
public
getModifiers(): int
public
getPrototype(): ReflectionMethod
public hasPrototype(): bool
public invoke(?object
$object, mixed
...$args): mixed
public invokeArgs(?object
$object, array
$args): mixed
public
isAbstract(): bool
public
isConstructor(): bool
public
isDestructor(): bool
public
isFinal(): bool
public
isPrivate(): bool
public
isProtected(): bool
public
isPublic(): bool
public setAccessible(bool
$accessible): void
public
__toString(): string
/* Méthodes héritées */
private ReflectionFunctionAbstract::__clone(): void
public ReflectionFunctionAbstract::getAttributes(?string
$name =
null, int
$flags = 0): array
public ReflectionFunctionAbstract::getClosureScopeClass(): ?ReflectionClass
public ReflectionFunctionAbstract::getClosureThis(): ?object
public ReflectionFunctionAbstract::getClosureUsedVariables(): array
public ReflectionFunctionAbstract::getDocComment(): string|false
public ReflectionFunctionAbstract::getEndLine(): int|false
public ReflectionFunctionAbstract::getExtension(): ?ReflectionExtension
public ReflectionFunctionAbstract::getExtensionName(): string|false
public ReflectionFunctionAbstract::getFileName(): string|false
public ReflectionFunctionAbstract::getName(): string
public ReflectionFunctionAbstract::getNamespaceName(): string
public ReflectionFunctionAbstract::getNumberOfParameters(): int
public ReflectionFunctionAbstract::getNumberOfRequiredParameters(): int
public ReflectionFunctionAbstract::getParameters(): array
public ReflectionFunctionAbstract::getReturnType(): ?ReflectionType
public ReflectionFunctionAbstract::getShortName(): string
public ReflectionFunctionAbstract::getStartLine(): int|false
public ReflectionFunctionAbstract::getStaticVariables(): array
public ReflectionFunctionAbstract::getTentativeReturnType(): ?ReflectionType
public ReflectionFunctionAbstract::hasReturnType(): bool
public ReflectionFunctionAbstract::hasTentativeReturnType(): bool
public ReflectionFunctionAbstract::inNamespace(): bool
public ReflectionFunctionAbstract::isClosure(): bool
public ReflectionFunctionAbstract::isDeprecated(): bool
public ReflectionFunctionAbstract::isGenerator(): bool
public ReflectionFunctionAbstract::isInternal(): bool
public ReflectionFunctionAbstract::isStatic(): bool
public ReflectionFunctionAbstract::isUserDefined(): bool
public ReflectionFunctionAbstract::isVariadic(): bool
public ReflectionFunctionAbstract::returnsReference(): bool
abstract public ReflectionFunctionAbstract::__toString(): void
}
Propriétés
- name
-
Nom de la méthode
- class
-
Nom de la classe
Constantes pré-définies
Modificateurs de ReflectionMethod
ReflectionMethod::IS_STATIC
-
Indique que la méthode est statique
Antérieur à PHP 7.4.0, la valeur était 1.
ReflectionMethod::IS_PUBLIC
-
Indique que la méthode est publique
Antérieur à PHP 7.4.0, la valeur était 256.
ReflectionMethod::IS_PROTECTED
-
Indique que la méthode est protégée
Antérieur à PHP 7.4.0, la valeur était 512.
ReflectionMethod::IS_PRIVATE
-
Indique que la méthode est privée
Antérieur à PHP 7.4.0, la valeur était 1024.
ReflectionMethod::IS_ABSTRACT
-
Indique que la méthode est abstraite
Antérieur à PHP 7.4.0, la valeur était 2.
ReflectionMethod::IS_FINAL
-
Indique que la méthode est finale
Antérieur à PHP 7.4.0, la valeur était 4.
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
- ReflectionMethod::__construct — Construit un nouvel objet ReflectionMethod
- ReflectionMethod::export — Exportation d'une méthode de reflection
- ReflectionMethod::getClosure — Retourne une fermeture créée dynamiquement pour la méthode
- ReflectionMethod::getDeclaringClass — Récupère la déclaration de la classe de la méthode réfléchie
- ReflectionMethod::getModifiers — Récupère les modificateurs de la méthode
- ReflectionMethod::getPrototype — Récupère le prototype de la méthode (s'il existe)
- ReflectionMethod::hasPrototype — Returns whether a method has a prototype
- ReflectionMethod::invoke — Invoque
- ReflectionMethod::invokeArgs — Invoque les arguments
- ReflectionMethod::isAbstract — Vérifie si la méthode est abstraite
- ReflectionMethod::isConstructor — Vérifie si la méthode est un constructeur
- ReflectionMethod::isDestructor — Vérifie si la méthode est un destructeur
- ReflectionMethod::isFinal — Vérifie si la méthode est finale
- ReflectionMethod::isPrivate — Vérifie si la méthode est privée
- ReflectionMethod::isProtected — Vérifie si la méthode est protégée
- ReflectionMethod::isPublic — Vérifie si la méthode est publique
- ReflectionMethod::setAccessible — Définit l'accessibilité de la méthode
- ReflectionMethod::__toString — Retourne une représentation textuelle de la méthode