From 97fdd0adb71cbb129e416ea370db5f846eaef8f9 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Oct 2014 18:14:33 +0200 Subject: [PATCH] #1120 - cleaning up try-catch code when fetching metadata --- .../ORM/Tools/Console/Command/MappingDescribeCommand.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php index 543dc6514..1718df3cd 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php @@ -19,6 +19,7 @@ namespace Doctrine\ORM\Tools\Console\Command; +use Doctrine\Common\Persistence\Mapping\MappingException; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table; @@ -172,8 +173,8 @@ EOT private function getClassMetadata($entityName, EntityManagerInterface $entityManager) { try { - $meta = $entityManager->getClassMetadata($entityName); - } catch (\Doctrine\Common\Persistence\Mapping\MappingException $e) { + return $entityManager->getClassMetadata($entityName); + } catch (MappingException $e) { $mappedEntities = $this->getMappedEntities($entityManager); $matches = array_filter($mappedEntities, function ($mappedEntity) use ($entityName) { if (preg_match('{' . preg_quote($entityName) . '}', $mappedEntity)) { @@ -198,9 +199,9 @@ EOT $entityName, implode(', ', $matches) )); } - } - return $meta; + return $meta; + } } /**