Skip to content

Commit

Permalink
Merge pull request #329 from nicolas-grekas/fix-trim
Browse files Browse the repository at this point in the history
Fix #317
  • Loading branch information
greg0ire authored Feb 3, 2023
2 parents 920da29 + 659a733 commit 8bf8ab1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Persistence/Reflection/RuntimeReflectionProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use ReflectionProperty;
use ReturnTypeWillChange;

use function ltrim;
use function method_exists;

/**
Expand All @@ -26,7 +27,7 @@ public function __construct(string $class, string $name)
{
parent::__construct($class, $name);

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

/**
Expand Down
9 changes: 8 additions & 1 deletion tests/Persistence/RuntimeReflectionPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function testGetSetValue(string $name, string $value): void

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

$reflProperty->setAccessible(true);
$reflProperty->setValue($object, 'changedValue');

self::assertSame('changedValue', $reflProperty->getValue($object));
Expand All @@ -46,6 +47,7 @@ public function testGetSetValue(string $name, string $value): void
*
* @testWith ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
* ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestCommonProxyMock"]
* ["\\Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
*/
public function testGetValueOnProxyProperty(string $proxyClass): void
{
Expand Down Expand Up @@ -245,5 +247,10 @@ class RuntimeReflectionPropertyTestClass
public $test = 'testValue';

/** @var string|null */
public $privateTest = 'privateTestValue';
private $privateTest = 'privateTestValue';

public function getPrivateTest(): ?string
{
return $this->privateTest;
}
}

0 comments on commit 8bf8ab1

Please sign in to comment.