Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hack to access class scope inside closures #7776

Merged
merged 1 commit into from
Jul 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ protected function setUp() : void

public function testIssue() : void
{
$test = $this;
$user = new CmsUser();
$uow = $this->em->getUnitOfWork();

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

$this->em->getEventManager()->addEventListener(Events::postFlush, $listener);
Expand Down
12 changes: 4 additions & 8 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3644Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,19 @@ class DDC3644User

public function setAddresses(Collection $addresses)
{
$self = $this;

$this->addresses = $addresses;

$addresses->map(static function ($address) use ($self) {
$address->user = $self;
$addresses->map(function ($address) {
$address->user = $this;
});
}

public function setPets(Collection $pets)
{
$self = $this;

$this->pets = $pets;

$pets->map(static function ($pet) use ($self) {
$pet->owner = $self;
$pets->map(function ($pet) {
$pet->owner = $this;
});
}
}
Expand Down
10 changes: 4 additions & 6 deletions tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ public function testQuoteMetadata() : void
*/
public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMetadata() : void
{
$test = $this;

/** @var ClassMetadata $metadata */
$metadata = $this->createMock(ClassMetadata::class);
$cmf = new ClassMetadataFactory();
Expand All @@ -350,10 +348,10 @@ public function testFallbackLoadingCausesEventTriggeringThatCanModifyFetchedMeta
$listener
->expects($this->any())
->method('onClassMetadataNotFound')
->will($this->returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em, $test) {
$test->assertNull($args->getFoundMetadata());
$test->assertSame('Foo', $args->getClassName());
$test->assertSame($em, $args->getObjectManager());
->will($this->returnCallback(static function (OnClassMetadataNotFoundEventArgs $args) use ($metadata, $em) {
self::assertNull($args->getFoundMetadata());
self::assertSame('Foo', $args->getClassName());
self::assertSame($em, $args->getObjectManager());

$args->setFoundMetadata($metadata);
}));
Expand Down