Skip to content

Commit 79b038a

Browse files
committed
Remove hack to access class scope inside closures
This is possible since 5.4.
1 parent d606941 commit 79b038a

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

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

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

2323
public function testIssue() : void
2424
{
25-
$test = $this;
2625
$user = new CmsUser();
2726
$uow = $this->em->getUnitOfWork();
2827

@@ -39,8 +38,8 @@ public function testIssue() : void
3938
$listener
4039
->expects($this->once())
4140
->method(Events::postFlush)
42-
->will($this->returnCallback(static function () use ($uow, $test) {
43-
$test->assertAttributeEmpty('extraUpdates', $uow, 'ExtraUpdates are reset before postFlush');
41+
->will($this->returnCallback(function () use ($uow) {
42+
self::assertAttributeEmpty('extraUpdates', $uow, 'ExtraUpdates are reset before postFlush');
4443
}));
4544

4645
$this->em->getEventManager()->addEventListener(Events::postFlush, $listener);

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,19 @@ class DDC3644User
154154

155155
public function setAddresses(Collection $addresses)
156156
{
157-
$self = $this;
158-
159157
$this->addresses = $addresses;
160158

161-
$addresses->map(static function ($address) use ($self) {
162-
$address->user = $self;
159+
$addresses->map(function ($address) {
160+
$address->user = $this;
163161
});
164162
}
165163

166164
public function setPets(Collection $pets)
167165
{
168-
$self = $this;
169-
170166
$this->pets = $pets;
171167

172-
$pets->map(static function ($pet) use ($self) {
173-
$pet->owner = $self;
168+
$pets->map(function ($pet) {
169+
$pet->owner = $this;
174170
});
175171
}
176172
}

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

+4-6
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,6 @@ public function testQuoteMetadata() : void
336336
*/
337337
public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMetadata() : void
338338
{
339-
$test = $this;
340-
341339
/** @var ClassMetadata $metadata */
342340
$metadata = $this->createMock(ClassMetadata::class);
343341
$cmf = new ClassMetadataFactory();
@@ -351,10 +349,10 @@ public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMeta
351349
$listener
352350
->expects($this->any())
353351
->method('onClassMetadataNotFound')
354-
->will($this->returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em, $test) {
355-
$test->assertNull($args->getFoundMetadata());
356-
$test->assertSame('Foo', $args->getClassName());
357-
$test->assertSame($em, $args->getObjectManager());
352+
->will($this->returnCallback(function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em) {
353+
self::assertNull($args->getFoundMetadata());
354+
self::assertSame('Foo', $args->getClassName());
355+
self::assertSame($em, $args->getObjectManager());
358356

359357
$args->setFoundMetadata($metadata);
360358
}));

0 commit comments

Comments
 (0)