1 | <?php |
||
30 | class PhpProperty extends AbstractPhpMember { |
||
31 | |||
32 | use TypeDocblockGeneratorPart; |
||
33 | use ValuePart; |
||
34 | |||
35 | /** |
||
36 | * Creates a new PHP property |
||
37 | * |
||
38 | * @param string $name the properties name |
||
39 | * @return static |
||
40 | */ |
||
41 | 11 | public static function create($name) { |
|
44 | |||
45 | /** |
||
46 | * Creates a new PHP property from reflection |
||
47 | * |
||
48 | * @param \ReflectionProperty $ref |
||
49 | * @return static |
||
50 | */ |
||
51 | 4 | public static function fromReflection(\ReflectionProperty $ref) { |
|
52 | 4 | $property = new static($ref->name); |
|
53 | 4 | $property->setStatic($ref->isStatic()) |
|
54 | 4 | ->setVisibility($ref->isPublic() ? self::VISIBILITY_PUBLIC : ($ref->isProtected() ? self::VISIBILITY_PROTECTED : self::VISIBILITY_PRIVATE)); |
|
55 | |||
56 | 4 | $docblock = new Docblock($ref); |
|
57 | 4 | $property->setDocblock($docblock); |
|
58 | 4 | $property->setDescription($docblock->getShortDescription()); |
|
59 | 4 | $property->setLongDescription($docblock->getLongDescription()); |
|
60 | |||
61 | 4 | $vars = $docblock->getTags('var'); |
|
62 | 4 | if ($vars->size() > 0) { |
|
63 | 2 | $var = $vars->get(0); |
|
64 | 2 | $property->setType($var->getType(), $var->getDescription()); |
|
65 | } |
||
66 | |||
67 | 4 | $defaultProperties = $ref->getDeclaringClass()->getDefaultProperties(); |
|
68 | 4 | if (isset($defaultProperties[$ref->name])) { |
|
69 | 2 | $default = $defaultProperties[$ref->name]; |
|
70 | 2 | if (is_string($default)) { |
|
71 | $property->setValue($default); |
||
72 | } else { |
||
73 | 2 | $property->setExpression($default); |
|
74 | } |
||
75 | } |
||
76 | |||
77 | 4 | return $property; |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * Generates docblock based on provided information |
||
82 | */ |
||
83 | 8 | public function generateDocblock() { |
|
91 | } |
||
92 |