ReflectionProperty::getDocComment

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

ReflectionProperty::getDocCommentÖzellik açıklamalarını döndürür

Açıklama

public ReflectionProperty::getDocComment(): string|false

Özellik ile ilgili açıklamaları döndürür.

Değiştirgeler

Bu işlevin değiştirgesi yoktur.

Dönen Değerler

Varsa açıklamalar, yoksa false.

Örnekler

Örnek 1 - ReflectionProperty::getDocComment() örneği

<?php
class Str
{
    
/**
     * @var int  Dizge uzunluğu
     */
    
public $length 5;
}

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

var_dump($prop->getDocComment());

?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

string(44) "/**
     * @var int  Dizge uzunluğu
     */"

Örnek 2 - Çoklu özellik bildirimi

Aynı belgelendirme açıklaması birden fazla özellik hakkında ise açıklama sadece ilk özellik için döner.

<?php
class Foo
{
    
/** @var string */
    
public $a$b;
}
$class = new \ReflectionClass('Foo');
foreach (
$class->getProperties() as $property) {
    echo 
$property->getName() . ': ' var_export($property->getDocComment(), true) . PHP_EOL;
}
?>

Yukarıdaki örneğin çıktısı:

a: '/** @var string */'
b: false

Ayrıca Bakınız

add a note add a note

User Contributed Notes

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