Skip to content

Commit 2936bac

Browse files
carusogabrielgreg0ire
authored andcommitted
Remove hack to access class scope inside closures
This is possible since 5.4.
1 parent b6d7826 commit 2936bac

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ protected function setUp(): void
2323

2424
public function testIssue(): void
2525
{
26-
$test = $this;
2726
$user = new CmsUser();
2827
$uow = $this->_em->getUnitOfWork();
2928

@@ -40,12 +39,12 @@ public function testIssue(): void
4039
$listener
4140
->expects($this->once())
4241
->method(Events::postFlush)
43-
->will($this->returnCallback(static function () use ($uow, $test): void {
42+
->will($this->returnCallback(function () use ($uow): void {
4443
$reflection = new ReflectionObject($uow);
4544
$property = $reflection->getProperty('extraUpdates');
4645

4746
$property->setAccessible(true);
48-
$test->assertEmpty(
47+
$this->assertEmpty(
4948
$property->getValue($uow),
5049
'ExtraUpdates are reset before postFlush'
5150
);

tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -164,23 +164,19 @@ class DDC3644User
164164

165165
public function setAddresses(Collection $addresses): void
166166
{
167-
$self = $this;
168-
169167
$this->addresses = $addresses;
170168

171-
$addresses->map(static function ($address) use ($self): void {
172-
$address->user = $self;
169+
$addresses->map(function ($address): void {
170+
$address->user = $this;
173171
});
174172
}
175173

176174
public function setPets(Collection $pets): void
177175
{
178-
$self = $this;
179-
180176
$this->pets = $pets;
181177

182-
$pets->map(static function ($pet) use ($self): void {
183-
$pet->owner = $self;
178+
$pets->map(function ($pet): void {
179+
$pet->owner = $this;
184180
});
185181
}
186182
}

tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,10 @@ public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMeta
392392
$listener
393393
->expects($this->any())
394394
->method('onClassMetadataNotFound')
395-
->will($this->returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em, $test): void {
396-
$test->assertNull($args->getFoundMetadata());
397-
$test->assertSame('Foo', $args->getClassName());
398-
$test->assertSame($em, $args->getObjectManager());
395+
->will($this->returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em): void {
396+
self::assertNull($args->getFoundMetadata());
397+
self::assertSame('Foo', $args->getClassName());
398+
self::assertSame($em, $args->getObjectManager());
399399

400400
$args->setFoundMetadata($metadata);
401401
}));

0 commit comments

Comments
 (0)