Skip to content

Commit

Permalink
Use finally insead of isset on error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BackEndTea authored and sebastianbergmann committed Oct 28, 2019
1 parent 7be53b7 commit ea510c5
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit ea510c5

Please sign in to comment.