Skip to content

Commit 92d19dc

Browse files
authored
phpstan: lvl 1 -> 2 (#1854)
1 parent ab9334a commit 92d19dc

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

phpstan.neon.dist

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
parameters:
2-
level: 1
2+
level: 2
33
paths:
44
- src
55
- tests
66

77
excludePaths:
88
- src/Command/Proxy/ConvertMappingDoctrineCommand.php
99
- src/Command/Proxy/EnsureProductionSettingsDoctrineCommand.php
10+
ignoreErrors:
11+
# Available in ORM < 3 only
12+
- '#Doctrine\\ORM\\Tools\\EntityGenerator.#'
13+
- '#Doctrine\\ORM\\Tools\\DisconnectedClassMetadataFactory.#'
14+
- '#Doctrine\\ORM\\Tools\\Export\\ClassMetadataExporter.#'
15+
# phpstan has no array shape intersection support https://github.com/phpstan/phpstan/issues/12414
16+
- message: '#unresolvable type.#'
17+
path: src/DataCollector/DoctrineDataCollector.php
18+
# Probably needs Symfony plugin
19+
- message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\Node#'
20+
path: src/DependencyInjection/Configuration.php

src/Command/DoctrineCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ public function __construct(ManagerRegistry $doctrine)
2929
* get a doctrine entity generator
3030
*
3131
* @return EntityGenerator
32-
*
33-
* @psalm-suppress UndefinedDocblockClass ORM < 3 specific
3432
*/
3533
protected function getEntityGenerator()
3634
{
37-
/** @phpstan-ignore class.notFound */
3835
$entityGenerator = new EntityGenerator();
3936
$entityGenerator->setGenerateAnnotations(false);
4037
$entityGenerator->setGenerateStubMethods(true);

src/Command/ImportMappingDoctrineCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Doctrine\Bundle\DoctrineBundle\Command;
44

5+
use Doctrine\ORM\Mapping\ClassMetadata;
56
use Doctrine\ORM\Mapping\Driver\DatabaseDriver;
67
use Doctrine\ORM\Tools\Console\MetadataFilter;
78
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
@@ -13,6 +14,7 @@
1314
use Symfony\Component\Console\Input\InputOption;
1415
use Symfony\Component\Console\Output\OutputInterface;
1516

17+
use function assert;
1618
use function chmod;
1719
use function dirname;
1820
use function file_put_contents;
@@ -91,6 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9193

9294
$namespaceOrBundle = $input->getArgument('name');
9395
if (isset($this->bundles[$namespaceOrBundle])) {
96+
/** @phpstan-ignore method.notFound */
9497
$bundle = $this->getApplication()->getKernel()->getBundle($namespaceOrBundle);
9598
$namespace = $bundle->getNamespace() . '\Entity';
9699

@@ -121,20 +124,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
121124

122125
$em = $this->getEntityManager($input->getOption('em'));
123126

127+
/* @phpstan-ignore method.notFound (Available in DBAL < 4) */
124128
$databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());
125129
$em->getConfiguration()->setMetadataDriverImpl($databaseDriver);
126130

127131
$emName = $input->getOption('em');
128132
$emName = $emName ? $emName : 'default';
129133

130-
/* @phpstan-ignore class.notFound */
131134
$cmf = new DisconnectedClassMetadataFactory();
132135
$cmf->setEntityManager($em);
133136
$metadata = $cmf->getAllMetadata();
134137
$metadata = MetadataFilter::filter($metadata, $input->getOption('filter'));
135138
if ($metadata) {
136139
$output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
137140
foreach ($metadata as $class) {
141+
assert($class instanceof ClassMetadata);
138142
$className = $class->name;
139143
$class->name = $namespace . '\\' . $className;
140144
if ($type === 'annotation') {

src/ConnectionFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function createConnection(array $params, ?Configuration $config = null, ?
119119
$connection = DriverManager::getConnection(...array_merge([$params, $config], $eventManager ? [$eventManager] : []));
120120
$params = $this->addDatabaseSuffix(array_merge($connection->getParams(), $overriddenOptions));
121121
$driver = $connection->getDriver();
122-
/** @psalm-suppress InvalidScalarArgument Bogus error, StaticServerVersionProvider implements Doctrine\DBAL\ServerVersionProvider */
122+
/** @phpstan-ignore arguments.count (DBAL < 4.x doesn't accept an argument) */
123123
$platform = $driver->getDatabasePlatform(
124124
...(class_exists(StaticServerVersionProvider::class)
125125
? [new StaticServerVersionProvider($params['serverVersion'] ?? $params['primary']['serverVersion'] ?? '')]

src/Registry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getAliasNamespace($alias)
5151
}
5252

5353
try {
54-
/** @psalm-suppress UndefinedMethod ORM < 3 specific */
54+
/** @phpstan-ignore method.notFound (ORM < 3 specific) */
5555
return $objectManager->getConfiguration()->getEntityNamespace($alias);
5656
/* @phpstan-ignore class.notFound */
5757
} catch (ORMException $e) {

0 commit comments

Comments
 (0)