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 @@ -86,7 +86,7 @@ public static function generateLazyGhost(\ReflectionClass $class): string
86
86
.($ p ->isProtected () ? 'protected ' : 'public ' )
87
87
.($ p ->isProtectedSet () ? ' protected(set) ' : '' )
88
88
." {$ type } \${$ name }"
89
- .($ p ->hasDefaultValue () ? ' = ' .$ p ->getDefaultValue () : '' )
89
+ .($ p ->hasDefaultValue () ? ' = ' .VarExporter:: export ( $ p ->getDefaultValue () ) : '' )
90
90
." { \n" ;
91
91
92
92
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 @@ -332,16 +332,22 @@ public function testPropertyHooksWithDefaultValue()
332
332
$ initialized = true ;
333
333
});
334
334
335
- $ this ->assertSame (321 , $ object ->backedWithDefault );
335
+ $ this ->assertSame (321 , $ object ->backedIntWithDefault );
336
+ $ this ->assertSame ('321 ' , $ object ->backedStringWithDefault );
337
+ $ this ->assertSame (false , $ object ->backedBoolWithDefault );
336
338
$ this ->assertTrue ($ initialized );
337
339
338
340
$ initialized = false ;
339
341
$ object = $ this ->createLazyGhost (HookedWithDefaultValue::class, function ($ instance ) use (&$ initialized ) {
340
342
$ initialized = true ;
341
343
});
342
- $ object ->backedWithDefault = 654 ;
344
+ $ object ->backedIntWithDefault = 654 ;
345
+ $ object ->backedStringWithDefault = '654 ' ;
346
+ $ object ->backedBoolWithDefault = true ;
343
347
$ this ->assertTrue ($ initialized );
344
- $ this ->assertSame (654 , $ object ->backedWithDefault );
348
+ $ this ->assertSame (654 , $ object ->backedIntWithDefault );
349
+ $ this ->assertSame ('654 ' , $ object ->backedStringWithDefault );
350
+ $ this ->assertSame (true , $ object ->backedBoolWithDefault );
345
351
}
346
352
347
353
/**
You can’t perform that action at this time.
0 commit comments