File tree 4 files changed +36
-4
lines changed
4 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 36
36
use function interface_exists ;
37
37
use function is_callable ;
38
38
use function is_dir ;
39
+ use function is_scalar ;
39
40
use function is_string ;
40
41
use function is_writable ;
41
42
use function lcfirst ;
@@ -1122,7 +1123,7 @@ private function getParameterDefaultValue(ReflectionParameter $parameter)
1122
1123
return '' ;
1123
1124
}
1124
1125
1125
- if (PHP_VERSION_ID < 80100 ) {
1126
+ if (PHP_VERSION_ID < 80100 || is_scalar ( $ parameter -> getDefaultValue ()) ) {
1126
1127
return ' = ' . var_export ($ parameter ->getDefaultValue (), true );
1127
1128
}
1128
1129
Original file line number Diff line number Diff line change @@ -23,7 +23,22 @@ public function arrayInDefault(array $foo = [new \DateTimeImmutable('2022-08-22
23
23
24
24
}
25
25
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
27
42
{
28
43
29
44
}
Original file line number Diff line number Diff line change @@ -602,7 +602,22 @@ public function testPhp81NewInInitializers()
602
602
);
603
603
604
604
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 " ,
606
621
file_get_contents (__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php ' )
607
622
);
608
623
}
Original file line number Diff line number Diff line change 6
6
7
7
class ConstProvider
8
8
{
9
- public const FOO = 'foo ' ;
9
+ public const FOO = ['foo ' ];
10
+ public const FOO_SCALAR = 'foo ' ;
10
11
}
You can’t perform that action at this time.
0 commit comments