PHP Velho Oeste 2024

ReflectionProperty::getDocComment

(PHP 5 >= 5.1.0, PHP 7)

ReflectionProperty::getDocCommentGets the property doc comment

설명

public string ReflectionProperty::getDocComment ( void )

Gets the doc comment for a property.

인수

이 함수는 인수가 없습니다.

반환값

The property doc comment.

예제

Example #1 ReflectionProperty::getDocComment() example

<?php
class Str
{
    
/**
     * @var int  The length of the string
     */
    
public $length 5;
}

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

var_dump($prop->getDocComment());

?>

위 예제의 출력 예시:

string(53) "/**
     * @var int  The length of the string
     */"

참고

add a note add a note

User Contributed Notes 1 note

up
1
Jim
1 year ago
Unfortunately, inherited doc comments are not supported.

<?php

class 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