Skip to content

Fix the EntityRegenerator on Mac #179

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

Merged
merged 2 commits into from
May 11, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
if (!file_exists(__DIR__.'/src')) {
exit(0);
}

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
// the PHP template files are a bit special
->notName('*.tpl.php')
;

if (\PHP_VERSION_ID < 70100) {
// EntityRegenerator works only with PHP 7.1+
$finder->notName('EntityRegenerator.php');
}

return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
Expand All @@ -22,10 +34,5 @@ EOF
]
))
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
// the PHP template files are a bit special
->notName('*.tpl.php')
)
->setFinder($finder)
;
3 changes: 2 additions & 1 deletion src/Doctrine/EntityRegenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\MakerBundle\Doctrine;

use Doctrine\Common\Persistence\Mapping\MappingException as CommonMappingException;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\MappingException;
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException;
Expand Down Expand Up @@ -43,7 +44,7 @@ public function regenerateEntities(string $classOrNamespace)
{
try {
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace);
} catch (MappingException $mappingException) {
} catch (MappingException | CommonMappingException $mappingException) {
Copy link
Member Author

@dunglas dunglas May 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excluding this file on PHP 7 makes Travis happy!

This cause PHP CS Fixer's linting to fail on PHP 7 because this syntax is supported only since PHP 7.1. However the make:entity command already requires 7.1.
Do you want me to use multiple catch blocks or just to ignore this file in the PHP CS config on PHP 7?

$metadata = $this->doctrineHelper->getMetadata($classOrNamespace, true);
}

Expand Down