8
8
use phpDocumentor \Reflection \DocBlockFactoryInterface ;
9
9
use phpDocumentor \Reflection \Fqsen ;
10
10
use phpDocumentor \Reflection \Location ;
11
- use phpDocumentor \Reflection \Php \AsyncVisibility ;
12
11
use phpDocumentor \Reflection \Php \Class_ as ClassElement ;
13
12
use phpDocumentor \Reflection \Php \Factory \Reducer \Reducer ;
14
13
use phpDocumentor \Reflection \Php \ProjectFactoryStrategy ;
15
- use phpDocumentor \Reflection \Php \Property ;
16
14
use phpDocumentor \Reflection \Php \StrategyContainer ;
17
- use phpDocumentor \Reflection \Php \Visibility ;
18
15
use PhpParser \Modifiers ;
19
16
use PhpParser \Node \Expr \Variable ;
20
17
use PhpParser \Node \Param ;
@@ -67,17 +64,18 @@ private function promoteParameterToProperty(ContextStack $context, StrategyConta
67
64
Assert::isInstanceOf ($ methodContainer , ClassElement::class);
68
65
Assert::isInstanceOf ($ param ->var , Variable::class);
69
66
70
- $ property = new Property (
71
- new Fqsen ($ methodContainer ->getFqsen () . '::$ ' . (string ) $ param ->var ->name ),
72
- $ this ->buildPropertyVisibilty ($ param ->flags ),
73
- $ this ->createDocBlock ($ param ->getDocComment (), $ context ->getTypeContext ()),
74
- $ param ->default !== null ? $ this ->valueConverter ->prettyPrintExpr ($ param ->default ) : null ,
75
- false ,
76
- new Location ($ param ->getLine ()),
77
- new Location ($ param ->getEndLine ()),
78
- (new Type ())->fromPhpParser ($ param ->type ),
79
- $ this ->readOnly ($ param ->flags ),
80
- );
67
+ $ property = PropertyBuilder::create (
68
+ $ this ->valueConverter ,
69
+ )->fqsen (new Fqsen ($ methodContainer ->getFqsen () . '::$ ' . (string ) $ param ->var ->name ))
70
+ ->visibility ($ param )
71
+ ->type ($ param ->type )
72
+ ->docblock ($ this ->createDocBlock ($ param ->getDocComment (), $ context ->getTypeContext ()))
73
+ ->default ($ param ->default )
74
+ ->readOnly ($ this ->readOnly ($ param ->flags ))
75
+ ->static (false )
76
+ ->startLocation (new Location ($ param ->getLine (), $ param ->getStartFilePos ()))
77
+ ->endLocation (new Location ($ param ->getEndLine (), $ param ->getEndFilePos ()))
78
+ ->build ();
81
79
82
80
foreach ($ this ->reducers as $ reducer ) {
83
81
$ property = $ reducer ->reduce ($ context , $ param , $ strategies , $ property );
@@ -90,44 +88,6 @@ private function promoteParameterToProperty(ContextStack $context, StrategyConta
90
88
$ methodContainer ->addProperty ($ property );
91
89
}
92
90
93
- private function buildPropertyVisibilty (int $ flags ): Visibility
94
- {
95
- if ((bool ) ($ flags & Modifiers::VISIBILITY_SET_MASK ) !== false ) {
96
- return new AsyncVisibility (
97
- $ this ->buildReadVisibility ($ flags ),
98
- $ this ->buildWriteVisibility ($ flags ),
99
- );
100
- }
101
-
102
- return $ this ->buildReadVisibility ($ flags );
103
- }
104
-
105
- private function buildReadVisibility (int $ flags ): Visibility
106
- {
107
- if ((bool ) ($ flags & Modifiers::PRIVATE ) === true ) {
108
- return new Visibility (Visibility::PRIVATE_ );
109
- }
110
-
111
- if ((bool ) ($ flags & Modifiers::PROTECTED ) === true ) {
112
- return new Visibility (Visibility::PROTECTED_ );
113
- }
114
-
115
- return new Visibility (Visibility::PUBLIC_ );
116
- }
117
-
118
- private function buildWriteVisibility (int $ flags ): Visibility
119
- {
120
- if ((bool ) ($ flags & Modifiers::PRIVATE_SET ) === true ) {
121
- return new Visibility (Visibility::PRIVATE_ );
122
- }
123
-
124
- if ((bool ) ($ flags & Modifiers::PROTECTED_SET ) === true ) {
125
- return new Visibility (Visibility::PROTECTED_ );
126
- }
127
-
128
- return new Visibility (Visibility::PUBLIC_ );
129
- }
130
-
131
91
private function readOnly (int $ flags ): bool
132
92
{
133
93
return (bool ) ($ flags & Modifiers::READONLY ) === true ;
0 commit comments