File tree 3 files changed +23
-7
lines changed
src/Symfony/Component/VarExporter
3 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ public static function generateLazyGhost(\ReflectionClass $class): string
80
80
.($ p ->isProtected () ? 'protected ' : 'public ' )
81
81
.($ p ->isProtectedSet () ? ' protected(set) ' : '' )
82
82
." {$ type } \${$ name }"
83
- .($ p ->hasDefaultValue () ? ' = ' .$ p ->getDefaultValue () : '' )
83
+ .($ p ->hasDefaultValue () ? ' = ' .VarExporter:: export ( $ p ->getDefaultValue () ) : '' )
84
84
." { \n" ;
85
85
86
86
foreach ($ p ->getHooks () as $ hook => $ method ) {
Original file line number Diff line number Diff line change 4
4
5
5
class HookedWithDefaultValue
6
6
{
7
- public int $ backedWithDefault = 321 {
8
- get => $ this ->backedWithDefault ;
9
- set => $ this ->backedWithDefault = $ value ;
7
+ public int $ backedIntWithDefault = 321 {
8
+ get => $ this ->backedIntWithDefault ;
9
+ set => $ this ->backedIntWithDefault = $ value ;
10
+ }
11
+
12
+ public string $ backedStringWithDefault = '321 ' {
13
+ get => $ this ->backedStringWithDefault ;
14
+ set => $ this ->backedStringWithDefault = $ value ;
15
+ }
16
+
17
+ public bool $ backedBoolWithDefault = false {
18
+ get => $ this ->backedBoolWithDefault ;
19
+ set => $ this ->backedBoolWithDefault = $ value ;
10
20
}
11
21
}
Original file line number Diff line number Diff line change @@ -516,16 +516,22 @@ public function testPropertyHooksWithDefaultValue()
516
516
$ initialized = true ;
517
517
});
518
518
519
- $ this ->assertSame (321 , $ object ->backedWithDefault );
519
+ $ this ->assertSame (321 , $ object ->backedIntWithDefault );
520
+ $ this ->assertSame ('321 ' , $ object ->backedStringWithDefault );
521
+ $ this ->assertSame (false , $ object ->backedBoolWithDefault );
520
522
$ this ->assertTrue ($ initialized );
521
523
522
524
$ initialized = false ;
523
525
$ object = $ this ->createLazyGhost (HookedWithDefaultValue::class, function ($ instance ) use (&$ initialized ) {
524
526
$ initialized = true ;
525
527
});
526
- $ object ->backedWithDefault = 654 ;
528
+ $ object ->backedIntWithDefault = 654 ;
529
+ $ object ->backedStringWithDefault = '654 ' ;
530
+ $ object ->backedBoolWithDefault = true ;
527
531
$ this ->assertTrue ($ initialized );
528
- $ this ->assertSame (654 , $ object ->backedWithDefault );
532
+ $ this ->assertSame (654 , $ object ->backedIntWithDefault );
533
+ $ this ->assertSame ('654 ' , $ object ->backedStringWithDefault );
534
+ $ this ->assertSame (true , $ object ->backedBoolWithDefault );
529
535
}
530
536
531
537
/**
You can’t perform that action at this time.
0 commit comments