1111use phpDocumentor \Reflection \Location ;
1212use phpDocumentor \Reflection \Php \Class_ as ClassElement ;
1313use phpDocumentor \Reflection \Php \Factory \Reducer \Reducer ;
14- use phpDocumentor \Reflection \Php \Expression ;
15- use phpDocumentor \Reflection \Php \Expression \ExpressionPrinter ;
1614use phpDocumentor \Reflection \Php \ProjectFactoryStrategy ;
1715use phpDocumentor \Reflection \Php \StrategyContainer ;
1816use PhpParser \Modifiers ;
2220use PhpParser \PrettyPrinter \Standard as PrettyPrinter ;
2321use Webmozart \Assert \Assert ;
2422
25- use function is_string ;
26-
2723final class ConstructorPromotion extends AbstractFactory
2824{
2925 /** @param iterable<Reducer> $reducers */
@@ -80,11 +76,11 @@ private function promoteParameterToProperty(ContextStack $context, StrategyConta
8076 ->visibility ($ param )
8177 ->type ($ param ->type )
8278 ->docblock ($ param ->getDocComment ())
83- ->default ($ this -> determineDefault ( $ param ) )
79+ ->default ($ param -> default )
8480 ->readOnly ($ this ->readOnly ($ param ->flags ))
8581 ->static (false )
86- ->startLocation (new Location ($ param ->getLine (), $ param -> getStartFilePos () ))
87- ->endLocation (new Location ($ param ->getEndLine (), $ param -> getEndFilePos () ))
82+ ->startLocation (new Location ($ param ->getLine ()))
83+ ->endLocation (new Location ($ param ->getEndLine ()))
8884 ->hooks ($ param ->hooks ?? [])
8985 ->build ($ context );
9086
@@ -99,24 +95,6 @@ private function promoteParameterToProperty(ContextStack $context, StrategyConta
9995 $ methodContainer ->addProperty ($ property );
10096 }
10197
102- private function determineDefault (Param $ value ): Expression |null
103- {
104- $ expression = $ value ->default !== null ? $ this ->valueConverter ->prettyPrintExpr ($ value ->default ) : null ;
105- if ($ expression === null ) {
106- return null ;
107- }
108-
109- if ($ this ->valueConverter instanceof ExpressionPrinter) {
110- $ expression = new Expression ($ expression , $ this ->valueConverter ->getParts ());
111- }
112-
113- if (is_string ($ expression )) {
114- $ expression = new Expression ($ expression , []);
115- }
116-
117- return $ expression ;
118- }
119-
12098 private function readOnly (int $ flags ): bool
12199 {
122100 return (bool ) ($ flags & Modifiers::READONLY ) === true ;
0 commit comments