Skip to content

Commit 8bcdf91

Browse files
committed
Remove support for Doctrine Common proxies
1 parent 3e3b9e4 commit 8bcdf91

File tree

7 files changed

+3
-119
lines changed

7 files changed

+3
-119
lines changed

.github/workflows/coding-standards.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ jobs:
1313
coding-standards:
1414
name: "Coding Standards"
1515
uses: "doctrine/.github/.github/workflows/[email protected]"
16-
with:
17-
composer-root-version: "3.0"

.github/workflows/continuous-integration.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
name: "PHPUnit"
1515
uses: "doctrine/.github/.github/workflows/[email protected]"
1616
with:
17-
composer-root-version: "3.0"
1817
php-versions: '["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]'
1918
secrets:
2019
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"

.github/workflows/static-analysis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ jobs:
1313
static-analysis:
1414
name: "Static Analysis"
1515
uses: "doctrine/.github/.github/workflows/[email protected]"
16-
with:
17-
composer-root-version: "3.0"

CONTRIBUTING.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"phpstan/phpstan-phpunit": "^1",
3030
"phpstan/phpstan-strict-rules": "^1.1",
3131
"doctrine/coding-standard": "^12",
32-
"doctrine/common": "^3.0",
3332
"phpunit/phpunit": "^8.5 || ^9.5",
3433
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
3534
"vimeo/psalm": "4.30.0 || 5.24.0"

src/Persistence/Reflection/RuntimeReflectionProperty.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Doctrine\Persistence\Reflection;
66

7-
use Doctrine\Common\Proxy\Proxy as CommonProxy;
87
use Doctrine\Persistence\Proxy;
98
use ReflectionProperty;
109
use ReturnTypeWillChange;
@@ -63,17 +62,6 @@ public function setValue($object, $value = null)
6362
return;
6463
}
6564

66-
if ($object instanceof CommonProxy) {
67-
$originalInitializer = $object->__getInitializer();
68-
$object->__setInitializer(null);
69-
70-
parent::setValue($object, $value);
71-
72-
$object->__setInitializer($originalInitializer);
73-
74-
return;
75-
}
76-
7765
if (! method_exists($object, '__setInitialized')) {
7866
return;
7967
}

tests/Persistence/RuntimeReflectionPropertyTest.php

Lines changed: 3 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
namespace Doctrine\Tests\Persistence;
66

77
use Closure;
8-
use Doctrine\Common\Proxy\Proxy as CommonProxy;
98
use Doctrine\Persistence\Proxy;
109
use Doctrine\Persistence\Reflection\RuntimeReflectionProperty;
11-
use LogicException;
1210
use PHPUnit\Framework\TestCase;
1311

1412
class DummyMock
@@ -46,7 +44,6 @@ public function testGetSetValue(string $name, string $value): void
4644
* @param class-string<RuntimeReflectionPropertyTestProxyMock> $proxyClass
4745
*
4846
* @testWith ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
49-
* ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestCommonProxyMock"]
5047
* ["\\Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
5148
*/
5249
public function testGetValueOnProxyProperty(string $proxyClass): void
@@ -66,47 +63,23 @@ public function testGetValueOnProxyProperty(string $proxyClass): void
6663
self::assertNull($reflProperty->getValue($mockProxy));
6764
}
6865

69-
/**
70-
* @param class-string<RuntimeReflectionPropertyTestProxyMock> $proxyClass
71-
*
72-
* @testWith ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestProxyMock"]
73-
* ["Doctrine\\Tests\\Persistence\\RuntimeReflectionPropertyTestCommonProxyMock"]
74-
*/
75-
public function testSetValueOnProxyProperty(string $proxyClass): void
66+
public function testSetValueOnProxyProperty(): void
7667
{
7768
$setCheckMock = $this->createMock(DummyMock::class);
7869
$setCheckMock->expects(self::never())->method('callSet');
7970
$initializer = static function () use ($setCheckMock): void {
8071
$setCheckMock->callSet();
8172
};
8273

83-
$mockProxy = new $proxyClass($initializer);
84-
85-
$reflProperty = new RuntimeReflectionProperty($proxyClass, 'checkedProperty');
74+
$mockProxy = new RuntimeReflectionPropertyTestProxyMock($initializer);
75+
$reflProperty = new RuntimeReflectionProperty(RuntimeReflectionPropertyTestProxyMock::class, 'checkedProperty');
8676

8777
$reflProperty->setValue($mockProxy, 'newValue');
8878
self::assertSame('newValue', $mockProxy->checkedProperty);
8979

9080
unset($mockProxy->checkedProperty);
9181
$reflProperty->setValue($mockProxy, 'otherNewValue');
9282
self::assertSame('otherNewValue', $mockProxy->checkedProperty);
93-
94-
if (! $mockProxy instanceof CommonProxy) {
95-
return;
96-
}
97-
98-
$setCheckMock = $this->createMock(DummyMock::class);
99-
$setCheckMock->expects(self::once())->method('callSet');
100-
$initializer = static function () use ($setCheckMock): void {
101-
$setCheckMock->callSet();
102-
};
103-
104-
$mockProxy->__setInitializer($initializer);
105-
$mockProxy->__setInitialized(true);
106-
107-
unset($mockProxy->checkedProperty);
108-
$reflProperty->setValue($mockProxy, 'againNewValue');
109-
self::assertSame('againNewValue', $mockProxy->checkedProperty);
11083
}
11184
}
11285

@@ -180,66 +153,6 @@ public function __isset(string $name): bool
180153
return isset($this->checkedProperty);
181154
}
182155
}
183-
/**
184-
* Mock that simulates proxy property lazy loading
185-
*
186-
* @implements CommonProxy<object>
187-
*/
188-
class RuntimeReflectionPropertyTestCommonProxyMock extends RuntimeReflectionPropertyTestProxyMock implements CommonProxy
189-
{
190-
/** @param mixed $value */
191-
public function __set(string $name, $value): void
192-
{
193-
if ($this->initializer !== null) {
194-
($this->initializer)();
195-
}
196-
197-
$this->checkedProperty = $value;
198-
}
199-
200-
/**
201-
* {@inheritDoc}
202-
*/
203-
public function __getInitializer()
204-
{
205-
return $this->initializer;
206-
}
207-
208-
/**
209-
* {@inheritDoc}
210-
*/
211-
public function __setInitializer(?Closure $initializer = null)
212-
{
213-
$this->initializer = $initializer;
214-
}
215-
216-
/**
217-
* {@inheritDoc}
218-
*
219-
* @return mixed[] Keys are the property names, and values are the default
220-
* values for those properties.
221-
* @phpstan-return array<string, mixed>
222-
*/
223-
public function __getLazyProperties()
224-
{
225-
return [];
226-
}
227-
228-
/**
229-
* {@inheritDoc}
230-
*/
231-
public function __setCloner(?Closure $cloner = null)
232-
{
233-
}
234-
235-
/**
236-
* {@inheritDoc}
237-
*/
238-
public function __getCloner()
239-
{
240-
throw new LogicException('Not implemented');
241-
}
242-
}
243156

244157
class RuntimeReflectionPropertyTestClass
245158
{

0 commit comments

Comments
 (0)