
getDefaultProperties 메서드는 클래스의 정적 속성을 가져오기 위한 메서드입니다. 이 메서드는 클래스의 인스턴스 속성을 가져올 수 없으며, private 속성을 가져오려고 해도 접근 불가로 처리됩니다.
getDefaultProperties 메서드는 클래스의 정적 속성을 가져올 때, 접근 가능한 속성만 가져오고 접근 불가 속성은 무시합니다. 따라서 private 속성을 가져오려고 하면 getDefaultProperties 메서드는 해당 속성을 가져오지 않습니다.
getDefaultProperties 메서드는 클래스의 정적 속성을 가져올 때, 속성의 이름과 타입을 반환합니다. 예를 들어, 다음 코드를 살펴보겠습니다.
#hostingforum.kr
php
class MyClass {
public static $publicProperty = 'public';
protected static $protectedProperty = 'protected';
private static $privateProperty = 'private';
}
$reflectionClass = new ReflectionClass('MyClass');
$defaultProperties = $reflectionClass->getDefaultProperties();
print_r($defaultProperties);
위 코드를 실행하면 다음 결과가 출력됩니다.
#hostingforum.kr
php
Array
(
[publicProperty] => public
[protectedProperty] => protected
)
위 결과에서 볼 수 있듯이, getDefaultProperties 메서드는 private 속성을 가져오지 않았습니다. getDefaultProperties 메서드는 클래스의 정적 속성을 가져올 때, 접근 가능한 속성만 가져오고 접근 불가 속성은 무시합니다.
2025-07-07 04:03