|
2 | 2 |
|
3 | 3 | namespace Doctrine\Bundle\DoctrineBundle\Command; |
4 | 4 |
|
| 5 | +use Doctrine\ORM\Mapping\ClassMetadata; |
5 | 6 | use Doctrine\ORM\Mapping\Driver\DatabaseDriver; |
6 | 7 | use Doctrine\ORM\Tools\Console\MetadataFilter; |
7 | 8 | use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; |
|
13 | 14 | use Symfony\Component\Console\Input\InputOption; |
14 | 15 | use Symfony\Component\Console\Output\OutputInterface; |
15 | 16 |
|
| 17 | +use function assert; |
16 | 18 | use function chmod; |
17 | 19 | use function dirname; |
18 | 20 | use function file_put_contents; |
@@ -91,6 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int |
91 | 93 |
|
92 | 94 | $namespaceOrBundle = $input->getArgument('name'); |
93 | 95 | if (isset($this->bundles[$namespaceOrBundle])) { |
| 96 | + /** @phpstan-ignore method.notFound */ |
94 | 97 | $bundle = $this->getApplication()->getKernel()->getBundle($namespaceOrBundle); |
95 | 98 | $namespace = $bundle->getNamespace() . '\Entity'; |
96 | 99 |
|
@@ -121,20 +124,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int |
121 | 124 |
|
122 | 125 | $em = $this->getEntityManager($input->getOption('em')); |
123 | 126 |
|
| 127 | + /* @phpstan-ignore method.notFound (Available in DBAL < 4) */ |
124 | 128 | $databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager()); |
125 | 129 | $em->getConfiguration()->setMetadataDriverImpl($databaseDriver); |
126 | 130 |
|
127 | 131 | $emName = $input->getOption('em'); |
128 | 132 | $emName = $emName ? $emName : 'default'; |
129 | 133 |
|
130 | | - /* @phpstan-ignore class.notFound */ |
131 | 134 | $cmf = new DisconnectedClassMetadataFactory(); |
132 | 135 | $cmf->setEntityManager($em); |
133 | 136 | $metadata = $cmf->getAllMetadata(); |
134 | 137 | $metadata = MetadataFilter::filter($metadata, $input->getOption('filter')); |
135 | 138 | if ($metadata) { |
136 | 139 | $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName)); |
137 | 140 | foreach ($metadata as $class) { |
| 141 | + assert($class instanceof ClassMetadata); |
138 | 142 | $className = $class->name; |
139 | 143 | $class->name = $namespace . '\\' . $className; |
140 | 144 | if ($type === 'annotation') { |
|
0 commit comments