Skip to content

Commit 8bf8ab1

Browse files
authored
Merge pull request #329 from nicolas-grekas/fix-trim
Fix #317
2 parents 920da29 + 659a733 commit 8bf8ab1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Persistence/Reflection/RuntimeReflectionProperty.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use ReflectionProperty;
1010
use ReturnTypeWillChange;
1111

12+
use function ltrim;
1213
use function method_exists;
1314

1415
/**
@@ -26,7 +27,7 @@ public function __construct(string $class, string $name)
2627
{
2728
parent::__construct($class, $name);
2829

29-
$this->key = $this->isPrivate() ? "\0" . $class . "\0" . $name : ($this->isProtected() ? "\0*\0" . $name : $name);
30+
$this->key = $this->isPrivate() ? "\0" . ltrim($class, '\\') . "\0" . $name : ($this->isProtected() ? "\0*\0" . $name : $name);
3031
}
3132

3233
/**

tests/Persistence/RuntimeReflectionPropertyTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function testGetSetValue(string $name, string $value): void
3636

3737
self::assertSame($value, $reflProperty->getValue($object));
3838

39+
$reflProperty->setAccessible(true);
3940
$reflProperty->setValue($object, 'changedValue');
4041

4142
self::assertSame('changedValue', $reflProperty->getValue($object));
@@ -46,6 +47,7 @@ public function testGetSetValue(string $name, string $value): void
4647
*
4748
* @testWith ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
4849
* ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestCommonProxyMock"]
50+
* ["\\Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
4951
*/
5052
public function testGetValueOnProxyProperty(string $proxyClass): void
5153
{
@@ -245,5 +247,10 @@ class RuntimeReflectionPropertyTestClass
245247
public $test = 'testValue';
246248

247249
/** @var string|null */
248-
public $privateTest = 'privateTestValue';
250+
private $privateTest = 'privateTestValue';
251+
252+
public function getPrivateTest(): ?string
253+
{
254+
return $this->privateTest;
255+
}
249256
}

0 commit comments

Comments
 (0)