88use phpDocumentor \Reflection \DocBlockFactoryInterface ;
99use phpDocumentor \Reflection \Fqsen ;
1010use phpDocumentor \Reflection \Location ;
11- use phpDocumentor \Reflection \Php \AsyncVisibility ;
1211use phpDocumentor \Reflection \Php \Class_ as ClassElement ;
1312use phpDocumentor \Reflection \Php \Factory \Reducer \Reducer ;
1413use phpDocumentor \Reflection \Php \ProjectFactoryStrategy ;
15- use phpDocumentor \Reflection \Php \Property ;
1614use phpDocumentor \Reflection \Php \StrategyContainer ;
17- use phpDocumentor \Reflection \Php \Visibility ;
1815use PhpParser \Modifiers ;
1916use PhpParser \Node \Expr \Variable ;
2017use PhpParser \Node \Param ;
@@ -67,17 +64,18 @@ private function promoteParameterToProperty(ContextStack $context, StrategyConta
6764 Assert::isInstanceOf ($ methodContainer , ClassElement::class);
6865 Assert::isInstanceOf ($ param ->var , Variable::class);
6966
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 ();
8179
8280 foreach ($ this ->reducers as $ reducer ) {
8381 $ property = $ reducer ->reduce ($ context , $ param , $ strategies , $ property );
@@ -90,44 +88,6 @@ private function promoteParameterToProperty(ContextStack $context, StrategyConta
9088 $ methodContainer ->addProperty ($ property );
9189 }
9290
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-
13191 private function readOnly (int $ flags ): bool
13292 {
13393 return (bool ) ($ flags & Modifiers::READONLY ) === true ;
0 commit comments