File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
src/phpDocumentor/Reflection/Php/Expression
tests/unit/phpDocumentor/Reflection/Php/Expression Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 2424use PhpParser \Node \Name ;
2525use PhpParser \PrettyPrinter \Standard ;
2626
27+ use function ltrim ;
28+
2729final class ExpressionPrinter extends Standard
2830{
2931 /** @var array<string, Fqsen|Type> */
@@ -93,7 +95,7 @@ protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node): string
9395
9496 $ placeholder = Expression::generatePlaceholder ((string ) $ renderedName );
9597 $ this ->parts [$ placeholder ] = new Fqsen (
96- $ className . ':: ' . $ renderedName ,
98+ '\\' . ltrim (( string ) $ className, '\\' ) . ':: ' . $ renderedName ,
9799 );
98100
99101 return $ placeholder ;
Original file line number Diff line number Diff line change @@ -63,6 +63,13 @@ public static function argumentProvider(): array
6363 '{{ PHPDOCe54b7c24dd0f847c3193039223751b3d }} ' => new Fqsen ('\MyClass::SOME_CONST ' ),
6464 ],
6565 ],
66+ 'selfConstantDefault ' => [
67+ 'code ' => '<?php function foo(MyClass $arg = self::SOME_CONST) {} ' ,
68+ 'expectedExpression ' => '{{ PHPDOCe54b7c24dd0f847c3193039223751b3d }} ' ,
69+ 'expectedParts ' => [
70+ '{{ PHPDOCe54b7c24dd0f847c3193039223751b3d }} ' => new Fqsen ('\self::SOME_CONST ' ),
71+ ],
72+ ],
6673 'stringDefault ' => [
6774 'code ' => '<?php function foo(string $arg = \'hello \') {} ' ,
6875 'expectedExpression ' => "'hello' " ,
You can’t perform that action at this time.
0 commit comments