Reflection ReflectionClass::getDefaultProperties

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getDefaultProperties — 기본 속성 가져오기


설명

public ReflectionClass::getDefaultProperties(): array

클래스에서 기본 속성을 가져옵니다(상속된 속성 포함).

메모: 이 메서드는 내부 클래스에서 사용될 때 정적 속성에만 작동합니다. 사용자 정의 클래스에서 이 메서드를 사용하는 경우 정적 클래스 속성의 기본값을 추적할 수 없습니다.


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

키는 속성의 이름이고 값은 속성의 기본값이거나 속성에 기본값이 없는 경우 null이 있는 기본 속성의 배열입니다. 이 함수는 정적 속성과 비정적 속성을 구분하지 않으며 가시성 수정자를 고려하지 않습니다.


Examples

예제 #1 ReflectionClass::getDefaultProperties() 예제

                  
<?php
class Bar {
    protected $inheritedProperty = 'inheritedDefault';
}

class Foo extends Bar {
    public $property = 'propertyDefault';
    private $privateProperty = 'privatePropertyDefault';
    public static $staticProperty = 'staticProperty';
    public $defaultlessProperty;
}

$reflectionClass = new ReflectionClass('Foo');
var_dump($reflectionClass->getDefaultProperties());
?>
                  
                

위의 예는 다음을 출력합니다.

array(5) {
   ["staticProperty"]=>
   string(14) "staticProperty"
   ["property"]=>
   string(15) "propertyDefault"
   ["privateProperty"]=>
   string(22) "privatePropertyDefault"
   ["defaultlessProperty"]=>
   NULL
   ["inheritedProperty"]=>
   string(16) "inheritedDefault"
}
                

기타