downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

ReflectionClass::getDocComment> <ReflectionClass::getConstructor
[edit] Last updated: Fri, 17 May 2013

view this page in

ReflectionClass::getDefaultProperties

(PHP 5)

ReflectionClass::getDefaultPropertiesデフォルトプロパティを取得する

説明

public array ReflectionClass::getDefaultProperties ( void )

クラスのデフォルトプロパティ (継承したプロパティを含む) を取得します。

注意:

このメソッドで static プロパティを扱えるのは、内部クラスの場合だけです。 ユーザー定義クラスで使った場合は、 クラスの static なプロパティのデフォルト値はこのメソッドでは追跡できません。

パラメータ

この関数にはパラメータはありません。

返り値

デフォルトプロパティの配列を返します。プロパティ名が配列のキー、 そしてそのプロパティのデフォルト値が配列の値 (デフォルト値が存在しない場合は NULL) となります。 この関数は静的なプロパティとそうでないプロパティを区別せず、 アクセス修飾子も考慮しません。

例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"
}

参考



add a note add a note User Contributed Notes ReflectionClass::getDefaultProperties - [2 notes]
up
0
runaurufu AT gmail.com
1 year ago
Worth noting that it will not return private parameters of parent class...
so it works exactly as get_class_vars or get_object_vars
up
0
captainjester at hotmail dot com
3 years ago
This will return all properties in a class and any parent classes.  The array will have keys set to the property names and empty values.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites