8000 [VarExporter] Fix: Use correct closure call for property-specific log… · symfony/symfony@b1f0602 · GitHub
[go: up one dir, main page]

Skip to content

Commit b1f0602

Browse files
Hakayashiifabpot
authored andcommitted
[VarExporter] Fix: Use correct closure call for property-specific logic in $notByRef
1 parent 368bfb7 commit b1f0602

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/Symfony/Component/VarExporter/Internal/Hydrator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static function getSimpleHydrator($class)
166166
$object->$name = $value;
167167
$object->$name = &$value;
168168
} elseif (true !== $noRef) {
169-
$notByRef($object, $value);
169+
$noRef($object, $value);
170170
} else {
171171
$object->$name = $value;
172172
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy;
4+
5+
class HookedWithDefaultValue
6+
{
7+
public int $backedWithDefault = 321 {
8+
get => $this->backedWithDefault;
9+
set => $this->backedWithDefault = $value;
10+
}
11+
}

src/Symfony/Component/VarExporter/Tests/LazyGhostTraitTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Symfony\Component\VarExporter\Tests\Fixtures\LazyGhost\TestClass;
2828
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\AsymmetricVisibility;
2929
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\Hooked;
30+
use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\HookedWithDefaultValue;
3031
use Symfony\Component\VarExporter\Tests\Fixtures\SimpleObject;
3132

3233
class LazyGhostTraitTest extends TestCase
@@ -505,6 +506,28 @@ public function testPropertyHooks()
505506
$this->assertSame(345, $object->backed);
506507
}
507508

509+
/**
510+
* @requires PHP 8.4
511+
*/
512+
public function testPropertyHooksWithDefaultValue()
513+
{
514+
$initialized = false;
515+
$object = $this->createLazyGhost(HookedWithDefaultValue::class, function ($instance) use (&$initialized) {
516+
$initialized = true;
517+
});
518+
519+
$this->assertSame(321, $object->backedWithDefault);
520+
$this->assertTrue($initialized);
521+
522+
$initialized = false;
523+
$object = $this->createLazyGhost(HookedWithDefaultValue::class, function ($instance) use (&$initialized) {
524+
$initialized = true;
525+
});
526+
$object->backedWithDefault = 654;
527+
$this->assertTrue($initialized);
528+
$this->assertSame(654, $object->backedWithDefault);
529+
}
530+
508531
/**
509532
* @requires PHP 8.4
510533
*/

0 commit comments

Comments
 (0)
0