Skip to content

Commit 785cff5

Browse files
Merge branch '6.4' into 7.2
* 6.4: [Validator] Review Latvian translations Fixed lazy-loading ghost objects generation with property hooks with default values. remove no longer used service definition [Config] Fix generated comment for multiline "info" Fix: exclude remember_me from security login authenticators
2 parents 422b8de + f28cf84 commit 785cff5

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

ProxyHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static function generateLazyGhost(\ReflectionClass $class): string
8080
.($p->isProtected() ? 'protected' : 'public')
8181
.($p->isProtectedSet() ? ' protected(set)' : '')
8282
." {$type} \${$name}"
83-
.($p->hasDefaultValue() ? ' = '.$p->getDefaultValue() : '')
83+
.($p->hasDefaultValue() ? ' = '.VarExporter::export($p->getDefaultValue()) : '')
8484
." {\n";
8585

8686
foreach ($p->getHooks() as $hook => $method) {

Tests/Fixtures/LazyProxy/HookedWithDefaultValue.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@
44

55
class HookedWithDefaultValue
66
{
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;
1020
}
1121
}

Tests/LazyGhostTraitTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,22 @@ public function testPropertyHooksWithDefaultValue()
329329
$initialized = true;
330330
});
331331

332-
$this->assertSame(321, $object->backedWithDefault);
332+
$this->assertSame(321, $object->backedIntWithDefault);
333+
$this->assertSame('321', $object->backedStringWithDefault);
334+
$this->assertSame(false, $object->backedBoolWithDefault);
333335
$this->assertTrue($initialized);
334336

335337
$initialized = false;
336338
$object = $this->createLazyGhost(HookedWithDefaultValue::class, function ($instance) use (&$initialized) {
337339
$initialized = true;
338340
});
339-
$object->backedWithDefault = 654;
341+
$object->backedIntWithDefault = 654;
342+
$object->backedStringWithDefault = '654';
343+
$object->backedBoolWithDefault = true;
340344
$this->assertTrue($initialized);
341-
$this->assertSame(654, $object->backedWithDefault);
345+
$this->assertSame(654, $object->backedIntWithDefault);
346+
$this->assertSame('654', $object->backedStringWithDefault);
347+
$this->assertSame(true, $object->backedBoolWithDefault);
342348
}
343349

344350
/**

0 commit comments

Comments
 (0)