From ea510c5e2e453a10c528e46e68ae4dd51aa3aab6 Mon Sep 17 00:00:00 2001 From: BackEndTea Date: Tue, 15 Oct 2019 12:25:32 +0200 Subject: [PATCH] Use finally insead of isset on error By using the `finally` keyword we don't need to check if the error was thrown, and then throw it again after the checks. This _should_ also help a bit more in case one needs to debug where an error came from, as the original error is still raised, instead of being caught and thrown again. --- src/Framework/TestCase.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 82f702001a4..355d11f74af 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -1662,22 +1662,16 @@ private function verifyMockObjects(): void if ($this->prophet !== null) { try { $this->prophet->checkPredictions(); - } catch (Throwable $t) { - /* Intentionally left empty */ - } - - foreach ($this->prophet->getProphecies() as $objectProphecy) { - foreach ($objectProphecy->getMethodProphecies() as $methodProphecies) { - /** @var MethodProphecy[] $methodProphecies */ - foreach ($methodProphecies as $methodProphecy) { - $this->numAssertions += \count($methodProphecy->getCheckedPredictions()); + } finally { + foreach ($this->prophet->getProphecies() as $objectProphecy) { + foreach ($objectProphecy->getMethodProphecies() as $methodProphecies) { + /** @var MethodProphecy[] $methodProphecies */ + foreach ($methodProphecies as $methodProphecy) { + $this->numAssertions += \count($methodProphecy->getCheckedPredictions()); + } } } } - - if (isset($t)) { - throw $t; - } } }