diff --git a/src/DataPersister/ChainDataPersister.php b/src/DataPersister/ChainDataPersister.php index 1a1bcbb638c..6abf03987a6 100644 --- a/src/DataPersister/ChainDataPersister.php +++ b/src/DataPersister/ChainDataPersister.php @@ -51,11 +51,9 @@ public function persist($data) { foreach ($this->persisters as $persister) { if ($persister->supports($data)) { - $data = $persister->persist($data) ?? $data; + return $persister->persist($data) ?? $data; } } - - return $data; } /** diff --git a/tests/DataPersister/ChainDataPersisterTest.php b/tests/DataPersister/ChainDataPersisterTest.php index 877270ffdd8..82d82631bed 100644 --- a/tests/DataPersister/ChainDataPersisterTest.php +++ b/tests/DataPersister/ChainDataPersisterTest.php @@ -60,15 +60,7 @@ public function testPersist() $barPersisterProphecy->supports($dummy)->willReturn(true)->shouldBeCalled(); $barPersisterProphecy->persist($dummy)->shouldBeCalled(); - $bazPersisterProphecy = $this->prophesize(DataPersisterInterface::class); - $bazPersisterProphecy->supports($dummy)->willReturn(true)->shouldBeCalled(); - $bazPersisterProphecy->persist($dummy)->shouldBeCalled(); - - (new ChainDataPersister([ - $fooPersisterProphecy->reveal(), - $barPersisterProphecy->reveal(), - $bazPersisterProphecy->reveal(), - ]))->persist($dummy); + (new ChainDataPersister([$fooPersisterProphecy->reveal(), $barPersisterProphecy->reveal()]))->persist($dummy); } public function testRemove()