Skip to content

Commit

Permalink
PHPStan 1.5, Doctrine Coding Standard 9 (#1248)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Apr 1, 2022
1 parent be5d46d commit f9b4c80
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 23 deletions.
12 changes: 6 additions & 6 deletions composer.json
Expand Up @@ -36,16 +36,16 @@
},
"require-dev": {
"ext-pdo_sqlite": "*",
"doctrine/coding-standard": "^8.0",
"doctrine/coding-standard": "^9",
"doctrine/orm": "^2.6",
"doctrine/persistence": "^1.3 || ^2.0",
"doctrine/sql-formatter": "^1.0",
"ergebnis/composer-normalize": "^2.9",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpstan/phpstan-symfony": "^0.12",
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-deprecation-rules": "^1",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.1",
"phpstan/phpstan-symfony": "^1.1",
"phpunit/phpunit": "^8.5 || ^9.4",
"symfony/cache": "^3.4.26 || ^4.2.12 || ^5.0 || ^6.0",
"symfony/process": "^3.4 || ^4.0 || ^5.0 || ^6.0",
Expand Down
Expand Up @@ -15,7 +15,7 @@
*/
final class CurrentCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:current';

protected function configure(): void
Expand Down
Expand Up @@ -31,7 +31,7 @@
*/
final class DiffCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:diff';

protected function configure(): void
Expand Down
Expand Up @@ -27,7 +27,7 @@
*/
final class DumpSchemaCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:dump-schema';

protected function configure(): void
Expand Down
Expand Up @@ -25,7 +25,7 @@
*/
final class ExecuteCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:execute';

protected function configure(): void
Expand Down
Expand Up @@ -19,7 +19,7 @@
*/
final class GenerateCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:generate';

protected function configure(): void
Expand Down
Expand Up @@ -15,7 +15,7 @@
*/
final class LatestCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:latest';

protected function configure(): void
Expand Down
Expand Up @@ -22,7 +22,7 @@
*/
final class ListCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:list';

protected function configure(): void
Expand Down
Expand Up @@ -30,7 +30,7 @@
*/
final class MigrateCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:migrate';

protected function configure(): void
Expand Down
Expand Up @@ -15,7 +15,7 @@
*/
final class RollupCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:rollup';

protected function configure(): void
Expand Down
Expand Up @@ -13,7 +13,7 @@
*/
final class StatusCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:status';

protected function configure(): void
Expand Down
Expand Up @@ -9,7 +9,7 @@

final class SyncMetadataCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:sync-metadata-storage';

protected function configure(): void
Expand Down
Expand Up @@ -26,7 +26,7 @@
*/
final class UpToDateCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:up-to-date';

protected function configure(): void
Expand Down
Expand Up @@ -25,7 +25,7 @@
*/
final class VersionCommand extends DoctrineCommand
{
/** @var string */
/** @var string|null */
protected static $defaultName = 'migrations:version';

/** @var bool */
Expand Down
7 changes: 7 additions & 0 deletions phpstan-common.neon.dist
Expand Up @@ -24,6 +24,8 @@ parameters:
message: '~^Method Doctrine\\Migrations\\Tests\\Stub\\DoctrineRegistry::getService\(\) should return Doctrine\\Persistence\\ObjectManager but returns Doctrine\\DBAL\\Connection\|Doctrine\\ORM\\EntityManager~'
path: tests/Doctrine/Migrations/Tests/Stub/DoctrineRegistry.php

- '~^Property Doctrine\\Migrations\\Tests\\Provider\\\w+::\$id is never written, only read\.$~'

# https://github.com/phpstan/phpstan/issues/5982
-
message: '~^Cannot call method getWrappedConnection\(\) on class-string\|object\.~'
Expand All @@ -35,6 +37,11 @@ parameters:
paths:
- tests/Doctrine/Migrations/Tests/Generator/ClassNameGeneratorTest.php

# TODO: Be more precise about class-strings
-
message: '~^Method Doctrine\\Migrations\\Version\\DbalMigrationFactory::createVersion\(\) should return Doctrine\\Migrations\\AbstractMigration but returns object\.$~'
paths:
- lib/Doctrine/Migrations/Version/DbalMigrationFactory.php

symfony:
console_application_loader: %currentWorkingDirectory%/tests/Doctrine/Migrations/Tests/doctrine-migrations-phpstan-app.php
Expand Down
5 changes: 5 additions & 0 deletions phpstan-dbal-2.neon.dist
Expand Up @@ -35,3 +35,8 @@ parameters:
- tests/Doctrine/Migrations/Tests/SchemaDumperTest.php

- '~Trying to mock an undefined method getNativeConnection\(\) on class Doctrine\\DBAL\\Connection~'

-
message: '~^Expression on left side of \?\? is not nullable\.$~'
paths:
- lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php
Expand Up @@ -52,7 +52,7 @@ public function testListenerDoesFinalCommitWhenAutoCommitIsOff(): void

protected function setUp(): void
{
$this->conn = $this->createStub(Connection::class);
$this->conn = $this->createMock(Connection::class);
$driverConnection = $this->createStub(DriverConnection::class);
$this->conn->method('getWrappedConnection')->willReturn($driverConnection);

Expand Down
Expand Up @@ -144,8 +144,8 @@ public function testExecutedUnavailableMigrationsCancel(): void

protected function setUp(): void
{
$this->migrationDiffGenerator = $this->createStub(DiffGenerator::class);
$this->migrationStatusCalculator = $this->createStub(MigrationStatusCalculator::class);
$this->migrationDiffGenerator = $this->createMock(DiffGenerator::class);
$this->migrationStatusCalculator = $this->createMock(MigrationStatusCalculator::class);
$this->configuration = new Configuration();
$this->configuration->addMigrationsDirectory('FooNs', sys_get_temp_dir());

Expand Down
Expand Up @@ -374,8 +374,9 @@ public function testExecuteMigrateDown(): void
}

/**
* @dataProvider allOrNothing
* @psalm-param array<string, bool> $input
*
* @dataProvider allOrNothing
*/
public function testExecuteMigrateAllOrNothing(bool $default, array $input, bool $expected): void
{
Expand Down

0 comments on commit f9b4c80

Please sign in to comment.