File tree Expand file tree Collapse file tree 4 files changed +36
-4
lines changed Expand file tree Collapse file tree 4 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 3636use function interface_exists ;
3737use function is_callable ;
3838use function is_dir ;
39+ use function is_scalar ;
3940use function is_string ;
4041use function is_writable ;
4142use function lcfirst ;
@@ -1122,7 +1123,7 @@ private function getParameterDefaultValue(ReflectionParameter $parameter)
11221123 return '' ;
11231124 }
11241125
1125- if (PHP_VERSION_ID < 80100 ) {
1126+ if (PHP_VERSION_ID < 80100 || is_scalar ( $ parameter -> getDefaultValue ()) ) {
11261127 return ' = ' . var_export ($ parameter ->getDefaultValue (), true );
11271128 }
11281129
Original file line number Diff line number Diff line change @@ -23,7 +23,22 @@ public function arrayInDefault(array $foo = [new \DateTimeImmutable('2022-08-22
2323
2424 }
2525
26- public function constInDefault (string $ foo = ConstProvider::FOO ): void
26+ public function scalarConstInDefault (string $ foo = ConstProvider::FOO_SCALAR ): void
27+ {
28+
29+ }
30+
31+ public function constInDefault (array $ foo = ConstProvider::FOO ): void
32+ {
33+
34+ }
35+
36+ public function globalEolInDefault (string $ foo = \PHP_EOL ): void
37+ {
38+
39+ }
40+
41+ public function specialCharacterInDefault (string $ foo = "\n" ): void
2742 {
2843
2944 }
Original file line number Diff line number Diff line change @@ -602,7 +602,22 @@ public function testPhp81NewInInitializers()
602602 );
603603
604604 self ::assertStringContainsString (
605- 'constInDefault(string $foo = \Doctrine\Tests\Common\Util\TestAsset\ConstProvider::FOO): void ' ,
605+ 'scalarConstInDefault(string $foo = \'foo \'): void ' ,
606+ file_get_contents (__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php ' )
607+ );
608+
609+ self ::assertStringContainsString (
610+ 'constInDefault(array $foo = \Doctrine\Tests\Common\Util\TestAsset\ConstProvider::FOO): void ' ,
611+ file_get_contents (__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php ' )
612+ );
613+
614+ self ::assertStringContainsString (
615+ "globalEolInDefault(string \$foo = ' \n'): void " ,
616+ file_get_contents (__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php ' )
617+ );
618+
619+ self ::assertStringContainsString (
620+ "specialCharacterInDefault(string \$foo = ' \n'): void " ,
606621 file_get_contents (__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php ' )
607622 );
608623 }
Original file line number Diff line number Diff line change 66
77class ConstProvider
88{
9- public const FOO = 'foo ' ;
9+ public const FOO = ['foo ' ];
10+ public const FOO_SCALAR = 'foo ' ;
1011}
You can’t perform that action at this time.
0 commit comments