ReflectionProperty::getDocComment

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

ReflectionProperty::getDocCommentObtiene los comentarios de documentación de una propiedad

Descripción

public ReflectionProperty::getDocComment(): string

Obtiene los comentarios de documentación de una propiedad.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Los comentarios de documentación de una propiedad.

Ejemplos

Ejemplo #1 Ejemplo de ReflectionProperty::getDocComment()

<?php
class Str
{
/**
* @var int La longitud del string
*/
public $length = 5;
}

$prop = new ReflectionProperty('Str', 'length');

var_dump($prop->getDocComment());

?>

El resultado del ejemplo sería algo similar a:

string(51) "/**
     * @var int  La longitud del string
     */"

Ver también

add a note

User Contributed Notes 1 note

up
1
Jim
3 years ago
Unfortunately, inherited doc comments are not supported.<?phpclass A {    /**     * @var string     */    public string $prop = 'A';}class B extends A {    public string $prop = 'B';}$prop = new ReflectionProperty('B', 'prop');var_dump($prop->getDocComment());?>results in FALSE
To Top