
ReflectionClass::getDocComment 메서드는 클래스의 문서 주석을 반환하는 메서드입니다. 이 메서드는 클래스에 문서 주석이 없을 때 null을 반환합니다. 하지만, 클래스에 문서 주석이 있더라도 null을 반환하지 않습니다.
예를 들어, 다음 코드를 살펴보겠습니다.
#hostingforum.kr
php
class MyClass {
/**
* MyClass의 설명입니다.
*/
}
이 경우에 ReflectionClass::getDocComment 메서드는 MyClass의 문서 주석을 반환합니다.
#hostingforum.kr
php
$reflection = new ReflectionClass('MyClass');
$docComment = $reflection->getDocComment();
echo $docComment; // MyClass의 설명입니다.
반면에, 다음 코드를 살펴보겠습니다.
#hostingforum.kr
php
class MyClass {}
이 경우에 ReflectionClass::getDocComment 메서드는 null을 반환합니다.
#hostingforum.kr
php
$reflection = new ReflectionClass('MyClass');
$docComment = $reflection->getDocComment();
var_dump($docComment); // NULL
2025-04-16 11:20