From dbbd7b33b8329ec1914eeb45741fd940ea7dec3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 2 Dec 2020 22:43:46 +0100 Subject: [PATCH 01/10] Address MasterSlaveConnection rename MasterSlaveConnection has been deprecated in favor of PrimaryReadReplicaConnection, which it extends before being removed in DBAL 3. This ensure both cases are handled when it comes to making sure we connect to the primary, while not bumping the requirement to doctrine/dbal 2.11 (which requires PHP 7.3, although subsequent version might restore compatibility with 7.1). --- .../Configuration/Configuration.php | 14 +++++-- phpstan.neon.dist | 2 + .../Tests/Configuration/ConfigurationTest.php | 37 ++++++++++++++++++- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/Migrations/Configuration/Configuration.php b/lib/Doctrine/Migrations/Configuration/Configuration.php index d9f40008a6..1067db3211 100644 --- a/lib/Doctrine/Migrations/Configuration/Configuration.php +++ b/lib/Doctrine/Migrations/Configuration/Configuration.php @@ -10,6 +10,7 @@ use Doctrine\Common\EventArgs; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connections\MasterSlaveConnection; +use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; use Doctrine\Migrations\Configuration\Exception\MigrationsNamespaceRequired; use Doctrine\Migrations\Configuration\Exception\ParameterIncompatibleWithFinder; use Doctrine\Migrations\DependencyFactory; @@ -351,13 +352,18 @@ public function generateVersionNumber(?DateTimeInterface $now = null) : string /** * Explicitely opens the database connection. This is done to play nice - * with DBAL's MasterSlaveConnection. Which, in some cases, connects to a - * follower when fetching the executed migrations. If a follower is lagging - * significantly behind that means the migrations system may see unexecuted - * migrations that were actually executed earlier. + * with DBAL's PrimaryReadReplicaConnection. Which, in some cases, connects + * to a follower when fetching the executed migrations. If a follower is + * lagging significantly behind that means the migrations system may see + * unexecuted migrations that were actually executed earlier. */ public function connect() : bool { + if ($this->connection instanceof PrimaryReadReplicaConnection) { + return $this->connection->ensureConnectedToPrimary(); + } + + // Drop this if block when bumping to doctrine/dbal 2.11.0 if ($this->connection instanceof MasterSlaveConnection) { return $this->connection->connect('master'); } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6f673e5f68..b666732ada 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -17,6 +17,8 @@ parameters: - '~^Parameter #1 \$files of method Doctrine\\Migrations\\Finder\\Finder::loadMigrationClasses\(\) expects array, array given\.\z~' - '~^Class Doctrine\\Migrations\\Tests\\DoesNotExistAtAll not found\.\z~' - '~^Call to method getVersion\(\) of deprecated class PackageVersions\\Versions\.$~' + # Drop when bumping to doctrine/dbal 2.11+ + - '~^.*PrimaryReadReplicaConnection.*$~' includes: - vendor/phpstan/phpstan-deprecation-rules/rules.neon diff --git a/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php b/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php index d1fecf73bf..d7c5766b6f 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php @@ -8,6 +8,7 @@ use DateTimeZone; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connections\MasterSlaveConnection; +use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; use Doctrine\DBAL\Platforms\Keywords\KeywordList; use Doctrine\Migrations\Configuration\Configuration; @@ -24,6 +25,7 @@ use Symfony\Component\Stopwatch\Stopwatch as SymfonyStopwatch; use function array_keys; use function call_user_func_array; +use function class_exists; use function sprintf; use function str_replace; @@ -176,9 +178,40 @@ public function testMasterSlaveConnectionAlwaysConnectsToMaster() : void { $connection = $this->createMock(MasterSlaveConnection::class); + if (class_exists(PrimaryReadReplicaConnection::class)) { + $connection->expects(self::once()) + ->method('ensureConnectedToPrimary') + ->willReturn(true); + } else { + $connection->expects(self::once()) + ->method('connect') + ->with('master') + ->willReturn(true); + } + + $configuration = new Configuration($connection); + $configuration->setMigrationsNamespace(str_replace('\Version1Test', '', Version1Test::class)); + $configuration->setMigrationsDirectory(__DIR__ . '/../Stub/Configuration/AutoloadVersions'); + + self::assertTrue($configuration->connect()); + } + + /** + * Connection is tested via the `getMigratedVersions` method which is the + * simplest to set up for. + * + * @see https://github.com/doctrine/migrations/issues/336 + */ + public function testPrimaryReadReplicaConnectionAlwaysConnectsToMaster() : void + { + if (! class_exists(PrimaryReadReplicaConnection::class)) { + self::markTestSkipped('This test requires doctrine/dbal 2.11+'); + } + + $connection = $this->createMock(PrimaryReadReplicaConnection::class); + $connection->expects(self::once()) - ->method('connect') - ->with('master') + ->method('ensureConnectedToPrimary') ->willReturn(true); $configuration = new Configuration($connection); From 3297cccad39532118ec902fa9bd8a33c69481ba7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 23 Dec 2020 09:48:00 +0100 Subject: [PATCH 02/10] Allow PHP 8 --- .github/workflows/continuous-integration.yml | 1 + composer.json | 4 ++-- download-box.sh | 2 +- lib/Doctrine/Migrations/SchemaDumper.php | 2 +- phpstan.neon.dist | 2 -- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index bc1c2fc1d1..a4dfb517db 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -32,6 +32,7 @@ jobs: - "7.2" - "7.3" - "7.4" + - "8.0" deps: - "normal" include: diff --git a/composer.json b/composer.json index 9ab1cdbbe7..d2b476d7e4 100644 --- a/composer.json +++ b/composer.json @@ -24,11 +24,11 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "composer/package-versions-deprecated": "^1.8", "doctrine/dbal": "^2.10", "doctrine/event-manager": "^1.0", - "ocramius/proxy-manager": "^2.0.2", + "friendsofphp/proxy-manager-lts": "^1.0", "psr/log": "^1.1.3", "symfony/console": "^3.4 || ^4.4.16 || ^5.0", "symfony/stopwatch": "^3.4 || ^4.0 || ^5.0" diff --git a/download-box.sh b/download-box.sh index 36f31d00e5..554a0dc725 100755 --- a/download-box.sh +++ b/download-box.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash if [ ! -f box.phar ]; then - wget https://github.com/box-project/box/releases/download/3.9.1/box.phar -O box.phar + wget https://github.com/box-project/box/releases/download/$(php -r 'echo PHP_VERSION_ID >= 70300 ? "3.11.0" : "3.9.1";')/box.phar -O box.phar fi diff --git a/lib/Doctrine/Migrations/SchemaDumper.php b/lib/Doctrine/Migrations/SchemaDumper.php index 5bc5993ac1..6c2b659a42 100644 --- a/lib/Doctrine/Migrations/SchemaDumper.php +++ b/lib/Doctrine/Migrations/SchemaDumper.php @@ -158,7 +158,7 @@ private static function pregMatch(string $pattern, string $subject, ?array &$mat { try { $errorMessages = []; - set_error_handler(static function (int $severity, string $message, string $file, int $line, array $params) use (&$errorMessages): bool { + set_error_handler(static function (int $severity, string $message, string $file, int $line) use (&$errorMessages): bool { $errorMessages[] = $message; return true; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 476ba18882..4d4ffc30a7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -9,8 +9,6 @@ parameters: excludes_analyse: - %currentWorkingDirectory%/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTestSource/Migrations/Version123.php ignoreErrors: - # Ignore proxy manager magic - - '~ProxyManager\\Proxy\\VirtualProxyInterface~' - '~Variable method call on Doctrine\\Migrations\\AbstractMigration~' - message: '~^Call to function in_array\(\) requires parameter #3 to be true\.$~' From 325d36a51f64ec86538e380fd1afbe122fcf56f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 26 May 2020 21:26:29 +0200 Subject: [PATCH 03/10] Allow PHP 8 --- .github/workflows/continuous-integration.yml | 1 + composer.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 16ed9331bb..185b9be2ae 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -19,6 +19,7 @@ jobs: - "7.2" - "7.3" - "7.4" + - "8.0" deps: - "normal" include: diff --git a/composer.json b/composer.json index 8a1ac64231..e611baaf2f 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ {"name": "Michael Simonson", "email": "contact@mikesimonson.com" } ], "require": { - "php": "^7.1", + "php": "^7.1 || ^8.0", "composer/package-versions-deprecated": "^1.8", "doctrine/dbal": "^2.9", "ocramius/proxy-manager": "^2.0.2", From bb722660b696c24ce061ff1bcf51c2f644934785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 8 Nov 2020 22:49:49 +0100 Subject: [PATCH 04/10] Relax constraints on PHPStan --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index e611baaf2f..4365572d00 100644 --- a/composer.json +++ b/composer.json @@ -24,10 +24,10 @@ "doctrine/orm": "^2.6", "jdorn/sql-formatter": "^1.1", "mikey179/vfsstream": "^1.6", - "phpstan/phpstan": "^0.10", - "phpstan/phpstan-deprecation-rules": "^0.10", - "phpstan/phpstan-phpunit": "^0.10", - "phpstan/phpstan-strict-rules": "^0.10", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-deprecation-rules": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpstan/phpstan-strict-rules": "^0.12", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.4", "symfony/process": "^3.4||^4.0||^5.0", "symfony/yaml": "^3.4||^4.0||^5.0" From 53a5da0a0b1ca5cc90061b128c4bed956e6ae754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 12 Nov 2020 20:20:06 +0100 Subject: [PATCH 05/10] Upgrade CS lib --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4365572d00..d0f3fe75e2 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ }, "require-dev": { "ext-pdo_sqlite": "*", - "doctrine/coding-standard": "^6.0", + "doctrine/coding-standard": "^8.2", "doctrine/orm": "^2.6", "jdorn/sql-formatter": "^1.1", "mikey179/vfsstream": "^1.6", From ef842cfb1944606148159e724d8ae7e7845cf4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 12 Nov 2020 20:20:40 +0100 Subject: [PATCH 06/10] Automatically fix cs --- bin/doctrine-migrations.php | 10 +- lib/Doctrine/Migrations/AbstractMigration.php | 29 ++-- .../AbstractFileConfiguration.php | 17 ++- .../Configuration/ArrayConfiguration.php | 3 +- .../Configuration/Configuration.php | 139 +++++++++--------- .../Connection/ConnectionLoaderInterface.php | 2 +- .../ArrayConnectionConfigurationLoader.php | 3 +- .../ConnectionConfigurationChainLoader.php | 2 +- .../Loader/ConnectionConfigurationLoader.php | 2 +- .../Loader/ConnectionHelperLoader.php | 2 +- .../Loader/Exception/InvalidConfiguration.php | 2 +- .../Exception/FileAlreadyLoaded.php | 2 +- .../Configuration/Exception/FileNotFound.php | 2 +- .../Exception/InvalidConfigurationKey.php | 3 +- .../Configuration/Exception/JsonNotValid.php | 2 +- .../Exception/MigrationsNamespaceRequired.php | 2 +- .../ParameterIncompatibleWithFinder.php | 3 +- .../Exception/UnknownConfigurationValue.php | 3 +- .../Configuration/Exception/XmlNotValid.php | 4 +- .../Exception/YamlNotAvailable.php | 2 +- .../Configuration/Exception/YamlNotValid.php | 4 +- .../Configuration/JsonConfiguration.php | 7 +- .../Configuration/XmlConfiguration.php | 9 +- .../Configuration/YamlConfiguration.php | 6 +- lib/Doctrine/Migrations/DependencyFactory.php | 90 ++++++------ .../Event/Listeners/AutoCommitListener.php | 2 +- .../Migrations/Event/MigrationsEventArgs.php | 8 +- .../Event/MigrationsVersionEventArgs.php | 2 +- lib/Doctrine/Migrations/EventDispatcher.php | 10 +- .../Migrations/Exception/AlreadyAtVersion.php | 3 +- .../Exception/DuplicateMigrationVersion.php | 3 +- .../Exception/MigrationClassNotFound.php | 3 +- .../MigrationNotConvertibleToSql.php | 3 +- .../Exception/MigrationsDirectoryRequired.php | 2 +- .../Exception/NoMigrationsToExecute.php | 2 +- .../Migrations/Exception/NoTablesFound.php | 2 +- .../Migrations/Exception/RollupFailed.php | 4 +- .../Exception/UnknownMigrationVersion.php | 3 +- lib/Doctrine/Migrations/FileQueryWriter.php | 5 +- .../Finder/Exception/InvalidDirectory.php | 3 +- .../Finder/Exception/NameIsReserved.php | 6 +- lib/Doctrine/Migrations/Finder/Finder.php | 14 +- lib/Doctrine/Migrations/Finder/GlobFinder.php | 2 +- .../Migrations/Finder/MigrationFinder.php | 2 +- .../Finder/RecursiveRegexFinder.php | 12 +- .../Migrations/Generator/DiffGenerator.php | 11 +- .../Exception/InvalidTemplateSpecified.php | 7 +- .../Generator/Exception/NoChangesDetected.php | 2 +- .../Migrations/Generator/FileBuilder.php | 5 +- .../Migrations/Generator/Generator.php | 7 +- .../Migrations/Generator/SqlGenerator.php | 3 +- .../Migrations/MigrationPlanCalculator.php | 5 +- .../Migrations/MigrationRepository.php | 60 ++++---- lib/Doctrine/Migrations/Migrator.php | 18 ++- .../Migrations/MigratorConfiguration.php | 20 +-- lib/Doctrine/Migrations/OutputWriter.php | 8 +- .../Migrations/ParameterFormatter.php | 7 +- .../ParameterFormatterInterface.php | 2 +- .../Provider/EmptySchemaProvider.php | 2 +- .../Provider/Exception/NoMappingFound.php | 2 +- .../Provider/LazySchemaDiffProvider.php | 14 +- .../Migrations/Provider/OrmSchemaProvider.php | 3 +- .../Provider/SchemaDiffProvider.php | 6 +- .../Provider/SchemaDiffProviderInterface.php | 6 +- .../Provider/SchemaProviderInterface.php | 2 +- .../Provider/StubSchemaProvider.php | 2 +- lib/Doctrine/Migrations/QueryWriter.php | 2 +- lib/Doctrine/Migrations/Rollup.php | 3 +- lib/Doctrine/Migrations/SchemaDumper.php | 3 +- lib/Doctrine/Migrations/Stopwatch.php | 2 +- .../Tools/BooleanStringFormatter.php | 6 +- .../Migrations/Tools/BytesFormatter.php | 2 +- .../Tools/Console/Command/AbstractCommand.php | 35 ++--- .../Tools/Console/Command/DiffCommand.php | 15 +- .../Console/Command/DumpSchemaCommand.php | 5 +- .../Tools/Console/Command/ExecuteCommand.php | 5 +- .../Tools/Console/Command/GenerateCommand.php | 5 +- .../Tools/Console/Command/LatestCommand.php | 5 +- .../Tools/Console/Command/MigrateCommand.php | 13 +- .../Tools/Console/Command/RollupCommand.php | 5 +- .../Tools/Console/Command/StatusCommand.php | 9 +- .../Tools/Console/Command/UpToDateCommand.php | 5 +- .../Tools/Console/Command/VersionCommand.php | 9 +- .../Tools/Console/ConnectionLoader.php | 5 +- .../Tools/Console/ConsoleRunner.php | 6 +- .../Exception/ConnectionNotSpecified.php | 2 +- .../Exception/DirectoryDoesNotExist.php | 3 +- .../Exception/FileTypeNotSupported.php | 2 +- .../Console/Exception/InvalidOptionUsage.php | 2 +- .../SchemaDumpRequiresNoMigrations.php | 2 +- .../Exception/VersionAlreadyExists.php | 3 +- .../Console/Exception/VersionDoesNotExist.php | 3 +- .../Console/Helper/ConfigurationHelper.php | 12 +- .../Helper/ConfigurationHelperInterface.php | 2 +- .../Helper/MigrationDirectoryHelper.php | 10 +- .../Helper/MigrationStatusInfosHelper.php | 5 +- .../Migrations/Tracking/TableDefinition.php | 20 +-- .../Migrations/Tracking/TableManipulator.php | 2 +- .../Migrations/Tracking/TableStatus.php | 8 +- .../Migrations/Tracking/TableUpdater.php | 7 +- .../Migrations/Version/AliasResolver.php | 8 +- .../Migrations/Version/ExecutionResult.php | 39 ++--- lib/Doctrine/Migrations/Version/Executor.php | 31 ++-- .../Migrations/Version/ExecutorInterface.php | 4 +- lib/Doctrine/Migrations/Version/Factory.php | 2 +- lib/Doctrine/Migrations/Version/Version.php | 38 ++--- phpcs.xml.dist | 11 +- .../Tests/AbstractMigrationTest.php | 29 ++-- .../Migrations/Tests/BoxPharCompileTest.php | 8 +- .../AbstractConfigurationTest.php | 53 +++---- .../AbstractFileConfigurationTest.php | 13 +- .../Configuration/ArrayConfigurationTest.php | 5 +- .../Tests/Configuration/ConfigurationTest.php | 43 +++--- .../ConnectionConfigurationLoaderTest.php | 6 +- .../Configuration/JsonConfigurationTest.php | 7 +- .../Configuration/XmlConfigurationTest.php | 5 +- .../Configuration/YamlConfigurationTest.php | 5 +- .../Migrations/Tests/ConfigurationTest.php | 55 +++---- .../Listeners/AutoCommitListenerTest.php | 12 +- .../Migrations/Tests/FileQueryWriterTest.php | 5 +- .../Tests/Finder/FinderTestCase.php | 4 +- .../Tests/Finder/GlobFinderTest.php | 8 +- .../Tests/Finder/RecursiveRegexFinderTest.php | 21 +-- .../_features/MultiNamespace/Version0001.php | 4 +- .../_features/MultiNamespace/Version0002.php | 4 +- .../MultiNamespaceNested/Deep/Version0002.php | 4 +- .../MultiNamespaceNested/Version0001.php | 4 +- .../Finder/_files/Version20150502000000.php | 4 +- .../Finder/_files/Version20150502000001.php | 4 +- .../_files/deep/Version1ResetVersions.php | 4 +- .../_files/deep/Version20150502000003.php | 4 +- .../Version20150502000005.php | 4 +- .../deep/deeper/Version20150502000004.php | 4 +- .../_regression/NoVersionNamed0/Version0.php | 4 +- .../Version1SymlinkedFile.php | 4 +- .../Migrations/Tests/Functional/CliTest.php | 51 ++++--- .../Tests/Functional/FunctionalTest.php | 81 +++++----- .../MigrationTableManipulatorTest.php | 8 +- .../Tests/Generator/DiffGeneratorTest.php | 6 +- .../Tests/Generator/FileBuilderTest.php | 4 +- .../Tests/Generator/GeneratorTest.php | 11 +- .../Tests/Generator/SqlGeneratorTest.php | 11 +- tests/Doctrine/Migrations/Tests/Helper.php | 2 +- .../Tests/MigrationPlanCalculatorTest.php | 6 +- .../Tests/MigrationRepositoryTest.php | 12 +- .../Migrations/Tests/MigrationTestCase.php | 19 +-- .../Tests/MigratorConfigurationTest.php | 10 +- .../Migrations/Tests/MigratorTest.php | 35 +++-- .../Migrations/Tests/OutputWriterTest.php | 12 +- .../Tests/ParameterFormatterTest.php | 4 +- .../Doctrine/Migrations/Tests/Provider/A.php | 2 +- .../Doctrine/Migrations/Tests/Provider/B.php | 2 +- .../Doctrine/Migrations/Tests/Provider/C.php | 2 +- .../Tests/Provider/ClassMetadataFactory.php | 3 +- .../Provider/EmptySchemaProviderTest.php | 4 +- .../Tests/Provider/OrmSchemaProviderTest.php | 6 +- .../Doctrine/Migrations/Tests/RollupTest.php | 8 +- .../Migrations/Tests/SchemaDumperTest.php | 6 +- .../Migrations/Tests/StopwatchTest.php | 4 +- .../Tests/Stub/AbstractMigrationStub.php | 12 +- .../AutoloadVersions/Version1Test.php | 4 +- .../AutoloadVersions/Version2Test.php | 4 +- .../AutoloadVersions/Version3Test.php | 4 +- .../AutoloadVersions/Version4Test.php | 4 +- .../AutoloadVersions/Version5Test.php | 4 +- .../Tests/Stub/EventVerificationListener.php | 12 +- .../Tests/Stub/ExceptionVersionDummy.php | 4 +- .../Tests/Stub/Functional/DryRun/DryRun1.php | 4 +- .../Tests/Stub/Functional/DryRun/DryRun2.php | 4 +- .../MigrateAddSqlPostAndPreUpAndDownTest.php | 13 +- .../Stub/Functional/MigrateAddSqlTest.php | 4 +- .../MigrateNotTouchingTheSchema.php | 12 +- .../MigrateWithDataModification.php | 6 +- .../Functional/MigrationMigrateFurther.php | 4 +- .../Stub/Functional/MigrationMigrateUp.php | 4 +- .../MigrationModifySchemaInPreAndPost.php | 14 +- .../Functional/MigrationSkipMigration.php | 4 +- .../Stub/Functional/MigrationThrowsError.php | 4 +- .../Migrations/Tests/Stub/Version1Test.php | 4 +- .../Migrations/Tests/Stub/Version2Test.php | 4 +- .../Migrations/Tests/Stub/Version3Test.php | 4 +- .../Tests/Stub/VersionDryRunNamedParams.php | 4 +- .../Stub/VersionDryRunQuestionMarkParams.php | 4 +- .../Tests/Stub/VersionDryRunTypes.php | 6 +- .../Tests/Stub/VersionDryRunWithoutParams.php | 4 +- .../Migrations/Tests/Stub/VersionDummy.php | 4 +- .../Tests/Stub/VersionDummyDescription.php | 6 +- .../Tests/Stub/VersionOutputSql.php | 4 +- .../Tests/Stub/VersionOutputSqlWithParam.php | 6 +- .../Stub/VersionOutputSqlWithParamAndType.php | 8 +- .../Tools/BooleanStringFormatterTest.php | 2 +- .../Tests/Tools/BytesFormatterTest.php | 2 +- .../Console/Command/AbstractCommandTest.php | 41 +++--- .../Tools/Console/Command/CommandTestCase.php | 11 +- .../Tools/Console/Command/DialogSupport.php | 4 +- .../Tools/Console/Command/DiffCommandTest.php | 4 +- .../Console/Command/DumpSchemaCommandTest.php | 6 +- .../Console/Command/ExecuteCommandTest.php | 11 +- .../Console/Command/GenerateCommandTest.php | 4 +- .../Console/Command/MigrateCommandTest.php | 27 ++-- .../Console/Command/MigrationStatusTest.php | 9 +- .../Console/Command/MigrationVersionTest.php | 33 +++-- .../Console/Command/RollupCommandTest.php | 4 +- .../Console/Command/StatusCommandTest.php | 4 +- .../Console/Command/UpToDateCommandTest.php | 8 +- .../Tools/Console/ConnectionLoaderTest.php | 4 +- .../Tests/Tools/Console/ConsoleRunnerTest.php | 26 ++-- .../Helper/ConfigurationHelperTest.php | 13 +- .../Helper/MigrationDirectoryHelperTest.php | 12 +- .../Helper/MigrationStatusInfosHelperTest.php | 4 +- .../Tests/Tracking/TableDefinitionTest.php | 20 +-- .../Tests/Tracking/TableManipulatorTest.php | 8 +- .../Tests/Tracking/TableStatusTest.php | 14 +- .../Tests/Tracking/TableUpdaterTest.php | 6 +- .../Tests/Version/AliasResolverTest.php | 8 +- .../Tests/Version/ExecutionResultTest.php | 26 ++-- .../Migrations/Tests/Version/ExecutorTest.php | 26 ++-- .../Migrations/Tests/Version/FactoryTest.php | 8 +- .../Migrations/Tests/Version/VersionTest.php | 81 +++++----- 219 files changed, 1181 insertions(+), 1049 deletions(-) diff --git a/bin/doctrine-migrations.php b/bin/doctrine-migrations.php index e106154cea..148efdd363 100644 --- a/bin/doctrine-migrations.php +++ b/bin/doctrine-migrations.php @@ -8,16 +8,18 @@ use Phar; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Helper\QuestionHelper; -use const DIRECTORY_SEPARATOR; -use const E_USER_ERROR; -use const PHP_EOL; + use function extension_loaded; use function file_exists; use function getcwd; use function is_readable; use function trigger_error; -(static function () : void { +use const DIRECTORY_SEPARATOR; +use const E_USER_ERROR; +use const PHP_EOL; + +(static function (): void { $autoloadFiles = [ __DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php', diff --git a/lib/Doctrine/Migrations/AbstractMigration.php b/lib/Doctrine/Migrations/AbstractMigration.php index dcfa08c1f9..38c0d3e1b0 100644 --- a/lib/Doctrine/Migrations/AbstractMigration.php +++ b/lib/Doctrine/Migrations/AbstractMigration.php @@ -14,6 +14,7 @@ use Doctrine\Migrations\Exception\MigrationException; use Doctrine\Migrations\Exception\SkipMigration; use Doctrine\Migrations\Version\Version; + use function sprintf; /** @@ -57,17 +58,17 @@ public function __construct(Version $version) * * Extending class should override this function to alter the return value. */ - public function isTransactional() : bool + public function isTransactional(): bool { return true; } - public function getDescription() : string + public function getDescription(): string { return ''; } - public function warnIf(bool $condition, string $message = '') : void + public function warnIf(bool $condition, string $message = ''): void { if (! $condition) { return; @@ -85,7 +86,7 @@ public function warnIf(bool $condition, string $message = '') : void /** * @throws AbortMigration */ - public function abortIf(bool $condition, string $message = '') : void + public function abortIf(bool $condition, string $message = ''): void { if ($condition) { throw new AbortMigration($message ?: 'Unknown Reason'); @@ -95,7 +96,7 @@ public function abortIf(bool $condition, string $message = '') : void /** * @throws SkipMigration */ - public function skipIf(bool $condition, string $message = '') : void + public function skipIf(bool $condition, string $message = ''): void { if ($condition) { throw new SkipMigration($message ?: 'Unknown Reason'); @@ -105,40 +106,40 @@ public function skipIf(bool $condition, string $message = '') : void /** * @throws MigrationException|DBALException */ - public function preUp(Schema $schema) : void + public function preUp(Schema $schema): void { } /** * @throws MigrationException|DBALException */ - public function postUp(Schema $schema) : void + public function postUp(Schema $schema): void { } /** * @throws MigrationException|DBALException */ - public function preDown(Schema $schema) : void + public function preDown(Schema $schema): void { } /** * @throws MigrationException|DBALException */ - public function postDown(Schema $schema) : void + public function postDown(Schema $schema): void { } /** * @throws MigrationException|DBALException */ - abstract public function up(Schema $schema) : void; + abstract public function up(Schema $schema): void; /** * @throws MigrationException|DBALException */ - abstract public function down(Schema $schema) : void; + abstract public function down(Schema $schema): void; /** * @param mixed[] $params @@ -148,11 +149,11 @@ protected function addSql( string $sql, array $params = [], array $types = [] - ) : void { + ): void { $this->version->addSql($sql, $params, $types); } - protected function write(string $message) : void + protected function write(string $message): void { $this->outputWriter->write($message); } @@ -160,7 +161,7 @@ protected function write(string $message) : void /** * @throws IrreversibleMigration */ - protected function throwIrreversibleMigrationException(?string $message = null) : void + protected function throwIrreversibleMigrationException(?string $message = null): void { if ($message === null) { $message = 'This migration is irreversible and cannot be reverted.'; diff --git a/lib/Doctrine/Migrations/Configuration/AbstractFileConfiguration.php b/lib/Doctrine/Migrations/Configuration/AbstractFileConfiguration.php index 554de779e9..129b4dcb8a 100644 --- a/lib/Doctrine/Migrations/Configuration/AbstractFileConfiguration.php +++ b/lib/Doctrine/Migrations/Configuration/AbstractFileConfiguration.php @@ -8,6 +8,7 @@ use Doctrine\Migrations\Configuration\Exception\FileNotFound; use Doctrine\Migrations\Configuration\Exception\InvalidConfigurationKey; use Doctrine\Migrations\Configuration\Exception\UnknownConfigurationValue; + use function dirname; use function file_exists; use function getcwd; @@ -61,7 +62,7 @@ abstract class AbstractFileConfiguration extends Configuration /** * @throws FileNotFound */ - public function load(string $file) : void + public function load(string $file): void { if ($this->loaded) { throw FileAlreadyLoaded::new(); @@ -83,7 +84,7 @@ public function load(string $file) : void $this->loaded = true; } - public function getFile() : string + public function getFile(): string { return $this->file; } @@ -91,7 +92,7 @@ public function getFile() : string /** * @param mixed[] $config */ - protected function setConfiguration(array $config) : void + protected function setConfiguration(array $config): void { foreach ($config as $configurationKey => $configurationValue) { if (! in_array($configurationKey, self::ALLOWED_CONFIGURATION_KEYS, true)) { @@ -108,7 +109,7 @@ protected function setConfiguration(array $config) : void } } - protected function getDirectoryRelativeToFile(string $file, string $input) : string + protected function getDirectoryRelativeToFile(string $file, string $input): string { $path = realpath(dirname($file) . '/' . $input); @@ -120,16 +121,16 @@ protected function getDirectoryRelativeToFile(string $file, string $input) : str * load the given configuration file whether it be xml, yaml, etc. or something * else. */ - abstract protected function doLoad(string $file) : void; + abstract protected function doLoad(string $file): void; - private function loadMigrationsFromDirectory(string $migrationsDirectory) : void + private function loadMigrationsFromDirectory(string $migrationsDirectory): void { $this->setMigrationsDirectory($migrationsDirectory); $this->registerMigrationsFromDirectory($migrationsDirectory); } /** @param string[][] $migrations */ - private function loadMigrations(array $migrations) : void + private function loadMigrations(array $migrations): void { foreach ($migrations as $migration) { $this->registerMigration( @@ -139,7 +140,7 @@ private function loadMigrations(array $migrations) : void } } - private function setMigrationOrganization(string $migrationOrganization) : void + private function setMigrationOrganization(string $migrationOrganization): void { if (strcasecmp($migrationOrganization, self::VERSIONS_ORGANIZATION_BY_YEAR) === 0) { $this->setMigrationsAreOrganizedByYear(); diff --git a/lib/Doctrine/Migrations/Configuration/ArrayConfiguration.php b/lib/Doctrine/Migrations/Configuration/ArrayConfiguration.php index 95a2cbf15f..6afe340163 100644 --- a/lib/Doctrine/Migrations/Configuration/ArrayConfiguration.php +++ b/lib/Doctrine/Migrations/Configuration/ArrayConfiguration.php @@ -11,8 +11,7 @@ */ class ArrayConfiguration extends AbstractFileConfiguration { - /** @inheritdoc */ - protected function doLoad(string $file) : void + protected function doLoad(string $file): void { $config = require $file; diff --git a/lib/Doctrine/Migrations/Configuration/Configuration.php b/lib/Doctrine/Migrations/Configuration/Configuration.php index 1067db3211..cd71ce7c76 100644 --- a/lib/Doctrine/Migrations/Configuration/Configuration.php +++ b/lib/Doctrine/Migrations/Configuration/Configuration.php @@ -21,6 +21,7 @@ use Doctrine\Migrations\OutputWriter; use Doctrine\Migrations\QueryWriter; use Doctrine\Migrations\Version\Version; + use function str_replace; use function strlen; @@ -104,42 +105,42 @@ public function __construct( $this->migrationsColumnLength = strlen($this->createDateTime()->format(self::VERSION_FORMAT)); } - public function setName(string $name) : void + public function setName(string $name): void { $this->name = $name; } - public function getName() : ?string + public function getName(): ?string { return $this->name; } - public function getConnection() : Connection + public function getConnection(): Connection { return $this->connection; } - public function setMigrationsTableName(string $tableName) : void + public function setMigrationsTableName(string $tableName): void { $this->migrationsTableName = $tableName; } - public function getMigrationsTableName() : string + public function getMigrationsTableName(): string { return $this->migrationsTableName; } - public function setMigrationsColumnName(string $columnName) : void + public function setMigrationsColumnName(string $columnName): void { $this->migrationsColumnName = $columnName; } - public function getMigrationsColumnName() : string + public function getMigrationsColumnName(): string { return $this->migrationsColumnName; } - public function getQuotedMigrationsColumnName() : string + public function getQuotedMigrationsColumnName(): string { return $this->getDependencyFactory() ->getTrackingTableDefinition() @@ -147,27 +148,27 @@ public function getQuotedMigrationsColumnName() : string ->getQuotedName($this->connection->getDatabasePlatform()); } - public function setMigrationsColumnLength(int $columnLength) : void + public function setMigrationsColumnLength(int $columnLength): void { $this->migrationsColumnLength = $columnLength; } - public function getMigrationsColumnLength() : int + public function getMigrationsColumnLength(): int { return $this->migrationsColumnLength; } - public function setMigrationsExecutedAtColumnName(string $migrationsExecutedAtColumnName) : void + public function setMigrationsExecutedAtColumnName(string $migrationsExecutedAtColumnName): void { $this->migrationsExecutedAtColumnName = $migrationsExecutedAtColumnName; } - public function getMigrationsExecutedAtColumnName() : string + public function getMigrationsExecutedAtColumnName(): string { return $this->migrationsExecutedAtColumnName; } - public function getQuotedMigrationsExecutedAtColumnName() : string + public function getQuotedMigrationsExecutedAtColumnName(): string { return $this->getDependencyFactory() ->getTrackingTableDefinition() @@ -175,37 +176,37 @@ public function getQuotedMigrationsExecutedAtColumnName() : string ->getQuotedName($this->connection->getDatabasePlatform()); } - public function setMigrationsDirectory(string $migrationsDirectory) : void + public function setMigrationsDirectory(string $migrationsDirectory): void { $this->migrationsDirectory = $migrationsDirectory; } - public function getMigrationsDirectory() : ?string + public function getMigrationsDirectory(): ?string { return $this->migrationsDirectory; } - public function setMigrationsNamespace(string $migrationsNamespace) : void + public function setMigrationsNamespace(string $migrationsNamespace): void { $this->migrationsNamespace = $migrationsNamespace; } - public function getMigrationsNamespace() : ?string + public function getMigrationsNamespace(): ?string { return $this->migrationsNamespace; } - public function setCustomTemplate(?string $customTemplate) : void + public function setCustomTemplate(?string $customTemplate): void { $this->customTemplate = $customTemplate; } - public function getCustomTemplate() : ?string + public function getCustomTemplate(): ?string { return $this->customTemplate; } - public function areMigrationsOrganizedByYear() : bool + public function areMigrationsOrganizedByYear(): bool { return $this->migrationsAreOrganizedByYear; } @@ -215,7 +216,7 @@ public function areMigrationsOrganizedByYear() : bool */ public function setMigrationsAreOrganizedByYear( bool $migrationsAreOrganizedByYear = true - ) : void { + ): void { $this->ensureOrganizeMigrationsIsCompatibleWithFinder(); $this->migrationsAreOrganizedByYear = $migrationsAreOrganizedByYear; @@ -226,23 +227,25 @@ public function setMigrationsAreOrganizedByYear( */ public function setMigrationsAreOrganizedByYearAndMonth( bool $migrationsAreOrganizedByYearAndMonth = true - ) : void { + ): void { $this->ensureOrganizeMigrationsIsCompatibleWithFinder(); $this->migrationsAreOrganizedByYear = $migrationsAreOrganizedByYearAndMonth; $this->migrationsAreOrganizedByYearAndMonth = $migrationsAreOrganizedByYearAndMonth; } - public function areMigrationsOrganizedByYearAndMonth() : bool + public function areMigrationsOrganizedByYearAndMonth(): bool { return $this->migrationsAreOrganizedByYearAndMonth; } /** @throws MigrationException */ - public function setMigrationsFinder(MigrationFinder $migrationFinder) : void + public function setMigrationsFinder(MigrationFinder $migrationFinder): void { - if (($this->migrationsAreOrganizedByYear || $this->migrationsAreOrganizedByYearAndMonth) - && ! ($migrationFinder instanceof MigrationDeepFinder)) { + if ( + ($this->migrationsAreOrganizedByYear || $this->migrationsAreOrganizedByYearAndMonth) + && ! ($migrationFinder instanceof MigrationDeepFinder) + ) { throw ParameterIncompatibleWithFinder::new( 'organize-migrations', $migrationFinder @@ -252,7 +255,7 @@ public function setMigrationsFinder(MigrationFinder $migrationFinder) : void $this->migrationFinder = $migrationFinder; } - public function getMigrationsFinder() : MigrationFinder + public function getMigrationsFinder(): MigrationFinder { if ($this->migrationFinder === null) { $this->migrationFinder = $this->getDependencyFactory()->getRecursiveRegexFinder(); @@ -262,7 +265,7 @@ public function getMigrationsFinder() : MigrationFinder } /** @throws MigrationException */ - public function validate() : void + public function validate(): void { if ($this->migrationsNamespace === null) { throw MigrationsNamespaceRequired::new(); @@ -273,7 +276,7 @@ public function validate() : void } } - public function hasVersionMigrated(Version $version) : bool + public function hasVersionMigrated(Version $version): bool { return $this->getDependencyFactory()->getMigrationRepository()->hasVersionMigrated($version); } @@ -281,57 +284,57 @@ public function hasVersionMigrated(Version $version) : bool /** * @return mixed[] */ - public function getVersionData(Version $version) : ?array + public function getVersionData(Version $version): ?array { return $this->getDependencyFactory()->getMigrationRepository()->getVersionData($version); } - public function resolveVersionAlias(string $alias) : ?string + public function resolveVersionAlias(string $alias): ?string { return $this->getDependencyFactory()->getVersionAliasResolver()->resolveVersionAlias($alias); } - public function setIsDryRun(bool $isDryRun) : void + public function setIsDryRun(bool $isDryRun): void { $this->isDryRun = $isDryRun; } - public function isDryRun() : bool + public function isDryRun(): bool { return $this->isDryRun; } - public function setAllOrNothing(bool $allOrNothing) : void + public function setAllOrNothing(bool $allOrNothing): void { $this->allOrNothing = $allOrNothing; } - public function isAllOrNothing() : bool + public function isAllOrNothing(): bool { return $this->allOrNothing; } - public function setCheckDatabasePlatform(bool $checkDbPlatform) : void + public function setCheckDatabasePlatform(bool $checkDbPlatform): void { $this->checkDbPlatform = $checkDbPlatform; } - public function isDatabasePlatformChecked() : bool + public function isDatabasePlatformChecked(): bool { return $this->checkDbPlatform; } - public function isMigrationTableCreated() : bool + public function isMigrationTableCreated(): bool { return $this->getDependencyFactory()->getTrackingTableStatus()->isCreated(); } - public function createMigrationTable() : bool + public function createMigrationTable(): bool { return $this->getDependencyFactory()->getTrackingTableManipulator()->createMigrationTable(); } - public function getDateTime(string $version) : string + public function getDateTime(string $version): string { $datetime = str_replace('Version', '', $version); $datetime = DateTimeImmutable::createFromFormat(self::VERSION_FORMAT, $datetime); @@ -343,7 +346,7 @@ public function getDateTime(string $version) : string return $datetime->format('Y-m-d H:i:s'); } - public function generateVersionNumber(?DateTimeInterface $now = null) : string + public function generateVersionNumber(?DateTimeInterface $now = null): string { $now = $now ?: $this->createDateTime(); @@ -357,7 +360,7 @@ public function generateVersionNumber(?DateTimeInterface $now = null) : string * lagging significantly behind that means the migrations system may see * unexecuted migrations that were actually executed earlier. */ - public function connect() : bool + public function connect(): bool { if ($this->connection instanceof PrimaryReadReplicaConnection) { return $this->connection->ensureConnectedToPrimary(); @@ -371,7 +374,7 @@ public function connect() : bool return $this->connection->connect(); } - public function dispatchMigrationEvent(string $eventName, string $direction, bool $dryRun) : void + public function dispatchMigrationEvent(string $eventName, string $direction, bool $dryRun): void { $this->getDependencyFactory()->getEventDispatcher()->dispatchMigrationEvent( $eventName, @@ -385,7 +388,7 @@ public function dispatchVersionEvent( string $eventName, string $direction, bool $dryRun - ) : void { + ): void { $this->getDependencyFactory()->getEventDispatcher()->dispatchVersionEvent( $version, $eventName, @@ -394,7 +397,7 @@ public function dispatchVersionEvent( ); } - public function dispatchEvent(string $eventName, ?EventArgs $args = null) : void + public function dispatchEvent(string $eventName, ?EventArgs $args = null): void { $this->getDependencyFactory()->getEventDispatcher()->dispatchEvent( $eventName, @@ -402,40 +405,40 @@ public function dispatchEvent(string $eventName, ?EventArgs $args = null) : void ); } - public function getNumberOfExecutedMigrations() : int + public function getNumberOfExecutedMigrations(): int { return $this->getDependencyFactory()->getMigrationRepository()->getNumberOfExecutedMigrations(); } - public function getNumberOfAvailableMigrations() : int + public function getNumberOfAvailableMigrations(): int { return $this->getDependencyFactory()->getMigrationRepository()->getNumberOfAvailableMigrations(); } - public function getLatestVersion() : string + public function getLatestVersion(): string { return $this->getDependencyFactory()->getMigrationRepository()->getLatestVersion(); } /** @return string[] */ - public function getMigratedVersions() : array + public function getMigratedVersions(): array { return $this->getDependencyFactory()->getMigrationRepository()->getMigratedVersions(); } /** @return string[] */ - public function getAvailableVersions() : array + public function getAvailableVersions(): array { return $this->getDependencyFactory()->getMigrationRepository()->getAvailableVersions(); } - public function getCurrentVersion() : string + public function getCurrentVersion(): string { return $this->getDependencyFactory()->getMigrationRepository()->getCurrentVersion(); } /** @return Version[] */ - public function registerMigrationsFromDirectory(string $path) : array + public function registerMigrationsFromDirectory(string $path): array { $this->validate(); @@ -443,7 +446,7 @@ public function registerMigrationsFromDirectory(string $path) : array } /** @throws MigrationException */ - public function registerMigration(string $version, string $class) : Version + public function registerMigration(string $version, string $class): Version { return $this->getDependencyFactory()->getMigrationRepository()->registerMigration($version, $class); } @@ -453,7 +456,7 @@ public function registerMigration(string $version, string $class) : Version * * @return Version[] */ - public function registerMigrations(array $migrations) : array + public function registerMigrations(array $migrations): array { return $this->getDependencyFactory()->getMigrationRepository()->registerMigrations($migrations); } @@ -461,53 +464,53 @@ public function registerMigrations(array $migrations) : array /** * @return Version[] */ - public function getMigrations() : array + public function getMigrations(): array { return $this->getDependencyFactory()->getMigrationRepository()->getMigrations(); } - public function getVersion(string $version) : Version + public function getVersion(string $version): Version { return $this->getDependencyFactory()->getMigrationRepository()->getVersion($version); } - public function hasVersion(string $version) : bool + public function hasVersion(string $version): bool { return $this->getDependencyFactory()->getMigrationRepository()->hasVersion($version); } /** @return Version[] */ - public function getMigrationsToExecute(string $direction, string $to) : array + public function getMigrationsToExecute(string $direction, string $to): array { return $this->getDependencyFactory()->getMigrationPlanCalculator()->getMigrationsToExecute($direction, $to); } - public function getPrevVersion() : ?string + public function getPrevVersion(): ?string { return $this->getDependencyFactory()->getMigrationRepository()->getPrevVersion(); } - public function getNextVersion() : ?string + public function getNextVersion(): ?string { return $this->getDependencyFactory()->getMigrationRepository()->getNextVersion(); } - public function getRelativeVersion(string $version, int $delta) : ?string + public function getRelativeVersion(string $version, int $delta): ?string { return $this->getDependencyFactory()->getMigrationRepository()->getRelativeVersion($version, $delta); } - public function getDeltaVersion(string $delta) : ?string + public function getDeltaVersion(string $delta): ?string { return $this->getDependencyFactory()->getMigrationRepository()->getDeltaVersion($delta); } - public function setOutputWriter(OutputWriter $outputWriter) : void + public function setOutputWriter(OutputWriter $outputWriter): void { $this->outputWriter = $outputWriter; } - public function getOutputWriter() : OutputWriter + public function getOutputWriter(): OutputWriter { if ($this->outputWriter === null) { $this->outputWriter = $this->getDependencyFactory()->getOutputWriter(); @@ -516,7 +519,7 @@ public function getOutputWriter() : OutputWriter return $this->outputWriter; } - public function getQueryWriter() : QueryWriter + public function getQueryWriter(): QueryWriter { if ($this->queryWriter === null) { $this->queryWriter = $this->getDependencyFactory()->getQueryWriter(); @@ -525,7 +528,7 @@ public function getQueryWriter() : QueryWriter return $this->queryWriter; } - public function getDependencyFactory() : DependencyFactory + public function getDependencyFactory(): DependencyFactory { if ($this->dependencyFactory === null) { $this->dependencyFactory = new DependencyFactory($this); @@ -537,7 +540,7 @@ public function getDependencyFactory() : DependencyFactory /** * @throws MigrationException */ - private function ensureOrganizeMigrationsIsCompatibleWithFinder() : void + private function ensureOrganizeMigrationsIsCompatibleWithFinder(): void { if (! ($this->getMigrationsFinder() instanceof MigrationDeepFinder)) { throw ParameterIncompatibleWithFinder::new( @@ -547,7 +550,7 @@ private function ensureOrganizeMigrationsIsCompatibleWithFinder() : void } } - private function createDateTime() : DateTimeImmutable + private function createDateTime(): DateTimeImmutable { return new DateTimeImmutable('now', new DateTimeZone('UTC')); } diff --git a/lib/Doctrine/Migrations/Configuration/Connection/ConnectionLoaderInterface.php b/lib/Doctrine/Migrations/Configuration/Connection/ConnectionLoaderInterface.php index 43ce1db41d..396e18adfe 100644 --- a/lib/Doctrine/Migrations/Configuration/Connection/ConnectionLoaderInterface.php +++ b/lib/Doctrine/Migrations/Configuration/Connection/ConnectionLoaderInterface.php @@ -18,5 +18,5 @@ interface ConnectionLoaderInterface * Read the input and return a Connection, returns null if the config * is not supported. */ - public function chosen() : ?Connection; + public function chosen(): ?Connection; } diff --git a/lib/Doctrine/Migrations/Configuration/Connection/Loader/ArrayConnectionConfigurationLoader.php b/lib/Doctrine/Migrations/Configuration/Connection/Loader/ArrayConnectionConfigurationLoader.php index d380ab8e0e..00b70c8d90 100644 --- a/lib/Doctrine/Migrations/Configuration/Connection/Loader/ArrayConnectionConfigurationLoader.php +++ b/lib/Doctrine/Migrations/Configuration/Connection/Loader/ArrayConnectionConfigurationLoader.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\DriverManager; use Doctrine\Migrations\Configuration\Connection\ConnectionLoaderInterface; use Doctrine\Migrations\Configuration\Connection\Loader\Exception\InvalidConfiguration; + use function file_exists; use function is_array; @@ -33,7 +34,7 @@ public function __construct(?string $filename) * * @throws InvalidConfiguration */ - public function chosen() : ?Connection + public function chosen(): ?Connection { if ($this->filename === null) { return null; diff --git a/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionConfigurationChainLoader.php b/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionConfigurationChainLoader.php index cd36ea8560..24fac43a30 100644 --- a/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionConfigurationChainLoader.php +++ b/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionConfigurationChainLoader.php @@ -33,7 +33,7 @@ public function __construct(array $loaders) * * @throws InvalidConfiguration */ - public function chosen() : ?Connection + public function chosen(): ?Connection { foreach ($this->loaders as $loader) { $confObj = $loader->chosen(); diff --git a/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionConfigurationLoader.php b/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionConfigurationLoader.php index b5f601e878..f7907770d3 100644 --- a/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionConfigurationLoader.php +++ b/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionConfigurationLoader.php @@ -28,7 +28,7 @@ public function __construct(?Configuration $configuration = null) * Read the input and return a Configuration, returns null if the config * is not supported. */ - public function chosen() : ?Connection + public function chosen(): ?Connection { if ($this->configuration !== null) { return $this->configuration->getConnection(); diff --git a/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionHelperLoader.php b/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionHelperLoader.php index f4567da201..6eb38b1067 100644 --- a/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionHelperLoader.php +++ b/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionHelperLoader.php @@ -37,7 +37,7 @@ public function __construct(?HelperSet $helperSet = null, string $helperName) * Read the input and return a Configuration, returns null if the config * is not supported. */ - public function chosen() : ?Connection + public function chosen(): ?Connection { if ($this->helperSet->has($this->helperName)) { $connectionHelper = $this->helperSet->get($this->helperName); diff --git a/lib/Doctrine/Migrations/Configuration/Connection/Loader/Exception/InvalidConfiguration.php b/lib/Doctrine/Migrations/Configuration/Connection/Loader/Exception/InvalidConfiguration.php index 3b14f939a8..c9b005a13e 100644 --- a/lib/Doctrine/Migrations/Configuration/Connection/Loader/Exception/InvalidConfiguration.php +++ b/lib/Doctrine/Migrations/Configuration/Connection/Loader/Exception/InvalidConfiguration.php @@ -8,7 +8,7 @@ final class InvalidConfiguration extends InvalidArgumentException implements LoaderException { - public static function invalidArrayConfiguration() : self + public static function invalidArrayConfiguration(): self { return new self('The connection file has to return an array with database configuration parameters.'); } diff --git a/lib/Doctrine/Migrations/Configuration/Exception/FileAlreadyLoaded.php b/lib/Doctrine/Migrations/Configuration/Exception/FileAlreadyLoaded.php index 35ceb70a22..d7a88ddd68 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/FileAlreadyLoaded.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/FileAlreadyLoaded.php @@ -8,7 +8,7 @@ final class FileAlreadyLoaded extends LogicException implements ConfigurationException { - public static function new() : self + public static function new(): self { return new self('Migrations configuration file already loaded', 8); } diff --git a/lib/Doctrine/Migrations/Configuration/Exception/FileNotFound.php b/lib/Doctrine/Migrations/Configuration/Exception/FileNotFound.php index 1577f1051c..6c612a625b 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/FileNotFound.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/FileNotFound.php @@ -8,7 +8,7 @@ final class FileNotFound extends InvalidArgumentException implements ConfigurationException { - public static function new() : self + public static function new(): self { return new self('Given config file does not exist'); } diff --git a/lib/Doctrine/Migrations/Configuration/Exception/InvalidConfigurationKey.php b/lib/Doctrine/Migrations/Configuration/Exception/InvalidConfigurationKey.php index a0e48bc5fb..f461738a63 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/InvalidConfigurationKey.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/InvalidConfigurationKey.php @@ -5,11 +5,12 @@ namespace Doctrine\Migrations\Configuration\Exception; use LogicException; + use function sprintf; final class InvalidConfigurationKey extends LogicException implements ConfigurationException { - public static function new(string $key) : self + public static function new(string $key): self { return new self(sprintf('Migrations configuration key "%s" does not exist.', $key), 10); } diff --git a/lib/Doctrine/Migrations/Configuration/Exception/JsonNotValid.php b/lib/Doctrine/Migrations/Configuration/Exception/JsonNotValid.php index b670ba31df..0d7d4e5695 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/JsonNotValid.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/JsonNotValid.php @@ -8,7 +8,7 @@ final class JsonNotValid extends LogicException implements ConfigurationException { - public static function new() : self + public static function new(): self { return new self('Configuration is not valid JSON.', 10); } diff --git a/lib/Doctrine/Migrations/Configuration/Exception/MigrationsNamespaceRequired.php b/lib/Doctrine/Migrations/Configuration/Exception/MigrationsNamespaceRequired.php index 3df3b3ace7..706d0b844d 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/MigrationsNamespaceRequired.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/MigrationsNamespaceRequired.php @@ -8,7 +8,7 @@ final class MigrationsNamespaceRequired extends LogicException implements ConfigurationException { - public static function new() : self + public static function new(): self { return new self( 'Migrations namespace must be configured in order to use Doctrine migrations.', diff --git a/lib/Doctrine/Migrations/Configuration/Exception/ParameterIncompatibleWithFinder.php b/lib/Doctrine/Migrations/Configuration/Exception/ParameterIncompatibleWithFinder.php index 06abaee20f..81ef07be02 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/ParameterIncompatibleWithFinder.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/ParameterIncompatibleWithFinder.php @@ -6,12 +6,13 @@ use Doctrine\Migrations\Finder\MigrationFinder; use LogicException; + use function get_class; use function sprintf; final class ParameterIncompatibleWithFinder extends LogicException implements ConfigurationException { - public static function new(string $configurationParameterName, MigrationFinder $finder) : self + public static function new(string $configurationParameterName, MigrationFinder $finder): self { return new self( sprintf( diff --git a/lib/Doctrine/Migrations/Configuration/Exception/UnknownConfigurationValue.php b/lib/Doctrine/Migrations/Configuration/Exception/UnknownConfigurationValue.php index ccdd6cddf2..3479f67c95 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/UnknownConfigurationValue.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/UnknownConfigurationValue.php @@ -5,6 +5,7 @@ namespace Doctrine\Migrations\Configuration\Exception; use LogicException; + use function sprintf; use function var_export; @@ -13,7 +14,7 @@ final class UnknownConfigurationValue extends LogicException implements Configur /** * @param mixed $value */ - public static function new(string $key, $value) : self + public static function new(string $key, $value): self { return new self( sprintf( diff --git a/lib/Doctrine/Migrations/Configuration/Exception/XmlNotValid.php b/lib/Doctrine/Migrations/Configuration/Exception/XmlNotValid.php index 566577ea53..cc67ded0b2 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/XmlNotValid.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/XmlNotValid.php @@ -8,12 +8,12 @@ final class XmlNotValid extends LogicException implements ConfigurationException { - public static function malformed() : self + public static function malformed(): self { return new self('The XML configuration is malformed.'); } - public static function failedValidation() : self + public static function failedValidation(): self { return new self('XML configuration did not pass the validation test.', 10); } diff --git a/lib/Doctrine/Migrations/Configuration/Exception/YamlNotAvailable.php b/lib/Doctrine/Migrations/Configuration/Exception/YamlNotAvailable.php index 6fc631c589..62a2c2f57a 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/YamlNotAvailable.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/YamlNotAvailable.php @@ -8,7 +8,7 @@ final class YamlNotAvailable extends LogicException implements ConfigurationException { - public static function new() : self + public static function new(): self { return new self( 'Unable to load yaml configuration files, please run ' diff --git a/lib/Doctrine/Migrations/Configuration/Exception/YamlNotValid.php b/lib/Doctrine/Migrations/Configuration/Exception/YamlNotValid.php index 3343e47676..67483736af 100644 --- a/lib/Doctrine/Migrations/Configuration/Exception/YamlNotValid.php +++ b/lib/Doctrine/Migrations/Configuration/Exception/YamlNotValid.php @@ -8,12 +8,12 @@ final class YamlNotValid extends LogicException implements ConfigurationException { - public static function malformed() : self + public static function malformed(): self { return new self('The YAML configuration is malformed.'); } - public static function invalid() : self + public static function invalid(): self { return new self('Configuration is not valid YAML.', 10); } diff --git a/lib/Doctrine/Migrations/Configuration/JsonConfiguration.php b/lib/Doctrine/Migrations/Configuration/JsonConfiguration.php index a1afbc38bf..18334a4c7f 100644 --- a/lib/Doctrine/Migrations/Configuration/JsonConfiguration.php +++ b/lib/Doctrine/Migrations/Configuration/JsonConfiguration.php @@ -5,12 +5,14 @@ namespace Doctrine\Migrations\Configuration; use Doctrine\Migrations\Configuration\Exception\JsonNotValid; -use const JSON_ERROR_NONE; + use function assert; use function file_get_contents; use function json_decode; use function json_last_error; +use const JSON_ERROR_NONE; + /** * The YamlConfiguration class is responsible for loading migration configuration information from a JSON file. * @@ -18,8 +20,7 @@ */ class JsonConfiguration extends AbstractFileConfiguration { - /** @inheritdoc */ - protected function doLoad(string $file) : void + protected function doLoad(string $file): void { $contents = file_get_contents($file); diff --git a/lib/Doctrine/Migrations/Configuration/XmlConfiguration.php b/lib/Doctrine/Migrations/Configuration/XmlConfiguration.php index 0c074828db..3631ce439e 100644 --- a/lib/Doctrine/Migrations/Configuration/XmlConfiguration.php +++ b/lib/Doctrine/Migrations/Configuration/XmlConfiguration.php @@ -8,14 +8,16 @@ use Doctrine\Migrations\Tools\BooleanStringFormatter; use DOMDocument; use SimpleXMLElement; -use const DIRECTORY_SEPARATOR; -use const LIBXML_NOCDATA; + use function assert; use function file_get_contents; use function libxml_clear_errors; use function libxml_use_internal_errors; use function simplexml_load_string; +use const DIRECTORY_SEPARATOR; +use const LIBXML_NOCDATA; + /** * The XmlConfiguration class is responsible for loading migration configuration information from a XML file. * @@ -23,8 +25,7 @@ */ class XmlConfiguration extends AbstractFileConfiguration { - /** @inheritdoc */ - protected function doLoad(string $file) : void + protected function doLoad(string $file): void { libxml_use_internal_errors(true); diff --git a/lib/Doctrine/Migrations/Configuration/YamlConfiguration.php b/lib/Doctrine/Migrations/Configuration/YamlConfiguration.php index 17c86c7bee..665111b6d5 100644 --- a/lib/Doctrine/Migrations/Configuration/YamlConfiguration.php +++ b/lib/Doctrine/Migrations/Configuration/YamlConfiguration.php @@ -8,6 +8,7 @@ use Doctrine\Migrations\Configuration\Exception\YamlNotValid; use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Yaml; + use function assert; use function class_exists; use function file_get_contents; @@ -20,10 +21,7 @@ */ class YamlConfiguration extends AbstractFileConfiguration { - /** - * @inheritdoc - */ - protected function doLoad(string $file) : void + protected function doLoad(string $file): void { if (! class_exists(Yaml::class)) { throw YamlNotAvailable::new(); diff --git a/lib/Doctrine/Migrations/DependencyFactory.php b/lib/Doctrine/Migrations/DependencyFactory.php index 87090c350c..443483d7e6 100644 --- a/lib/Doctrine/Migrations/DependencyFactory.php +++ b/lib/Doctrine/Migrations/DependencyFactory.php @@ -41,9 +41,9 @@ public function __construct(Configuration $configuration) $this->configuration = $configuration; } - public function getEventDispatcher() : EventDispatcher + public function getEventDispatcher(): EventDispatcher { - return $this->getDependency(EventDispatcher::class, function () : EventDispatcher { + return $this->getDependency(EventDispatcher::class, function (): EventDispatcher { return new EventDispatcher( $this->configuration, $this->getConnection()->getEventManager() @@ -51,9 +51,9 @@ public function getEventDispatcher() : EventDispatcher }); } - public function getSchemaDumper() : SchemaDumper + public function getSchemaDumper(): SchemaDumper { - return $this->getDependency(SchemaDumper::class, function () : SchemaDumper { + return $this->getDependency(SchemaDumper::class, function (): SchemaDumper { return new SchemaDumper( $this->getConnection()->getDatabasePlatform(), $this->getConnection()->getSchemaManager(), @@ -63,9 +63,9 @@ public function getSchemaDumper() : SchemaDumper }); } - public function getSchemaDiffProvider() : SchemaDiffProviderInterface + public function getSchemaDiffProvider(): SchemaDiffProviderInterface { - return $this->getDependency(SchemaDiffProviderInterface::class, function () : LazySchemaDiffProvider { + return $this->getDependency(SchemaDiffProviderInterface::class, function (): LazySchemaDiffProvider { return LazySchemaDiffProvider::fromDefaultProxyFactoryConfiguration( new SchemaDiffProvider( $this->getConnection()->getSchemaManager(), @@ -75,9 +75,9 @@ public function getSchemaDiffProvider() : SchemaDiffProviderInterface }); } - public function getFileBuilder() : FileBuilder + public function getFileBuilder(): FileBuilder { - return $this->getDependency(FileBuilder::class, function () : FileBuilder { + return $this->getDependency(FileBuilder::class, function (): FileBuilder { return new FileBuilder( $this->getConnection()->getDatabasePlatform(), $this->configuration->getMigrationsTableName(), @@ -87,16 +87,16 @@ public function getFileBuilder() : FileBuilder }); } - public function getParameterFormatter() : ParameterFormatterInterface + public function getParameterFormatter(): ParameterFormatterInterface { - return $this->getDependency(ParameterFormatter::class, function () : ParameterFormatter { + return $this->getDependency(ParameterFormatter::class, function (): ParameterFormatter { return new ParameterFormatter($this->getConnection()); }); } - public function getMigrationRepository() : MigrationRepository + public function getMigrationRepository(): MigrationRepository { - return $this->getDependency(MigrationRepository::class, function () : MigrationRepository { + return $this->getDependency(MigrationRepository::class, function (): MigrationRepository { return new MigrationRepository( $this->configuration, $this->getConnection(), @@ -106,9 +106,9 @@ public function getMigrationRepository() : MigrationRepository }); } - public function getTrackingTableManipulator() : TableManipulator + public function getTrackingTableManipulator(): TableManipulator { - return $this->getDependency(TableManipulator::class, function () : TableManipulator { + return $this->getDependency(TableManipulator::class, function (): TableManipulator { return new TableManipulator( $this->configuration, $this->getConnection()->getSchemaManager(), @@ -119,9 +119,9 @@ public function getTrackingTableManipulator() : TableManipulator }); } - public function getTrackingTableDefinition() : TableDefinition + public function getTrackingTableDefinition(): TableDefinition { - return $this->getDependency(TableDefinition::class, function () : TableDefinition { + return $this->getDependency(TableDefinition::class, function (): TableDefinition { return new TableDefinition( $this->getConnection()->getSchemaManager(), $this->configuration->getMigrationsTableName(), @@ -132,9 +132,9 @@ public function getTrackingTableDefinition() : TableDefinition }); } - public function getTrackingTableStatus() : TableStatus + public function getTrackingTableStatus(): TableStatus { - return $this->getDependency(TableStatus::class, function () : TableStatus { + return $this->getDependency(TableStatus::class, function (): TableStatus { return new TableStatus( $this->getConnection()->getSchemaManager(), $this->getTrackingTableDefinition() @@ -142,9 +142,9 @@ public function getTrackingTableStatus() : TableStatus }); } - public function getTrackingTableUpdater() : TableUpdater + public function getTrackingTableUpdater(): TableUpdater { - return $this->getDependency(TableUpdater::class, function () : TableUpdater { + return $this->getDependency(TableUpdater::class, function (): TableUpdater { return new TableUpdater( $this->getConnection(), $this->getConnection()->getSchemaManager(), @@ -154,9 +154,9 @@ public function getTrackingTableUpdater() : TableUpdater }); } - public function getVersionExecutor() : Executor + public function getVersionExecutor(): Executor { - return $this->getDependency(Executor::class, function () : Executor { + return $this->getDependency(Executor::class, function (): Executor { return new Executor( $this->configuration, $this->getConnection(), @@ -168,9 +168,9 @@ public function getVersionExecutor() : Executor }); } - public function getQueryWriter() : FileQueryWriter + public function getQueryWriter(): FileQueryWriter { - return $this->getDependency(FileQueryWriter::class, function () : FileQueryWriter { + return $this->getDependency(FileQueryWriter::class, function (): FileQueryWriter { return new FileQueryWriter( $this->getOutputWriter(), $this->getFileBuilder() @@ -178,46 +178,46 @@ public function getQueryWriter() : FileQueryWriter }); } - public function getOutputWriter() : OutputWriter + public function getOutputWriter(): OutputWriter { - return $this->getDependency(OutputWriter::class, static function () : OutputWriter { + return $this->getDependency(OutputWriter::class, static function (): OutputWriter { return new OutputWriter(); }); } - public function getVersionAliasResolver() : AliasResolver + public function getVersionAliasResolver(): AliasResolver { - return $this->getDependency(AliasResolver::class, function () : AliasResolver { + return $this->getDependency(AliasResolver::class, function (): AliasResolver { return new AliasResolver( $this->getMigrationRepository() ); }); } - public function getMigrationPlanCalculator() : MigrationPlanCalculator + public function getMigrationPlanCalculator(): MigrationPlanCalculator { - return $this->getDependency(MigrationPlanCalculator::class, function () : MigrationPlanCalculator { + return $this->getDependency(MigrationPlanCalculator::class, function (): MigrationPlanCalculator { return new MigrationPlanCalculator($this->getMigrationRepository()); }); } - public function getRecursiveRegexFinder() : RecursiveRegexFinder + public function getRecursiveRegexFinder(): RecursiveRegexFinder { - return $this->getDependency(RecursiveRegexFinder::class, static function () : RecursiveRegexFinder { + return $this->getDependency(RecursiveRegexFinder::class, static function (): RecursiveRegexFinder { return new RecursiveRegexFinder(); }); } - public function getMigrationGenerator() : Generator + public function getMigrationGenerator(): Generator { - return $this->getDependency(Generator::class, function () : Generator { + return $this->getDependency(Generator::class, function (): Generator { return new Generator($this->configuration); }); } - public function getMigrationSqlGenerator() : SqlGenerator + public function getMigrationSqlGenerator(): SqlGenerator { - return $this->getDependency(SqlGenerator::class, function () : SqlGenerator { + return $this->getDependency(SqlGenerator::class, function (): SqlGenerator { return new SqlGenerator( $this->configuration, $this->getConnection()->getDatabasePlatform() @@ -225,9 +225,9 @@ public function getMigrationSqlGenerator() : SqlGenerator }); } - public function getMigrationStatusInfosHelper() : MigrationStatusInfosHelper + public function getMigrationStatusInfosHelper(): MigrationStatusInfosHelper { - return $this->getDependency(MigrationStatusInfosHelper::class, function () : MigrationStatusInfosHelper { + return $this->getDependency(MigrationStatusInfosHelper::class, function (): MigrationStatusInfosHelper { return new MigrationStatusInfosHelper( $this->configuration, $this->getMigrationRepository() @@ -235,9 +235,9 @@ public function getMigrationStatusInfosHelper() : MigrationStatusInfosHelper }); } - public function getMigrator() : Migrator + public function getMigrator(): Migrator { - return $this->getDependency(Migrator::class, function () : Migrator { + return $this->getDependency(Migrator::class, function (): Migrator { return new Migrator( $this->configuration, $this->getMigrationRepository(), @@ -247,18 +247,18 @@ public function getMigrator() : Migrator }); } - public function getStopwatch() : Stopwatch + public function getStopwatch(): Stopwatch { - return $this->getDependency(Stopwatch::class, static function () : Stopwatch { + return $this->getDependency(Stopwatch::class, static function (): Stopwatch { $symfonyStopwatch = new SymfonyStopwatch(true); return new Stopwatch($symfonyStopwatch); }); } - public function getRollup() : Rollup + public function getRollup(): Rollup { - return $this->getDependency(Rollup::class, function () : Rollup { + return $this->getDependency(Rollup::class, function (): Rollup { return new Rollup( $this->configuration, $this->getConnection(), @@ -279,7 +279,7 @@ private function getDependency(string $className, callable $callback) return $this->dependencies[$className]; } - private function getConnection() : Connection + private function getConnection(): Connection { return $this->configuration->getConnection(); } diff --git a/lib/Doctrine/Migrations/Event/Listeners/AutoCommitListener.php b/lib/Doctrine/Migrations/Event/Listeners/AutoCommitListener.php index 8d723c6641..cfa92b56e2 100644 --- a/lib/Doctrine/Migrations/Event/Listeners/AutoCommitListener.php +++ b/lib/Doctrine/Migrations/Event/Listeners/AutoCommitListener.php @@ -16,7 +16,7 @@ */ final class AutoCommitListener implements EventSubscriber { - public function onMigrationsMigrated(MigrationsEventArgs $args) : void + public function onMigrationsMigrated(MigrationsEventArgs $args): void { $conn = $args->getConnection(); diff --git a/lib/Doctrine/Migrations/Event/MigrationsEventArgs.php b/lib/Doctrine/Migrations/Event/MigrationsEventArgs.php index 6778a815ba..833f231a18 100644 --- a/lib/Doctrine/Migrations/Event/MigrationsEventArgs.php +++ b/lib/Doctrine/Migrations/Event/MigrationsEventArgs.php @@ -29,22 +29,22 @@ public function __construct(Configuration $config, string $direction, bool $dryR $this->dryRun = $dryRun; } - public function getConfiguration() : Configuration + public function getConfiguration(): Configuration { return $this->config; } - public function getConnection() : Connection + public function getConnection(): Connection { return $this->config->getConnection(); } - public function getDirection() : string + public function getDirection(): string { return $this->direction; } - public function isDryRun() : bool + public function isDryRun(): bool { return $this->dryRun; } diff --git a/lib/Doctrine/Migrations/Event/MigrationsVersionEventArgs.php b/lib/Doctrine/Migrations/Event/MigrationsVersionEventArgs.php index 83f11f2d83..17f5489d86 100644 --- a/lib/Doctrine/Migrations/Event/MigrationsVersionEventArgs.php +++ b/lib/Doctrine/Migrations/Event/MigrationsVersionEventArgs.php @@ -26,7 +26,7 @@ public function __construct( $this->version = $version; } - public function getVersion() : Version + public function getVersion(): Version { return $this->version; } diff --git a/lib/Doctrine/Migrations/EventDispatcher.php b/lib/Doctrine/Migrations/EventDispatcher.php index d8e562555f..454e33443f 100644 --- a/lib/Doctrine/Migrations/EventDispatcher.php +++ b/lib/Doctrine/Migrations/EventDispatcher.php @@ -30,7 +30,7 @@ public function __construct(Configuration $configuration, EventManager $eventMan $this->eventManager = $eventManager; } - public function dispatchMigrationEvent(string $eventName, string $direction, bool $dryRun) : void + public function dispatchMigrationEvent(string $eventName, string $direction, bool $dryRun): void { $event = $this->createMigrationEventArgs($direction, $dryRun); @@ -42,7 +42,7 @@ public function dispatchVersionEvent( string $eventName, string $direction, bool $dryRun - ) : void { + ): void { $event = $this->createMigrationsVersionEventArgs( $version, $direction, @@ -52,12 +52,12 @@ public function dispatchVersionEvent( $this->dispatchEvent($eventName, $event); } - public function dispatchEvent(string $eventName, ?EventArgs $args = null) : void + public function dispatchEvent(string $eventName, ?EventArgs $args = null): void { $this->eventManager->dispatchEvent($eventName, $args); } - private function createMigrationEventArgs(string $direction, bool $dryRun) : MigrationsEventArgs + private function createMigrationEventArgs(string $direction, bool $dryRun): MigrationsEventArgs { return new MigrationsEventArgs($this->configuration, $direction, $dryRun); } @@ -66,7 +66,7 @@ private function createMigrationsVersionEventArgs( Version $version, string $direction, bool $dryRun - ) : MigrationsVersionEventArgs { + ): MigrationsVersionEventArgs { return new MigrationsVersionEventArgs( $version, $this->configuration, diff --git a/lib/Doctrine/Migrations/Exception/AlreadyAtVersion.php b/lib/Doctrine/Migrations/Exception/AlreadyAtVersion.php index 48810e7a6e..a0c22b1db5 100644 --- a/lib/Doctrine/Migrations/Exception/AlreadyAtVersion.php +++ b/lib/Doctrine/Migrations/Exception/AlreadyAtVersion.php @@ -5,11 +5,12 @@ namespace Doctrine\Migrations\Exception; use RuntimeException; + use function sprintf; final class AlreadyAtVersion extends RuntimeException implements MigrationException { - public static function new(string $version) : self + public static function new(string $version): self { return new self( sprintf( diff --git a/lib/Doctrine/Migrations/Exception/DuplicateMigrationVersion.php b/lib/Doctrine/Migrations/Exception/DuplicateMigrationVersion.php index 4d22e93803..7a94990155 100644 --- a/lib/Doctrine/Migrations/Exception/DuplicateMigrationVersion.php +++ b/lib/Doctrine/Migrations/Exception/DuplicateMigrationVersion.php @@ -5,11 +5,12 @@ namespace Doctrine\Migrations\Exception; use RuntimeException; + use function sprintf; final class DuplicateMigrationVersion extends RuntimeException implements MigrationException { - public static function new(string $version, string $class) : self + public static function new(string $version, string $class): self { return new self( sprintf( diff --git a/lib/Doctrine/Migrations/Exception/MigrationClassNotFound.php b/lib/Doctrine/Migrations/Exception/MigrationClassNotFound.php index fe392068fe..4f2c078052 100644 --- a/lib/Doctrine/Migrations/Exception/MigrationClassNotFound.php +++ b/lib/Doctrine/Migrations/Exception/MigrationClassNotFound.php @@ -5,11 +5,12 @@ namespace Doctrine\Migrations\Exception; use RuntimeException; + use function sprintf; final class MigrationClassNotFound extends RuntimeException implements MigrationException { - public static function new(string $migrationClass, ?string $migrationNamespace) : self + public static function new(string $migrationClass, ?string $migrationNamespace): self { return new self( sprintf( diff --git a/lib/Doctrine/Migrations/Exception/MigrationNotConvertibleToSql.php b/lib/Doctrine/Migrations/Exception/MigrationNotConvertibleToSql.php index b8be43db7b..08e16405c1 100644 --- a/lib/Doctrine/Migrations/Exception/MigrationNotConvertibleToSql.php +++ b/lib/Doctrine/Migrations/Exception/MigrationNotConvertibleToSql.php @@ -5,11 +5,12 @@ namespace Doctrine\Migrations\Exception; use RuntimeException; + use function sprintf; final class MigrationNotConvertibleToSql extends RuntimeException implements MigrationException { - public static function new(string $migrationClass) : self + public static function new(string $migrationClass): self { return new self( sprintf( diff --git a/lib/Doctrine/Migrations/Exception/MigrationsDirectoryRequired.php b/lib/Doctrine/Migrations/Exception/MigrationsDirectoryRequired.php index c06ca407eb..a6eaf77d5d 100644 --- a/lib/Doctrine/Migrations/Exception/MigrationsDirectoryRequired.php +++ b/lib/Doctrine/Migrations/Exception/MigrationsDirectoryRequired.php @@ -8,7 +8,7 @@ final class MigrationsDirectoryRequired extends RuntimeException implements MigrationException { - public static function new() : self + public static function new(): self { return new self( 'Migrations directory must be configured in order to use Doctrine migrations.', diff --git a/lib/Doctrine/Migrations/Exception/NoMigrationsToExecute.php b/lib/Doctrine/Migrations/Exception/NoMigrationsToExecute.php index 662e6f266d..4d8ecf8d67 100644 --- a/lib/Doctrine/Migrations/Exception/NoMigrationsToExecute.php +++ b/lib/Doctrine/Migrations/Exception/NoMigrationsToExecute.php @@ -8,7 +8,7 @@ final class NoMigrationsToExecute extends RuntimeException implements MigrationException { - public static function new() : self + public static function new(): self { return new self( 'Could not find any migrations to execute.', diff --git a/lib/Doctrine/Migrations/Exception/NoTablesFound.php b/lib/Doctrine/Migrations/Exception/NoTablesFound.php index 0a46a579de..1dd01e9bf7 100644 --- a/lib/Doctrine/Migrations/Exception/NoTablesFound.php +++ b/lib/Doctrine/Migrations/Exception/NoTablesFound.php @@ -8,7 +8,7 @@ final class NoTablesFound extends RuntimeException implements MigrationException { - public static function new() : self + public static function new(): self { return new self('Your database schema does not contain any tables.'); } diff --git a/lib/Doctrine/Migrations/Exception/RollupFailed.php b/lib/Doctrine/Migrations/Exception/RollupFailed.php index 470dbb05b9..5c180c7afe 100644 --- a/lib/Doctrine/Migrations/Exception/RollupFailed.php +++ b/lib/Doctrine/Migrations/Exception/RollupFailed.php @@ -8,12 +8,12 @@ final class RollupFailed extends RuntimeException implements MigrationException { - public static function noMigrationsFound() : self + public static function noMigrationsFound(): self { return new self('No migrations found.'); } - public static function tooManyMigrations() : self + public static function tooManyMigrations(): self { return new self('Too many migrations.'); } diff --git a/lib/Doctrine/Migrations/Exception/UnknownMigrationVersion.php b/lib/Doctrine/Migrations/Exception/UnknownMigrationVersion.php index b3a129b94d..c8a5ccbdd0 100644 --- a/lib/Doctrine/Migrations/Exception/UnknownMigrationVersion.php +++ b/lib/Doctrine/Migrations/Exception/UnknownMigrationVersion.php @@ -5,11 +5,12 @@ namespace Doctrine\Migrations\Exception; use RuntimeException; + use function sprintf; final class UnknownMigrationVersion extends RuntimeException implements MigrationException { - public static function new(string $version) : self + public static function new(string $version): self { return new self( sprintf( diff --git a/lib/Doctrine/Migrations/FileQueryWriter.php b/lib/Doctrine/Migrations/FileQueryWriter.php index 8a2b47205e..02f7878d3c 100644 --- a/lib/Doctrine/Migrations/FileQueryWriter.php +++ b/lib/Doctrine/Migrations/FileQueryWriter.php @@ -7,6 +7,7 @@ use DateTimeImmutable; use DateTimeInterface; use Doctrine\Migrations\Generator\FileBuilder; + use function file_put_contents; use function is_dir; use function sprintf; @@ -40,7 +41,7 @@ public function write( string $direction, array $queriesByVersion, ?DateTimeInterface $now = null - ) : bool { + ): bool { $now = $now ?? new DateTimeImmutable(); $string = $this->migrationFileBuilder @@ -57,7 +58,7 @@ public function write( return file_put_contents($path, $string) !== false; } - private function buildMigrationFilePath(string $path, DateTimeInterface $now) : string + private function buildMigrationFilePath(string $path, DateTimeInterface $now): string { if (is_dir($path)) { $path = realpath($path); diff --git a/lib/Doctrine/Migrations/Finder/Exception/InvalidDirectory.php b/lib/Doctrine/Migrations/Finder/Exception/InvalidDirectory.php index 510a864718..bd3b0d71fb 100644 --- a/lib/Doctrine/Migrations/Finder/Exception/InvalidDirectory.php +++ b/lib/Doctrine/Migrations/Finder/Exception/InvalidDirectory.php @@ -5,11 +5,12 @@ namespace Doctrine\Migrations\Finder\Exception; use InvalidArgumentException; + use function sprintf; final class InvalidDirectory extends InvalidArgumentException implements FinderException { - public static function new(string $directory) : self + public static function new(string $directory): self { return new self(sprintf('Cannot load migrations from "%s" because it is not a valid directory', $directory)); } diff --git a/lib/Doctrine/Migrations/Finder/Exception/NameIsReserved.php b/lib/Doctrine/Migrations/Finder/Exception/NameIsReserved.php index c58aeec196..61b657358a 100644 --- a/lib/Doctrine/Migrations/Finder/Exception/NameIsReserved.php +++ b/lib/Doctrine/Migrations/Finder/Exception/NameIsReserved.php @@ -5,12 +5,14 @@ namespace Doctrine\Migrations\Finder\Exception; use InvalidArgumentException; -use const PHP_EOL; + use function sprintf; +use const PHP_EOL; + final class NameIsReserved extends InvalidArgumentException implements FinderException { - public static function new(string $version) : self + public static function new(string $version): self { return new self(sprintf( 'Cannot load a migrations with the name "%s" because it is a number reserved by Doctrine Migrations.' diff --git a/lib/Doctrine/Migrations/Finder/Finder.php b/lib/Doctrine/Migrations/Finder/Finder.php index 1c7b3db02b..b5c29824a9 100644 --- a/lib/Doctrine/Migrations/Finder/Finder.php +++ b/lib/Doctrine/Migrations/Finder/Finder.php @@ -7,7 +7,7 @@ use Doctrine\Migrations\Finder\Exception\InvalidDirectory; use Doctrine\Migrations\Finder\Exception\NameIsReserved; use ReflectionClass; -use const SORT_STRING; + use function assert; use function get_declared_classes; use function in_array; @@ -18,12 +18,14 @@ use function strncmp; use function substr; +use const SORT_STRING; + /** * The Finder class is responsible for for finding migrations on disk at a given path. */ abstract class Finder implements MigrationFinder { - protected static function requireOnce(string $path) : void + protected static function requireOnce(string $path): void { require_once $path; } @@ -31,7 +33,7 @@ protected static function requireOnce(string $path) : void /** * @throws InvalidDirectory */ - protected function getRealPath(string $directory) : string + protected function getRealPath(string $directory): string { $dir = realpath($directory); @@ -49,7 +51,7 @@ protected function getRealPath(string $directory) : string * * @throws NameIsReserved */ - protected function loadMigrations(array $files, ?string $namespace) : array + protected function loadMigrations(array $files, ?string $namespace): array { $includedFiles = []; foreach ($files as $file) { @@ -87,7 +89,7 @@ protected function loadMigrations(array $files, ?string $namespace) : array * * @return ReflectionClass[] the classes in `$files` */ - protected function loadMigrationClasses(array $files, ?string $namespace) : array + protected function loadMigrationClasses(array $files, ?string $namespace): array { $classes = []; foreach (get_declared_classes() as $class) { @@ -107,7 +109,7 @@ protected function loadMigrationClasses(array $files, ?string $namespace) : arra return $classes; } - private function isReflectionClassInNamespace(ReflectionClass $reflectionClass, string $namespace) : bool + private function isReflectionClassInNamespace(ReflectionClass $reflectionClass, string $namespace): bool { return strncmp($reflectionClass->getName(), $namespace . '\\', strlen($namespace) + 1) === 0; } diff --git a/lib/Doctrine/Migrations/Finder/GlobFinder.php b/lib/Doctrine/Migrations/Finder/GlobFinder.php index aa4045e045..c45f21099f 100644 --- a/lib/Doctrine/Migrations/Finder/GlobFinder.php +++ b/lib/Doctrine/Migrations/Finder/GlobFinder.php @@ -15,7 +15,7 @@ final class GlobFinder extends Finder /** * @return string[] */ - public function findMigrations(string $directory, ?string $namespace = null) : array + public function findMigrations(string $directory, ?string $namespace = null): array { $dir = $this->getRealPath($directory); diff --git a/lib/Doctrine/Migrations/Finder/MigrationFinder.php b/lib/Doctrine/Migrations/Finder/MigrationFinder.php index 182f651078..d86216579b 100644 --- a/lib/Doctrine/Migrations/Finder/MigrationFinder.php +++ b/lib/Doctrine/Migrations/Finder/MigrationFinder.php @@ -15,5 +15,5 @@ interface MigrationFinder * * @return string[] */ - public function findMigrations(string $directory, ?string $namespace = null) : array; + public function findMigrations(string $directory, ?string $namespace = null): array; } diff --git a/lib/Doctrine/Migrations/Finder/RecursiveRegexFinder.php b/lib/Doctrine/Migrations/Finder/RecursiveRegexFinder.php index 41a224f8be..7857ae92ae 100644 --- a/lib/Doctrine/Migrations/Finder/RecursiveRegexFinder.php +++ b/lib/Doctrine/Migrations/Finder/RecursiveRegexFinder.php @@ -8,9 +8,11 @@ use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use RegexIterator; -use const DIRECTORY_SEPARATOR; + use function sprintf; +use const DIRECTORY_SEPARATOR; + /** * The RecursiveRegexFinder class recursively searches the given directory for migrations. */ @@ -19,7 +21,7 @@ final class RecursiveRegexFinder extends Finder implements MigrationDeepFinder /** * @return string[] */ - public function findMigrations(string $directory, ?string $namespace = null) : array + public function findMigrations(string $directory, ?string $namespace = null): array { $dir = $this->getRealPath($directory); @@ -29,7 +31,7 @@ public function findMigrations(string $directory, ?string $namespace = null) : a ); } - private function createIterator(string $dir) : RegexIterator + private function createIterator(string $dir): RegexIterator { return new RegexIterator( new RecursiveIteratorIterator( @@ -41,7 +43,7 @@ private function createIterator(string $dir) : RegexIterator ); } - private function getPattern() : string + private function getPattern(): string { return sprintf( '#^.+\\%sVersion[^\\%s]{1,255}\\.php$#i', @@ -53,7 +55,7 @@ private function getPattern() : string /** * @return string[] */ - private function getMatches(RegexIterator $iteratorFilesMatch) : array + private function getMatches(RegexIterator $iteratorFilesMatch): array { $files = []; foreach ($iteratorFilesMatch as $file) { diff --git a/lib/Doctrine/Migrations/Generator/DiffGenerator.php b/lib/Doctrine/Migrations/Generator/DiffGenerator.php index 90fb133511..87b2a8761e 100644 --- a/lib/Doctrine/Migrations/Generator/DiffGenerator.php +++ b/lib/Doctrine/Migrations/Generator/DiffGenerator.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\Generator\Exception\NoChangesDetected; use Doctrine\Migrations\Provider\SchemaProviderInterface; + use function preg_match; use function strpos; use function substr; @@ -72,7 +73,7 @@ public function generate( int $lineLength = 120, bool $checkDbPlatform = true, bool $fromEmptySchema = false - ) : string { + ): string { if ($filterExpression !== null) { $this->dbalConfiguration->setSchemaAssetsFilter( static function ($assetName) use ($filterExpression) { @@ -116,17 +117,17 @@ static function ($assetName) use ($filterExpression) { ); } - private function createEmptySchema() : Schema + private function createEmptySchema(): Schema { return $this->emptySchemaProvider->createSchema(); } - private function createFromSchema() : Schema + private function createFromSchema(): Schema { return $this->schemaManager->createSchema(); } - private function createToSchema() : Schema + private function createToSchema(): Schema { $toSchema = $this->schemaProvider->createSchema(); @@ -153,7 +154,7 @@ private function createToSchema() : Schema * a namespaced name with the form `{namespace}.{tableName}`. This extracts * the table name from that. */ - private function resolveTableName(string $name) : string + private function resolveTableName(string $name): string { $pos = strpos($name, '.'); diff --git a/lib/Doctrine/Migrations/Generator/Exception/InvalidTemplateSpecified.php b/lib/Doctrine/Migrations/Generator/Exception/InvalidTemplateSpecified.php index 1ad53a6c73..0269b9f96a 100644 --- a/lib/Doctrine/Migrations/Generator/Exception/InvalidTemplateSpecified.php +++ b/lib/Doctrine/Migrations/Generator/Exception/InvalidTemplateSpecified.php @@ -5,21 +5,22 @@ namespace Doctrine\Migrations\Generator\Exception; use InvalidArgumentException; + use function sprintf; final class InvalidTemplateSpecified extends InvalidArgumentException implements GeneratorException { - public static function notFoundOrNotReadable(string $path) : self + public static function notFoundOrNotReadable(string $path): self { return new self(sprintf('The specified template "%s" cannot be found or is not readable.', $path)); } - public static function notReadable(string $path) : self + public static function notReadable(string $path): self { return new self(sprintf('The specified template "%s" could not be read.', $path)); } - public static function empty(string $path) : self + public static function empty(string $path): self { return new self(sprintf('The specified template "%s" is empty.', $path)); } diff --git a/lib/Doctrine/Migrations/Generator/Exception/NoChangesDetected.php b/lib/Doctrine/Migrations/Generator/Exception/NoChangesDetected.php index 7b550bd4d9..02b21b031c 100644 --- a/lib/Doctrine/Migrations/Generator/Exception/NoChangesDetected.php +++ b/lib/Doctrine/Migrations/Generator/Exception/NoChangesDetected.php @@ -8,7 +8,7 @@ final class NoChangesDetected extends RuntimeException implements GeneratorException { - public static function new() : self + public static function new(): self { return new self('No changes detected in your mapping information.'); } diff --git a/lib/Doctrine/Migrations/Generator/FileBuilder.php b/lib/Doctrine/Migrations/Generator/FileBuilder.php index 933860855a..d4a51ae674 100644 --- a/lib/Doctrine/Migrations/Generator/FileBuilder.php +++ b/lib/Doctrine/Migrations/Generator/FileBuilder.php @@ -7,6 +7,7 @@ use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\Migrations\Version\Direction; + use function sprintf; /** @@ -45,7 +46,7 @@ public function buildMigrationFile( array $queriesByVersion, string $direction, DateTimeInterface $now - ) : string { + ): string { $string = sprintf("-- Doctrine Migration File Generated on %s\n", $now->format('Y-m-d H:i:s')); foreach ($queriesByVersion as $version => $queries) { @@ -63,7 +64,7 @@ public function buildMigrationFile( return $string; } - private function getVersionUpdateQuery(string $version, string $direction) : string + private function getVersionUpdateQuery(string $version, string $direction): string { if ($direction === Direction::DOWN) { return sprintf( diff --git a/lib/Doctrine/Migrations/Generator/Generator.php b/lib/Doctrine/Migrations/Generator/Generator.php index 86b73086e1..156c9d2db7 100644 --- a/lib/Doctrine/Migrations/Generator/Generator.php +++ b/lib/Doctrine/Migrations/Generator/Generator.php @@ -7,6 +7,7 @@ use Doctrine\Migrations\Configuration\Configuration; use Doctrine\Migrations\Generator\Exception\InvalidTemplateSpecified; use Doctrine\Migrations\Tools\Console\Helper\MigrationDirectoryHelper; + use function explode; use function file_get_contents; use function file_put_contents; @@ -74,7 +75,7 @@ public function generateMigration( string $version, ?string $up = null, ?string $down = null - ) : string { + ): string { $placeHolders = [ '', '', @@ -101,7 +102,7 @@ public function generateMigration( return $path; } - private function getTemplate() : string + private function getTemplate(): string { if ($this->template === null) { $this->template = $this->loadCustomTemplate(); @@ -117,7 +118,7 @@ private function getTemplate() : string /** * @throws InvalidTemplateSpecified */ - private function loadCustomTemplate() : ?string + private function loadCustomTemplate(): ?string { $customTemplate = $this->configuration->getCustomTemplate(); diff --git a/lib/Doctrine/Migrations/Generator/SqlGenerator.php b/lib/Doctrine/Migrations/Generator/SqlGenerator.php index fa216179bc..bafcab376b 100644 --- a/lib/Doctrine/Migrations/Generator/SqlGenerator.php +++ b/lib/Doctrine/Migrations/Generator/SqlGenerator.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\Migrations\Configuration\Configuration; use SqlFormatter; + use function array_unshift; use function count; use function implode; @@ -41,7 +42,7 @@ public function generate( bool $formatted = false, int $lineLength = 120, bool $checkDbPlatform = true - ) : string { + ): string { $code = []; foreach ($sql as $query) { diff --git a/lib/Doctrine/Migrations/MigrationPlanCalculator.php b/lib/Doctrine/Migrations/MigrationPlanCalculator.php index b494ddb598..f12a9d2f4a 100644 --- a/lib/Doctrine/Migrations/MigrationPlanCalculator.php +++ b/lib/Doctrine/Migrations/MigrationPlanCalculator.php @@ -6,6 +6,7 @@ use Doctrine\Migrations\Version\Direction; use Doctrine\Migrations\Version\Version; + use function array_filter; use function array_reverse; use function count; @@ -28,7 +29,7 @@ public function __construct(MigrationRepository $migrationRepository) } /** @return Version[] */ - public function getMigrationsToExecute(string $direction, string $to) : array + public function getMigrationsToExecute(string $direction, string $to): array { $allVersions = $this->migrationRepository->getMigrations(); @@ -53,7 +54,7 @@ private function shouldExecuteMigration( Version $version, string $to, array $migrated - ) : bool { + ): bool { $to = (int) $to; if ($direction === Direction::DOWN) { diff --git a/lib/Doctrine/Migrations/MigrationRepository.php b/lib/Doctrine/Migrations/MigrationRepository.php index 31a4292794..c775f93068 100644 --- a/lib/Doctrine/Migrations/MigrationRepository.php +++ b/lib/Doctrine/Migrations/MigrationRepository.php @@ -13,7 +13,7 @@ use Doctrine\Migrations\Finder\MigrationFinder; use Doctrine\Migrations\Version\Factory; use Doctrine\Migrations\Version\Version; -use const SORT_STRING; + use function array_diff; use function array_keys; use function array_map; @@ -29,6 +29,8 @@ use function sprintf; use function substr; +use const SORT_STRING; + /** * The MigrationRepository class is responsible for retrieving migrations, determing what the current migration * version, etc. @@ -67,7 +69,7 @@ public function __construct( /** * @return string[] */ - public function findMigrations(string $path) : array + public function findMigrations(string $path): array { return $this->migrationFinder->findMigrations( $path, @@ -76,12 +78,12 @@ public function findMigrations(string $path) : array } /** @return Version[] */ - public function registerMigrationsFromDirectory(string $path) : array + public function registerMigrationsFromDirectory(string $path): array { return $this->registerMigrations($this->findMigrations($path)); } - public function addVersion(Version $version) : void + public function addVersion(Version $version): void { $this->versions[$version->getVersion()] = $version; @@ -91,14 +93,14 @@ public function addVersion(Version $version) : void /** * @param Version[] $versions */ - public function addVersions(array $versions) : void + public function addVersions(array $versions): void { foreach ($versions as $version) { $this->addVersion($version); } } - public function removeMigrationVersionFromDatabase(string $version) : void + public function removeMigrationVersionFromDatabase(string $version): void { $this->connection->delete( $this->configuration->getMigrationsTableName(), @@ -107,7 +109,7 @@ public function removeMigrationVersionFromDatabase(string $version) : void } /** @throws MigrationException */ - public function registerMigration(string $version, string $migrationClassName) : Version + public function registerMigration(string $version, string $migrationClassName): Version { $this->ensureMigrationClassExists($migrationClassName); @@ -130,7 +132,7 @@ public function registerMigration(string $version, string $migrationClassName) : * * @return Version[] */ - public function registerMigrations(array $migrations) : array + public function registerMigrations(array $migrations): array { $versions = []; @@ -141,7 +143,7 @@ public function registerMigrations(array $migrations) : array return $versions; } - public function getCurrentVersion() : string + public function getCurrentVersion(): string { $this->configuration->createMigrationTable(); @@ -186,19 +188,19 @@ public function getCurrentVersion() : string /** * @return Version[] */ - public function getVersions() : array + public function getVersions(): array { $this->loadMigrationsFromDirectory(); return $this->versions; } - public function clearVersions() : void + public function clearVersions(): void { $this->versions = []; } - public function getVersion(string $version) : Version + public function getVersion(string $version): Version { $this->loadMigrationsFromDirectory(); @@ -209,14 +211,14 @@ public function getVersion(string $version) : Version return $this->versions[$version]; } - public function hasVersion(string $version) : bool + public function hasVersion(string $version): bool { $this->loadMigrationsFromDirectory(); return isset($this->versions[$version]); } - public function hasVersionMigrated(Version $version) : bool + public function hasVersionMigrated(Version $version): bool { return $this->getVersionData($version) !== null; } @@ -224,7 +226,7 @@ public function hasVersionMigrated(Version $version) : bool /** * @return mixed[]|null */ - public function getVersionData(Version $version) : ?array + public function getVersionData(Version $version): ?array { $this->configuration->connect(); $this->configuration->createMigrationTable(); @@ -245,7 +247,7 @@ public function getVersionData(Version $version) : ?array /** * @return Version[] */ - public function getMigrations() : array + public function getMigrations(): array { $this->loadMigrationsFromDirectory(); @@ -253,7 +255,7 @@ public function getMigrations() : array } /** @return string[] */ - public function getAvailableVersions() : array + public function getAvailableVersions(): array { $availableVersions = []; @@ -267,7 +269,7 @@ public function getAvailableVersions() : array } /** @return string[] */ - public function getNewVersions() : array + public function getNewVersions(): array { $availableMigrations = $this->getAvailableVersions(); $executedMigrations = $this->getMigratedVersions(); @@ -276,7 +278,7 @@ public function getNewVersions() : array } /** @return string[] */ - public function getMigratedVersions() : array + public function getMigratedVersions(): array { $this->configuration->createMigrationTable(); @@ -300,7 +302,7 @@ public function getMigratedVersions() : array /** * @return string[] */ - public function getExecutedUnavailableMigrations() : array + public function getExecutedUnavailableMigrations(): array { $executedMigrations = $this->getMigratedVersions(); $availableMigrations = $this->getAvailableVersions(); @@ -308,14 +310,14 @@ public function getExecutedUnavailableMigrations() : array return array_diff($executedMigrations, $availableMigrations); } - public function getNumberOfAvailableMigrations() : int + public function getNumberOfAvailableMigrations(): int { $this->loadMigrationsFromDirectory(); return count($this->versions); } - public function getLatestVersion() : string + public function getLatestVersion(): string { $this->loadMigrationsFromDirectory(); @@ -325,7 +327,7 @@ public function getLatestVersion() : string return $latest !== false ? (string) $latest : '0'; } - public function getNumberOfExecutedMigrations() : int + public function getNumberOfExecutedMigrations(): int { $this->configuration->connect(); $this->configuration->createMigrationTable(); @@ -341,7 +343,7 @@ public function getNumberOfExecutedMigrations() : int return $result !== false ? (int) $result : 0; } - public function getRelativeVersion(string $version, int $delta) : ?string + public function getRelativeVersion(string $version, int $delta): ?string { $this->loadMigrationsFromDirectory(); @@ -365,7 +367,7 @@ public function getRelativeVersion(string $version, int $delta) : ?string return $versions[$relativeVersion]; } - public function getDeltaVersion(string $delta) : ?string + public function getDeltaVersion(string $delta): ?string { $symbol = substr($delta, 0, 1); $number = (int) substr($delta, 1); @@ -381,17 +383,17 @@ public function getDeltaVersion(string $delta) : ?string return null; } - public function getPrevVersion() : ?string + public function getPrevVersion(): ?string { return $this->getRelativeVersion($this->getCurrentVersion(), -1); } - public function getNextVersion() : ?string + public function getNextVersion(): ?string { return $this->getRelativeVersion($this->getCurrentVersion(), 1); } - private function loadMigrationsFromDirectory() : void + private function loadMigrationsFromDirectory(): void { $migrationsDirectory = $this->configuration->getMigrationsDirectory(); @@ -403,7 +405,7 @@ private function loadMigrationsFromDirectory() : void } /** @throws MigrationException */ - private function ensureMigrationClassExists(string $class) : void + private function ensureMigrationClassExists(string $class): void { if (! class_exists($class)) { throw MigrationClassNotFound::new( diff --git a/lib/Doctrine/Migrations/Migrator.php b/lib/Doctrine/Migrations/Migrator.php index dfa5fad4ca..51f1928df0 100644 --- a/lib/Doctrine/Migrations/Migrator.php +++ b/lib/Doctrine/Migrations/Migrator.php @@ -13,10 +13,12 @@ use Doctrine\Migrations\Version\Version; use Symfony\Component\Stopwatch\StopwatchEvent; use Throwable; -use const COUNT_RECURSIVE; + use function count; use function sprintf; +use const COUNT_RECURSIVE; + /** * The Migrator class is responsible for generating and executing the SQL for a migration. * @@ -49,7 +51,7 @@ public function __construct( } /** @return string[][] */ - public function getSql(?string $to = null) : array + public function getSql(?string $to = null): array { $migratorConfiguration = (new MigratorConfiguration()) ->setDryRun(true); @@ -57,7 +59,7 @@ public function getSql(?string $to = null) : array return $this->migrate($to, $migratorConfiguration); } - public function writeSqlFile(string $path, ?string $to = null) : bool + public function writeSqlFile(string $path, ?string $to = null): bool { $sql = $this->getSql($to); @@ -92,7 +94,7 @@ public function writeSqlFile(string $path, ?string $to = null) : bool public function migrate( ?string $to = null, ?MigratorConfiguration $migratorConfiguration = null - ) : array { + ): array { $migratorConfiguration = $migratorConfiguration ?? new MigratorConfiguration(); $dryRun = $migratorConfiguration->isDryRun(); @@ -159,7 +161,7 @@ private function executeMigration( array $migrationsToExecute, string $direction, MigratorConfiguration $migratorConfiguration - ) : array { + ): array { $dryRun = $migratorConfiguration->isDryRun(); $connection = $this->configuration->getConnection(); @@ -214,7 +216,7 @@ private function endMigration( StopwatchEvent $stopwatchEvent, array $migrationsToExecute, array $sql - ) : void { + ): void { $stopwatchEvent->stop(); $this->outputWriter->write("\n ------------------------\n"); @@ -240,13 +242,13 @@ private function endMigration( )); } - private function calculateDirection(string $from, string $to) : string + private function calculateDirection(string $from, string $to): string { return (int) $from > (int) $to ? Direction::DOWN : Direction::UP; } /** @return string[][] */ - private function noMigrations() : array + private function noMigrations(): array { $this->outputWriter->write('No migrations to execute.'); diff --git a/lib/Doctrine/Migrations/MigratorConfiguration.php b/lib/Doctrine/Migrations/MigratorConfiguration.php index 1c902b316d..59f3b6ae9b 100644 --- a/lib/Doctrine/Migrations/MigratorConfiguration.php +++ b/lib/Doctrine/Migrations/MigratorConfiguration.php @@ -31,60 +31,60 @@ class MigratorConfiguration /** @var Schema|null */ private $fromSchema; - public function isDryRun() : bool + public function isDryRun(): bool { return $this->dryRun; } - public function setDryRun(bool $dryRun) : self + public function setDryRun(bool $dryRun): self { $this->dryRun = $dryRun; return $this; } - public function getTimeAllQueries() : bool + public function getTimeAllQueries(): bool { return $this->timeAllQueries; } - public function setTimeAllQueries(bool $timeAllQueries) : self + public function setTimeAllQueries(bool $timeAllQueries): self { $this->timeAllQueries = $timeAllQueries; return $this; } - public function getNoMigrationException() : bool + public function getNoMigrationException(): bool { return $this->noMigrationException; } - public function setNoMigrationException(bool $noMigrationException = false) : self + public function setNoMigrationException(bool $noMigrationException = false): self { $this->noMigrationException = $noMigrationException; return $this; } - public function isAllOrNothing() : bool + public function isAllOrNothing(): bool { return $this->allOrNothing; } - public function setAllOrNothing(bool $allOrNothing) : self + public function setAllOrNothing(bool $allOrNothing): self { $this->allOrNothing = $allOrNothing; return $this; } - public function getFromSchema() : ?Schema + public function getFromSchema(): ?Schema { return $this->fromSchema; } - public function setFromSchema(Schema $fromSchema) : self + public function setFromSchema(Schema $fromSchema): self { $this->fromSchema = $fromSchema; diff --git a/lib/Doctrine/Migrations/OutputWriter.php b/lib/Doctrine/Migrations/OutputWriter.php index ebb04adfb0..fb3535390e 100644 --- a/lib/Doctrine/Migrations/OutputWriter.php +++ b/lib/Doctrine/Migrations/OutputWriter.php @@ -18,7 +18,7 @@ class OutputWriter public function __construct(?callable $callback = null) { if ($callback === null) { - $callback = function (string $message) : void { + $callback = function (string $message): void { $this->lastMessage = $message; }; } @@ -26,17 +26,17 @@ public function __construct(?callable $callback = null) $this->callback = $callback; } - public function setCallback(callable $callback) : void + public function setCallback(callable $callback): void { $this->callback = $callback; } - public function write(string $message) : void + public function write(string $message): void { ($this->callback)($message); } - public function getLastMessage() : string + public function getLastMessage(): string { return $this->lastMessage; } diff --git a/lib/Doctrine/Migrations/ParameterFormatter.php b/lib/Doctrine/Migrations/ParameterFormatter.php index 8576fc5b00..7eb5363f2f 100644 --- a/lib/Doctrine/Migrations/ParameterFormatter.php +++ b/lib/Doctrine/Migrations/ParameterFormatter.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Type; + use function array_map; use function implode; use function is_array; @@ -34,7 +35,7 @@ public function __construct(Connection $connection) * @param mixed[] $params * @param mixed[] $types */ - public function formatParameters(array $params, array $types) : string + public function formatParameters(array $params, array $types): string { if ($params === []) { return ''; @@ -76,10 +77,10 @@ private function formatParameter($value, $type) /** * @param int[]|bool[]|string[]|array|int|string|bool $value */ - private function parameterToString($value) : string + private function parameterToString($value): string { if (is_array($value)) { - return implode(', ', array_map(function ($value) : string { + return implode(', ', array_map(function ($value): string { return $this->parameterToString($value); }, $value)); } diff --git a/lib/Doctrine/Migrations/ParameterFormatterInterface.php b/lib/Doctrine/Migrations/ParameterFormatterInterface.php index dc8efc5a26..1d2ea3e6fd 100644 --- a/lib/Doctrine/Migrations/ParameterFormatterInterface.php +++ b/lib/Doctrine/Migrations/ParameterFormatterInterface.php @@ -18,5 +18,5 @@ interface ParameterFormatterInterface * @param mixed[] $params * @param mixed[] $types */ - public function formatParameters(array $params, array $types) : string; + public function formatParameters(array $params, array $types): string; } diff --git a/lib/Doctrine/Migrations/Provider/EmptySchemaProvider.php b/lib/Doctrine/Migrations/Provider/EmptySchemaProvider.php index df52188bcb..a51688a64d 100644 --- a/lib/Doctrine/Migrations/Provider/EmptySchemaProvider.php +++ b/lib/Doctrine/Migrations/Provider/EmptySchemaProvider.php @@ -23,7 +23,7 @@ public function __construct(AbstractSchemaManager $schemaManager) $this->schemaManager = $schemaManager; } - public function createSchema() : Schema + public function createSchema(): Schema { return new Schema([], [], $this->schemaManager->createSchemaConfig()); } diff --git a/lib/Doctrine/Migrations/Provider/Exception/NoMappingFound.php b/lib/Doctrine/Migrations/Provider/Exception/NoMappingFound.php index eded25a06f..fd5fc5115c 100644 --- a/lib/Doctrine/Migrations/Provider/Exception/NoMappingFound.php +++ b/lib/Doctrine/Migrations/Provider/Exception/NoMappingFound.php @@ -8,7 +8,7 @@ final class NoMappingFound extends UnexpectedValueException implements ProviderException { - public static function new() : self + public static function new(): self { return new self('No mapping information to process'); } diff --git a/lib/Doctrine/Migrations/Provider/LazySchemaDiffProvider.php b/lib/Doctrine/Migrations/Provider/LazySchemaDiffProvider.php index cafddbf435..3183bfbc08 100644 --- a/lib/Doctrine/Migrations/Provider/LazySchemaDiffProvider.php +++ b/lib/Doctrine/Migrations/Provider/LazySchemaDiffProvider.php @@ -34,7 +34,7 @@ public function __construct( public static function fromDefaultProxyFactoryConfiguration( SchemaDiffProviderInterface $originalSchemaManipulator - ) : LazySchemaDiffProvider { + ): LazySchemaDiffProvider { $proxyConfig = new Configuration(); $proxyConfig->setGeneratorStrategy(new EvaluatingGeneratorStrategy()); $proxyFactory = new LazyLoadingValueHolderFactory($proxyConfig); @@ -42,7 +42,7 @@ public static function fromDefaultProxyFactoryConfiguration( return new LazySchemaDiffProvider($proxyFactory, $originalSchemaManipulator); } - public function createFromSchema() : Schema + public function createFromSchema(): Schema { $originalSchemaManipulator = $this->originalSchemaManipulator; @@ -58,7 +58,7 @@ static function (&$wrappedObject, $proxy, $method, array $parameters, &$initiali ); } - public function createToSchema(Schema $fromSchema) : Schema + public function createToSchema(Schema $fromSchema): Schema { $originalSchemaManipulator = $this->originalSchemaManipulator; @@ -79,10 +79,12 @@ static function (&$wrappedObject, $proxy, $method, array $parameters, &$initiali } /** @return string[] */ - public function getSqlDiffToMigrate(Schema $fromSchema, Schema $toSchema) : array + public function getSqlDiffToMigrate(Schema $fromSchema, Schema $toSchema): array { - if ($toSchema instanceof LazyLoadingInterface - && ! $toSchema->isProxyInitialized()) { + if ( + $toSchema instanceof LazyLoadingInterface + && ! $toSchema->isProxyInitialized() + ) { return []; } diff --git a/lib/Doctrine/Migrations/Provider/OrmSchemaProvider.php b/lib/Doctrine/Migrations/Provider/OrmSchemaProvider.php index 102a1c6097..3711a2bfad 100644 --- a/lib/Doctrine/Migrations/Provider/OrmSchemaProvider.php +++ b/lib/Doctrine/Migrations/Provider/OrmSchemaProvider.php @@ -9,6 +9,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Tools\SchemaTool; + use function count; use function usort; @@ -32,7 +33,7 @@ public function __construct(EntityManagerInterface $em) /** * @throws NoMappingFound */ - public function createSchema() : Schema + public function createSchema(): Schema { $metadata = $this->entityManager->getMetadataFactory()->getAllMetadata(); diff --git a/lib/Doctrine/Migrations/Provider/SchemaDiffProvider.php b/lib/Doctrine/Migrations/Provider/SchemaDiffProvider.php index d97870acfe..88ea904400 100644 --- a/lib/Doctrine/Migrations/Provider/SchemaDiffProvider.php +++ b/lib/Doctrine/Migrations/Provider/SchemaDiffProvider.php @@ -32,18 +32,18 @@ public function __construct(AbstractSchemaManager $schemaManager, AbstractPlatfo $this->platform = $platform; } - public function createFromSchema() : Schema + public function createFromSchema(): Schema { return $this->schemaManager->createSchema(); } - public function createToSchema(Schema $fromSchema) : Schema + public function createToSchema(Schema $fromSchema): Schema { return clone $fromSchema; } /** @return string[] */ - public function getSqlDiffToMigrate(Schema $fromSchema, Schema $toSchema) : array + public function getSqlDiffToMigrate(Schema $fromSchema, Schema $toSchema): array { return $fromSchema->getMigrateToSql($toSchema, $this->platform); } diff --git a/lib/Doctrine/Migrations/Provider/SchemaDiffProviderInterface.php b/lib/Doctrine/Migrations/Provider/SchemaDiffProviderInterface.php index e0666cd211..d4af9ee7a3 100644 --- a/lib/Doctrine/Migrations/Provider/SchemaDiffProviderInterface.php +++ b/lib/Doctrine/Migrations/Provider/SchemaDiffProviderInterface.php @@ -14,10 +14,10 @@ */ interface SchemaDiffProviderInterface { - public function createFromSchema() : Schema; + public function createFromSchema(): Schema; - public function createToSchema(Schema $fromSchema) : Schema; + public function createToSchema(Schema $fromSchema): Schema; /** @return string[] */ - public function getSqlDiffToMigrate(Schema $fromSchema, Schema $toSchema) : array; + public function getSqlDiffToMigrate(Schema $fromSchema, Schema $toSchema): array; } diff --git a/lib/Doctrine/Migrations/Provider/SchemaProviderInterface.php b/lib/Doctrine/Migrations/Provider/SchemaProviderInterface.php index 324dc5028a..869561f968 100644 --- a/lib/Doctrine/Migrations/Provider/SchemaProviderInterface.php +++ b/lib/Doctrine/Migrations/Provider/SchemaProviderInterface.php @@ -12,5 +12,5 @@ */ interface SchemaProviderInterface { - public function createSchema() : Schema; + public function createSchema(): Schema; } diff --git a/lib/Doctrine/Migrations/Provider/StubSchemaProvider.php b/lib/Doctrine/Migrations/Provider/StubSchemaProvider.php index 77976ef959..2f5c9e022f 100644 --- a/lib/Doctrine/Migrations/Provider/StubSchemaProvider.php +++ b/lib/Doctrine/Migrations/Provider/StubSchemaProvider.php @@ -20,7 +20,7 @@ public function __construct(Schema $schema) $this->toSchema = $schema; } - public function createSchema() : Schema + public function createSchema(): Schema { return $this->toSchema; } diff --git a/lib/Doctrine/Migrations/QueryWriter.php b/lib/Doctrine/Migrations/QueryWriter.php index 501f772051..953a23448b 100644 --- a/lib/Doctrine/Migrations/QueryWriter.php +++ b/lib/Doctrine/Migrations/QueryWriter.php @@ -18,5 +18,5 @@ public function write( string $path, string $direction, array $queriesByVersion - ) : bool; + ): bool; } diff --git a/lib/Doctrine/Migrations/Rollup.php b/lib/Doctrine/Migrations/Rollup.php index 7323ef5cac..f20db85fc4 100644 --- a/lib/Doctrine/Migrations/Rollup.php +++ b/lib/Doctrine/Migrations/Rollup.php @@ -8,6 +8,7 @@ use Doctrine\Migrations\Configuration\Configuration; use Doctrine\Migrations\Exception\RollupFailed; use Doctrine\Migrations\Version\Version; + use function count; use function current; use function sprintf; @@ -44,7 +45,7 @@ public function __construct( /** * @throws RollupFailed */ - public function rollup() : Version + public function rollup(): Version { $versions = $this->migrationRepository->getVersions(); diff --git a/lib/Doctrine/Migrations/SchemaDumper.php b/lib/Doctrine/Migrations/SchemaDumper.php index b8298227df..f7f1b86434 100644 --- a/lib/Doctrine/Migrations/SchemaDumper.php +++ b/lib/Doctrine/Migrations/SchemaDumper.php @@ -9,6 +9,7 @@ use Doctrine\Migrations\Exception\NoTablesFound; use Doctrine\Migrations\Generator\Generator; use Doctrine\Migrations\Generator\SqlGenerator; + use function count; use function implode; @@ -53,7 +54,7 @@ public function dump( string $versionNumber, bool $formatted = false, int $lineLength = 120 - ) : string { + ): string { $schema = $this->schemaManager->createSchema(); $up = []; diff --git a/lib/Doctrine/Migrations/Stopwatch.php b/lib/Doctrine/Migrations/Stopwatch.php index fe0ef30c76..b449eab4fa 100644 --- a/lib/Doctrine/Migrations/Stopwatch.php +++ b/lib/Doctrine/Migrations/Stopwatch.php @@ -22,7 +22,7 @@ public function __construct(SymfonyStopwatch $symfonyStopwatch) $this->symfonyStopwatch = $symfonyStopwatch; } - public function start(string $section) : StopwatchEvent + public function start(string $section): StopwatchEvent { return $this->symfonyStopwatch->start($section); } diff --git a/lib/Doctrine/Migrations/Tools/BooleanStringFormatter.php b/lib/Doctrine/Migrations/Tools/BooleanStringFormatter.php index aa3319565e..9f3f42fe0f 100644 --- a/lib/Doctrine/Migrations/Tools/BooleanStringFormatter.php +++ b/lib/Doctrine/Migrations/Tools/BooleanStringFormatter.php @@ -16,17 +16,21 @@ */ class BooleanStringFormatter { - public static function toBoolean(string $value, bool $default) : bool + public static function toBoolean(string $value, bool $default): bool { switch (strtolower($value)) { case 'true': return true; + case '1': return true; + case 'false': return false; + case '0': return false; + default: return $default; } diff --git a/lib/Doctrine/Migrations/Tools/BytesFormatter.php b/lib/Doctrine/Migrations/Tools/BytesFormatter.php index d828fdc276..d63062e582 100644 --- a/lib/Doctrine/Migrations/Tools/BytesFormatter.php +++ b/lib/Doctrine/Migrations/Tools/BytesFormatter.php @@ -17,7 +17,7 @@ */ final class BytesFormatter { - public static function formatBytes(float $size, int $precision = 2) : string + public static function formatBytes(float $size, int $precision = 2): string { $base = log($size, 1024); $suffixes = ['', 'K', 'M', 'G', 'T']; diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/AbstractCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/AbstractCommand.php index 77b599755d..4479d878ab 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/AbstractCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/AbstractCommand.php @@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; + use function assert; use function escapeshellarg; use function proc_open; @@ -43,24 +44,24 @@ abstract class AbstractCommand extends Command /** @var Configuration|null */ protected $migrationConfiguration; - public function setMigrationConfiguration(Configuration $configuration) : void + public function setMigrationConfiguration(Configuration $configuration): void { $this->configuration = $configuration; $this->initializeDependencies(); } - public function setConnection(Connection $connection) : void + public function setConnection(Connection $connection): void { $this->connection = $connection; } - public function setDependencyFactory(DependencyFactory $dependencyFactory) : void + public function setDependencyFactory(DependencyFactory $dependencyFactory): void { $this->dependencyFactory = $dependencyFactory; } - public function setMigrationRepository(MigrationRepository $migrationRepository) : void + public function setMigrationRepository(MigrationRepository $migrationRepository): void { $this->migrationRepository = $migrationRepository; } @@ -68,7 +69,7 @@ public function setMigrationRepository(MigrationRepository $migrationRepository) public function initialize( InputInterface $input, OutputInterface $output - ) : void { + ): void { $this->configuration = $this->getMigrationConfiguration($input, $output); $this->initializeDependencies(); @@ -77,7 +78,7 @@ public function initialize( $this->configuration->createMigrationTable(); } - protected function configure() : void + protected function configure(): void { $this->addOption( 'configuration', @@ -96,7 +97,7 @@ protected function configure() : void protected function outputHeader( OutputInterface $output - ) : void { + ): void { $name = $this->configuration->getName(); $name = $name ?? 'Doctrine Database Migrations'; $name = str_repeat(' ', 20) . $name . str_repeat(' ', 20); @@ -109,13 +110,13 @@ protected function outputHeader( protected function getMigrationConfiguration( InputInterface $input, OutputInterface $output - ) : Configuration { + ): Configuration { if ($this->migrationConfiguration === null) { if ($this->hasConfigurationHelper()) { $helperSet = $this->getHelperSet(); assert($helperSet !== null); - /** @var ConfigurationHelper $configHelper */ $configHelper = $helperSet->get('configuration'); + assert($configHelper instanceof ConfigurationHelper); } else { $configHelper = new ConfigurationHelper( $this->getConnection($input), @@ -126,7 +127,7 @@ protected function getMigrationConfiguration( $this->migrationConfiguration = $configHelper->getMigrationConfig($input); $this->migrationConfiguration->getOutputWriter()->setCallback( - static function (string $message) use ($output) : void { + static function (string $message) use ($output): void { $output->writeln($message); } ); @@ -143,7 +144,7 @@ protected function askConfirmation( string $question, InputInterface $input, OutputInterface $output - ) : bool { + ): bool { return $this->getHelper('question')->ask( $input, $output, @@ -155,26 +156,26 @@ protected function canExecute( string $question, InputInterface $input, OutputInterface $output - ) : bool { + ): bool { return ! $input->isInteractive() || $this->askConfirmation($question, $input, $output); } - protected function procOpen(string $editorCommand, string $path) : void + protected function procOpen(string $editorCommand, string $path): void { proc_open($editorCommand . ' ' . escapeshellarg($path), [], $pipes); } - private function initializeDependencies() : void + private function initializeDependencies(): void { $this->connection = $this->configuration->getConnection(); $this->dependencyFactory = $this->configuration->getDependencyFactory(); $this->migrationRepository = $this->dependencyFactory->getMigrationRepository(); } - private function hasConfigurationHelper() : bool + private function hasConfigurationHelper(): bool { - /** @var HelperSet|null $helperSet */ $helperSet = $this->getHelperSet(); + assert($helperSet instanceof HelperSet || $helperSet === null); if ($helperSet === null) { return false; @@ -187,7 +188,7 @@ private function hasConfigurationHelper() : bool return $helperSet->get('configuration') instanceof ConfigurationHelperInterface; } - private function getConnection(InputInterface $input) : Connection + private function getConnection(InputInterface $input): Connection { if ($this->connection === null) { $helperSet = $this->getHelperSet(); diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/DiffCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/DiffCommand.php index f8bd0d6e82..172e5431e6 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/DiffCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/DiffCommand.php @@ -13,7 +13,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use const FILTER_VALIDATE_BOOLEAN; + use function assert; use function class_exists; use function filter_var; @@ -22,6 +22,8 @@ use function is_string; use function sprintf; +use const FILTER_VALIDATE_BOOLEAN; + /** * The DiffCommand class is responsible for generating a migration by comparing your current database schema to * your mapping information. @@ -44,7 +46,7 @@ public function __construct(?SchemaProviderInterface $schemaProvider = null) parent::__construct(); } - protected function configure() : void + protected function configure(): void { parent::configure(); @@ -113,7 +115,7 @@ protected function configure() : void public function execute( InputInterface $input, OutputInterface $output - ) : ?int { + ): ?int { $filterExpression = $input->getOption('filter-expression') ?? null; assert(is_string($filterExpression) || $filterExpression === null); $formatted = (bool) $input->getOption('formatted'); @@ -149,6 +151,7 @@ public function execute( return 0; } + throw $exception; } @@ -176,7 +179,7 @@ public function execute( return 0; } - protected function createMigrationDiffGenerator() : DiffGenerator + protected function createMigrationDiffGenerator(): DiffGenerator { return new DiffGenerator( $this->connection->getConfiguration(), @@ -189,7 +192,7 @@ protected function createMigrationDiffGenerator() : DiffGenerator ); } - private function getSchemaProvider() : SchemaProviderInterface + private function getSchemaProvider(): SchemaProviderInterface { if ($this->schemaProvider === null) { $this->schemaProvider = new OrmSchemaProvider( @@ -200,7 +203,7 @@ private function getSchemaProvider() : SchemaProviderInterface return $this->schemaProvider; } - private function getEmptySchemaProvider() : EmptySchemaProvider + private function getEmptySchemaProvider(): EmptySchemaProvider { if ($this->emptySchemaProvider === null) { $this->emptySchemaProvider = new EmptySchemaProvider( diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/DumpSchemaCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/DumpSchemaCommand.php index 33d16e4b77..4e12e57c63 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/DumpSchemaCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/DumpSchemaCommand.php @@ -9,6 +9,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function class_exists; use function count; @@ -28,7 +29,7 @@ class DumpSchemaCommand extends AbstractCommand /** @var string */ protected static $defaultName = 'migrations:dump-schema'; - protected function configure() : void + protected function configure(): void { parent::configure(); @@ -70,7 +71,7 @@ protected function configure() : void public function execute( InputInterface $input, OutputInterface $output - ) : ?int { + ): ?int { $formatted = (bool) $input->getOption('formatted'); $lineLength = $input->getOption('line-length'); assert(! is_array($lineLength) && ! is_bool($lineLength)); diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php index 6084299f57..63ae431487 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php @@ -10,6 +10,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function getcwd; use function is_string; @@ -22,7 +23,7 @@ class ExecuteCommand extends AbstractCommand /** @var string */ protected static $defaultName = 'migrations:execute'; - protected function configure() : void + protected function configure(): void { $this ->setAliases(['execute']) @@ -92,7 +93,7 @@ protected function configure() : void parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) : ?int + public function execute(InputInterface $input, OutputInterface $output): ?int { $version = $input->getArgument('version'); assert(is_string($version)); diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/GenerateCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/GenerateCommand.php index 80130feb8b..a7f3537ef0 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/GenerateCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/GenerateCommand.php @@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function is_string; use function sprintf; @@ -19,7 +20,7 @@ class GenerateCommand extends AbstractCommand /** @var string */ protected static $defaultName = 'migrations:generate'; - protected function configure() : void + protected function configure(): void { $this ->setAliases(['generate']) @@ -44,7 +45,7 @@ protected function configure() : void parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) : ?int + public function execute(InputInterface $input, OutputInterface $output): ?int { $versionNumber = $this->configuration->generateVersionNumber(); diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/LatestCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/LatestCommand.php index 592239a878..8bf06003ec 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/LatestCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/LatestCommand.php @@ -6,6 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; + use function sprintf; /** @@ -16,7 +17,7 @@ class LatestCommand extends AbstractCommand /** @var string */ protected static $defaultName = 'migrations:latest'; - protected function configure() : void + protected function configure(): void { $this ->setAliases(['latest']) @@ -25,7 +26,7 @@ protected function configure() : void parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) : ?int + public function execute(InputInterface $input, OutputInterface $output): ?int { $latestVersion = $this->migrationRepository->getLatestVersion(); $version = $this->migrationRepository->getVersion($latestVersion); diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php index 3c01e41aef..213e417328 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php @@ -11,6 +11,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function count; use function getcwd; @@ -27,7 +28,7 @@ class MigrateCommand extends AbstractCommand /** @var string */ protected static $defaultName = 'migrations:migrate'; - protected function configure() : void + protected function configure(): void { $this ->setAliases(['migrate']) @@ -113,7 +114,7 @@ protected function configure() : void parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) : ?int + public function execute(InputInterface $input, OutputInterface $output): ?int { $this->outputHeader($output); @@ -170,7 +171,7 @@ public function execute(InputInterface $input, OutputInterface $output) : ?int return 0; } - protected function createMigrator() : Migrator + protected function createMigrator(): Migrator { return $this->dependencyFactory->getMigrator(); } @@ -178,7 +179,7 @@ protected function createMigrator() : Migrator private function checkExecutedUnavailableMigrations( InputInterface $input, OutputInterface $output - ) : int { + ): int { $executedUnavailableMigrations = $this->migrationRepository->getExecutedUnavailableMigrations(); if (count($executedUnavailableMigrations) !== 0) { @@ -210,7 +211,7 @@ private function checkExecutedUnavailableMigrations( private function getVersionNameFromAlias( string $versionAlias, OutputInterface $output - ) : string { + ): string { $version = $this->configuration->resolveVersionAlias($versionAlias); if ($version !== null) { @@ -246,7 +247,7 @@ private function getVersionNameFromAlias( /** * @param mixed $allOrNothing */ - private function getAllOrNothing($allOrNothing) : bool + private function getAllOrNothing($allOrNothing): bool { if ($allOrNothing !== false) { return $allOrNothing !== null diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php index 7f20cdc90e..96f11313f8 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php @@ -6,6 +6,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; + use function sprintf; /** @@ -17,7 +18,7 @@ class RollupCommand extends AbstractCommand /** @var string */ protected static $defaultName = 'migrations:rollup'; - protected function configure() : void + protected function configure(): void { parent::configure(); @@ -38,7 +39,7 @@ protected function configure() : void public function execute( InputInterface $input, OutputInterface $output - ) : ?int { + ): ?int { $version = $this->dependencyFactory ->getRollup()->rollup(); diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/StatusCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/StatusCommand.php index 382bc3223b..3a005f00fc 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/StatusCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/StatusCommand.php @@ -9,6 +9,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function count; use function is_string; @@ -26,7 +27,7 @@ class StatusCommand extends AbstractCommand /** @var string */ protected static $defaultName = 'migrations:status'; - protected function configure() : void + protected function configure(): void { $this ->setAliases(['status']) @@ -51,7 +52,7 @@ protected function configure() : void parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) : ?int + public function execute(InputInterface $input, OutputInterface $output): ?int { $output->writeln("\n == Configuration\n"); @@ -107,7 +108,7 @@ public function execute(InputInterface $input, OutputInterface $output) : ?int return 0; } - private function writeStatusInfosLineAligned(OutputInterface $output, string $title, ?string $value) : void + private function writeStatusInfosLineAligned(OutputInterface $output, string $title, ?string $value): void { $output->writeln(sprintf( ' >> %s: %s%s', @@ -123,7 +124,7 @@ private function writeStatusInfosLineAligned(OutputInterface $output, string $ti private function showVersions( array $versions, OutputInterface $output - ) : void { + ): void { foreach ($versions as $version) { $executedAt = $version->getExecutedAt(); diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/UpToDateCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/UpToDateCommand.php index 68344fbfd6..1154e9c206 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/UpToDateCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/UpToDateCommand.php @@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function count; use function sprintf; @@ -19,7 +20,7 @@ class UpToDateCommand extends AbstractCommand /** @var string */ protected static $defaultName = 'migrations:up-to-date'; - protected function configure() : void + protected function configure(): void { $this ->setAliases(['up-to-date']) @@ -35,7 +36,7 @@ protected function configure() : void parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) : ?int + public function execute(InputInterface $input, OutputInterface $output): ?int { $migrations = count($this->migrationRepository->getMigrations()); $migratedVersions = count($this->migrationRepository->getMigratedVersions()); diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/VersionCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/VersionCommand.php index ce076c502a..391e12174b 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/VersionCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/VersionCommand.php @@ -12,6 +12,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function is_string; use function sprintf; @@ -27,7 +28,7 @@ class VersionCommand extends AbstractCommand /** @var bool */ private $markMigrated; - protected function configure() : void + protected function configure(): void { $this ->setAliases(['version']) @@ -99,7 +100,7 @@ protected function configure() : void /** * @throws InvalidOptionUsage */ - public function execute(InputInterface $input, OutputInterface $output) : ?int + public function execute(InputInterface $input, OutputInterface $output): ?int { if ($input->getOption('add') === false && $input->getOption('delete') === false) { throw InvalidOptionUsage::new('You must specify whether you want to --add or --delete the specified version.'); @@ -127,7 +128,7 @@ public function execute(InputInterface $input, OutputInterface $output) : ?int /** * @throws InvalidOptionUsage */ - private function markVersions(InputInterface $input, OutputInterface $output) : void + private function markVersions(InputInterface $input, OutputInterface $output): void { $affectedVersion = $input->getArgument('version'); assert(is_string($affectedVersion) || $affectedVersion === null); @@ -174,7 +175,7 @@ private function markVersions(InputInterface $input, OutputInterface $output) : * @throws VersionDoesNotExist * @throws UnknownMigrationVersion */ - private function mark(InputInterface $input, OutputInterface $output, string $version, bool $all = false) : void + private function mark(InputInterface $input, OutputInterface $output, string $version, bool $all = false): void { if (! $this->migrationRepository->hasVersion($version)) { if ((bool) $input->getOption('delete') === false) { diff --git a/lib/Doctrine/Migrations/Tools/Console/ConnectionLoader.php b/lib/Doctrine/Migrations/Tools/Console/ConnectionLoader.php index 1c0f2523e2..0586b13328 100644 --- a/lib/Doctrine/Migrations/Tools/Console/ConnectionLoader.php +++ b/lib/Doctrine/Migrations/Tools/Console/ConnectionLoader.php @@ -14,6 +14,7 @@ use Doctrine\Migrations\Tools\Console\Exception\ConnectionNotSpecified; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Input\InputInterface; + use function assert; use function is_string; @@ -32,7 +33,7 @@ public function __construct(?Configuration $configuration) $this->configuration = $configuration; } - public function getConnection(InputInterface $input, HelperSet $helperSet) : Connection + public function getConnection(InputInterface $input, HelperSet $helperSet): Connection { $connection = $this->createConnectionConfigurationChainLoader($input, $helperSet) ->chosen(); @@ -47,7 +48,7 @@ public function getConnection(InputInterface $input, HelperSet $helperSet) : Con protected function createConnectionConfigurationChainLoader( InputInterface $input, HelperSet $helperSet - ) : ConnectionLoaderInterface { + ): ConnectionLoaderInterface { $dbConfiguration = $input->getOption('db-configuration'); assert(is_string($dbConfiguration) || $dbConfiguration === null); diff --git a/lib/Doctrine/Migrations/Tools/Console/ConsoleRunner.php b/lib/Doctrine/Migrations/Tools/Console/ConsoleRunner.php index d7a37a7912..541051e804 100644 --- a/lib/Doctrine/Migrations/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/Migrations/Tools/Console/ConsoleRunner.php @@ -29,14 +29,14 @@ class ConsoleRunner { /** @param AbstractCommand[] $commands */ - public static function run(HelperSet $helperSet, array $commands = []) : void + public static function run(HelperSet $helperSet, array $commands = []): void { $cli = static::createApplication($helperSet, $commands); $cli->run(); } /** @param AbstractCommand[] $commands */ - public static function createApplication(HelperSet $helperSet, array $commands = []) : Application + public static function createApplication(HelperSet $helperSet, array $commands = []): Application { $cli = new Application('Doctrine Migrations', Versions::getVersion('doctrine/migrations')); $cli->setCatchExceptions(true); @@ -47,7 +47,7 @@ public static function createApplication(HelperSet $helperSet, array $commands = return $cli; } - public static function addCommands(Application $cli) : void + public static function addCommands(Application $cli): void { $cli->addCommands([ new DumpSchemaCommand(), diff --git a/lib/Doctrine/Migrations/Tools/Console/Exception/ConnectionNotSpecified.php b/lib/Doctrine/Migrations/Tools/Console/Exception/ConnectionNotSpecified.php index 098c841efc..a5e293b760 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Exception/ConnectionNotSpecified.php +++ b/lib/Doctrine/Migrations/Tools/Console/Exception/ConnectionNotSpecified.php @@ -8,7 +8,7 @@ final class ConnectionNotSpecified extends InvalidArgumentException implements ConsoleException { - public static function new() : self + public static function new(): self { return new self( 'You have to specify a --db-configuration file or pass a Database Connection as a dependency to the Migrations.' diff --git a/lib/Doctrine/Migrations/Tools/Console/Exception/DirectoryDoesNotExist.php b/lib/Doctrine/Migrations/Tools/Console/Exception/DirectoryDoesNotExist.php index 5a1e98381e..4a6165ffa2 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Exception/DirectoryDoesNotExist.php +++ b/lib/Doctrine/Migrations/Tools/Console/Exception/DirectoryDoesNotExist.php @@ -5,11 +5,12 @@ namespace Doctrine\Migrations\Tools\Console\Exception; use InvalidArgumentException; + use function sprintf; final class DirectoryDoesNotExist extends InvalidArgumentException implements ConsoleException { - public static function new(string $directory) : self + public static function new(string $directory): self { return new self(sprintf('Migrations directory "%s" does not exist.', $directory)); } diff --git a/lib/Doctrine/Migrations/Tools/Console/Exception/FileTypeNotSupported.php b/lib/Doctrine/Migrations/Tools/Console/Exception/FileTypeNotSupported.php index cc74a039cd..255fe49611 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Exception/FileTypeNotSupported.php +++ b/lib/Doctrine/Migrations/Tools/Console/Exception/FileTypeNotSupported.php @@ -8,7 +8,7 @@ final class FileTypeNotSupported extends InvalidArgumentException implements ConsoleException { - public static function new() : self + public static function new(): self { return new self('Given config file type is not supported'); } diff --git a/lib/Doctrine/Migrations/Tools/Console/Exception/InvalidOptionUsage.php b/lib/Doctrine/Migrations/Tools/Console/Exception/InvalidOptionUsage.php index f30bccbb76..9fa7cfc176 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Exception/InvalidOptionUsage.php +++ b/lib/Doctrine/Migrations/Tools/Console/Exception/InvalidOptionUsage.php @@ -8,7 +8,7 @@ final class InvalidOptionUsage extends InvalidArgumentException implements ConsoleException { - public static function new(string $explanation) : self + public static function new(string $explanation): self { return new self($explanation); } diff --git a/lib/Doctrine/Migrations/Tools/Console/Exception/SchemaDumpRequiresNoMigrations.php b/lib/Doctrine/Migrations/Tools/Console/Exception/SchemaDumpRequiresNoMigrations.php index 35ff60d179..ef03cbc242 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Exception/SchemaDumpRequiresNoMigrations.php +++ b/lib/Doctrine/Migrations/Tools/Console/Exception/SchemaDumpRequiresNoMigrations.php @@ -8,7 +8,7 @@ final class SchemaDumpRequiresNoMigrations extends RuntimeException implements ConsoleException { - public static function new() : self + public static function new(): self { return new self('Delete any previous migrations before dumping your schema.'); } diff --git a/lib/Doctrine/Migrations/Tools/Console/Exception/VersionAlreadyExists.php b/lib/Doctrine/Migrations/Tools/Console/Exception/VersionAlreadyExists.php index 2ff7a6321e..dbe6771fe3 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Exception/VersionAlreadyExists.php +++ b/lib/Doctrine/Migrations/Tools/Console/Exception/VersionAlreadyExists.php @@ -6,11 +6,12 @@ use Doctrine\Migrations\Version\Version; use InvalidArgumentException; + use function sprintf; final class VersionAlreadyExists extends InvalidArgumentException implements ConsoleException { - public static function new(Version $version) : self + public static function new(Version $version): self { return new self(sprintf('The version "%s" already exists in the version table.', $version->getVersion())); } diff --git a/lib/Doctrine/Migrations/Tools/Console/Exception/VersionDoesNotExist.php b/lib/Doctrine/Migrations/Tools/Console/Exception/VersionDoesNotExist.php index c2ee7f8538..49f2c85b51 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Exception/VersionDoesNotExist.php +++ b/lib/Doctrine/Migrations/Tools/Console/Exception/VersionDoesNotExist.php @@ -6,11 +6,12 @@ use Doctrine\Migrations\Version\Version; use InvalidArgumentException; + use function sprintf; final class VersionDoesNotExist extends InvalidArgumentException implements ConsoleException { - public static function new(Version $version) : self + public static function new(Version $version): self { return new self(sprintf('The version "%s" does not exist in the version table.', $version->getVersion())); } diff --git a/lib/Doctrine/Migrations/Tools/Console/Helper/ConfigurationHelper.php b/lib/Doctrine/Migrations/Tools/Console/Helper/ConfigurationHelper.php index 4e3b096c56..abb90e86b8 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Helper/ConfigurationHelper.php +++ b/lib/Doctrine/Migrations/Tools/Console/Helper/ConfigurationHelper.php @@ -13,6 +13,7 @@ use Doctrine\Migrations\Tools\Console\Exception\FileTypeNotSupported; use Symfony\Component\Console\Helper\Helper; use Symfony\Component\Console\Input\InputInterface; + use function assert; use function file_exists; use function is_string; @@ -38,7 +39,7 @@ public function __construct( $this->configuration = $configuration; } - public function getMigrationConfig(InputInterface $input) : Configuration + public function getMigrationConfig(InputInterface $input): Configuration { /** * If a configuration option is passed to the command line, use that configuration @@ -79,7 +80,7 @@ public function getMigrationConfig(InputInterface $input) : Configuration return new Configuration($this->connection); } - private function configExists(string $config) : bool + private function configExists(string $config): bool { return file_exists($config); } @@ -87,7 +88,7 @@ private function configExists(string $config) : bool /** * @throws FileTypeNotSupported */ - private function loadConfig(string $config) : Configuration + private function loadConfig(string $config): Configuration { $map = [ 'xml' => XmlConfiguration::class, @@ -111,10 +112,7 @@ private function loadConfig(string $config) : Configuration return $configuration; } - /** - * {@inheritdoc} - */ - public function getName() : string + public function getName(): string { return 'configuration'; } diff --git a/lib/Doctrine/Migrations/Tools/Console/Helper/ConfigurationHelperInterface.php b/lib/Doctrine/Migrations/Tools/Console/Helper/ConfigurationHelperInterface.php index 38386b4de9..0b3a0b33f0 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Helper/ConfigurationHelperInterface.php +++ b/lib/Doctrine/Migrations/Tools/Console/Helper/ConfigurationHelperInterface.php @@ -14,5 +14,5 @@ interface ConfigurationHelperInterface { public function getMigrationConfig( InputInterface $input - ) : Configuration; + ): Configuration; } diff --git a/lib/Doctrine/Migrations/Tools/Console/Helper/MigrationDirectoryHelper.php b/lib/Doctrine/Migrations/Tools/Console/Helper/MigrationDirectoryHelper.php index d3a01ccf5c..a1a6301934 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Helper/MigrationDirectoryHelper.php +++ b/lib/Doctrine/Migrations/Tools/Console/Helper/MigrationDirectoryHelper.php @@ -6,7 +6,7 @@ use Doctrine\Migrations\Configuration\Configuration; use Doctrine\Migrations\Tools\Console\Exception\DirectoryDoesNotExist; -use const DIRECTORY_SEPARATOR; + use function assert; use function date; use function file_exists; @@ -14,6 +14,8 @@ use function mkdir; use function rtrim; +use const DIRECTORY_SEPARATOR; + /** * The MigrationDirectoryHelper class is responsible for returning the directory that migrations are stored in. * @@ -32,7 +34,7 @@ public function __construct(Configuration $configuration) /** * @throws DirectoryDoesNotExist */ - public function getMigrationDirectory() : string + public function getMigrationDirectory(): string { $dir = $this->configuration->getMigrationsDirectory(); $dir = $dir ?? getcwd(); @@ -58,12 +60,12 @@ public function getMigrationDirectory() : string return $dir; } - private function appendDir(string $dir) : string + private function appendDir(string $dir): string { return DIRECTORY_SEPARATOR . $dir; } - private function createDirIfNotExists(string $dir) : void + private function createDirIfNotExists(string $dir): void { if (file_exists($dir)) { return; diff --git a/lib/Doctrine/Migrations/Tools/Console/Helper/MigrationStatusInfosHelper.php b/lib/Doctrine/Migrations/Tools/Console/Helper/MigrationStatusInfosHelper.php index 4b28c911ea..742db7648c 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Helper/MigrationStatusInfosHelper.php +++ b/lib/Doctrine/Migrations/Tools/Console/Helper/MigrationStatusInfosHelper.php @@ -7,6 +7,7 @@ use Doctrine\Migrations\Configuration\AbstractFileConfiguration; use Doctrine\Migrations\Configuration\Configuration; use Doctrine\Migrations\MigrationRepository; + use function count; use function sprintf; @@ -35,7 +36,7 @@ public function __construct( } /** @return string[]|int[]|null[] */ - public function getMigrationsInfos() : array + public function getMigrationsInfos(): array { $executedMigrations = $this->migrationRepository->getMigratedVersions(); $availableMigrations = $this->migrationRepository->getAvailableVersions(); @@ -63,7 +64,7 @@ public function getMigrationsInfos() : array ]; } - private function getFormattedVersionAlias(string $alias) : string + private function getFormattedVersionAlias(string $alias): string { $version = $this->configuration->resolveVersionAlias($alias); diff --git a/lib/Doctrine/Migrations/Tracking/TableDefinition.php b/lib/Doctrine/Migrations/Tracking/TableDefinition.php index 58724dcde6..2a221c561d 100644 --- a/lib/Doctrine/Migrations/Tracking/TableDefinition.php +++ b/lib/Doctrine/Migrations/Tracking/TableDefinition.php @@ -49,27 +49,27 @@ public function __construct( $this->executedAtColumnName = $executedAtColumnName; } - public function getName() : string + public function getName(): string { return $this->name; } - public function getColumnName() : string + public function getColumnName(): string { return $this->columnName; } - public function getColumnLength() : int + public function getColumnLength(): int { return $this->columnLength; } - public function getExecutedAtColumnName() : string + public function getExecutedAtColumnName(): string { return $this->executedAtColumnName; } - public function getMigrationsColumn() : Column + public function getMigrationsColumn(): Column { return new Column( $this->columnName, @@ -78,7 +78,7 @@ public function getMigrationsColumn() : Column ); } - public function getExecutedAtColumn() : Column + public function getExecutedAtColumn(): Column { return new Column( $this->executedAtColumnName, @@ -89,7 +89,7 @@ public function getExecutedAtColumn() : Column /** * @return string[] */ - public function getColumnNames() : array + public function getColumnNames(): array { return [ $this->columnName, @@ -97,7 +97,7 @@ public function getColumnNames() : array ]; } - public function getDBALTable() : Table + public function getDBALTable(): Table { $executedAtColumn = $this->getExecutedAtColumn(); $executedAtColumn->setNotnull(false); @@ -110,7 +110,7 @@ public function getDBALTable() : Table return $this->createDBALTable($columns); } - public function getNewDBALTable() : Table + public function getNewDBALTable(): Table { $executedAtColumn = $this->getExecutedAtColumn(); $executedAtColumn->setNotnull(true); @@ -126,7 +126,7 @@ public function getNewDBALTable() : Table /** * @param Column[] $columns */ - public function createDBALTable(array $columns) : Table + public function createDBALTable(array $columns): Table { $schemaConfig = $this->schemaManager->createSchemaConfig(); diff --git a/lib/Doctrine/Migrations/Tracking/TableManipulator.php b/lib/Doctrine/Migrations/Tracking/TableManipulator.php index 6dbbde1e8c..b24c267b36 100644 --- a/lib/Doctrine/Migrations/Tracking/TableManipulator.php +++ b/lib/Doctrine/Migrations/Tracking/TableManipulator.php @@ -44,7 +44,7 @@ public function __construct( $this->migrationTableUpdater = $migrationTableUpdater; } - public function createMigrationTable() : bool + public function createMigrationTable(): bool { $this->configuration->validate(); diff --git a/lib/Doctrine/Migrations/Tracking/TableStatus.php b/lib/Doctrine/Migrations/Tracking/TableStatus.php index a3b781de4f..a6235df2b5 100644 --- a/lib/Doctrine/Migrations/Tracking/TableStatus.php +++ b/lib/Doctrine/Migrations/Tracking/TableStatus.php @@ -33,12 +33,12 @@ public function __construct( $this->migrationTable = $migrationTable; } - public function setCreated(bool $created) : void + public function setCreated(bool $created): void { $this->created = $created; } - public function isCreated() : bool + public function isCreated(): bool { if ($this->created !== null) { return $this->created; @@ -49,12 +49,12 @@ public function isCreated() : bool return $this->created; } - public function setUpToDate(bool $upToDate) : void + public function setUpToDate(bool $upToDate): void { $this->upToDate = $upToDate; } - public function isUpToDate() : bool + public function isUpToDate(): bool { if ($this->upToDate !== null) { return $this->upToDate; diff --git a/lib/Doctrine/Migrations/Tracking/TableUpdater.php b/lib/Doctrine/Migrations/Tracking/TableUpdater.php index 66693acdf2..9911c24162 100644 --- a/lib/Doctrine/Migrations/Tracking/TableUpdater.php +++ b/lib/Doctrine/Migrations/Tracking/TableUpdater.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; use Throwable; + use function in_array; /** @@ -43,7 +44,7 @@ public function __construct( $this->platform = $platform; } - public function updateMigrationTable() : void + public function updateMigrationTable(): void { $fromTable = $this->getFromTable(); $toTable = $this->migrationTable->getDBALTable(); @@ -71,12 +72,12 @@ public function updateMigrationTable() : void /** * @param Table[] $tables */ - protected function createSchema(array $tables) : Schema + protected function createSchema(array $tables): Schema { return new Schema($tables); } - private function getFromTable() : Table + private function getFromTable(): Table { $tableName = $this->migrationTable->getName(); $columnNames = $this->migrationTable->getColumnNames(); diff --git a/lib/Doctrine/Migrations/Version/AliasResolver.php b/lib/Doctrine/Migrations/Version/AliasResolver.php index e48416198d..a1443218b1 100644 --- a/lib/Doctrine/Migrations/Version/AliasResolver.php +++ b/lib/Doctrine/Migrations/Version/AliasResolver.php @@ -5,6 +5,7 @@ namespace Doctrine\Migrations\Version; use Doctrine\Migrations\MigrationRepository; + use function substr; /** @@ -41,7 +42,7 @@ public function __construct(MigrationRepository $migrationRepository) * * If an existing version number is specified, it is returned verbatimly. */ - public function resolveVersionAlias(string $alias) : ?string + public function resolveVersionAlias(string $alias): ?string { if ($this->migrationRepository->hasVersion($alias)) { return $alias; @@ -50,14 +51,19 @@ public function resolveVersionAlias(string $alias) : ?string switch ($alias) { case self::ALIAS_FIRST: return '0'; + case self::ALIAS_CURRENT: return $this->migrationRepository->getCurrentVersion(); + case self::ALIAS_PREV: return $this->migrationRepository->getPrevVersion(); + case self::ALIAS_NEXT: return $this->migrationRepository->getNextVersion(); + case self::ALIAS_LATEST: return $this->migrationRepository->getLatestVersion(); + default: if (substr($alias, 0, 7) === self::ALIAS_CURRENT) { return $this->migrationRepository->getDeltaVersion(substr($alias, 7)); diff --git a/lib/Doctrine/Migrations/Version/ExecutionResult.php b/lib/Doctrine/Migrations/Version/ExecutionResult.php index ff934722d4..2d5d102e1d 100644 --- a/lib/Doctrine/Migrations/Version/ExecutionResult.php +++ b/lib/Doctrine/Migrations/Version/ExecutionResult.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Schema; use RuntimeException; use Throwable; + use function count; /** @@ -55,7 +56,7 @@ public function __construct(array $sql = [], array $params = [], array $types = $this->types = $types; } - public function hasSql() : bool + public function hasSql(): bool { return count($this->sql) !== 0; } @@ -63,7 +64,7 @@ public function hasSql() : bool /** * @return string[] */ - public function getSql() : array + public function getSql(): array { return $this->sql; } @@ -71,7 +72,7 @@ public function getSql() : array /** * @param string[] $sql */ - public function setSql(array $sql) : void + public function setSql(array $sql): void { $this->sql = $sql; } @@ -79,7 +80,7 @@ public function setSql(array $sql) : void /** * @return mixed[] */ - public function getParams() : array + public function getParams(): array { return $this->params; } @@ -87,7 +88,7 @@ public function getParams() : array /** * @param mixed[] $params */ - public function setParams(array $params) : void + public function setParams(array $params): void { $this->params = $params; } @@ -95,7 +96,7 @@ public function setParams(array $params) : void /** * @return mixed[] */ - public function getTypes() : array + public function getTypes(): array { return $this->types; } @@ -103,67 +104,67 @@ public function getTypes() : array /** * @param mixed[] $types */ - public function setTypes(array $types) : void + public function setTypes(array $types): void { $this->types = $types; } - public function getTime() : ?float + public function getTime(): ?float { return $this->time; } - public function setTime(float $time) : void + public function setTime(float $time): void { $this->time = $time; } - public function getMemory() : ?float + public function getMemory(): ?float { return $this->memory; } - public function setMemory(float $memory) : void + public function setMemory(float $memory): void { $this->memory = $memory; } - public function setSkipped(bool $skipped) : void + public function setSkipped(bool $skipped): void { $this->skipped = $skipped; } - public function isSkipped() : bool + public function isSkipped(): bool { return $this->skipped; } - public function setError(bool $error) : void + public function setError(bool $error): void { $this->error = $error; } - public function hasError() : bool + public function hasError(): bool { return $this->error; } - public function setException(Throwable $exception) : void + public function setException(Throwable $exception): void { $this->exception = $exception; } - public function getException() : ?Throwable + public function getException(): ?Throwable { return $this->exception; } - public function setToSchema(Schema $toSchema) : void + public function setToSchema(Schema $toSchema): void { $this->toSchema = $toSchema; } - public function getToSchema() : Schema + public function getToSchema(): Schema { if ($this->toSchema === null) { throw new RuntimeException('Cannot call getToSchema() when toSchema is null.'); diff --git a/lib/Doctrine/Migrations/Version/Executor.php b/lib/Doctrine/Migrations/Version/Executor.php index 18f3265eed..3477ac1485 100644 --- a/lib/Doctrine/Migrations/Version/Executor.php +++ b/lib/Doctrine/Migrations/Version/Executor.php @@ -17,6 +17,7 @@ use Doctrine\Migrations\Stopwatch; use Doctrine\Migrations\Tools\BytesFormatter; use Throwable; + use function count; use function rtrim; use function sprintf; @@ -75,7 +76,7 @@ public function __construct( /** * @return string[] */ - public function getSql() : array + public function getSql(): array { return $this->sql; } @@ -83,7 +84,7 @@ public function getSql() : array /** * @return mixed[] */ - public function getParams() : array + public function getParams(): array { return $this->params; } @@ -91,7 +92,7 @@ public function getParams() : array /** * @return mixed[] */ - public function getTypes() : array + public function getTypes(): array { return $this->types; } @@ -100,7 +101,7 @@ public function getTypes() : array * @param mixed[] $params * @param mixed[] $types */ - public function addSql(string $sql, array $params = [], array $types = []) : void + public function addSql(string $sql, array $params = [], array $types = []): void { $this->sql[] = $sql; @@ -116,7 +117,7 @@ public function execute( AbstractMigration $migration, string $direction, ?MigratorConfiguration $migratorConfiguration = null - ) : ExecutionResult { + ): ExecutionResult { $migratorConfiguration = $migratorConfiguration ?? new MigratorConfiguration(); $versionExecutionResult = new ExecutionResult(); @@ -162,7 +163,7 @@ private function startMigration( AbstractMigration $migration, string $direction, MigratorConfiguration $migratorConfiguration - ) : void { + ): void { $this->sql = []; $this->params = []; $this->types = []; @@ -188,7 +189,7 @@ private function executeMigration( ExecutionResult $versionExecutionResult, string $direction, MigratorConfiguration $migratorConfiguration - ) : ExecutionResult { + ): ExecutionResult { $stopwatchEvent = $this->stopwatch->start('execute'); $version->setState(State::PRE); @@ -236,7 +237,7 @@ private function executeMigration( $stopwatchEvent->stop(); $periods = $stopwatchEvent->getPeriods(); - $lastPeriod = $periods[count($periods) -1]; + $lastPeriod = $periods[count($periods) - 1]; $versionExecutionResult->setTime($lastPeriod->getDuration()); $versionExecutionResult->setMemory($lastPeriod->getMemory()); @@ -272,7 +273,7 @@ private function executeMigration( return $versionExecutionResult; } - private function getMigrationHeader(Version $version, AbstractMigration $migration, string $direction) : string + private function getMigrationHeader(Version $version, AbstractMigration $migration, string $direction): string { $versionInfo = $version->getVersion(); $description = $migration->getDescription(); @@ -294,7 +295,7 @@ private function skipMigration( AbstractMigration $migration, string $direction, MigratorConfiguration $migratorConfiguration - ) : void { + ): void { if ($migration->isTransactional()) { //only rollback transaction if in transactional mode $this->connection->rollBack(); @@ -319,7 +320,7 @@ private function skipMigration( /** * @throws Throwable */ - private function migrationError(Throwable $e, Version $version, AbstractMigration $migration) : void + private function migrationError(Throwable $e, Version $version, AbstractMigration $migration): void { $this->outputWriter->write(sprintf( 'Migration %s failed during %s. Error %s', @@ -339,7 +340,7 @@ private function migrationError(Throwable $e, Version $version, AbstractMigratio private function executeVersionExecutionResult( Version $version, MigratorConfiguration $migratorConfiguration - ) : void { + ): void { foreach ($this->sql as $key => $query) { $stopwatchEvent = $this->stopwatch->start('query'); @@ -366,14 +367,14 @@ private function executeVersionExecutionResult( * @param mixed[]|int $params * @param mixed[]|int $types */ - private function addQueryParams($params, $types) : void + private function addQueryParams($params, $types): void { $index = count($this->sql) - 1; $this->params[$index] = $params; $this->types[$index] = $types; } - private function outputSqlQuery(int $idx, string $query) : void + private function outputSqlQuery(int $idx, string $query): void { $params = $this->parameterFormatter->formatParameters( $this->params[$idx] ?? [], @@ -387,7 +388,7 @@ private function outputSqlQuery(int $idx, string $query) : void ))); } - private function getFromSchema(MigratorConfiguration $migratorConfiguration) : Schema + private function getFromSchema(MigratorConfiguration $migratorConfiguration): Schema { // if we're in a dry run, use the from Schema instead of reading the schema from the database if ($migratorConfiguration->isDryRun() && $migratorConfiguration->getFromSchema() !== null) { diff --git a/lib/Doctrine/Migrations/Version/ExecutorInterface.php b/lib/Doctrine/Migrations/Version/ExecutorInterface.php index 5d132566ad..668276de23 100644 --- a/lib/Doctrine/Migrations/Version/ExecutorInterface.php +++ b/lib/Doctrine/Migrations/Version/ExecutorInterface.php @@ -18,12 +18,12 @@ interface ExecutorInterface * @param mixed[] $params * @param mixed[] $types */ - public function addSql(string $sql, array $params = [], array $types = []) : void; + public function addSql(string $sql, array $params = [], array $types = []): void; public function execute( Version $version, AbstractMigration $migration, string $direction, ?MigratorConfiguration $migratorConfiguration = null - ) : ExecutionResult; + ): ExecutionResult; } diff --git a/lib/Doctrine/Migrations/Version/Factory.php b/lib/Doctrine/Migrations/Version/Factory.php index 9e25c09313..e08e087ab5 100644 --- a/lib/Doctrine/Migrations/Version/Factory.php +++ b/lib/Doctrine/Migrations/Version/Factory.php @@ -26,7 +26,7 @@ public function __construct(Configuration $configuration, ExecutorInterface $ver $this->versionExecutor = $versionExecutor; } - public function createVersion(string $version, string $migrationClassName) : Version + public function createVersion(string $version, string $migrationClassName): Version { return new Version( $this->configuration, diff --git a/lib/Doctrine/Migrations/Version/Version.php b/lib/Doctrine/Migrations/Version/Version.php index 160bf81125..f90e64d63b 100644 --- a/lib/Doctrine/Migrations/Version/Version.php +++ b/lib/Doctrine/Migrations/Version/Version.php @@ -14,6 +14,7 @@ use Doctrine\Migrations\MigratorConfiguration; use Doctrine\Migrations\OutputWriter; use Doctrine\Migrations\Tracking\TableDefinition; + use function assert; use function count; use function date_default_timezone_get; @@ -67,17 +68,17 @@ public function __construct( $this->versionExecutor = $versionExecutor; } - public function __toString() : string + public function __toString(): string { return $this->version; } - public function getVersion() : string + public function getVersion(): string { return $this->version; } - public function getDateTime() : string + public function getDateTime(): string { $datetime = str_replace('Version', '', $this->version); $datetime = DateTimeImmutable::createFromFormat('YmdHis', $datetime); @@ -89,22 +90,22 @@ public function getDateTime() : string return $datetime->format('Y-m-d H:i:s'); } - public function getConfiguration() : Configuration + public function getConfiguration(): Configuration { return $this->configuration; } - public function getMigration() : AbstractMigration + public function getMigration(): AbstractMigration { return $this->migration; } - public function isMigrated() : bool + public function isMigrated(): bool { return $this->configuration->hasVersionMigrated($this); } - public function getExecutedAt() : ?DateTimeImmutable + public function getExecutedAt(): ?DateTimeImmutable { $versionData = $this->configuration->getVersionData($this); $executedAtColumnName = $this->configuration->getMigrationsExecutedAtColumnName(); @@ -117,22 +118,25 @@ public function getExecutedAt() : ?DateTimeImmutable ->setTimezone(new DateTimeZone(date_default_timezone_get())); } - public function setState(int $state) : void + public function setState(int $state): void { assert(in_array($state, State::STATES, true)); $this->state = $state; } - public function getExecutionState() : string + public function getExecutionState(): string { switch ($this->state) { case State::PRE: return 'Pre-Checks'; + case State::POST: return 'Post-Checks'; + case State::EXEC: return 'Execution'; + default: return 'No State'; } @@ -142,7 +146,7 @@ public function getExecutionState() : string * @param mixed[] $params * @param mixed[] $types */ - public function addSql(string $sql, array $params = [], array $types = []) : void + public function addSql(string $sql, array $params = [], array $types = []): void { $this->versionExecutor->addSql($sql, $params, $types); } @@ -150,7 +154,7 @@ public function addSql(string $sql, array $params = [], array $types = []) : voi public function writeSqlFile( string $path, string $direction = Direction::UP - ) : bool { + ): bool { $versionExecutionResult = $this->execute( $direction, $this->getWriteSqlFileMigratorConfig() @@ -176,7 +180,7 @@ public function writeSqlFile( public function execute( string $direction, ?MigratorConfiguration $migratorConfiguration = null - ) : ExecutionResult { + ): ExecutionResult { return $this->versionExecutor->execute( $this, $this->migration, @@ -185,17 +189,17 @@ public function execute( ); } - public function markMigrated() : void + public function markMigrated(): void { $this->markVersion(Direction::UP); } - public function markNotMigrated() : void + public function markNotMigrated(): void { $this->markVersion(Direction::DOWN); } - public function markVersion(string $direction) : void + public function markVersion(string $direction): void { $this->configuration->createMigrationTable(); @@ -225,12 +229,12 @@ public function markVersion(string $direction) : void ); } - private function getWriteSqlFileMigratorConfig() : MigratorConfiguration + private function getWriteSqlFileMigratorConfig(): MigratorConfiguration { return (new MigratorConfiguration())->setDryRun(true); } - private function getExecutedAtDatabaseValue() : string + private function getExecutedAtDatabaseValue(): string { return Type::getType(TableDefinition::MIGRATION_EXECUTED_AT_COLUMN_TYPE)->convertToDatabaseValue( (new DateTimeImmutable('now'))->setTimezone(new DateTimeZone('UTC')), diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 4ea840a08c..cfd4f7652a 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -13,7 +13,16 @@ lib tests - + + + + + + + + + + lib/Doctrine/Migrations/FileQueryWriter.php diff --git a/tests/Doctrine/Migrations/Tests/AbstractMigrationTest.php b/tests/Doctrine/Migrations/Tests/AbstractMigrationTest.php index a3bbafc375..71932797e6 100644 --- a/tests/Doctrine/Migrations/Tests/AbstractMigrationTest.php +++ b/tests/Doctrine/Migrations/Tests/AbstractMigrationTest.php @@ -13,6 +13,7 @@ use Doctrine\Migrations\Tests\Stub\VersionDummy; use Doctrine\Migrations\Version\ExecutorInterface; use Doctrine\Migrations\Version\Version; + use function sys_get_temp_dir; class AbstractMigrationTest extends MigrationTestCase @@ -29,7 +30,7 @@ class AbstractMigrationTest extends MigrationTestCase /** @var OutputWriter */ private $outputWriter; - protected function setUp() : void + protected function setUp(): void { $this->outputWriter = $this->getOutputWriter(); @@ -49,36 +50,36 @@ protected function setUp() : void $this->migration = new AbstractMigrationStub($this->version); } - public function testGetDescriptionReturnsEmptyString() : void + public function testGetDescriptionReturnsEmptyString(): void { self::assertSame('', $this->migration->getDescription()); } - public function testWarnIfOutputMessage() : void + public function testWarnIfOutputMessage(): void { $this->migration->warnIf(true, 'Warning was thrown'); self::assertStringContainsString('Warning during No State: Warning was thrown', $this->getOutputStreamContent($this->output)); } - public function testWarnIfAddDefaultMessage() : void + public function testWarnIfAddDefaultMessage(): void { $this->migration->warnIf(true); self::assertStringContainsString('Warning during No State: Unknown Reason', $this->getOutputStreamContent($this->output)); } - public function testWarnIfDontOutputMessageIfFalse() : void + public function testWarnIfDontOutputMessageIfFalse(): void { $this->migration->warnIf(false, 'trallala'); self::assertSame('', $this->getOutputStreamContent($this->output)); } - public function testWriteInvokesOutputWriter() : void + public function testWriteInvokesOutputWriter(): void { $this->migration->exposedWrite('Message'); self::assertStringContainsString('Message', $this->getOutputStreamContent($this->output)); } - public function testAbortIfThrowsException() : void + public function testAbortIfThrowsException(): void { $this->expectException(AbortMigration::class); $this->expectExceptionMessage('Something failed'); @@ -86,13 +87,13 @@ public function testAbortIfThrowsException() : void $this->migration->abortIf(true, 'Something failed'); } - public function testAbortIfDontThrowsException() : void + public function testAbortIfDontThrowsException(): void { $this->migration->abortIf(false, 'Something failed'); $this->addToAssertionCount(1); } - public function testAbortIfThrowsExceptionEvenWithoutMessage() : void + public function testAbortIfThrowsExceptionEvenWithoutMessage(): void { $this->expectException(AbortMigration::class); $this->expectExceptionMessage('Unknown Reason'); @@ -100,7 +101,7 @@ public function testAbortIfThrowsExceptionEvenWithoutMessage() : void $this->migration->abortIf(true); } - public function testSkipIfThrowsException() : void + public function testSkipIfThrowsException(): void { $this->expectException(SkipMigration::class); $this->expectExceptionMessage('Something skipped'); @@ -108,13 +109,13 @@ public function testSkipIfThrowsException() : void $this->migration->skipIf(true, 'Something skipped'); } - public function testSkipIfDontThrowsException() : void + public function testSkipIfDontThrowsException(): void { $this->migration->skipIf(false, 'Something skipped'); $this->addToAssertionCount(1); } - public function testThrowIrreversibleMigrationException() : void + public function testThrowIrreversibleMigrationException(): void { $this->expectException(IrreversibleMigration::class); $this->expectExceptionMessage('Irreversible migration'); @@ -122,7 +123,7 @@ public function testThrowIrreversibleMigrationException() : void $this->migration->exposedThrowIrreversibleMigrationException('Irreversible migration'); } - public function testThrowIrreversibleMigrationExceptionWithoutMessage() : void + public function testThrowIrreversibleMigrationExceptionWithoutMessage(): void { $this->expectException(IrreversibleMigration::class); $this->expectExceptionMessage('This migration is irreversible and cannot be reverted.'); @@ -130,7 +131,7 @@ public function testThrowIrreversibleMigrationExceptionWithoutMessage() : void $this->migration->exposedThrowIrreversibleMigrationException(); } - public function testIstransactional() : void + public function testIstransactional(): void { self::assertTrue($this->migration->isTransactional()); } diff --git a/tests/Doctrine/Migrations/Tests/BoxPharCompileTest.php b/tests/Doctrine/Migrations/Tests/BoxPharCompileTest.php index 05c3634b6f..af83feac26 100644 --- a/tests/Doctrine/Migrations/Tests/BoxPharCompileTest.php +++ b/tests/Doctrine/Migrations/Tests/BoxPharCompileTest.php @@ -6,18 +6,20 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Process\Process; -use const PHP_VERSION_ID; + use function assert; use function file_exists; use function realpath; use function sprintf; +use const PHP_VERSION_ID; + /** * @requires OS Linux|Darwin */ class BoxPharCompileTest extends TestCase { - public function testCompile() : void + public function testCompile(): void { if (PHP_VERSION_ID < 70200) { self::markTestSkipped('https://github.com/box-project/box/issues/489'); @@ -50,7 +52,7 @@ public function testCompile() : void $process = new Process(['php', $doctrinePharPath]); - $process->start(static function ($type) use (&$successful) : void { + $process->start(static function ($type) use (&$successful): void { if ($type !== 'err') { return; } diff --git a/tests/Doctrine/Migrations/Tests/Configuration/AbstractConfigurationTest.php b/tests/Doctrine/Migrations/Tests/Configuration/AbstractConfigurationTest.php index 4fbd9c4cc6..95d1979126 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/AbstractConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/AbstractConfigurationTest.php @@ -13,6 +13,9 @@ use Doctrine\Migrations\Tests\MigrationTestCase; use InvalidArgumentException; use ReflectionProperty; + +use function assert; + use const DIRECTORY_SEPARATOR; abstract class AbstractConfigurationTest extends MigrationTestCase @@ -21,69 +24,69 @@ abstract public function loadConfiguration( string $configFileSuffix = '', ?OutputWriter $outputWriter = null, ?MigrationFinder $migrationFinder = null - ) : AbstractFileConfiguration; + ): AbstractFileConfiguration; - public function testMigrationDirectory() : void + public function testMigrationDirectory(): void { $config = $this->loadConfiguration(); self::assertSame(__DIR__ . DIRECTORY_SEPARATOR . '_files', $config->getMigrationsDirectory()); } - public function testMigrationNamespace() : void + public function testMigrationNamespace(): void { $config = $this->loadConfiguration(); self::assertSame('DoctrineMigrationsTest', $config->getMigrationsNamespace()); } - public function testMigrationName() : void + public function testMigrationName(): void { $config = $this->loadConfiguration(); self::assertSame('Doctrine Sandbox Migrations', $config->getName()); } - public function testMigrationsTable() : void + public function testMigrationsTable(): void { $config = $this->loadConfiguration(); self::assertSame('doctrine_migration_versions_test', $config->getMigrationsTableName()); } - public function testMigrationsColumnName() : void + public function testMigrationsColumnName(): void { $config = $this->loadConfiguration(); self::assertSame('doctrine_migration_column_test', $config->getMigrationsColumnName()); } - public function testMigrationsColumnLength() : void + public function testMigrationsColumnLength(): void { $config = $this->loadConfiguration(); self::assertSame(200, $config->getMigrationsColumnLength()); } - public function testAllOrNothing() : void + public function testAllOrNothing(): void { $config = $this->loadConfiguration(); self::assertTrue($config->isAllOrNothing()); } - public function testMigrationsExecutedAtColumnName() : void + public function testMigrationsExecutedAtColumnName(): void { $config = $this->loadConfiguration(); self::assertSame('doctrine_migration_executed_at_column_test', $config->getMigrationsExecutedAtColumnName()); } - public function testFinderIsIncompatibleWithConfiguration() : void + public function testFinderIsIncompatibleWithConfiguration(): void { $this->expectException(MigrationException::class); $this->loadConfiguration('organize_by_year', null, new GlobFinder()); } - public function testSetMigrationFinder() : void + public function testSetMigrationFinder(): void { $migrationFinderProphecy = $this->prophesize(MigrationFinder::class); - /** @var MigrationFinder $migrationFinder */ - $migrationFinder = $migrationFinderProphecy->reveal(); + $migrationFinder = $migrationFinderProphecy->reveal(); + assert($migrationFinder instanceof MigrationFinder); $config = $this->loadConfiguration(); $config->setMigrationsFinder($migrationFinder); @@ -96,49 +99,49 @@ public function testSetMigrationFinder() : void self::assertSame($migrationFinder, $migrationFinderPropertyReflected->getValue($config)); } - public function testThrowExceptionIfAlreadyLoaded() : void + public function testThrowExceptionIfAlreadyLoaded(): void { $config = $this->loadConfiguration(); $this->expectException(MigrationException::class); $config->load($config->getFile()); } - public function testVersionsOrganizationNoConfig() : void + public function testVersionsOrganizationNoConfig(): void { $config = $this->loadConfiguration(); self::assertFalse($config->areMigrationsOrganizedByYear()); self::assertFalse($config->areMigrationsOrganizedByYearAndMonth()); } - public function testVersionsOrganizationByYear() : void + public function testVersionsOrganizationByYear(): void { $config = $this->loadConfiguration('organize_by_year'); self::assertTrue($config->areMigrationsOrganizedByYear()); self::assertFalse($config->areMigrationsOrganizedByYearAndMonth()); } - public function testVersionsOrganizationByYearAndMonth() : void + public function testVersionsOrganizationByYearAndMonth(): void { $config = $this->loadConfiguration('organize_by_year_and_month'); self::assertTrue($config->areMigrationsOrganizedByYear()); self::assertTrue($config->areMigrationsOrganizedByYearAndMonth()); } - public function testVersionsOrganizationInvalid() : void + public function testVersionsOrganizationInvalid(): void { $this->expectException(MigrationException::class); $this->loadConfiguration('organize_invalid'); } - public function testCustomTemplate() : void + public function testCustomTemplate(): void { $config = $this->loadConfiguration('custom_template'); self::assertSame('template.tpl', $config->getCustomTemplate()); } - public function testVersionsOrganizationIncompatibleFinder() : void + public function testVersionsOrganizationIncompatibleFinder(): void { $this->expectException(MigrationException::class); @@ -146,7 +149,7 @@ public function testVersionsOrganizationIncompatibleFinder() : void $config->setMigrationsFinder(new GlobFinder()); } - public function testConfigurationWithInvalidOption() : void + public function testConfigurationWithInvalidOption(): void { $this->expectException(MigrationException::class); $this->expectExceptionCode(10); @@ -154,14 +157,14 @@ public function testConfigurationWithInvalidOption() : void $this->loadConfiguration('invalid'); } - public function testConfigurationFileNotExists() : void + public function testConfigurationFileNotExists(): void { $this->expectException(InvalidArgumentException::class); $this->loadConfiguration('file_not_exists'); } - public function testLoadMigrationsList() : void + public function testLoadMigrationsList(): void { $configuration1 = $this->loadConfiguration('migrations_list'); @@ -175,7 +178,7 @@ public function testLoadMigrationsList() : void /** * @dataProvider getConfigWithKeysInVariousOrder */ - public function testThatTheOrderOfConfigKeysDoesNotMatter(string $file) : void + public function testThatTheOrderOfConfigKeysDoesNotMatter(string $file): void { $configuration = $this->loadConfiguration($file); @@ -183,7 +186,7 @@ public function testThatTheOrderOfConfigKeysDoesNotMatter(string $file) : void } /** @return string[][] */ - public function getConfigWithKeysInVariousOrder() : array + public function getConfigWithKeysInVariousOrder(): array { return [ ['order_1'], diff --git a/tests/Doctrine/Migrations/Tests/Configuration/AbstractFileConfigurationTest.php b/tests/Doctrine/Migrations/Tests/Configuration/AbstractFileConfigurationTest.php index bc6d733cc4..26ebb3d6a4 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/AbstractFileConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/AbstractFileConfigurationTest.php @@ -8,6 +8,7 @@ use Doctrine\Migrations\Configuration\AbstractFileConfiguration; use Doctrine\Migrations\Configuration\Exception\InvalidConfigurationKey; use PHPUnit\Framework\TestCase; + use function assert; use function basename; use function chdir; @@ -21,7 +22,7 @@ class AbstractFileConfigurationTest extends TestCase /** @var TestAbstractFileConfiguration */ private $fileConfiguration; - public function testLoadChecksCurrentWorkingDirectory() : void + public function testLoadChecksCurrentWorkingDirectory(): void { $cwd = getcwd(); @@ -38,7 +39,7 @@ public function testLoadChecksCurrentWorkingDirectory() : void chdir($cwd); } - public function testSetConfiguration() : void + public function testSetConfiguration(): void { $fileConfiguration = $this->createPartialMock(TestAbstractFileConfiguration::class, [ 'setMigrationsNamespace', @@ -128,7 +129,7 @@ public function testSetConfiguration() : void ]); } - public function testSetConfigurationThrowsInvalidConfigurationKey() : void + public function testSetConfigurationThrowsInvalidConfigurationKey(): void { $this->expectException(InvalidConfigurationKey::class); $this->expectExceptionMessage('Migrations configuration key "unknown" does not exist.'); @@ -136,7 +137,7 @@ public function testSetConfigurationThrowsInvalidConfigurationKey() : void $this->fileConfiguration->setTestConfiguration(['unknown' => 'value']); } - protected function setUp() : void + protected function setUp(): void { $this->connection = $this->createMock(Connection::class); @@ -149,12 +150,12 @@ class TestAbstractFileConfiguration extends AbstractFileConfiguration /** * @param mixed[] $config */ - public function setTestConfiguration(array $config) : void + public function setTestConfiguration(array $config): void { $this->setConfiguration($config); } - protected function doLoad(string $file) : void + protected function doLoad(string $file): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Configuration/ArrayConfigurationTest.php b/tests/Doctrine/Migrations/Tests/Configuration/ArrayConfigurationTest.php index 8924682614..ce7ffe5668 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/ArrayConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/ArrayConfigurationTest.php @@ -9,6 +9,7 @@ use Doctrine\Migrations\Finder\MigrationFinder; use Doctrine\Migrations\OutputWriter; use InvalidArgumentException; + use const DIRECTORY_SEPARATOR; class ArrayConfigurationTest extends AbstractConfigurationTest @@ -17,7 +18,7 @@ public function loadConfiguration( string $configFileSuffix = '', ?OutputWriter $outputWriter = null, ?MigrationFinder $migrationFinder = null - ) : AbstractFileConfiguration { + ): AbstractFileConfiguration { $configFile = 'config.php'; if ($configFileSuffix !== '') { @@ -33,7 +34,7 @@ public function loadConfiguration( /** * Test that config file not exists exception */ - public function testThrowExceptionIfFileNotExist() : void + public function testThrowExceptionIfFileNotExist(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Given config file does not exist'); diff --git a/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php b/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php index d7c5766b6f..31ea179088 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php @@ -23,15 +23,18 @@ use Doctrine\Migrations\Version\Version; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Stopwatch\Stopwatch as SymfonyStopwatch; + use function array_keys; +use function assert; use function call_user_func_array; use function class_exists; +use function is_callable; use function sprintf; use function str_replace; class ConfigurationTest extends MigrationTestCase { - public function testConstructorSetsOutputWriter() : void + public function testConstructorSetsOutputWriter(): void { $outputWriter = $this->getOutputWriterMock(); @@ -43,7 +46,7 @@ public function testConstructorSetsOutputWriter() : void self::assertSame($outputWriter, $configuration->getOutputWriter()); } - public function testOutputWriterIsCreatedIfNotInjected() : void + public function testOutputWriterIsCreatedIfNotInjected(): void { $dependencyFactory = $this->createMock(DependencyFactory::class); @@ -58,7 +61,7 @@ public function testOutputWriterIsCreatedIfNotInjected() : void self::assertSame($outputWriter, $configuration->getOutputWriter()); } - public function testOutputWriterCanBeSet() : void + public function testOutputWriterCanBeSet(): void { $outputWriter = $this->getOutputWriterMock(); @@ -68,7 +71,7 @@ public function testOutputWriterCanBeSet() : void self::assertSame($outputWriter, $configuration->getOutputWriter()); } - public function testGetSetMigrationsColumnName() : void + public function testGetSetMigrationsColumnName(): void { $configuration = new Configuration($this->getConnectionMock()); @@ -88,7 +91,7 @@ public function testVersionsTryToGetLoadedIfNotAlreadyLoadedWhenAccessingMethodT string $method, array $args, $expectedResult - ) : void { + ): void { $configuration = new Configuration($this->getSqliteConnection()); $configuration->setMigrationsNamespace(str_replace('\Version1Test', '', Version1Test::class)); $configuration->setMigrationsDirectory(__DIR__ . '/../Stub/Configuration/AutoloadVersions'); @@ -112,7 +115,7 @@ public function testVersionsTryToGetLoadedIfNotAlreadyLoadedWhenAccessingMethodT string $method, array $args, $expectedResult - ) : void { + ): void { $configuration = new Configuration($this->getSqliteConnection()); $configuration->setMigrationsNamespace(str_replace('\Version1Test', '', Version1Test::class)); $configuration->setMigrationsDirectory(__DIR__ . '/../Stub/Configuration/AutoloadVersions'); @@ -130,8 +133,8 @@ public function testVersionsTryToGetLoadedIfNotAlreadyLoadedWhenAccessingMethodT ); $migrator->migrate('3Test'); - /** @var callable $callable */ $callable = [$configuration, $method]; + assert(is_callable($callable)); $result = call_user_func_array($callable, $args); @@ -142,7 +145,7 @@ public function testVersionsTryToGetLoadedIfNotAlreadyLoadedWhenAccessingMethodT self::assertSame($expectedResult, $result); } - public function testGenerateVersionNumberFormatsTheDatePassedIn() : void + public function testGenerateVersionNumberFormatsTheDatePassedIn(): void { $configuration = new Configuration($this->getSqliteConnection()); $now = new DateTime('2016-07-05 01:00:00'); @@ -158,7 +161,7 @@ public function testGenerateVersionNumberFormatsTheDatePassedIn() : void * that has the current date, hour, and minute. We're really just testing * the `?: new DateTime(...)` bit of generateVersionNumber */ - public function testGenerateVersionNumberWithoutNowUsesTheCurrentTime() : void + public function testGenerateVersionNumberWithoutNowUsesTheCurrentTime(): void { $configuration = new Configuration($this->getSqliteConnection()); @@ -174,7 +177,7 @@ public function testGenerateVersionNumberWithoutNowUsesTheCurrentTime() : void * * @see https://github.com/doctrine/migrations/issues/336 */ - public function testMasterSlaveConnectionAlwaysConnectsToMaster() : void + public function testMasterSlaveConnectionAlwaysConnectsToMaster(): void { $connection = $this->createMock(MasterSlaveConnection::class); @@ -202,7 +205,7 @@ public function testMasterSlaveConnectionAlwaysConnectsToMaster() : void * * @see https://github.com/doctrine/migrations/issues/336 */ - public function testPrimaryReadReplicaConnectionAlwaysConnectsToMaster() : void + public function testPrimaryReadReplicaConnectionAlwaysConnectsToMaster(): void { if (! class_exists(PrimaryReadReplicaConnection::class)) { self::markTestSkipped('This test requires doctrine/dbal 2.11+'); @@ -222,7 +225,7 @@ public function testPrimaryReadReplicaConnectionAlwaysConnectsToMaster() : void } /** @return mixed[] */ - public function methodsThatNeedsVersionsLoadedWithAlreadyMigratedMigrations() : array + public function methodsThatNeedsVersionsLoadedWithAlreadyMigratedMigrations(): array { return [ ['hasVersion', ['4Test'], true], @@ -262,7 +265,7 @@ public function methodsThatNeedsVersionsLoadedWithAlreadyMigratedMigrations() : } /** @return mixed[] */ - public function methodsThatNeedsVersionsLoaded() : array + public function methodsThatNeedsVersionsLoaded(): array { return [ ['hasVersion', ['3Test'], true], @@ -287,7 +290,7 @@ public function methodsThatNeedsVersionsLoaded() : array ]; } - public function testGetQueryWriterShouldReturnTheObjectGivenOnTheConstructor() : void + public function testGetQueryWriterShouldReturnTheObjectGivenOnTheConstructor(): void { $queryWriter = $this->createMock(QueryWriter::class); $configuration = new Configuration($this->getConnectionMock(), null, null, $queryWriter); @@ -295,14 +298,14 @@ public function testGetQueryWriterShouldReturnTheObjectGivenOnTheConstructor() : self::assertSame($queryWriter, $configuration->getQueryWriter()); } - public function testDBWhereVersionIsKeywordReturnsColumnNameWithQuotes() : void + public function testDBWhereVersionIsKeywordReturnsColumnNameWithQuotes(): void { $config = new Configuration(new Connection([], new DB2Driver())); self::assertSame('"version"', $config->getQuotedMigrationsColumnName()); } - public function testGetVersionData() : void + public function testGetVersionData(): void { $dependencyFactory = $this->createMock(DependencyFactory::class); $migrationRepository = $this->createMock(MigrationRepository::class); @@ -327,7 +330,7 @@ public function testGetVersionData() : void self::assertSame($versionData, $configuration->getVersionData($version)); } - public function testGetSetAllOrNothing() : void + public function testGetSetAllOrNothing(): void { $configuration = $this->createPartialMock(Configuration::class, []); @@ -338,7 +341,7 @@ public function testGetSetAllOrNothing() : void self::assertTrue($configuration->isAllOrNothing()); } - public function testGetSetCheckDatabasePlatform() : void + public function testGetSetCheckDatabasePlatform(): void { $configuration = $this->createPartialMock(Configuration::class, []); @@ -369,12 +372,12 @@ private function getOutputWriterMock() final class EmptyKeywordList extends KeywordList { /** @return string[] */ - protected function getKeywords() : array + protected function getKeywords(): array { return []; } - public function getName() : string + public function getName(): string { return 'EMPTY'; } diff --git a/tests/Doctrine/Migrations/Tests/Configuration/Connection/Loader/ConnectionConfigurationLoaderTest.php b/tests/Doctrine/Migrations/Tests/Configuration/Connection/Loader/ConnectionConfigurationLoaderTest.php index ea0cea4677..a393bd9ed3 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/Connection/Loader/ConnectionConfigurationLoaderTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/Connection/Loader/ConnectionConfigurationLoaderTest.php @@ -18,14 +18,14 @@ final class ConnectionConfigurationLoaderTest extends TestCase /** @var ConnectionConfigurationLoader */ private $connectionConfigurationLoader; - public function testChosenReturnsNull() : void + public function testChosenReturnsNull(): void { $connectionConfigurationLoader = new ConnectionConfigurationLoader(); self::assertNull($connectionConfigurationLoader->chosen()); } - public function testChosenReturnsConfigurationConnection() : void + public function testChosenReturnsConfigurationConnection(): void { $connection = $this->createMock(Connection::class); @@ -36,7 +36,7 @@ public function testChosenReturnsConfigurationConnection() : void self::assertSame($connection, $this->connectionConfigurationLoader->chosen()); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); diff --git a/tests/Doctrine/Migrations/Tests/Configuration/JsonConfigurationTest.php b/tests/Doctrine/Migrations/Tests/Configuration/JsonConfigurationTest.php index 24c482158e..728d0aa5a3 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/JsonConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/JsonConfigurationTest.php @@ -10,6 +10,7 @@ use Doctrine\Migrations\Finder\MigrationFinder; use Doctrine\Migrations\OutputWriter; use InvalidArgumentException; + use const DIRECTORY_SEPARATOR; class JsonConfigurationTest extends AbstractConfigurationTest @@ -18,7 +19,7 @@ public function loadConfiguration( string $configFileSuffix = '', ?OutputWriter $outputWriter = null, ?MigrationFinder $migrationFinder = null - ) : AbstractFileConfiguration { + ): AbstractFileConfiguration { $configFile = 'config.json'; if ($configFileSuffix !== '') { @@ -34,7 +35,7 @@ public function loadConfiguration( /** * Test that config file not exists exception */ - public function testThrowExceptionIfFileNotExist() : void + public function testThrowExceptionIfFileNotExist(): void { $config = new JsonConfiguration($this->getSqliteConnection()); @@ -44,7 +45,7 @@ public function testThrowExceptionIfFileNotExist() : void $config->load(__DIR__ . '/_files/none.json'); } - public function testInvalid() : void + public function testInvalid(): void { $this->expectException(JsonNotValid::class); diff --git a/tests/Doctrine/Migrations/Tests/Configuration/XmlConfigurationTest.php b/tests/Doctrine/Migrations/Tests/Configuration/XmlConfigurationTest.php index 854c97ab39..86e909a753 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/XmlConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/XmlConfigurationTest.php @@ -9,6 +9,7 @@ use Doctrine\Migrations\Configuration\XmlConfiguration; use Doctrine\Migrations\Finder\MigrationFinder; use Doctrine\Migrations\OutputWriter; + use const DIRECTORY_SEPARATOR; class XmlConfigurationTest extends AbstractConfigurationTest @@ -17,7 +18,7 @@ public function loadConfiguration( string $configFileSuffix = '', ?OutputWriter $outputWriter = null, ?MigrationFinder $migrationFinder = null - ) : AbstractFileConfiguration { + ): AbstractFileConfiguration { $configFile = 'config.xml'; if ($configFileSuffix !== '') { $configFile = 'config_' . $configFileSuffix . '.xml'; @@ -29,7 +30,7 @@ public function loadConfiguration( return $configFileSuffix; } - public function testInvalid() : void + public function testInvalid(): void { $this->expectException(XmlNotValid::class); diff --git a/tests/Doctrine/Migrations/Tests/Configuration/YamlConfigurationTest.php b/tests/Doctrine/Migrations/Tests/Configuration/YamlConfigurationTest.php index e2d6a453bb..f5f28b64ca 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/YamlConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/YamlConfigurationTest.php @@ -9,6 +9,7 @@ use Doctrine\Migrations\Configuration\YamlConfiguration; use Doctrine\Migrations\Finder\MigrationFinder; use Doctrine\Migrations\OutputWriter; + use const DIRECTORY_SEPARATOR; class YamlConfigurationTest extends AbstractConfigurationTest @@ -17,7 +18,7 @@ public function loadConfiguration( string $configFileSuffix = '', ?OutputWriter $outputWriter = null, ?MigrationFinder $migrationFinder = null - ) : AbstractFileConfiguration { + ): AbstractFileConfiguration { $configFile = 'config.yml'; if ($configFileSuffix !== '') { $configFile = 'config_' . $configFileSuffix . '.yml'; @@ -29,7 +30,7 @@ public function loadConfiguration( return $configFileSuffix; } - public function testInvalid() : void + public function testInvalid(): void { $this->expectException(YamlNotValid::class); diff --git a/tests/Doctrine/Migrations/Tests/ConfigurationTest.php b/tests/Doctrine/Migrations/Tests/ConfigurationTest.php index 2745f3c01b..063a2f95f1 100644 --- a/tests/Doctrine/Migrations/Tests/ConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/ConfigurationTest.php @@ -12,11 +12,12 @@ use Doctrine\Migrations\Tests\Stub\Version1Test; use Doctrine\Migrations\Tests\Stub\Version2Test; use Doctrine\Migrations\Tests\Stub\Version3Test; + use function sys_get_temp_dir; class ConfigurationTest extends MigrationTestCase { - public function testGetConnection() : void + public function testGetConnection(): void { $conn = $this->getSqliteConnection(); $config = new Configuration($conn); @@ -24,7 +25,7 @@ public function testGetConnection() : void self::assertSame($conn, $config->getConnection()); } - public function testValidateMigrationsNamespaceRequired() : void + public function testValidateMigrationsNamespaceRequired(): void { $config = new Configuration($this->getSqliteConnection()); @@ -33,7 +34,7 @@ public function testValidateMigrationsNamespaceRequired() : void $config->validate(); } - public function testValidateMigrationsDirectoryRequired() : void + public function testValidateMigrationsDirectoryRequired(): void { $config = new Configuration($this->getSqliteConnection()); $config->setMigrationsNamespace('DoctrineMigrations\\'); @@ -44,7 +45,7 @@ public function testValidateMigrationsDirectoryRequired() : void $config->validate(); } - public function testValidateMigrations() : void + public function testValidateMigrations(): void { $config = new Configuration($this->getSqliteConnection()); $config->setMigrationsNamespace('DoctrineMigrations\\'); @@ -55,7 +56,7 @@ public function testValidateMigrations() : void $this->addToAssertionCount(1); } - public function testSetGetName() : void + public function testSetGetName(): void { $config = new Configuration($this->getSqliteConnection()); $config->setName('Test'); @@ -63,14 +64,14 @@ public function testSetGetName() : void self::assertSame('Test', $config->getName()); } - public function testMigrationsTable() : void + public function testMigrationsTable(): void { $config = new Configuration($this->getSqliteConnection()); self::assertSame('doctrine_migration_versions', $config->getMigrationsTableName()); } - public function testSetGetMigrationsColumnLength() : void + public function testSetGetMigrationsColumnLength(): void { $config = new Configuration($this->getSqliteConnection()); @@ -81,7 +82,7 @@ public function testSetGetMigrationsColumnLength() : void self::assertSame(200, $config->getMigrationsColumnLength()); } - public function testSetGetSetMigrationsExecutedAtColumnName() : void + public function testSetGetSetMigrationsExecutedAtColumnName(): void { $config = new Configuration($this->getSqliteConnection()); @@ -92,14 +93,14 @@ public function testSetGetSetMigrationsExecutedAtColumnName() : void self::assertSame('executedAt', $config->getMigrationsExecutedAtColumnName()); } - public function testGetQuotedMigrationsExecutedAtColumnName() : void + public function testGetQuotedMigrationsExecutedAtColumnName(): void { $config = new Configuration($this->getSqliteConnection()); self::assertSame('executed_at', $config->getQuotedMigrationsExecutedAtColumnName()); } - public function testEmptyProjectDefaults() : void + public function testEmptyProjectDefaults(): void { $config = $this->getSqliteConfiguration(); self::assertNull($config->getPrevVersion(), 'no prev version'); @@ -111,7 +112,7 @@ public function testEmptyProjectDefaults() : void self::assertSame([], $config->getMigrations()); } - public function testGetUnknownVersion() : void + public function testGetUnknownVersion(): void { $config = $this->getSqliteConfiguration(); @@ -121,7 +122,7 @@ public function testGetUnknownVersion() : void $config->getVersion('1234'); } - public function testRegisterMigration() : void + public function testRegisterMigration(): void { $config = $this->getSqliteConfiguration(); $config->registerMigration('1234', Version1Test::class); @@ -134,7 +135,7 @@ public function testRegisterMigration() : void self::assertFalse($version->isMigrated()); } - public function testRegisterMigrations() : void + public function testRegisterMigrations(): void { $config = $this->getSqliteConfiguration(); $config->registerMigrations([ @@ -151,7 +152,7 @@ public function testRegisterMigrations() : void self::assertSame('1235', $version->getVersion()); } - public function testRegisterDuplicateVersion() : void + public function testRegisterDuplicateVersion(): void { $config = $this->getSqliteConfiguration(); @@ -164,7 +165,7 @@ public function testRegisterDuplicateVersion() : void $config->registerMigration('1234', Version1Test::class); } - public function testRelativeVersion() : void + public function testRelativeVersion(): void { $config = $this->getSqliteConfiguration(); $config->registerMigrations([ @@ -227,7 +228,7 @@ public function testRelativeVersion() : void self::assertNull($config->getRelativeVersion('final', 1)); } - public function testPreviousCurrentNextLatestVersion() : void + public function testPreviousCurrentNextLatestVersion(): void { $config = $this->getSqliteConfiguration(); $config->registerMigrations([ @@ -271,7 +272,7 @@ public function testPreviousCurrentNextLatestVersion() : void self::assertSame('1236', $config->getLatestVersion(), 'latest version 1236'); } - public function testDeltaVersion() : void + public function testDeltaVersion(): void { $config = $this->getSqliteConfiguration(); $config->registerMigrations([ @@ -311,7 +312,7 @@ public function testDeltaVersion() : void self::assertNull($config->getDeltaVersion('+1'), 'no current+1'); } - public function testGetAvailableVersions() : void + public function testGetAvailableVersions(): void { $config = $this->getSqliteConfiguration(); @@ -319,7 +320,7 @@ public function testGetAvailableVersions() : void self::assertSame(['1234'], $config->getAvailableVersions()); } - public function testDispatchEventProxiesToConnectionsEventManager() : void + public function testDispatchEventProxiesToConnectionsEventManager(): void { $config = $this->getSqliteConfiguration(); $config->getConnection() @@ -338,7 +339,7 @@ public function testDispatchEventProxiesToConnectionsEventManager() : void /** * @dataProvider autoloadVersionProvider */ - public function testGetVersionAutoloadVersion(string $version) : void + public function testGetVersionAutoloadVersion(string $version): void { $config = $this->getSqliteConfiguration(); $config->setMigrationsNamespace('Doctrine\Migrations\Tests\Stub\Configuration\AutoloadVersions'); @@ -349,7 +350,7 @@ public function testGetVersionAutoloadVersion(string $version) : void self::assertSame($version, $result->getVersion()); } - public function testGetVersionNotFound() : void + public function testGetVersionNotFound(): void { $config = $this->getSqliteConfiguration(); @@ -361,14 +362,14 @@ public function testGetVersionNotFound() : void /** * @dataProvider versionProvider */ - public function testGetDatetime(string $version, string $return) : void + public function testGetDatetime(string $version, string $return): void { $config = $this->getSqliteConfiguration(); self::assertSame($return, $config->getDateTime($version)); } - public function testDryRunMigratedAndCurrentVersions() : void + public function testDryRunMigratedAndCurrentVersions(): void { // migrations table created $config1 = $this->getSqliteConfiguration(); @@ -414,7 +415,7 @@ public function testDryRunMigratedAndCurrentVersions() : void /** * @return string[][] */ - public function versionProvider() : array + public function versionProvider(): array { return [ ['20150101123545Version', '2015-01-01 12:35:45'], @@ -430,7 +431,7 @@ public function versionProvider() : array /** * @return string[][] */ - public function autoloadVersionProvider() : array + public function autoloadVersionProvider(): array { return [ ['1Test'], @@ -444,7 +445,7 @@ public function autoloadVersionProvider() : array /** * @dataProvider validCustomTemplates */ - public function testSetCustomTemplateShould(?string $template) : void + public function testSetCustomTemplateShould(?string $template): void { $config = new Configuration($this->getSqliteConnection()); $config->setCustomTemplate($template); @@ -455,7 +456,7 @@ public function testSetCustomTemplateShould(?string $template) : void /** * @return string[][]|null[][] */ - public function validCustomTemplates() : array + public function validCustomTemplates(): array { return [ 'null template' => [null], diff --git a/tests/Doctrine/Migrations/Tests/Event/Listeners/AutoCommitListenerTest.php b/tests/Doctrine/Migrations/Tests/Event/Listeners/AutoCommitListenerTest.php index c03df1851c..8167315aee 100644 --- a/tests/Doctrine/Migrations/Tests/Event/Listeners/AutoCommitListenerTest.php +++ b/tests/Doctrine/Migrations/Tests/Event/Listeners/AutoCommitListenerTest.php @@ -19,14 +19,14 @@ class AutoCommitListenerTest extends MigrationTestCase /** @var AutoCommitListener */ private $listener; - public function testListenerDoesNothingDuringADryRun() : void + public function testListenerDoesNothingDuringADryRun(): void { $this->willNotCommit(); $this->listener->onMigrationsMigrated($this->createArgs(true)); } - public function testListenerDoesNothingWhenConnecitonAutoCommitIsOn() : void + public function testListenerDoesNothingWhenConnecitonAutoCommitIsOn(): void { $this->willNotCommit(); $this->conn->expects(self::once()) @@ -36,7 +36,7 @@ public function testListenerDoesNothingWhenConnecitonAutoCommitIsOn() : void $this->listener->onMigrationsMigrated($this->createArgs(false)); } - public function testListenerDoesFinalCommitWhenAutoCommitIsOff() : void + public function testListenerDoesFinalCommitWhenAutoCommitIsOff(): void { $this->conn->expects(self::once()) ->method('isAutoCommit') @@ -47,7 +47,7 @@ public function testListenerDoesFinalCommitWhenAutoCommitIsOff() : void $this->listener->onMigrationsMigrated($this->createArgs(false)); } - protected function setUp() : void + protected function setUp(): void { $this->conn = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() @@ -56,13 +56,13 @@ protected function setUp() : void $this->listener = new AutoCommitListener(); } - private function willNotCommit() : void + private function willNotCommit(): void { $this->conn->expects(self::never()) ->method('commit'); } - private function createArgs(bool $isDryRun) : MigrationsEventArgs + private function createArgs(bool $isDryRun): MigrationsEventArgs { return new MigrationsEventArgs(new Configuration($this->conn), 'up', $isDryRun); } diff --git a/tests/Doctrine/Migrations/Tests/FileQueryWriterTest.php b/tests/Doctrine/Migrations/Tests/FileQueryWriterTest.php index e3860e0dc2..c9c3388e3b 100644 --- a/tests/Doctrine/Migrations/Tests/FileQueryWriterTest.php +++ b/tests/Doctrine/Migrations/Tests/FileQueryWriterTest.php @@ -9,6 +9,7 @@ use Doctrine\Migrations\Generator\FileBuilder; use Doctrine\Migrations\OutputWriter; use Doctrine\Migrations\Version\Direction; + use function file_get_contents; use function sprintf; use function unlink; @@ -31,7 +32,7 @@ public function testWrite( string $direction, array $queries, OutputWriter $outputWriter - ) : void { + ): void { $platform = $this->createMock(AbstractPlatform::class); $migrationFileBuilder = new FileBuilder( @@ -87,7 +88,7 @@ public function testWrite( } /** @return mixed[][] */ - public function writeProvider() : array + public function writeProvider(): array { $outputWriter = $this->createMock(OutputWriter::class); diff --git a/tests/Doctrine/Migrations/Tests/Finder/FinderTestCase.php b/tests/Doctrine/Migrations/Tests/Finder/FinderTestCase.php index 184f7ce2b4..aaf18ef3df 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/FinderTestCase.php +++ b/tests/Doctrine/Migrations/Tests/Finder/FinderTestCase.php @@ -12,7 +12,7 @@ abstract class FinderTestCase extends MigrationTestCase /** @var MigrationFinder */ protected $finder; - public function testClassesInMultipleNamespacesCanBeLoadedByTheFinder() : void + public function testClassesInMultipleNamespacesCanBeLoadedByTheFinder(): void { $versions = $this->finder->findMigrations(__DIR__ . '/_features/MultiNamespace'); @@ -22,7 +22,7 @@ public function testClassesInMultipleNamespacesCanBeLoadedByTheFinder() : void ], $versions); } - public function testOnlyClassesInTheProvidedNamespaceAreLoadedWhenNamespaceIsProvided() : void + public function testOnlyClassesInTheProvidedNamespaceAreLoadedWhenNamespaceIsProvided(): void { $versions = $this->finder->findMigrations( __DIR__ . '/_features/MultiNamespace', diff --git a/tests/Doctrine/Migrations/Tests/Finder/GlobFinderTest.php b/tests/Doctrine/Migrations/Tests/Finder/GlobFinderTest.php index 6dcdce18fa..fcc50b6c44 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/GlobFinderTest.php +++ b/tests/Doctrine/Migrations/Tests/Finder/GlobFinderTest.php @@ -9,21 +9,21 @@ class GlobFinderTest extends FinderTestCase { - public function testBadFilenameCausesErrorWhenFindingMigrations() : void + public function testBadFilenameCausesErrorWhenFindingMigrations(): void { $this->expectException(InvalidArgumentException::class); $this->finder->findMigrations(__DIR__ . '/does/not/exist/at/all'); } - public function testNonDirectoryCausesErrorWhenFindingMigrations() : void + public function testNonDirectoryCausesErrorWhenFindingMigrations(): void { $this->expectException(InvalidArgumentException::class); $this->finder->findMigrations(__FILE__); } - public function testFindMigrationsReturnsTheExpectedFilesFromDirectory() : void + public function testFindMigrationsReturnsTheExpectedFilesFromDirectory(): void { $migrations = $this->finder->findMigrations(__DIR__ . '/_files'); @@ -33,7 +33,7 @@ public function testFindMigrationsReturnsTheExpectedFilesFromDirectory() : void self::assertSame('TestMigrations\\Version20150502000001', $migrations['20150502000001']); } - protected function setUp() : void + protected function setUp(): void { $this->finder = new GlobFinder(); } diff --git a/tests/Doctrine/Migrations/Tests/Finder/RecursiveRegexFinderTest.php b/tests/Doctrine/Migrations/Tests/Finder/RecursiveRegexFinderTest.php index 2d60622f2c..c5862d707a 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/RecursiveRegexFinderTest.php +++ b/tests/Doctrine/Migrations/Tests/Finder/RecursiveRegexFinderTest.php @@ -6,35 +6,37 @@ use Doctrine\Migrations\Finder\RecursiveRegexFinder; use InvalidArgumentException; -use const PHP_OS; + use function asort; use function count; use function stripos; +use const PHP_OS; + class RecursiveRegexFinderTest extends FinderTestCase { - public function testVersionNameCausesErrorWhen0() : void + public function testVersionNameCausesErrorWhen0(): void { $this->expectException(InvalidArgumentException::class); $this->finder->findMigrations(__DIR__ . '/_regression/NoVersionNamed0'); } - public function testBadFilenameCausesErrorWhenFindingMigrations() : void + public function testBadFilenameCausesErrorWhenFindingMigrations(): void { $this->expectException(InvalidArgumentException::class); $this->finder->findMigrations(__DIR__ . '/does/not/exist/at/all'); } - public function testNonDirectoryCausesErrorWhenFindingMigrations() : void + public function testNonDirectoryCausesErrorWhenFindingMigrations(): void { $this->expectException(InvalidArgumentException::class); $this->finder->findMigrations(__FILE__); } - public function testFindMigrationsReturnsTheExpectedFilesFromDirectory() : void + public function testFindMigrationsReturnsTheExpectedFilesFromDirectory(): void { $migrations = $this->finder->findMigrations(__DIR__ . '/_files'); @@ -56,6 +58,7 @@ public function testFindMigrationsReturnsTheExpectedFilesFromDirectory() : void self::assertArrayHasKey($version, $migrations); self::assertSame($namespace, $migrations[$version]); } + $migrationsForTestSort = $migrations; asort($migrationsForTestSort); @@ -69,7 +72,7 @@ public function testFindMigrationsReturnsTheExpectedFilesFromDirectory() : void self::assertArrayNotHasKey('ARandomClass', $migrations); } - public function testFindMigrationsCanLocateClassesInNestedNamespacesAndDirectories() : void + public function testFindMigrationsCanLocateClassesInNestedNamespacesAndDirectories(): void { $versions = $this->finder->findMigrations(__DIR__ . '/_features/MultiNamespaceNested'); @@ -79,7 +82,7 @@ public function testFindMigrationsCanLocateClassesInNestedNamespacesAndDirectori ], $versions); } - public function testMigrationsInSubnamespaceAreLoadedIfNamespaceIsParentNamespace() : void + public function testMigrationsInSubnamespaceAreLoadedIfNamespaceIsParentNamespace(): void { $versions = $this->finder->findMigrations( __DIR__ . '/_features/MultiNamespaceNested', @@ -92,7 +95,7 @@ public function testMigrationsInSubnamespaceAreLoadedIfNamespaceIsParentNamespac ], $versions); } - public function testOnlyMigrationsInTheProvidedNamespacesAreLoadedIfNamespaceIsProvided() : void + public function testOnlyMigrationsInTheProvidedNamespacesAreLoadedIfNamespaceIsProvided(): void { $versions = $this->finder->findMigrations( __DIR__ . '/_features/MultiNamespaceNested', @@ -102,7 +105,7 @@ public function testOnlyMigrationsInTheProvidedNamespacesAreLoadedIfNamespaceIsP self::assertSame(['0002' => 'TestMigrations\MultiNested\Deep\Version0002'], $versions); } - protected function setUp() : void + protected function setUp(): void { $this->finder = new RecursiveRegexFinder(); } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespace/Version0001.php b/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespace/Version0001.php index eedafb3a7b..95f1cc02c9 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespace/Version0001.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespace/Version0001.php @@ -9,12 +9,12 @@ class Version0001 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespace/Version0002.php b/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespace/Version0002.php index 5132a9eae9..999ddb50b6 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespace/Version0002.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespace/Version0002.php @@ -9,12 +9,12 @@ class Version0002 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespaceNested/Deep/Version0002.php b/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespaceNested/Deep/Version0002.php index 0f0f04a0da..320963ff3c 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespaceNested/Deep/Version0002.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespaceNested/Deep/Version0002.php @@ -9,12 +9,12 @@ class Version0002 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespaceNested/Version0001.php b/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespaceNested/Version0001.php index b365b25fbc..a18f03b694 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespaceNested/Version0001.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_features/MultiNamespaceNested/Version0001.php @@ -9,12 +9,12 @@ class Version0001 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_files/Version20150502000000.php b/tests/Doctrine/Migrations/Tests/Finder/_files/Version20150502000000.php index adfa86bfd5..e8d513be92 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_files/Version20150502000000.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_files/Version20150502000000.php @@ -9,12 +9,12 @@ class Version20150502000000 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_files/Version20150502000001.php b/tests/Doctrine/Migrations/Tests/Finder/_files/Version20150502000001.php index 58f8c1e683..08e809407c 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_files/Version20150502000001.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_files/Version20150502000001.php @@ -9,12 +9,12 @@ class Version20150502000001 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version1ResetVersions.php b/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version1ResetVersions.php index 97cb4853a0..2f859c4cc8 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version1ResetVersions.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version1ResetVersions.php @@ -9,12 +9,12 @@ class Version1ResetVersions extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version20150502000003.php b/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version20150502000003.php index 98dbc845d6..3586590c48 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version20150502000003.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version20150502000003.php @@ -9,12 +9,12 @@ class Version20150502000003 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version20150502000003/Version20150502000005.php b/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version20150502000003/Version20150502000005.php index 28dbfdad69..f7c98fdf10 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version20150502000003/Version20150502000005.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_files/deep/Version20150502000003/Version20150502000005.php @@ -9,12 +9,12 @@ class Version20150502000005 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_files/deep/deeper/Version20150502000004.php b/tests/Doctrine/Migrations/Tests/Finder/_files/deep/deeper/Version20150502000004.php index 4e25c820cb..e83b10379c 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_files/deep/deeper/Version20150502000004.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_files/deep/deeper/Version20150502000004.php @@ -9,12 +9,12 @@ class Version20150502000004 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_regression/NoVersionNamed0/Version0.php b/tests/Doctrine/Migrations/Tests/Finder/_regression/NoVersionNamed0/Version0.php index 6542df135d..5306c8d9a9 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_regression/NoVersionNamed0/Version0.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_regression/NoVersionNamed0/Version0.php @@ -9,12 +9,12 @@ class Version0 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Finder/_symlinked_files/Version1SymlinkedFile.php b/tests/Doctrine/Migrations/Tests/Finder/_symlinked_files/Version1SymlinkedFile.php index 590eabe172..f8321b57ce 100644 --- a/tests/Doctrine/Migrations/Tests/Finder/_symlinked_files/Version1SymlinkedFile.php +++ b/tests/Doctrine/Migrations/Tests/Finder/_symlinked_files/Version1SymlinkedFile.php @@ -9,12 +9,12 @@ class Version1SymlinkedFile extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { // ignored } - public function down(Schema $schema) : void + public function down(Schema $schema): void { // ignored } diff --git a/tests/Doctrine/Migrations/Tests/Functional/CliTest.php b/tests/Doctrine/Migrations/Tests/Functional/CliTest.php index 4a21a52480..4567b673c9 100644 --- a/tests/Doctrine/Migrations/Tests/Functional/CliTest.php +++ b/tests/Doctrine/Migrations/Tests/Functional/CliTest.php @@ -23,7 +23,7 @@ use RuntimeException; use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\ArrayInput; -use const DIRECTORY_SEPARATOR; + use function array_merge; use function assert; use function count; @@ -33,6 +33,8 @@ use function reset; use function unlink; +use const DIRECTORY_SEPARATOR; + /** * Tests the entire console application, end to end. */ @@ -47,7 +49,7 @@ class CliTest extends MigrationTestCase /** @var int|null */ private $lastExit; - public function testDumpSchema() : void + public function testDumpSchema(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Delete any previous migrations before dumping your schema.'); @@ -55,14 +57,14 @@ public function testDumpSchema() : void $this->executeCommand('migrations:dump-schema'); } - public function testRollup() : void + public function testRollup(): void { $output = $this->executeCommand('migrations:rollup'); self::assertRegExp('/Rolled up migrations to version 20150426000000/', $output); } - public function testMigrationLifecycleFromCommandLine() : void + public function testMigrationLifecycleFromCommandLine(): void { $output = $this->executeCommand('migrations:status'); self::assertSuccessfulExit(); @@ -81,7 +83,7 @@ public function testMigrationLifecycleFromCommandLine() : void self::assertRegExp('/^.*new migrations:\s+0/im', $output); } - public function testGenerateCommandAddsNewVersion() : void + public function testGenerateCommandAddsNewVersion(): void { self::assertVersionCount(0, 'Should start with no versions'); $this->executeCommand('migrations:generate'); @@ -93,7 +95,7 @@ public function testGenerateCommandAddsNewVersion() : void self::assertRegExp('/available migrations:\s+2/im', $output); } - public function testGenerateCommandAddsNewMigrationOrganizedByYearAndMonth() : void + public function testGenerateCommandAddsNewMigrationOrganizedByYearAndMonth(): void { self::assertVersionCount(0, 'Should start with no versions'); $this->executeCommand('migrations:generate', 'config_organize_by_year_and_month.xml'); @@ -105,7 +107,7 @@ public function testGenerateCommandAddsNewMigrationOrganizedByYearAndMonth() : v self::assertRegExp('/available migrations:\s+1/im', $output); } - public function testMigrationDiffWritesNewMigrationWithExpectedSql() : void + public function testMigrationDiffWritesNewMigrationWithExpectedSql(): void { $this->withDiffCommand(new StubSchemaProvider($this->getSchema())); self::assertVersionCount(0, 'should start with no versions'); @@ -125,7 +127,7 @@ public function testMigrationDiffWritesNewMigrationWithExpectedSql() : void self::assertStringContainsString('DROP TABLE bar', $versionClassContents); } - public function testMigrationDiffWritesNewMigrationWithFormattedSql() : void + public function testMigrationDiffWritesNewMigrationWithFormattedSql(): void { $this->withDiffCommand(new StubSchemaProvider($this->getSchema())); self::assertVersionCount(0, 'should start with no versions'); @@ -152,7 +154,7 @@ public function testMigrationDiffWritesNewMigrationWithFormattedSql() : void self::assertStringContainsString('DROP TABLE bar', $versionClassContents); } - public function testMigrationDiffFromEmptySchemaGeneratesFullMigration() : void + public function testMigrationDiffFromEmptySchemaGeneratesFullMigration(): void { $this->withDiffCommand(new StubSchemaProvider($this->getSchema())); @@ -186,7 +188,7 @@ public function testMigrationDiffFromEmptySchemaGeneratesFullMigration() : void self::assertStringContainsString('DROP TABLE bar', $versionClassContents); } - public function testMigrationDiffWithEntityManagerGeneratesMigrationFromEntities() : void + public function testMigrationDiffWithEntityManagerGeneratesMigrationFromEntities(): void { $config = OrmSetup::createXMLMetadataConfiguration([__DIR__ . '/_files/entities'], true); $entityManager = EntityManager::create($this->conn, $config); @@ -210,7 +212,7 @@ public function testMigrationDiffWithEntityManagerGeneratesMigrationFromEntities self::assertStringContainsString('DROP TABLE sample_entity', $versionClassContents); } - public function testDiffCommandWithSchemaFilterOnlyWorksWithTablesThatMatchFilter() : void + public function testDiffCommandWithSchemaFilterOnlyWorksWithTablesThatMatchFilter(): void { $this->conn->getConfiguration()->setSchemaAssetsFilter( static function ($assetName) { @@ -243,7 +245,7 @@ static function ($assetName) { * * @group regression */ - public function testDiffCommandSchemaFilterAreCaseSensitive() : void + public function testDiffCommandSchemaFilterAreCaseSensitive(): void { $this->conn->getConfiguration()->setSchemaAssetsFilter( static function ($assetName) { @@ -271,13 +273,14 @@ static function ($assetName) { self::assertStringContainsString('DROP TABLE FOO', $versionClassContents); } - protected function setUp() : void + protected function setUp(): void { $migrationsDbFilePath = __DIR__ . DIRECTORY_SEPARATOR . '_files ' . DIRECTORY_SEPARATOR . 'migrations.db'; if (file_exists($migrationsDbFilePath)) { @unlink($migrationsDbFilePath); } + $this->deleteMigrationFiles(); $this->conn = $this->getSqliteConnection(); @@ -300,7 +303,7 @@ protected function setUp() : void ]); } - protected function withDiffCommand(?SchemaProviderInterface $provider = null) : void + protected function withDiffCommand(?SchemaProviderInterface $provider = null): void { $this->application->add(new MigrationCommands\DiffCommand($provider)); } @@ -312,7 +315,7 @@ protected function executeCommand( string $commandName, string $configFile = 'config.yml', array $args = [] - ) : string { + ): string { $input = new ArrayInput(array_merge( [ 'command' => $commandName, @@ -329,17 +332,17 @@ protected function executeCommand( return $this->getOutputStreamContent($output); } - protected function assertSuccessfulExit(string $msg = '') : void + protected function assertSuccessfulExit(string $msg = ''): void { self::assertSame(0, $this->lastExit, $msg); } - protected function assertVersionCount(int $count, string $msg = '') : void + protected function assertVersionCount(int $count, string $msg = ''): void { self::assertCount($count, $this->findMigrations(), $msg); } - protected function getSchema() : Schema + protected function getSchema(): Schema { $schema = new Schema(); @@ -357,7 +360,7 @@ protected function getSchema() : Schema /** * @return string[] */ - private function findMigrations() : array + private function findMigrations(): array { $finder = new RecursiveRegexFinder(); @@ -366,7 +369,7 @@ private function findMigrations() : array ); } - private function deleteMigrationFiles() : bool + private function deleteMigrationFiles(): bool { return Helper::deleteDir( __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'migrations' @@ -376,7 +379,7 @@ private function deleteMigrationFiles() : bool /** * @return string file content for latest version */ - private function getFileContentsForLatestVersion() : string + private function getFileContentsForLatestVersion(): string { $versions = $this->findMigrations(); self::assertCount( @@ -402,12 +405,12 @@ private function getFileContentsForLatestVersion() : string class FirstMigration extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('CREATE TABLE foo (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $this->addSql('DROP TABLE foo'); } @@ -418,7 +421,7 @@ class SampleEntity /** @var int|null */ private $id; - public function getId() : ?int + public function getId(): ?int { return $this->id; } diff --git a/tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php b/tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php index 20ce8b318f..dcc67af8f1 100644 --- a/tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php +++ b/tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php @@ -33,6 +33,7 @@ use Doctrine\Migrations\Version\Version; use Symfony\Component\Process\Process; use Symfony\Component\Stopwatch\Stopwatch as SymfonyStopwatch; + use function assert; use function file_exists; use function get_class_methods; @@ -50,7 +51,7 @@ class FunctionalTest extends MigrationTestCase /** @var Connection */ private $connection; - protected function setUp() : void + protected function setUp(): void { $this->connection = $this->getSqliteConnection(); $this->config = self::createConfiguration($this->connection); @@ -59,7 +60,7 @@ protected function setUp() : void /** * @requires OS Linux|Darwin */ - public function testDoctrineMigrationsBin() : void + public function testDoctrineMigrationsBin(): void { $process = new Process([__DIR__ . '/../../../../../bin/doctrine-migrations']); $process->run(); @@ -79,7 +80,7 @@ public function testDoctrineMigrationsBin() : void self::assertStringContainsString('migrations:version', $output); } - public function testMigrateUp() : void + public function testMigrateUp(): void { $version = $this->createTestVersion($this->config, '1', MigrationMigrateUp::class); @@ -92,7 +93,7 @@ public function testMigrateUp() : void self::assertTrue($this->config->hasVersionMigrated($version)); } - public function testMigrateDown() : void + public function testMigrateDown(): void { $version = $this->createTestVersion($this->config, '1', MigrationMigrateUp::class); @@ -110,7 +111,7 @@ public function testMigrateDown() : void self::assertFalse($this->config->hasVersionMigrated($version)); } - public function testSkipMigrateUp() : void + public function testSkipMigrateUp(): void { $version = $this->createTestVersion($this->config, '1', MigrationSkipMigration::class); @@ -123,7 +124,7 @@ public function testSkipMigrateUp() : void self::assertTrue($this->config->hasVersionMigrated($version)); } - public function testMigrateSeveralSteps() : void + public function testMigrateSeveralSteps(): void { $this->config->registerMigration('1', MigrationMigrateUp::class); $this->config->registerMigration('2', MigrationSkipMigration::class); @@ -150,7 +151,7 @@ public function testMigrateSeveralSteps() : void self::assertTrue($migrations['3']->isMigrated()); } - public function testMigrateToLastVersion() : void + public function testMigrateToLastVersion(): void { $this->config->registerMigration('1', MigrationMigrateUp::class); $this->config->registerMigration('2', MigrationSkipMigration::class); @@ -166,7 +167,7 @@ public function testMigrateToLastVersion() : void self::assertTrue($migrations['3']->isMigrated()); } - public function testDryRunMigration() : void + public function testDryRunMigration(): void { $this->config->registerMigration('1', MigrationMigrateUp::class); $this->config->registerMigration('2', MigrationSkipMigration::class); @@ -189,7 +190,7 @@ public function testDryRunMigration() : void self::assertFalse($migrations['3']->isMigrated()); } - public function testDryRunWithTableCreatedWithSchemaInFirstMigration() : void + public function testDryRunWithTableCreatedWithSchemaInFirstMigration(): void { $this->config->registerMigration('1', DryRun1::class); $this->config->registerMigration('2', DryRun2::class); @@ -209,7 +210,7 @@ public function testDryRunWithTableCreatedWithSchemaInFirstMigration() : void self::assertTrue($table->hasColumn('bar')); } - public function testMigrateDownSeveralSteps() : void + public function testMigrateDownSeveralSteps(): void { $this->config->registerMigration('1', MigrationMigrateUp::class); $this->config->registerMigration('2', MigrationSkipMigration::class); @@ -232,7 +233,7 @@ public function testMigrateDownSeveralSteps() : void self::assertFalse($migrations['3']->isMigrated()); } - public function testAddSql() : void + public function testAddSql(): void { $this->config->registerMigration('1', MigrateAddSqlTest::class); @@ -254,7 +255,7 @@ public function testAddSql() : void self::assertFalse($schema->hasTable('test_add_sql_table')); } - public function testAddSqlInPostUp() : void + public function testAddSqlInPostUp(): void { $this->config->registerMigration('1', MigrateAddSqlPostAndPreUpAndDownTest::class); $tableName = MigrateAddSqlPostAndPreUpAndDownTest::TABLE_NAME; @@ -287,7 +288,7 @@ public function testAddSqlInPostUp() : void $this->config->getConnection()->executeQuery(sprintf('DROP TABLE %s ', $tableName)); } - public function testVersionInDatabaseWithoutRegisteredMigrationStillMigrates() : void + public function testVersionInDatabaseWithoutRegisteredMigrationStillMigrates(): void { $this->config->registerMigration('1', MigrateAddSqlTest::class); $this->config->registerMigration('10', MigrationMigrateFurther::class); @@ -313,7 +314,7 @@ public function testVersionInDatabaseWithoutRegisteredMigrationStillMigrates() : self::assertSame('2', $config->getCurrentVersion()); } - public function testInterweavedMigrationsAreExecuted() : void + public function testInterweavedMigrationsAreExecuted(): void { $this->config->registerMigration('1', MigrateAddSqlTest::class); $this->config->registerMigration('3', MigrationMigrateFurther::class); @@ -351,7 +352,7 @@ public function testInterweavedMigrationsAreExecuted() : void self::assertSame('3', $config->getCurrentVersion()); } - public function testMigrateToCurrentVersionReturnsEmpty() : void + public function testMigrateToCurrentVersionReturnsEmpty(): void { $this->config->registerMigration('1', MigrateAddSqlTest::class); $this->config->registerMigration('2', MigrationMigrateFurther::class); @@ -372,7 +373,7 @@ public function testMigrateToCurrentVersionReturnsEmpty() : void * @group regression * @dataProvider provideTestMigrationNames */ - public function testMigrateExecutesOlderVersionsThatHaveNetYetBeenMigrated(array $migrations) : void + public function testMigrateExecutesOlderVersionsThatHaveNetYetBeenMigrated(array $migrations): void { foreach ($migrations as $key => $class) { $migrator = $this->createTestMigrator($this->config); @@ -382,7 +383,7 @@ public function testMigrateExecutesOlderVersionsThatHaveNetYetBeenMigrated(array } } - public function testSchemaChangeAreNotTakenIntoAccountInPreAndPostMethod() : void + public function testSchemaChangeAreNotTakenIntoAccountInPreAndPostMethod(): void { $version = $this->createTestVersion($this->config, '1', MigrationModifySchemaInPreAndPost::class); @@ -415,7 +416,7 @@ public function testSchemaChangeAreNotTakenIntoAccountInPreAndPostMethod() : voi /** * @return mixed[][] */ - public function provideTestMigrationNames() : array + public function provideTestMigrationNames(): array { return [ [ @@ -433,7 +434,7 @@ public function provideTestMigrationNames() : array ]; } - public function testMigrationWorksWhenNoCallsAreMadeToTheSchema() : void + public function testMigrationWorksWhenNoCallsAreMadeToTheSchema(): void { $schema = $this->createMock(Schema::class); $schemaDiffProvider = $this->createMock(SchemaDiffProviderInterface::class); @@ -464,7 +465,7 @@ public function testMigrationWorksWhenNoCallsAreMadeToTheSchema() : void } } - public function testSuccessfulMigrationDispatchesTheExpectedEvents() : void + public function testSuccessfulMigrationDispatchesTheExpectedEvents(): void { $this->config->registerMigration('1', MigrationMigrateUp::class); @@ -477,18 +478,20 @@ public function testSuccessfulMigrationDispatchesTheExpectedEvents() : void self::assertCount(4, $listener->events); - foreach ([ - Events::onMigrationsMigrating, - Events::onMigrationsMigrated, - Events::onMigrationsVersionExecuting, - Events::onMigrationsVersionExecuted, - ] as $eventName) { + foreach ( + [ + Events::onMigrationsMigrating, + Events::onMigrationsMigrated, + Events::onMigrationsVersionExecuting, + Events::onMigrationsVersionExecuted, + ] as $eventName + ) { self::assertCount(1, $listener->events[$eventName]); self::assertArrayHasKey($eventName, $listener->events); } } - public function testSkippedMigrationsDispatchesTheExpectedEvents() : void + public function testSkippedMigrationsDispatchesTheExpectedEvents(): void { $this->config->registerMigration('1', MigrationSkipMigration::class); @@ -501,12 +504,14 @@ public function testSkippedMigrationsDispatchesTheExpectedEvents() : void self::assertCount(4, $listener->events); - foreach ([ - Events::onMigrationsMigrating, - Events::onMigrationsMigrated, - Events::onMigrationsVersionExecuting, - Events::onMigrationsVersionSkipped, - ] as $eventName) { + foreach ( + [ + Events::onMigrationsMigrating, + Events::onMigrationsMigrated, + Events::onMigrationsVersionExecuting, + Events::onMigrationsVersionSkipped, + ] as $eventName + ) { self::assertArrayHasKey($eventName, $listener->events); } } @@ -517,7 +522,7 @@ public function testSkippedMigrationsDispatchesTheExpectedEvents() : void * * @group https://github.com/doctrine/migrations/issues/496 */ - public function testMigrateWithConnectionWithAutoCommitOffStillPersistsChanges() : void + public function testMigrateWithConnectionWithAutoCommitOffStillPersistsChanges(): void { $listener = new AutoCommitListener(); [$conn, $config] = self::fileConnectionAndConfig(); @@ -536,7 +541,7 @@ public function testMigrateWithConnectionWithAutoCommitOffStillPersistsChanges() self::assertCount(3, $conn->fetchAll('SELECT * FROM test_data_migration')); } - public function testMigrationExecutedAt() : void + public function testMigrationExecutedAt(): void { $version = $this->createTestVersion($this->config, '1', MigrationMigrateUp::class); $version->execute('up'); @@ -557,7 +562,7 @@ public function testMigrationExecutedAt() : void * * @psalm-return array{Connection,Configuration} */ - private static function fileConnectionAndConfig() : array + private static function fileConnectionAndConfig(): array { $path = __DIR__ . '/_files/db/sqlite_file_config.db'; @@ -575,7 +580,7 @@ private static function fileConnectionAndConfig() : array return [$conn, self::createConfiguration($conn)]; } - private static function createConfiguration(Connection $conn) : Configuration + private static function createConfiguration(Connection $conn): Configuration { $config = new Configuration($conn); $config->setMigrationsNamespace('Doctrine\Migrations\Tests\Functional'); @@ -591,7 +596,7 @@ private function createTestVersion( string $versionName, string $className, ?SchemaDiffProviderInterface $schemaDiffProvider = null - ) : Version { + ): Version { if ($schemaDiffProvider === null) { $schemaDiffProvider = new SchemaDiffProvider( $this->connection->getSchemaManager(), diff --git a/tests/Doctrine/Migrations/Tests/Functional/MigrationTableManipulatorTest.php b/tests/Doctrine/Migrations/Tests/Functional/MigrationTableManipulatorTest.php index 118eab593a..f28ee1b447 100644 --- a/tests/Doctrine/Migrations/Tests/Functional/MigrationTableManipulatorTest.php +++ b/tests/Doctrine/Migrations/Tests/Functional/MigrationTableManipulatorTest.php @@ -23,7 +23,7 @@ class MigrationTableManipulatorTest extends MigrationTestCase /** @var Connection */ private $connection; - public function testCreateMigrationTable() : void + public function testCreateMigrationTable(): void { $schemaManager = $this->connection->getSchemaManager(); @@ -46,7 +46,7 @@ public function testCreateMigrationTable() : void self::assertTrue($table->getIndex('unique_version')->isUnique()); } - public function testUpdateMigrationTable() : void + public function testUpdateMigrationTable(): void { $createTablesSql = [ 'CREATE TABLE doctrine_migration_versions (version varchar(200) NOT NULL, test varchar(255) DEFAULT NULL, PRIMARY KEY (version))', @@ -78,7 +78,7 @@ public function testUpdateMigrationTable() : void self::assertTrue($schemaManager->tablesExist(['test']), 'Check table not related to Doctrine was not dropped'); } - protected function setUp() : void + protected function setUp(): void { $this->connection = $this->getTestConnection(); @@ -93,7 +93,7 @@ protected function setUp() : void $this->trackingTableStatus = $dependencyFactory->getTrackingTableStatus(); } - private function getTestConnection() : Connection + private function getTestConnection(): Connection { $params = [ 'driver' => 'pdo_sqlite', diff --git a/tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php b/tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php index 802a8f6348..e755381772 100644 --- a/tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php +++ b/tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php @@ -42,7 +42,7 @@ class DiffGeneratorTest extends TestCase /** @var SchemaProviderInterface|MockObject */ private $emptySchemaProvider; - public function testGenerate() : void + public function testGenerate(): void { $fromSchema = $this->createMock(Schema::class); $toSchema = $this->createMock(Schema::class); @@ -124,7 +124,7 @@ static function ($name) { self::assertSame('path', $this->migrationDiffGenerator->generate('1234', '/table_name1/', true, 80)); } - public function testGenerateFromEmptySchema() : void + public function testGenerateFromEmptySchema(): void { $emptySchema = $this->createMock(Schema::class); $toSchema = $this->createMock(Schema::class); @@ -181,7 +181,7 @@ public function testGenerateFromEmptySchema() : void self::assertSame('path2', $this->migrationDiffGenerator->generate('2345', null, false, 120, true, true)); } - protected function setUp() : void + protected function setUp(): void { $this->dbalConfiguration = $this->createMock(DBALConfiguration::class); $this->schemaManager = $this->createMock(AbstractSchemaManager::class); diff --git a/tests/Doctrine/Migrations/Tests/Generator/FileBuilderTest.php b/tests/Doctrine/Migrations/Tests/Generator/FileBuilderTest.php index 074733777b..fd0e070d33 100644 --- a/tests/Doctrine/Migrations/Tests/Generator/FileBuilderTest.php +++ b/tests/Doctrine/Migrations/Tests/Generator/FileBuilderTest.php @@ -19,7 +19,7 @@ class FileBuilderTest extends TestCase /** @var FileBuilder */ private $migrationFileBuilder; - public function testBuildMigrationFile() : void + public function testBuildMigrationFile(): void { $queriesByVersion = [ '1' => [ @@ -69,7 +69,7 @@ public function testBuildMigrationFile() : void self::assertSame($expected, $migrationFile); } - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); diff --git a/tests/Doctrine/Migrations/Tests/Generator/GeneratorTest.php b/tests/Doctrine/Migrations/Tests/Generator/GeneratorTest.php index f06a8a8281..8bcb0a1272 100644 --- a/tests/Doctrine/Migrations/Tests/Generator/GeneratorTest.php +++ b/tests/Doctrine/Migrations/Tests/Generator/GeneratorTest.php @@ -9,6 +9,7 @@ use InvalidArgumentException; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function class_exists; use function file_get_contents; use function file_put_contents; @@ -24,7 +25,7 @@ final class GeneratorTest extends TestCase /** @var Generator */ private $migrationGenerator; - public function testGenerateMigration() : void + public function testGenerateMigration(): void { $this->configuration->expects(self::once()) ->method('getMigrationsNamespace') @@ -51,7 +52,7 @@ public function testGenerateMigration() : void unlink($path); } - public function testCustomTemplate() : void + public function testCustomTemplate(): void { $customTemplate = sprintf('%s/template', sys_get_temp_dir()); @@ -70,7 +71,7 @@ public function testCustomTemplate() : void unlink($path); } - public function testCustomTemplateThrowsInvalidArgumentExceptionWhenTemplateMissing() : void + public function testCustomTemplateThrowsInvalidArgumentExceptionWhenTemplateMissing(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The specified template "invalid" cannot be found or is not readable.'); @@ -82,7 +83,7 @@ public function testCustomTemplateThrowsInvalidArgumentExceptionWhenTemplateMiss $this->migrationGenerator->generateMigration('1234'); } - public function testCustomTemplateThrowsInvalidArgumentExceptionWhenTemplateEmpty() : void + public function testCustomTemplateThrowsInvalidArgumentExceptionWhenTemplateEmpty(): void { $customTemplate = sprintf('%s/template', sys_get_temp_dir()); @@ -103,7 +104,7 @@ public function testCustomTemplateThrowsInvalidArgumentExceptionWhenTemplateEmpt unlink($customTemplate); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); diff --git a/tests/Doctrine/Migrations/Tests/Generator/SqlGeneratorTest.php b/tests/Doctrine/Migrations/Tests/Generator/SqlGeneratorTest.php index fa57b3ae83..00279af199 100644 --- a/tests/Doctrine/Migrations/Tests/Generator/SqlGeneratorTest.php +++ b/tests/Doctrine/Migrations/Tests/Generator/SqlGeneratorTest.php @@ -10,6 +10,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use SqlFormatter; + use function sprintf; final class SqlGeneratorTest extends TestCase @@ -26,7 +27,7 @@ final class SqlGeneratorTest extends TestCase /** @var string[] */ private $sql; - public function testGenerate() : void + public function testGenerate(): void { $this->configuration->method('isDatabasePlatformChecked')->willReturn(true); @@ -49,7 +50,7 @@ public function testGenerate() : void self::assertSame($expectedCode, $code); } - public function testGenerationWithoutCheckingDatabasePlatform() : void + public function testGenerationWithoutCheckingDatabasePlatform(): void { $this->configuration->method('isDatabasePlatformChecked')->willReturn(true); @@ -66,7 +67,7 @@ public function testGenerationWithoutCheckingDatabasePlatform() : void self::assertSame($expectedCode, $code); } - public function testGenerationWithoutCheckingDatabasePlatformWithConfiguration() : void + public function testGenerationWithoutCheckingDatabasePlatformWithConfiguration(): void { $this->configuration->method('isDatabasePlatformChecked')->willReturn(false); @@ -83,7 +84,7 @@ public function testGenerationWithoutCheckingDatabasePlatformWithConfiguration() self::assertSame($expectedCode, $code); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->platform = $this->createMock(AbstractPlatform::class); @@ -94,7 +95,7 @@ protected function setUp() : void ); } - private function prepareGeneratedCode(string $expectedCode) : string + private function prepareGeneratedCode(string $expectedCode): string { $this->sql = [ 'SELECT 1', diff --git a/tests/Doctrine/Migrations/Tests/Helper.php b/tests/Doctrine/Migrations/Tests/Helper.php index fde13c7678..67fe32cac7 100644 --- a/tests/Doctrine/Migrations/Tests/Helper.php +++ b/tests/Doctrine/Migrations/Tests/Helper.php @@ -17,7 +17,7 @@ class Helper * * @see http://stackoverflow.com/a/8688278/1645517 */ - public static function deleteDir(string $path) : bool + public static function deleteDir(string $path): bool { if ($path === '') { return false; diff --git a/tests/Doctrine/Migrations/Tests/MigrationPlanCalculatorTest.php b/tests/Doctrine/Migrations/Tests/MigrationPlanCalculatorTest.php index 4257f8e594..7d5e6c4658 100644 --- a/tests/Doctrine/Migrations/Tests/MigrationPlanCalculatorTest.php +++ b/tests/Doctrine/Migrations/Tests/MigrationPlanCalculatorTest.php @@ -19,7 +19,7 @@ final class MigrationPlanCalculatorTest extends TestCase /** @var MigrationPlanCalculator */ private $migrationPlanCalculator; - public function testGetMigrationsToExecuteUp() : void + public function testGetMigrationsToExecuteUp(): void { $version1 = $this->createMock(Version::class); $version1->expects(self::any()) @@ -70,7 +70,7 @@ public function testGetMigrationsToExecuteUp() : void self::assertSame($expected, $migrationsToExecute); } - public function testGetMigrationsToExecuteDown() : void + public function testGetMigrationsToExecuteDown(): void { $version1 = $this->createMock(Version::class); $version1->expects(self::any()) @@ -121,7 +121,7 @@ public function testGetMigrationsToExecuteDown() : void self::assertSame($expected, $migrationsToExecute); } - protected function setUp() : void + protected function setUp(): void { $this->migrationRepository = $this->createMock(MigrationRepository::class); diff --git a/tests/Doctrine/Migrations/Tests/MigrationRepositoryTest.php b/tests/Doctrine/Migrations/Tests/MigrationRepositoryTest.php index 4ab5ea09a6..20033fcafe 100644 --- a/tests/Doctrine/Migrations/Tests/MigrationRepositoryTest.php +++ b/tests/Doctrine/Migrations/Tests/MigrationRepositoryTest.php @@ -31,13 +31,13 @@ class MigrationRepositoryTest extends TestCase /** @var MigrationRepository */ private $migrationRepository; - public function testGetDeltaVersionReturnsNull() : void + public function testGetDeltaVersionReturnsNull(): void { self::assertNull($this->migrationRepository->getDeltaVersion('00')); self::assertNull($this->migrationRepository->getDeltaVersion('01')); } - public function testGetVersions() : void + public function testGetVersions(): void { $version1 = $this->createMock(Version::class); $version1->expects(self::once()) @@ -63,7 +63,7 @@ public function testGetVersions() : void self::assertEmpty($this->migrationRepository->getVersions()); } - public function testGetVersionData() : void + public function testGetVersionData(): void { $version = $this->createMock(Version::class); @@ -98,14 +98,14 @@ public function testGetVersionData() : void self::assertSame($versionData, $this->migrationRepository->getVersionData($version)); } - public function testRegisterMigrationWithNonExistentClassCausesError() : void + public function testRegisterMigrationWithNonExistentClassCausesError(): void { $this->expectException(MigrationClassNotFound::class); $this->migrationRepository->registerMigration('123', DoesNotExistAtAll::class); } - public function testRemoveMigrationVersionFromDatabase() : void + public function testRemoveMigrationVersionFromDatabase(): void { $migrationsTableName = 'migration_versions'; $migrationsColumnName = 'version'; @@ -127,7 +127,7 @@ public function testRemoveMigrationVersionFromDatabase() : void $this->migrationRepository->removeMigrationVersionFromDatabase($version); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->connection = $this->createMock(Connection::class); diff --git a/tests/Doctrine/Migrations/Tests/MigrationTestCase.php b/tests/Doctrine/Migrations/Tests/MigrationTestCase.php index f015d9b7ea..d8c0ae0efb 100644 --- a/tests/Doctrine/Migrations/Tests/MigrationTestCase.php +++ b/tests/Doctrine/Migrations/Tests/MigrationTestCase.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Output\StreamOutput; use Symfony\Component\Stopwatch\Stopwatch as SymfonyStopwatch; + use function assert; use function fopen; use function fwrite; @@ -34,14 +35,14 @@ abstract class MigrationTestCase extends TestCase /** @var StreamOutput */ protected $output; - public function getSqliteConnection() : Connection + public function getSqliteConnection(): Connection { $params = ['driver' => 'pdo_sqlite', 'memory' => true]; return DriverManager::getConnection($params); } - public function getSqliteConfiguration() : Configuration + public function getSqliteConfiguration(): Configuration { $config = new Configuration($this->getSqliteConnection()); $config->setMigrationsDirectory(__DIR__ . '/Stub/migration-empty-folder'); @@ -50,7 +51,7 @@ public function getSqliteConfiguration() : Configuration return $config; } - public function getOutputStream() : StreamOutput + public function getOutputStream(): StreamOutput { $stream = fopen('php://memory', 'r+', false); @@ -59,7 +60,7 @@ public function getOutputStream() : StreamOutput return new StreamOutput($stream); } - public function getOutputStreamContent(StreamOutput $streamOutput) : string + public function getOutputStreamContent(StreamOutput $streamOutput): string { $stream = $streamOutput->getStream(); rewind($stream); @@ -82,7 +83,7 @@ public function getInputStream(string $input) return $stream; } - protected function getOutputWriter() : OutputWriter + protected function getOutputWriter(): OutputWriter { if ($this->outputWriter === null) { $this->output = $this->getOutputStream(); @@ -96,7 +97,7 @@ protected function getOutputWriter() : OutputWriter } /** @throws Exception */ - protected function createTempDirForMigrations(string $path) : void + protected function createTempDirForMigrations(string $path): void { if (! mkdir($path)) { throw new Exception('fail to create a temporary folder for the tests at ' . $path); @@ -104,7 +105,7 @@ protected function createTempDirForMigrations(string $path) : void } /** @return string[] */ - protected function getSqlFilesList(string $path) : array + protected function getSqlFilesList(string $path): array { if (is_dir($path)) { return glob(realpath($path) . '/*.sql'); @@ -117,7 +118,7 @@ protected function getSqlFilesList(string $path) : array return []; } - protected function createTestMigrator(Configuration $config) : Migrator + protected function createTestMigrator(Configuration $config): Migrator { $dependencyFactory = $config->getDependencyFactory(); $migrationRepository = $dependencyFactory->getMigrationRepository(); @@ -131,7 +132,7 @@ protected function createTestMigrator(Configuration $config) : Migrator /** * @return mixed[] */ - protected function getMigratorConstructorArgs(Configuration $config) : array + protected function getMigratorConstructorArgs(Configuration $config): array { $dependencyFactory = $config->getDependencyFactory(); $migrationRepository = $dependencyFactory->getMigrationRepository(); diff --git a/tests/Doctrine/Migrations/Tests/MigratorConfigurationTest.php b/tests/Doctrine/Migrations/Tests/MigratorConfigurationTest.php index 2e617d7bc0..8dd2294f80 100644 --- a/tests/Doctrine/Migrations/Tests/MigratorConfigurationTest.php +++ b/tests/Doctrine/Migrations/Tests/MigratorConfigurationTest.php @@ -12,7 +12,7 @@ class MigratorConfigurationTest extends TestCase /** @var MigratorConfiguration */ private $migratorConfiguration; - public function testDryRun() : void + public function testDryRun(): void { self::assertFalse($this->migratorConfiguration->isDryRun()); @@ -21,7 +21,7 @@ public function testDryRun() : void self::assertTrue($this->migratorConfiguration->isDryRun()); } - public function testTimeAllQueries() : void + public function testTimeAllQueries(): void { self::assertFalse($this->migratorConfiguration->getTimeAllQueries()); @@ -30,7 +30,7 @@ public function testTimeAllQueries() : void self::assertTrue($this->migratorConfiguration->getTimeAllQueries()); } - public function testNoMigrationException() : void + public function testNoMigrationException(): void { self::assertFalse($this->migratorConfiguration->getNoMigrationException()); @@ -39,7 +39,7 @@ public function testNoMigrationException() : void self::assertTrue($this->migratorConfiguration->getNoMigrationException()); } - public function testAllOrNothing() : void + public function testAllOrNothing(): void { self::assertFalse($this->migratorConfiguration->isAllOrNothing()); @@ -48,7 +48,7 @@ public function testAllOrNothing() : void self::assertTrue($this->migratorConfiguration->isAllOrNothing()); } - protected function setUp() : void + protected function setUp(): void { $this->migratorConfiguration = new MigratorConfiguration(); } diff --git a/tests/Doctrine/Migrations/Tests/MigratorTest.php b/tests/Doctrine/Migrations/Tests/MigratorTest.php index 97c440fa09..6fad33c204 100644 --- a/tests/Doctrine/Migrations/Tests/MigratorTest.php +++ b/tests/Doctrine/Migrations/Tests/MigratorTest.php @@ -21,6 +21,9 @@ use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Console\Output\StreamOutput; use Throwable; + +use function assert; + use const DIRECTORY_SEPARATOR; require_once __DIR__ . '/realpath.php'; @@ -36,7 +39,7 @@ class MigratorTest extends MigrationTestCase /** @var StreamOutput */ protected $output; - protected function setUp() : void + protected function setUp(): void { $this->conn = $this->getSqliteConnection(); $this->config = new Configuration($this->conn); @@ -44,7 +47,7 @@ protected function setUp() : void $this->config->setMigrationsNamespace('DoctrineMigrations\\'); } - public function testWriteSqlDown() : void + public function testWriteSqlDown(): void { $configuration = $this->createMock(Configuration::class); $migrationRepository = $this->createMock(MigrationRepository::class); @@ -88,7 +91,7 @@ public function testWriteSqlDown() : void $migration->writeSqlFile('/path', '1'); } - public function testMigrateToUnknownVersionThrowsException() : void + public function testMigrateToUnknownVersionThrowsException(): void { $migration = $this->createTestMigrator($this->config); @@ -98,7 +101,7 @@ public function testMigrateToUnknownVersionThrowsException() : void $migration->migrate('1234'); } - public function testMigrateWithNoMigrationsThrowsException() : void + public function testMigrateWithNoMigrationsThrowsException(): void { $migration = $this->createTestMigrator($this->config); @@ -108,11 +111,11 @@ public function testMigrateWithNoMigrationsThrowsException() : void $migration->migrate(); } - public function testMigrateWithNoMigrationsDontThrowsExceptionIfContiniousIntegrationOption() : void + public function testMigrateWithNoMigrationsDontThrowsExceptionIfContiniousIntegrationOption(): void { $messages = []; - $callback = static function ($msg) use (&$messages) : void { + $callback = static function ($msg) use (&$messages): void { $messages[] = $msg; }; @@ -132,13 +135,13 @@ public function testMigrateWithNoMigrationsDontThrowsExceptionIfContiniousIntegr /** * @dataProvider getSqlProvider */ - public function testGetSql(?string $to) : void + public function testGetSql(?string $to): void { - /** @var Migrator|MockObject $migration */ $migration = $this->getMockBuilder(Migrator::class) ->disableOriginalConstructor() ->setMethods(['migrate']) ->getMock(); + assert($migration instanceof Migrator || $migration instanceof MockObject); $expected = [['something']]; @@ -153,7 +156,7 @@ public function testGetSql(?string $to) : void } /** @return mixed[][] */ - public function getSqlProvider() : array + public function getSqlProvider(): array { return [ [null], @@ -166,7 +169,7 @@ public function getSqlProvider() : array * * @dataProvider writeSqlFileProvider */ - public function testWriteSqlFile(string $path, string $from, ?string $to, array $getSqlReturn) : void + public function testWriteSqlFile(string $path, string $from, ?string $to, array $getSqlReturn): void { $queryWriter = $this->createMock(QueryWriter::class); $outputWriter = $this->createMock(OutputWriter::class); @@ -210,11 +213,11 @@ public function testWriteSqlFile(string $path, string $from, ?string $to, array ->willReturn((string) ((int) $from + 1)); } - /** @var Migrator|MockObject $migration */ $migration = $this->getMockBuilder(Migrator::class) ->setConstructorArgs($this->getMigratorConstructorArgs($config)) ->setMethods(['getSql']) ->getMock(); + assert($migration instanceof Migrator || $migration instanceof MockObject); $migration->expects(self::once()) ->method('getSql') @@ -227,7 +230,7 @@ public function testWriteSqlFile(string $path, string $from, ?string $to, array /** * @return mixed[][] */ - public function writeSqlFileProvider() : array + public function writeSqlFileProvider(): array { return [ [__DIR__, '0', '1', ['1' => ['SHOW DATABASES;']]], // up @@ -238,11 +241,11 @@ public function writeSqlFileProvider() : array ]; } - public function testMigrateWithMigrationsAndAddTheCurrentVersionOutputsANoMigrationsMessage() : void + public function testMigrateWithMigrationsAndAddTheCurrentVersionOutputsANoMigrationsMessage(): void { $messages = []; - $callback = static function ($msg) use (&$messages) : void { + $callback = static function ($msg) use (&$messages): void { $messages[] = $msg; }; @@ -264,7 +267,7 @@ public function testMigrateWithMigrationsAndAddTheCurrentVersionOutputsANoMigrat self::assertStringContainsString('No migrations', $messages[0]); } - public function testMigrateAllOrNothing() : void + public function testMigrateAllOrNothing(): void { $this->config->setMigrationsDirectory(__DIR__ . '/Stub/migrations-empty-folder'); $this->config->setMigrationsNamespace('DoctrineMigrations\\'); @@ -278,7 +281,7 @@ public function testMigrateAllOrNothing() : void self::assertCount(1, $sql); } - public function testMigrateAllOrNothingRollback() : void + public function testMigrateAllOrNothingRollback(): void { $this->expectException(Throwable::class); $this->expectExceptionMessage('Migration up throws exception.'); diff --git a/tests/Doctrine/Migrations/Tests/OutputWriterTest.php b/tests/Doctrine/Migrations/Tests/OutputWriterTest.php index 253e7e8843..2558c3e822 100644 --- a/tests/Doctrine/Migrations/Tests/OutputWriterTest.php +++ b/tests/Doctrine/Migrations/Tests/OutputWriterTest.php @@ -15,7 +15,7 @@ final class OutputWriterTest extends TestCase /** @var string|null */ private $lastMessage; - public function testDefaultCallback() : void + public function testDefaultCallback(): void { $outputWriter = new OutputWriter(); @@ -24,16 +24,16 @@ public function testDefaultCallback() : void self::assertSame('test message', $outputWriter->getLastMessage()); } - public function testWrite() : void + public function testWrite(): void { $this->outputWriter->write('test message'); self::assertSame('test message', $this->lastMessage); } - public function testSetCallback() : void + public function testSetCallback(): void { - $this->outputWriter->setCallback(function (string $message) : void { + $this->outputWriter->setCallback(function (string $message): void { $this->lastMessage = '[LOG] ' . $message; }); @@ -42,9 +42,9 @@ public function testSetCallback() : void self::assertSame('[LOG] test message', $this->lastMessage); } - protected function setUp() : void + protected function setUp(): void { - $this->outputWriter = new OutputWriter(function (string $message) : void { + $this->outputWriter = new OutputWriter(function (string $message): void { $this->lastMessage = $message; }); } diff --git a/tests/Doctrine/Migrations/Tests/ParameterFormatterTest.php b/tests/Doctrine/Migrations/Tests/ParameterFormatterTest.php index 377b4a9fa9..bece097a76 100644 --- a/tests/Doctrine/Migrations/Tests/ParameterFormatterTest.php +++ b/tests/Doctrine/Migrations/Tests/ParameterFormatterTest.php @@ -21,7 +21,7 @@ class ParameterFormatterTest extends TestCase /** @var ParameterFormatter */ private $parameterFormatter; - public function testFormatParameters() : void + public function testFormatParameters(): void { $params = [ 0 => 'string value', @@ -58,7 +58,7 @@ public function testFormatParameters() : void self::assertSame($expected, $result); } - protected function setUp() : void + protected function setUp(): void { $this->connection = $this->createMock(Connection::class); diff --git a/tests/Doctrine/Migrations/Tests/Provider/A.php b/tests/Doctrine/Migrations/Tests/Provider/A.php index 55d80e0e2a..890cf663a1 100644 --- a/tests/Doctrine/Migrations/Tests/Provider/A.php +++ b/tests/Doctrine/Migrations/Tests/Provider/A.php @@ -9,7 +9,7 @@ class A /** @var int|null */ private $id; - public function getId() : ?int + public function getId(): ?int { return $this->id; } diff --git a/tests/Doctrine/Migrations/Tests/Provider/B.php b/tests/Doctrine/Migrations/Tests/Provider/B.php index 0bf35d5c8e..57c6b6b1c7 100644 --- a/tests/Doctrine/Migrations/Tests/Provider/B.php +++ b/tests/Doctrine/Migrations/Tests/Provider/B.php @@ -9,7 +9,7 @@ class B /** @var int|null */ private $id; - public function getId() : ?int + public function getId(): ?int { return $this->id; } diff --git a/tests/Doctrine/Migrations/Tests/Provider/C.php b/tests/Doctrine/Migrations/Tests/Provider/C.php index 5c509766c0..6d97ab3be2 100644 --- a/tests/Doctrine/Migrations/Tests/Provider/C.php +++ b/tests/Doctrine/Migrations/Tests/Provider/C.php @@ -9,7 +9,7 @@ class C /** @var int|null */ private $id; - public function getId() : ?int + public function getId(): ?int { return $this->id; } diff --git a/tests/Doctrine/Migrations/Tests/Provider/ClassMetadataFactory.php b/tests/Doctrine/Migrations/Tests/Provider/ClassMetadataFactory.php index 9abc7cbcd8..ef40f36dda 100644 --- a/tests/Doctrine/Migrations/Tests/Provider/ClassMetadataFactory.php +++ b/tests/Doctrine/Migrations/Tests/Provider/ClassMetadataFactory.php @@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping\ClassMetadataFactory as BaseMetadataFactoryAlias; use Doctrine\Persistence\Mapping\ClassMetadata; + use function array_reverse; class ClassMetadataFactory extends BaseMetadataFactoryAlias @@ -13,7 +14,7 @@ class ClassMetadataFactory extends BaseMetadataFactoryAlias /** * @return ClassMetadata[] */ - public function getAllMetadata() : array + public function getAllMetadata(): array { return array_reverse(parent::getAllMetadata()); } diff --git a/tests/Doctrine/Migrations/Tests/Provider/EmptySchemaProviderTest.php b/tests/Doctrine/Migrations/Tests/Provider/EmptySchemaProviderTest.php index bfbb5d5b4f..2beed27587 100644 --- a/tests/Doctrine/Migrations/Tests/Provider/EmptySchemaProviderTest.php +++ b/tests/Doctrine/Migrations/Tests/Provider/EmptySchemaProviderTest.php @@ -21,7 +21,7 @@ class EmptySchemaProviderTest extends MigrationTestCase /** @var EmptySchemaProvider */ private $emptyProvider; - public function testCreateSchema() : void + public function testCreateSchema(): void { $schemaConfig = new SchemaConfig(); $schemaConfig->setExplicitForeignKeyIndexes(true); @@ -38,7 +38,7 @@ public function testCreateSchema() : void self::assertSame([], $schema->getNamespaces()); } - protected function setUp() : void + protected function setUp(): void { $this->schemaManager = $this->createMock(AbstractSchemaManager::class); $this->emptyProvider = new EmptySchemaProvider($this->schemaManager); diff --git a/tests/Doctrine/Migrations/Tests/Provider/OrmSchemaProviderTest.php b/tests/Doctrine/Migrations/Tests/Provider/OrmSchemaProviderTest.php index 18a44f1449..caf33cd3f0 100644 --- a/tests/Doctrine/Migrations/Tests/Provider/OrmSchemaProviderTest.php +++ b/tests/Doctrine/Migrations/Tests/Provider/OrmSchemaProviderTest.php @@ -31,7 +31,7 @@ class OrmSchemaProviderTest extends MigrationTestCase /** @var OrmSchemaProvider */ private $ormProvider; - public function testCreateSchemaFetchesMetadataFromEntityManager() : void + public function testCreateSchemaFetchesMetadataFromEntityManager(): void { $schema = $this->ormProvider->createSchema(); @@ -50,7 +50,7 @@ public function testCreateSchemaFetchesMetadataFromEntityManager() : void } } - public function testEntityManagerWithoutMetadataCausesError() : void + public function testEntityManagerWithoutMetadataCausesError(): void { $this->expectException(UnexpectedValueException::class); @@ -59,7 +59,7 @@ public function testEntityManagerWithoutMetadataCausesError() : void $this->ormProvider->createSchema(); } - protected function setUp() : void + protected function setUp(): void { $this->config = Setup::createXMLMetadataConfiguration([__DIR__ . '/_files'], true); $this->config->setClassMetadataFactoryName(ClassMetadataFactory::class); diff --git a/tests/Doctrine/Migrations/Tests/RollupTest.php b/tests/Doctrine/Migrations/Tests/RollupTest.php index d55d84c351..83bd99ecc3 100644 --- a/tests/Doctrine/Migrations/Tests/RollupTest.php +++ b/tests/Doctrine/Migrations/Tests/RollupTest.php @@ -27,7 +27,7 @@ class RollupTest extends TestCase /** @var Rollup */ private $rollup; - public function testRollupNoMigrtionsFoundException() : void + public function testRollupNoMigrtionsFoundException(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('No migrations found.'); @@ -39,7 +39,7 @@ public function testRollupNoMigrtionsFoundException() : void $this->rollup->rollup(); } - public function testRollupTooManyMigrationsException() : void + public function testRollupTooManyMigrationsException(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Too many migrations.'); @@ -59,7 +59,7 @@ public function testRollupTooManyMigrationsException() : void $this->rollup->rollup(); } - public function testRollup() : void + public function testRollup(): void { $version1 = $this->createMock(Version::class); @@ -83,7 +83,7 @@ public function testRollup() : void self::assertSame($version1, $this->rollup->rollup()); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->connection = $this->createMock(Connection::class); diff --git a/tests/Doctrine/Migrations/Tests/SchemaDumperTest.php b/tests/Doctrine/Migrations/Tests/SchemaDumperTest.php index 1781daaa85..d5ab11614e 100644 --- a/tests/Doctrine/Migrations/Tests/SchemaDumperTest.php +++ b/tests/Doctrine/Migrations/Tests/SchemaDumperTest.php @@ -32,7 +32,7 @@ class SchemaDumperTest extends TestCase /** @var SchemaDumper */ private $schemaDumper; - public function testDumpNoTablesException() : void + public function testDumpNoTablesException(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Your database schema does not contain any tables.'); @@ -50,7 +50,7 @@ public function testDumpNoTablesException() : void $this->schemaDumper->dump('1234'); } - public function testDump() : void + public function testDump(): void { $table = $this->createMock(Table::class); @@ -90,7 +90,7 @@ public function testDump() : void self::assertSame('/path/to/migration.php', $this->schemaDumper->dump('1234')); } - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->schemaManager = $this->createMock(AbstractSchemaManager::class); diff --git a/tests/Doctrine/Migrations/Tests/StopwatchTest.php b/tests/Doctrine/Migrations/Tests/StopwatchTest.php index 022a29236b..cb8548468d 100644 --- a/tests/Doctrine/Migrations/Tests/StopwatchTest.php +++ b/tests/Doctrine/Migrations/Tests/StopwatchTest.php @@ -13,7 +13,7 @@ class StopwatchTest extends TestCase /** @var Stopwatch */ private $stopwatch; - public function testStart() : void + public function testStart(): void { $stopwatchEvent = $this->stopwatch->start('test'); @@ -22,7 +22,7 @@ public function testStart() : void $stopwatchEvent->stop(); } - protected function setUp() : void + protected function setUp(): void { $symfonyStopwatch = new SymfonyStopwatch(); diff --git a/tests/Doctrine/Migrations/Tests/Stub/AbstractMigrationStub.php b/tests/Doctrine/Migrations/Tests/Stub/AbstractMigrationStub.php index 6061903cf1..b86f1f85b7 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/AbstractMigrationStub.php +++ b/tests/Doctrine/Migrations/Tests/Stub/AbstractMigrationStub.php @@ -10,20 +10,20 @@ class AbstractMigrationStub extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { } - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function exposedWrite(string $message) : void + public function exposedWrite(string $message): void { $this->write($message); } - public function exposedThrowIrreversibleMigrationException(?string $message = null) : void + public function exposedThrowIrreversibleMigrationException(?string $message = null): void { $this->throwIrreversibleMigrationException($message); } @@ -32,12 +32,12 @@ public function exposedThrowIrreversibleMigrationException(?string $message = nu * @param int[] $params * @param int[] $types */ - public function exposedAddSql(string $sql, array $params = [], array $types = []) : void + public function exposedAddSql(string $sql, array $params = [], array $types = []): void { $this->addSql($sql, $params, $types); } - public function getVersion() : Version + public function getVersion(): Version { return $this->version; } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version1Test.php b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version1Test.php index 45fef775c0..32b7367682 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version1Test.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version1Test.php @@ -9,11 +9,11 @@ class Version1Test extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version2Test.php b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version2Test.php index a55f62abd5..1de42a4df4 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version2Test.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version2Test.php @@ -9,11 +9,11 @@ class Version2Test extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version3Test.php b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version3Test.php index 67b723b6c6..d33ba0db23 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version3Test.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version3Test.php @@ -9,11 +9,11 @@ class Version3Test extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version4Test.php b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version4Test.php index 306b5c9949..036ac1cfcd 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version4Test.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version4Test.php @@ -9,11 +9,11 @@ class Version4Test extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version5Test.php b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version5Test.php index 4b6befa149..4170a3be07 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version5Test.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Configuration/AutoloadVersions/Version5Test.php @@ -9,11 +9,11 @@ class Version5Test extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/EventVerificationListener.php b/tests/Doctrine/Migrations/Tests/Stub/EventVerificationListener.php index c390e7b69c..68cef247ae 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/EventVerificationListener.php +++ b/tests/Doctrine/Migrations/Tests/Stub/EventVerificationListener.php @@ -14,7 +14,7 @@ final class EventVerificationListener implements EventSubscriber public $events = []; /** @return string[] */ - public function getSubscribedEvents() : array + public function getSubscribedEvents(): array { return [ Events::onMigrationsMigrating, @@ -25,27 +25,27 @@ public function getSubscribedEvents() : array ]; } - public function onMigrationsMigrating(EventArgs $args) : void + public function onMigrationsMigrating(EventArgs $args): void { $this->events[__FUNCTION__][] = $args; } - public function onMigrationsMigrated(EventArgs $args) : void + public function onMigrationsMigrated(EventArgs $args): void { $this->events[__FUNCTION__][] = $args; } - public function onMigrationsVersionExecuting(EventArgs $args) : void + public function onMigrationsVersionExecuting(EventArgs $args): void { $this->events[__FUNCTION__][] = $args; } - public function onMigrationsVersionExecuted(EventArgs $args) : void + public function onMigrationsVersionExecuted(EventArgs $args): void { $this->events[__FUNCTION__][] = $args; } - public function onMigrationsVersionSkipped(EventArgs $args) : void + public function onMigrationsVersionSkipped(EventArgs $args): void { $this->events[__FUNCTION__][] = $args; } diff --git a/tests/Doctrine/Migrations/Tests/Stub/ExceptionVersionDummy.php b/tests/Doctrine/Migrations/Tests/Stub/ExceptionVersionDummy.php index 1960225f60..2cb795b2bf 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/ExceptionVersionDummy.php +++ b/tests/Doctrine/Migrations/Tests/Stub/ExceptionVersionDummy.php @@ -10,12 +10,12 @@ class ExceptionVersionDummy extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { throw new Exception('Super Exception'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { throw new Exception('Super Exception'); } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun1.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun1.php index 3f1039ce1e..fd07db00ff 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun1.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun1.php @@ -9,13 +9,13 @@ class DryRun1 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { $table = $schema->createTable('foo'); $table->addColumn('id', 'integer'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $schema->dropTable('foo'); } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun2.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun2.php index 7dab4b44e7..c3739a14c4 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun2.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/DryRun/DryRun2.php @@ -9,13 +9,13 @@ class DryRun2 extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { $table = $schema->getTable('foo'); $table->addColumn('bar', 'string', ['notnull' => false]); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $table = $schema->getTable('foo'); $table->dropColumn('bar'); diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateAddSqlPostAndPreUpAndDownTest.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateAddSqlPostAndPreUpAndDownTest.php index f730cd4a77..04a5a0db0e 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateAddSqlPostAndPreUpAndDownTest.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateAddSqlPostAndPreUpAndDownTest.php @@ -6,13 +6,14 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; + use function sprintf; class MigrateAddSqlPostAndPreUpAndDownTest extends AbstractMigration { public const TABLE_NAME = 'test_add_sql_post_up_table'; - public function preUp(Schema $schema) : void + public function preUp(Schema $schema): void { $this->addSql( sprintf('INSERT INTO %s (test) values (?)', self::TABLE_NAME), @@ -20,7 +21,7 @@ public function preUp(Schema $schema) : void ); } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql( sprintf('INSERT INTO %s (test) values (?)', self::TABLE_NAME), @@ -28,7 +29,7 @@ public function up(Schema $schema) : void ); } - public function postUp(Schema $schema) : void + public function postUp(Schema $schema): void { $this->addSql( sprintf('INSERT INTO %s (test) values (?)', self::TABLE_NAME), @@ -36,7 +37,7 @@ public function postUp(Schema $schema) : void ); } - public function preDown(Schema $schema) : void + public function preDown(Schema $schema): void { $this->addSql( sprintf('INSERT INTO %s (test) values (?)', self::TABLE_NAME), @@ -44,7 +45,7 @@ public function preDown(Schema $schema) : void ); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $this->addSql( sprintf('INSERT INTO %s (test) values (?)', self::TABLE_NAME), @@ -52,7 +53,7 @@ public function down(Schema $schema) : void ); } - public function postDown(Schema $schema) : void + public function postDown(Schema $schema): void { $this->addSql( sprintf('INSERT INTO %s (test) values (?)', self::TABLE_NAME), diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateAddSqlTest.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateAddSqlTest.php index 773d386018..26c391598f 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateAddSqlTest.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateAddSqlTest.php @@ -9,13 +9,13 @@ class MigrateAddSqlTest extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('CREATE TABLE test_add_sql_table (test varchar(255))'); $this->addSql('INSERT INTO test_add_sql_table (test) values (?)', ['test']); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $this->addSql('DROP TABLE test_add_sql_table'); } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateNotTouchingTheSchema.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateNotTouchingTheSchema.php index 700aef0b0e..ed67b5d0e5 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateNotTouchingTheSchema.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateNotTouchingTheSchema.php @@ -9,29 +9,29 @@ class MigrateNotTouchingTheSchema extends AbstractMigration { - public function preUp(Schema $schema) : void + public function preUp(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('SELECT 1'); } - public function postUp(Schema $schema) : void + public function postUp(Schema $schema): void { } - public function preDown(Schema $schema) : void + public function preDown(Schema $schema): void { } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $this->addSql('SELECT 1'); } - public function postDown(Schema $schema) : void + public function postDown(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateWithDataModification.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateWithDataModification.php index 0f191e8144..a113e47d25 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateWithDataModification.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrateWithDataModification.php @@ -9,19 +9,19 @@ class MigrateWithDataModification extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('INSERT INTO test_data_migration (test) VALUES (1)'); $this->addSql('INSERT INTO test_data_migration (test) VALUES (2)'); $this->addSql('INSERT INTO test_data_migration (test) VALUES (3)'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $this->addSql('DELETE FROM test_data_migration'); } - public function isTransactional() : bool + public function isTransactional(): bool { return true; } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationMigrateFurther.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationMigrateFurther.php index 628f2f8461..26054d9284 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationMigrateFurther.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationMigrateFurther.php @@ -9,12 +9,12 @@ class MigrationMigrateFurther extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { $schema->dropTable('bar'); } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $table = $schema->createTable('bar'); $table->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationMigrateUp.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationMigrateUp.php index b0ae002143..a51e004be6 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationMigrateUp.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationMigrateUp.php @@ -9,12 +9,12 @@ class MigrationMigrateUp extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { $schema->dropTable('foo'); } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $table = $schema->createTable('foo'); $table->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationModifySchemaInPreAndPost.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationModifySchemaInPreAndPost.php index 59668db399..b434e222c7 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationModifySchemaInPreAndPost.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationModifySchemaInPreAndPost.php @@ -9,38 +9,38 @@ class MigrationModifySchemaInPreAndPost extends AbstractMigration { - private function addTable(Schema $schema, string $tableName) : void + private function addTable(Schema $schema, string $tableName): void { $table = $schema->createTable($tableName); $table->addColumn('id', 'integer'); } - public function preUp(Schema $schema) : void + public function preUp(Schema $schema): void { $this->addTable($schema, 'bar'); } - public function preDown(Schema $schema) : void + public function preDown(Schema $schema): void { $this->addTable($schema, 'bar'); } - public function postUp(Schema $schema) : void + public function postUp(Schema $schema): void { $this->addTable($schema, 'bar2'); } - public function postDown(Schema $schema) : void + public function postDown(Schema $schema): void { $this->addTable($schema, 'bar2'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $schema->dropTable('foo'); } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $table = $schema->createTable('foo'); $table->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationSkipMigration.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationSkipMigration.php index f69ccf8acd..677f07ab83 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationSkipMigration.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationSkipMigration.php @@ -8,12 +8,12 @@ class MigrationSkipMigration extends MigrationMigrateUp { - public function preUp(Schema $schema) : void + public function preUp(Schema $schema): void { $this->skipIf(true); } - public function preDown(Schema $schema) : void + public function preDown(Schema $schema): void { $this->skipIf(true); } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationThrowsError.php b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationThrowsError.php index 314de7fa83..306d52a7a9 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationThrowsError.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Functional/MigrationThrowsError.php @@ -10,12 +10,12 @@ class MigrationThrowsError extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { throw new Exception('Migration up throws exception.'); } - public function down(Schema $schema) : void + public function down(Schema $schema): void { throw new Exception('Migration down throws exception.'); } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Version1Test.php b/tests/Doctrine/Migrations/Tests/Stub/Version1Test.php index 3a83e0cfef..225afc8775 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Version1Test.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Version1Test.php @@ -9,11 +9,11 @@ class Version1Test extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Version2Test.php b/tests/Doctrine/Migrations/Tests/Stub/Version2Test.php index ec9d388c16..987f2b33b7 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Version2Test.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Version2Test.php @@ -9,11 +9,11 @@ class Version2Test extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/Version3Test.php b/tests/Doctrine/Migrations/Tests/Stub/Version3Test.php index 7c4a1c3175..8e97ea1910 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/Version3Test.php +++ b/tests/Doctrine/Migrations/Tests/Stub/Version3Test.php @@ -9,11 +9,11 @@ class Version3Test extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunNamedParams.php b/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunNamedParams.php index d6fd1efe2b..5c4fe0fb4b 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunNamedParams.php +++ b/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunNamedParams.php @@ -9,11 +9,11 @@ class VersionDryRunNamedParams extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('INSERT INTO test VALUES (:one, :two)', [ 'one' => 'one', diff --git a/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunQuestionMarkParams.php b/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunQuestionMarkParams.php index c192b7a834..a161befecd 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunQuestionMarkParams.php +++ b/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunQuestionMarkParams.php @@ -9,11 +9,11 @@ class VersionDryRunQuestionMarkParams extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('INSERT INTO test VALUES (?, ?)', ['one', 'two']); } diff --git a/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunTypes.php b/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunTypes.php index 3e7307a668..14b3876dad 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunTypes.php +++ b/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunTypes.php @@ -19,17 +19,17 @@ class VersionDryRunTypes extends AbstractMigration * @param mixed[] $value * @param int[] $type */ - public function setParam(array $value, array $type) : void + public function setParam(array $value, array $type): void { $this->value = $value; $this->type = $type; } - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('INSERT INTO test VALUES (?)', $this->value, $this->type); } diff --git a/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunWithoutParams.php b/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunWithoutParams.php index 70a7391fbf..f1198fda04 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunWithoutParams.php +++ b/tests/Doctrine/Migrations/Tests/Stub/VersionDryRunWithoutParams.php @@ -9,11 +9,11 @@ class VersionDryRunWithoutParams extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('SELECT 1 WHERE 1'); } diff --git a/tests/Doctrine/Migrations/Tests/Stub/VersionDummy.php b/tests/Doctrine/Migrations/Tests/Stub/VersionDummy.php index e7bfcdbee7..4c8561f46c 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/VersionDummy.php +++ b/tests/Doctrine/Migrations/Tests/Stub/VersionDummy.php @@ -9,11 +9,11 @@ class VersionDummy extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { } - public function down(Schema $schema) : void + public function down(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/VersionDummyDescription.php b/tests/Doctrine/Migrations/Tests/Stub/VersionDummyDescription.php index 1e7a7a9a86..286111e1f9 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/VersionDummyDescription.php +++ b/tests/Doctrine/Migrations/Tests/Stub/VersionDummyDescription.php @@ -9,16 +9,16 @@ class VersionDummyDescription extends AbstractMigration { - public function getDescription() : string + public function getDescription(): string { return 'My super migration'; } - public function up(Schema $schema) : void + public function up(Schema $schema): void { } - public function down(Schema $schema) : void + public function down(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSql.php b/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSql.php index 2b49369f04..5e43b27007 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSql.php +++ b/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSql.php @@ -9,12 +9,12 @@ class VersionOutputSql extends AbstractMigration { - public function down(Schema $schema) : void + public function down(Schema $schema): void { $this->addSql('Select 1'); } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('Select 1'); } diff --git a/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSqlWithParam.php b/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSqlWithParam.php index 1852f679ef..4b4ddb3b6a 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSqlWithParam.php +++ b/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSqlWithParam.php @@ -17,16 +17,16 @@ class VersionOutputSqlWithParam extends AbstractMigration ]; /** @param mixed[] $param */ - public function setParam(array $param) : void + public function setParam(array $param): void { $this->param = $param; } - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('Select 1 WHERE 1'); $this->addSql('Select :param1 WHERE :param2 = :param3', $this->param); diff --git a/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSqlWithParamAndType.php b/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSqlWithParamAndType.php index e758272276..9230474358 100644 --- a/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSqlWithParamAndType.php +++ b/tests/Doctrine/Migrations/Tests/Stub/VersionOutputSqlWithParamAndType.php @@ -17,22 +17,22 @@ class VersionOutputSqlWithParamAndType extends AbstractMigration private $type = [Connection::PARAM_STR_ARRAY]; /** @param mixed[] $param */ - public function setParam(array $param) : void + public function setParam(array $param): void { $this->param = $param; } /** @param int[] $type */ - public function setType(array $type) : void + public function setType(array $type): void { $this->type = $type; } - public function down(Schema $schema) : void + public function down(Schema $schema): void { } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('Select id WHERE id IN ( :param1 )', $this->param, $this->type); } diff --git a/tests/Doctrine/Migrations/Tests/Tools/BooleanStringFormatterTest.php b/tests/Doctrine/Migrations/Tests/Tools/BooleanStringFormatterTest.php index 2c2d56a4e3..80603383e3 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/BooleanStringFormatterTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/BooleanStringFormatterTest.php @@ -9,7 +9,7 @@ class BooleanStringFormatterTest extends TestCase { - public function testToBoolean() : void + public function testToBoolean(): void { self::assertTrue(BooleanStringFormatter::toBoolean('true', false)); self::assertTrue(BooleanStringFormatter::toBoolean('1', false)); diff --git a/tests/Doctrine/Migrations/Tests/Tools/BytesFormatterTest.php b/tests/Doctrine/Migrations/Tests/Tools/BytesFormatterTest.php index 5f5f24e29b..ec09cbc89d 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/BytesFormatterTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/BytesFormatterTest.php @@ -9,7 +9,7 @@ class BytesFormatterTest extends TestCase { - public function testFormatBytes() : void + public function testFormatBytes(): void { self::assertSame('1000', BytesFormatter::formatBytes(1000)); self::assertSame('97.66K', BytesFormatter::formatBytes(100000)); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/AbstractCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/AbstractCommandTest.php index 693316cb59..c84486c906 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/AbstractCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/AbstractCommandTest.php @@ -19,6 +19,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\Output; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function chdir; use function getcwd; @@ -36,16 +37,16 @@ public function invokeMigrationConfigurationGetter( ?Configuration $configuration = null, bool $noConnection = false, ?HelperSet $helperSet = null - ) : Configuration { + ): Configuration { $class = new ReflectionClass(AbstractCommand::class); $method = $class->getMethod('getMigrationConfiguration'); $method->setAccessible(true); - /** @var AbstractCommand $command */ $command = $this->getMockForAbstractClass( AbstractCommand::class, ['command'] ); + assert($command instanceof AbstractCommand); if ($helperSet instanceof HelperSet) { $command->setHelperSet($helperSet); @@ -73,7 +74,7 @@ public function invokeMigrationConfigurationGetter( return $method->invokeArgs($command, [$input, $output]); } - public function testSetConnection() : void + public function testSetConnection(): void { $command = new TestAbstractCommand(); $connection = $this->createMock(Connection::class); @@ -83,7 +84,7 @@ public function testSetConnection() : void self::assertSame($connection, $command->getConnection()); } - public function testGetMigrationConfigurationDefaultsToConnection() : void + public function testGetMigrationConfigurationDefaultsToConnection(): void { $configuration = $this->createMock(Configuration::class); $input = $this->createMock(InputInterface::class); @@ -98,7 +99,7 @@ public function testGetMigrationConfigurationDefaultsToConnection() : void /** * Test if the returned migration configuration is the injected one */ - public function testInjectedMigrationConfigurationIsBeingReturned() : void + public function testInjectedMigrationConfigurationIsBeingReturned(): void { $input = $this->getMockBuilder(ArrayInput::class) ->setConstructorArgs([[]]) @@ -117,7 +118,7 @@ public function testInjectedMigrationConfigurationIsBeingReturned() : void /** * Test if the migration configuration returns the connection from the helper set */ - public function testMigrationConfigurationReturnsConnectionFromHelperSet() : void + public function testMigrationConfigurationReturnsConnectionFromHelperSet(): void { $input = $this->getMockBuilder(ArrayInput::class) ->setConstructorArgs([[]]) @@ -136,7 +137,7 @@ public function testMigrationConfigurationReturnsConnectionFromHelperSet() : voi /** * Test if the migration configuration returns the connection from the input option */ - public function testMigrationConfigurationReturnsConnectionFromInputOption() : void + public function testMigrationConfigurationReturnsConnectionFromInputOption(): void { $input = $this->getMockBuilder(ArrayInput::class) ->setConstructorArgs([[]]) @@ -156,7 +157,7 @@ public function testMigrationConfigurationReturnsConnectionFromInputOption() : v /** * Test if the migration configuration returns values from the configuration file */ - public function testMigrationConfigurationReturnsConfigurationFileOption() : void + public function testMigrationConfigurationReturnsConfigurationFileOption(): void { $input = $this->getMockBuilder(ArrayInput::class) ->setConstructorArgs([[]]) @@ -179,7 +180,7 @@ public function testMigrationConfigurationReturnsConfigurationFileOption() : voi /** * Test if the migration configuration use the connection in a configuration passed to it. */ - public function testMigrationConfigurationReturnsConnectionFromConfigurationIfNothingElseIsProvided() : void + public function testMigrationConfigurationReturnsConnectionFromConfigurationIfNothingElseIsProvided(): void { $input = $this->getMockBuilder(ArrayInput::class) ->setConstructorArgs([[]]) @@ -197,7 +198,7 @@ public function testMigrationConfigurationReturnsConnectionFromConfigurationIfNo /** * Test if throw an error if no connection is passed. */ - public function testMigrationConfigurationReturnsErrorWhenNoConnectionIsProvided() : void + public function testMigrationConfigurationReturnsErrorWhenNoConnectionIsProvided(): void { $input = $this->getMockBuilder(ArrayInput::class) ->setConstructorArgs([[]]) @@ -209,7 +210,7 @@ public function testMigrationConfigurationReturnsErrorWhenNoConnectionIsProvided $this->invokeMigrationConfigurationGetter($input, null, true); } - public function testMigrationsConfigurationFromCommandLineOverridesInjectedConfiguration() : void + public function testMigrationsConfigurationFromCommandLineOverridesInjectedConfiguration(): void { $input = $this->getMockBuilder(ArrayInput::class) ->setConstructorArgs([[]]) @@ -239,7 +240,7 @@ public function testMigrationsConfigurationFromCommandLineOverridesInjectedConfi * * @group regression */ - public function testInjectedConfigurationIsPreferedOverConfigFileIsCurrentWorkingDirectory() : void + public function testInjectedConfigurationIsPreferedOverConfigFileIsCurrentWorkingDirectory(): void { $input = $this->getMockBuilder(ArrayInput::class) ->setConstructorArgs([[]]) @@ -262,7 +263,7 @@ public function testInjectedConfigurationIsPreferedOverConfigFileIsCurrentWorkin /** * Test if the migration configuration can be set via ConfigurationHelper in HelperSet */ - public function testMigrationsConfigurationFromConfighelperInHelperset() : void + public function testMigrationsConfigurationFromConfighelperInHelperset(): void { $input = $this->getMockBuilder(ArrayInput::class) ->setConstructorArgs([[]]) @@ -287,16 +288,16 @@ private function invokeAbstractCommandConfirmation( QuestionHelper $helper, string $response = 'y', string $question = 'There is no question?' - ) : bool { + ): bool { $class = new ReflectionClass(AbstractCommand::class); $method = $class->getMethod('askConfirmation'); $method->setAccessible(true); - /** @var AbstractCommand $command */ $command = $this->getMockForAbstractClass( AbstractCommand::class, ['command'] ); + assert($command instanceof AbstractCommand); $input->setStream($this->getInputStream($response . "\n")); @@ -311,7 +312,7 @@ private function invokeAbstractCommandConfirmation( return $method->invokeArgs($command, [$question, $input, $output]); } - public function testAskConfirmation() : void + public function testAskConfirmation(): void { $input = new ArrayInput([]); $helper = new QuestionHelper(); @@ -320,7 +321,7 @@ public function testAskConfirmation() : void self::assertFalse($this->invokeAbstractCommandConfirmation($input, $helper, 'n')); } - protected function setUp() : void + protected function setUp(): void { $cwd = getcwd(); @@ -329,7 +330,7 @@ protected function setUp() : void $this->originalCwd = $cwd; } - protected function tearDown() : void + protected function tearDown(): void { if (getcwd() === $this->originalCwd) { return; @@ -341,12 +342,12 @@ protected function tearDown() : void class TestAbstractCommand extends AbstractCommand { - public function getConnection() : Connection + public function getConnection(): Connection { return $this->connection; } - public function getConfiguration(InputInterface $input, OutputInterface $output) : Configuration + public function getConfiguration(InputInterface $input, OutputInterface $output): Configuration { return $this->getMigrationConfiguration($input, $output); } diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/CommandTestCase.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/CommandTestCase.php index c4e6b81c20..28e3c9a1c6 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/CommandTestCase.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/CommandTestCase.php @@ -11,6 +11,7 @@ use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; + use function array_replace; use function assert; use function is_string; @@ -29,7 +30,7 @@ abstract class CommandTestCase extends MigrationTestCase /** @var Connection */ protected $connection; - protected function setUp() : void + protected function setUp(): void { $this->connection = $this->createConnection(); $this->config = $this->createMock(Configuration::class); @@ -40,14 +41,14 @@ protected function setUp() : void $this->app->add($this->command); } - abstract protected function createCommand() : AbstractCommand; + abstract protected function createCommand(): AbstractCommand; - protected function createConnection() : Connection + protected function createConnection(): Connection { return $this->getSqliteConnection(); } - protected function createCommandTester() : CommandTester + protected function createCommandTester(): CommandTester { $name = $this->command->getName(); assert(is_string($name)); @@ -61,7 +62,7 @@ protected function createCommandTester() : CommandTester * * @return mixed[] [CommandTester, int] */ - protected function executeCommand(array $args, array $options = []) : array + protected function executeCommand(array $args, array $options = []): array { $tester = $this->createCommandTester(); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DialogSupport.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DialogSupport.php index 8460174d54..87e9579f5a 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DialogSupport.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DialogSupport.php @@ -13,14 +13,14 @@ trait DialogSupport /** @var QuestionHelper|MockObject */ protected $questions; - protected function configureDialogs(Application $app) : void + protected function configureDialogs(Application $app): void { $this->questions = $this->createMock(QuestionHelper::class); $app->getHelperSet()->set($this->questions, 'question'); } - protected function willAskConfirmationAndReturn(bool $bool) : void + protected function willAskConfirmationAndReturn(bool $bool): void { $this->questions->expects(self::once()) ->method('ask') diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DiffCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DiffCommandTest.php index e95aef62a6..08fb1ab37f 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DiffCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DiffCommandTest.php @@ -23,7 +23,7 @@ final class DiffCommandTest extends TestCase /** @var DiffCommand|MockObject */ private $diffCommand; - public function testExecute() : void + public function testExecute(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -93,7 +93,7 @@ public function testExecute() : void $this->diffCommand->execute($input, $output); } - protected function setUp() : void + protected function setUp(): void { $this->migrationDiffGenerator = $this->createMock(DiffGenerator::class); $this->configuration = $this->createMock(Configuration::class); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DumpSchemaCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DumpSchemaCommandTest.php index 96e2f8e827..05d4008f07 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DumpSchemaCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/DumpSchemaCommandTest.php @@ -33,7 +33,7 @@ final class DumpSchemaCommandTest extends TestCase /** @var DumpSchemaCommand|MockObject */ private $dumpSchemaCommand; - public function testExecuteThrowsRuntimeException() : void + public function testExecuteThrowsRuntimeException(): void { $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Delete any previous migrations before dumping your schema.'); @@ -52,7 +52,7 @@ public function testExecuteThrowsRuntimeException() : void $this->dumpSchemaCommand->execute($input, $output); } - public function testExecute() : void + public function testExecute(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -101,7 +101,7 @@ public function testExecute() : void $this->dumpSchemaCommand->execute($input, $output); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->dependencyFactory = $this->createMock(DependencyFactory::class); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/ExecuteCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/ExecuteCommandTest.php index cfefee5e1e..160d3aff9d 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/ExecuteCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/ExecuteCommandTest.php @@ -11,6 +11,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; + use function getcwd; class ExecuteCommandTest extends TestCase @@ -21,7 +22,7 @@ class ExecuteCommandTest extends TestCase /** @var ExecuteCommand|MockObject */ private $executeCommand; - public function testWriteSqlCustomPath() : void + public function testWriteSqlCustomPath(): void { $versionName = '1'; @@ -56,7 +57,7 @@ public function testWriteSqlCustomPath() : void self::assertSame(0, $this->executeCommand->execute($input, $output)); } - public function testWriteSqlCurrentWorkingDirectory() : void + public function testWriteSqlCurrentWorkingDirectory(): void { $versionName = '1'; @@ -91,7 +92,7 @@ public function testWriteSqlCurrentWorkingDirectory() : void self::assertSame(0, $this->executeCommand->execute($input, $output)); } - public function testExecute() : void + public function testExecute(): void { $versionName = '1'; @@ -136,7 +137,7 @@ public function testExecute() : void self::assertSame(0, $this->executeCommand->execute($input, $output)); } - public function testExecuteCancel() : void + public function testExecuteCancel(): void { $versionName = '1'; @@ -184,7 +185,7 @@ public function testExecuteCancel() : void self::assertSame(1, $this->executeCommand->execute($input, $output)); } - protected function setUp() : void + protected function setUp(): void { $this->migrationRepository = $this->createMock(MigrationRepository::class); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/GenerateCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/GenerateCommandTest.php index a73a08d340..13d61a045a 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/GenerateCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/GenerateCommandTest.php @@ -27,7 +27,7 @@ final class GenerateCommandTest extends TestCase /** @var GenerateCommand|MockObject */ private $generateCommand; - public function testExecute() : void + public function testExecute(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -63,7 +63,7 @@ public function testExecute() : void $this->generateCommand->execute($input, $output); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->dependencyFactory = $this->createMock(DependencyFactory::class); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php index daf9e93056..fef6f517b2 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; + use function getcwd; class MigrateCommandTest extends TestCase @@ -29,7 +30,7 @@ class MigrateCommandTest extends TestCase /** @var MigrateCommand|MockObject */ private $migrateCommand; - public function testExecuteCouldNotResolveAlias() : void + public function testExecuteCouldNotResolveAlias(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -51,7 +52,7 @@ public function testExecuteCouldNotResolveAlias() : void self::assertSame(1, $this->migrateCommand->execute($input, $output)); } - public function testExecuteAlreadyAtFirstVersion() : void + public function testExecuteAlreadyAtFirstVersion(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -77,7 +78,7 @@ public function testExecuteAlreadyAtFirstVersion() : void self::assertSame(1, $this->migrateCommand->execute($input, $output)); } - public function testExecuteAlreadyAtLatestVersion() : void + public function testExecuteAlreadyAtLatestVersion(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -103,7 +104,7 @@ public function testExecuteAlreadyAtLatestVersion() : void self::assertSame(1, $this->migrateCommand->execute($input, $output)); } - public function testExecuteTheDeltaCouldNotBeReached() : void + public function testExecuteTheDeltaCouldNotBeReached(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -129,7 +130,7 @@ public function testExecuteTheDeltaCouldNotBeReached() : void self::assertSame(1, $this->migrateCommand->execute($input, $output)); } - public function testExecuteUnknownVersion() : void + public function testExecuteUnknownVersion(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -155,7 +156,7 @@ public function testExecuteUnknownVersion() : void self::assertSame(1, $this->migrateCommand->execute($input, $output)); } - public function testExecutedUnavailableMigrationsCancel() : void + public function testExecutedUnavailableMigrationsCancel(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -185,7 +186,7 @@ public function testExecutedUnavailableMigrationsCancel() : void self::assertSame(1, $this->migrateCommand->execute($input, $output)); } - public function testExecuteWriteSqlCustomPath() : void + public function testExecuteWriteSqlCustomPath(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -230,7 +231,7 @@ public function testExecuteWriteSqlCustomPath() : void self::assertSame(0, $this->migrateCommand->execute($input, $output)); } - public function testExecuteWriteSqlCurrentWorkingDirectory() : void + public function testExecuteWriteSqlCurrentWorkingDirectory(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -275,7 +276,7 @@ public function testExecuteWriteSqlCurrentWorkingDirectory() : void self::assertSame(0, $this->migrateCommand->execute($input, $output)); } - public function testExecuteMigrate() : void + public function testExecuteMigrate(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -326,7 +327,7 @@ public function testExecuteMigrate() : void self::assertSame(0, $this->migrateCommand->execute($input, $output)); } - public function testExecuteMigrateAllOrNothing() : void + public function testExecuteMigrateAllOrNothing(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -397,7 +398,7 @@ public function testExecuteMigrateAllOrNothing() : void self::assertSame(0, $this->migrateCommand->execute($input, $output)); } - public function testExecuteMigrateCancelExecutedUnavailableMigrations() : void + public function testExecuteMigrateCancelExecutedUnavailableMigrations(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -442,7 +443,7 @@ public function testExecuteMigrateCancelExecutedUnavailableMigrations() : void self::assertSame(1, $this->migrateCommand->execute($input, $output)); } - public function testExecuteMigrateCancel() : void + public function testExecuteMigrateCancel(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -492,7 +493,7 @@ public function testExecuteMigrateCancel() : void self::assertSame(1, $this->migrateCommand->execute($input, $output)); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->migrationRepository = $this->createMock(MigrationRepository::class); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationStatusTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationStatusTest.php index f284f04058..e146be3dea 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationStatusTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationStatusTest.php @@ -9,6 +9,7 @@ use Doctrine\Migrations\Tests\Stub\Version1Test; use Doctrine\Migrations\Tools\Console\Command\StatusCommand; use Symfony\Component\Console\Tester\CommandTester; + use function preg_quote; class MigrationStatusTest extends MigrationTestCase @@ -16,7 +17,7 @@ class MigrationStatusTest extends MigrationTestCase /** @var string */ private $migrationDirectory; - protected function setUp() : void + protected function setUp(): void { $this->migrationDirectory = __DIR__ . '/../../../Stub/migration-empty-folder'; } @@ -24,7 +25,7 @@ protected function setUp() : void /** * Tests the display of the previous/current/next/latest versions. */ - public function testVersions() : void + public function testVersions(): void { self::assertVersion('prev', '123', 'Previous Version', 'FORMATTED (123)'); self::assertVersion('current', '234', 'Current Version', 'FORMATTED (234)'); @@ -47,7 +48,7 @@ public function testVersions() : void * @param string $label The expected row label. * @param string $output The expected row value. */ - protected function assertVersion(string $alias, ?string $version, string $label, string $output) : void + protected function assertVersion(string $alias, ?string $version, string $label, string $output): void { $command = $this ->getMockBuilder(StatusCommand::class) @@ -95,7 +96,7 @@ protected function assertVersion(string $alias, ?string $version, string $label, self::assertRegExp('/\s+>> ' . $label . ':\s+' . preg_quote($output) . '/m', $textOutput); } - public function testShowVersions() : void + public function testShowVersions(): void { $configuration = new Configuration($this->getSqliteConnection()); $configuration->setMigrationsNamespace('DoctrineMigrations'); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationVersionTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationVersionTest.php index 012f53869d..acb1f7a296 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationVersionTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationVersionTest.php @@ -13,11 +13,13 @@ use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Tester\CommandTester; -use const DIRECTORY_SEPARATOR; + use function file_exists; use function mkdir; use function sys_get_temp_dir; +use const DIRECTORY_SEPARATOR; + class MigrationVersionTest extends MigrationTestCase { /** @var VersionCommand|MockObject */ @@ -26,7 +28,7 @@ class MigrationVersionTest extends MigrationTestCase /** @var Configuration */ private $configuration; - protected function setUp() : void + protected function setUp(): void { $this->command = $this ->getMockBuilder(VersionCommand::class) @@ -40,6 +42,7 @@ protected function setUp() : void if (! file_exists($migrationsDirectory)) { mkdir($migrationsDirectory); } + $this->configuration->setMigrationsDirectory($migrationsDirectory); $this->command @@ -51,7 +54,7 @@ protected function setUp() : void /** * Test "--add --range-to --range-from" options on migrate only versions in interval. */ - public function testAddRangeOption() : void + public function testAddRangeOption(): void { $this->configuration->registerMigration('1233', Version1Test::class); $this->configuration->registerMigration('1234', Version1Test::class); @@ -79,7 +82,7 @@ public function testAddRangeOption() : void /** * Test "--add --range-from" options without "--range-to". */ - public function testAddRangeWithoutRangeToOption() : void + public function testAddRangeWithoutRangeToOption(): void { $commandTester = new CommandTester($this->command); @@ -98,7 +101,7 @@ public function testAddRangeWithoutRangeToOption() : void /** * Test "--add --range-to" options without "--range-from". */ - public function testAddRangeWithoutRangeFromOption() : void + public function testAddRangeWithoutRangeFromOption(): void { $commandTester = new CommandTester($this->command); @@ -117,7 +120,7 @@ public function testAddRangeWithoutRangeFromOption() : void /** * Test "--add --all --range-to" options. */ - public function testAddAllOptionsWithRangeTo() : void + public function testAddAllOptionsWithRangeTo(): void { $commandTester = new CommandTester($this->command); @@ -137,7 +140,7 @@ public function testAddAllOptionsWithRangeTo() : void /** * Test "--add --all --range-from" options. */ - public function testAddAllOptionsWithRangeFrom() : void + public function testAddAllOptionsWithRangeFrom(): void { $commandTester = new CommandTester($this->command); @@ -157,7 +160,7 @@ public function testAddAllOptionsWithRangeFrom() : void /** * Test "--delete --range-to --range-from" options on migrate down only versions in interval. */ - public function testDeleteRangeOption() : void + public function testDeleteRangeOption(): void { $this->configuration->registerMigration('1233', Version1Test::class); $this->configuration->registerMigration('1234', Version1Test::class); @@ -190,7 +193,7 @@ public function testDeleteRangeOption() : void /** * Test "--add --all" options on migrate all versions. */ - public function testAddAllOption() : void + public function testAddAllOption(): void { $this->configuration->registerMigration('1233', Version1Test::class); $this->configuration->registerMigration('1234', Version1Test::class); @@ -217,7 +220,7 @@ public function testAddAllOption() : void /** * Test "--delete --all" options on migrate down all versions. */ - public function testDeleteAllOption() : void + public function testDeleteAllOption(): void { $this->configuration->registerMigration('1233', Version1Test::class); $this->configuration->registerMigration('1234', Version1Test::class); @@ -247,7 +250,7 @@ public function testDeleteAllOption() : void /** * Test "--add" option on migrate one version. */ - public function testAddOption() : void + public function testAddOption(): void { $this->configuration->registerMigration('1233', Version1Test::class); $this->configuration->registerMigration('1234', Version1Test::class); @@ -272,7 +275,7 @@ public function testAddOption() : void /** * Test "--delete" options on migrate down one version. */ - public function testDeleteOption() : void + public function testDeleteOption(): void { $this->configuration->registerMigration('1233', Version1Test::class); $this->configuration->registerMigration('1234', Version1Test::class); @@ -297,7 +300,7 @@ public function testDeleteOption() : void /** * Test "--add" option on migrate already migrated version. */ - public function testAddOptionIfVersionAlreadyMigrated() : void + public function testAddOptionIfVersionAlreadyMigrated(): void { $this->configuration->registerMigration('1233', Version1Test::class); $this->configuration->getVersion('1233')->markMigrated(); @@ -319,7 +322,7 @@ public function testAddOptionIfVersionAlreadyMigrated() : void /** * Test "--delete" option on not migrated version. */ - public function testDeleteOptionIfVersionNotMigrated() : void + public function testDeleteOptionIfVersionNotMigrated(): void { $this->configuration->registerMigration('1233', Version1Test::class); @@ -340,7 +343,7 @@ public function testDeleteOptionIfVersionNotMigrated() : void /** * Test "--delete" option on migrated version without existing version file. */ - public function testDeleteOptionIfVersionFileDoesNotExist() : void + public function testDeleteOptionIfVersionFileDoesNotExist(): void { $this->configuration->registerMigration('1233', Version1Test::class); $this->configuration->getVersion('1233')->markMigrated(); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/RollupCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/RollupCommandTest.php index f448453ba2..0507e83458 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/RollupCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/RollupCommandTest.php @@ -24,7 +24,7 @@ final class RollupCommandTest extends TestCase /** @var RollupCommand|MockObject */ private $rollupCommand; - public function testExecute() : void + public function testExecute(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -45,7 +45,7 @@ public function testExecute() : void $this->rollupCommand->execute($input, $output); } - protected function setUp() : void + protected function setUp(): void { $this->rollup = $this->createMock(Rollup::class); $this->dependencyFactory = $this->createMock(DependencyFactory::class); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/StatusCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/StatusCommandTest.php index 7ffeaa3dc7..9a54a4535d 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/StatusCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/StatusCommandTest.php @@ -34,7 +34,7 @@ class StatusCommandTest extends TestCase /** @var StatusCommand */ private $statusCommand; - public function testExecute() : void + public function testExecute(): void { $input = $this->createMock(InputInterface::class); $output = $this->createMock(OutputInterface::class); @@ -140,7 +140,7 @@ public function testExecute() : void $this->statusCommand->execute($input, $output); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->dependencyFactory = $this->createMock(DependencyFactory::class); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/UpToDateCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/UpToDateCommandTest.php index 60bdd14238..566e59829b 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/UpToDateCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/UpToDateCommandTest.php @@ -20,7 +20,7 @@ class UpToDateCommandTest extends TestCase /** @var UpToDateCommand */ private $upToDateCommand; - protected function setUp() : void + protected function setUp(): void { $this->migrationRepository = $this->createMock(MigrationRepository::class); @@ -34,7 +34,7 @@ protected function setUp() : void * * @dataProvider dataIsUpToDate */ - public function testIsUpToDate(array $migrations, array $migratedVersions, int $exitCode, bool $failOnUnregistered = false) : void + public function testIsUpToDate(array $migrations, array $migratedVersions, int $exitCode, bool $failOnUnregistered = false): void { $this->migrationRepository ->method('getMigrations') @@ -62,7 +62,7 @@ public function testIsUpToDate(array $migrations, array $migratedVersions, int $ /** * @return mixed[][] */ - public function dataIsUpToDate() : array + public function dataIsUpToDate(): array { return [ 'up-to-date' => [ @@ -108,7 +108,7 @@ public function dataIsUpToDate() : array ]; } - private function createVersion(string $migration) : Version + private function createVersion(string $migration): Version { $version = $this->createMock(Version::class); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/ConnectionLoaderTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/ConnectionLoaderTest.php index 19e63b6888..fedad45bcb 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/ConnectionLoaderTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/ConnectionLoaderTest.php @@ -25,7 +25,7 @@ class ConnectionLoaderTest extends TestCase /** @var ConnectionLoader */ private $connectionLoader; - public function testGetConnection() : void + public function testGetConnection(): void { $input = $this->createMock(InputInterface::class); $helperSet = $this->createMock(HelperSet::class); @@ -38,7 +38,7 @@ public function testGetConnection() : void self::assertSame($connection, $this->connectionLoader->getConnection($input, $helperSet)); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/ConsoleRunnerTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/ConsoleRunnerTest.php index c79f4bc648..ed1f9896ab 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/ConsoleRunnerTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/ConsoleRunnerTest.php @@ -23,7 +23,7 @@ class ConsoleRunnerTest extends TestCase /** @var Application */ private $application; - public function testRun() : void + public function testRun(): void { $helperSet = new HelperSet([]); @@ -37,56 +37,56 @@ public function testRun() : void ConsoleRunnerStub::run($helperSet, []); } - public function testHasExecuteCommand() : void + public function testHasExecuteCommand(): void { ConsoleRunner::addCommands($this->application); self::assertTrue($this->application->has('migrations:execute')); } - public function testHasGenerateCommand() : void + public function testHasGenerateCommand(): void { ConsoleRunner::addCommands($this->application); self::assertTrue($this->application->has('migrations:generate')); } - public function testHasLatestCommand() : void + public function testHasLatestCommand(): void { ConsoleRunner::addCommands($this->application); self::assertTrue($this->application->has('migrations:latest')); } - public function testHasMigrateCommand() : void + public function testHasMigrateCommand(): void { ConsoleRunner::addCommands($this->application); self::assertTrue($this->application->has('migrations:migrate')); } - public function testHasStatusCommand() : void + public function testHasStatusCommand(): void { ConsoleRunner::addCommands($this->application); self::assertTrue($this->application->has('migrations:status')); } - public function testHasVersionCommand() : void + public function testHasVersionCommand(): void { ConsoleRunner::addCommands($this->application); self::assertTrue($this->application->has('migrations:version')); } - public function testHasUpToDateCommand() : void + public function testHasUpToDateCommand(): void { ConsoleRunner::addCommands($this->application); self::assertTrue($this->application->has('migrations:up-to-date')); } - public function testHasDiffCommand() : void + public function testHasDiffCommand(): void { $this->application->setHelperSet(new HelperSet([ 'em' => $this->entityManagerHelper, @@ -97,7 +97,7 @@ public function testHasDiffCommand() : void self::assertTrue($this->application->has('migrations:diff')); } - public function testNotHasDiffCommand() : void + public function testNotHasDiffCommand(): void { $this->application->setHelperSet(new HelperSet([])); @@ -106,7 +106,7 @@ public function testNotHasDiffCommand() : void self::assertFalse($this->application->has('migrations:diff')); } - public function testCreateApplication() : void + public function testCreateApplication(): void { $helperSet = new HelperSet(); @@ -115,7 +115,7 @@ public function testCreateApplication() : void self::assertSame($helperSet, $application->getHelperSet()); } - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -134,7 +134,7 @@ class ConsoleRunnerStub extends ConsoleRunner /** * @param Command[] $commands */ - public static function createApplication(HelperSet $helperSet, array $commands = []) : Application + public static function createApplication(HelperSet $helperSet, array $commands = []): Application { return static::$application; } diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/ConfigurationHelperTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/ConfigurationHelperTest.php index c775736414..491d087db6 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/ConfigurationHelperTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/ConfigurationHelperTest.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\StreamOutput; + use function copy; use function trim; use function unlink; @@ -29,7 +30,7 @@ class ConfigurationHelperTest extends MigrationTestCase /** @var InputInterface|MockObject */ private $input; - protected function setUp() : void + protected function setUp(): void { $this->connection = $this->getSqliteConnection(); @@ -47,7 +48,7 @@ protected function setUp() : void protected function getConfigurationHelperLoadsASpecificFormat( string $baseFile, string $configFile - ) : string { + ): string { try { $file = 'tests/Doctrine/Migrations/Tests/Tools/Console/Helper/files/' . $baseFile; copy($file, $configFile); @@ -65,7 +66,7 @@ protected function getConfigurationHelperLoadsASpecificFormat( } } - public function testConfigurationHelperLoadsPhpArrayFormatFromCommandLine() : void + public function testConfigurationHelperLoadsPhpArrayFormatFromCommandLine(): void { $this->input->method('getOption') ->with('configuration') @@ -78,7 +79,7 @@ public function testConfigurationHelperLoadsPhpArrayFormatFromCommandLine() : vo self::assertSame('DoctrineMigrationsTest', $migrationConfig->getMigrationsNamespace()); } - public function testConfigurationHelperLoadsJsonFormatFromCommandLine() : void + public function testConfigurationHelperLoadsJsonFormatFromCommandLine(): void { $this->input->method('getOption') ->with('configuration') @@ -94,7 +95,7 @@ public function testConfigurationHelperLoadsJsonFormatFromCommandLine() : void /** * Test that unsupported file type throws exception */ - public function testConfigurationHelperFailsToLoadOtherFormat() : void + public function testConfigurationHelperFailsToLoadOtherFormat(): void { $this->input->method('getOption') ->with('configuration') @@ -108,7 +109,7 @@ public function testConfigurationHelperFailsToLoadOtherFormat() : void $configurationHelper->getMigrationConfig($this->input); } - public function testConfigurationHelperWithoutConfigurationFromSetterAndWithoutOverrideFromCommandLineAndWithoutConfigInPath() : void + public function testConfigurationHelperWithoutConfigurationFromSetterAndWithoutOverrideFromCommandLineAndWithoutConfigInPath(): void { $this->input->method('getOption') ->with('configuration') diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/MigrationDirectoryHelperTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/MigrationDirectoryHelperTest.php index 9599d8730e..912a4394e7 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/MigrationDirectoryHelperTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/MigrationDirectoryHelperTest.php @@ -7,19 +7,21 @@ use Doctrine\Migrations\Tests\MigrationTestCase; use Doctrine\Migrations\Tools\Console\Helper\MigrationDirectoryHelper; use InvalidArgumentException; -use const DIRECTORY_SEPARATOR; + use function date; +use const DIRECTORY_SEPARATOR; + class MigrationDirectoryHelperTest extends MigrationTestCase { - public function testMigrationDirectoryHelperReturnConfiguredDir() : void + public function testMigrationDirectoryHelperReturnConfiguredDir(): void { $mirationDirectoryHelper = new MigrationDirectoryHelper($this->getSqliteConfiguration()); self::assertSame($this->getSqliteConfiguration()->getMigrationsDirectory(), $mirationDirectoryHelper->getMigrationDirectory()); } - public function testMigrationDirectoryHelperReturnConfiguredDirWithYear() : void + public function testMigrationDirectoryHelperReturnConfiguredDirWithYear(): void { $configuration = $this->getSqliteConfiguration(); $configuration->setMigrationsAreOrganizedByYear(true); @@ -30,7 +32,7 @@ public function testMigrationDirectoryHelperReturnConfiguredDirWithYear() : void self::assertSame($dir, $mirationDirectoryHelper->getMigrationDirectory()); } - public function testMigrationDirectoryHelperReturnConfiguredDirWithYearAndMonth() : void + public function testMigrationDirectoryHelperReturnConfiguredDirWithYearAndMonth(): void { $configuration = $this->getSqliteConfiguration(); $configuration->setMigrationsAreOrganizedByYearAndMonth(true); @@ -41,7 +43,7 @@ public function testMigrationDirectoryHelperReturnConfiguredDirWithYearAndMonth( self::assertSame($dir, $mirationDirectoryHelper->getMigrationDirectory()); } - public function testMigrationsDirectoryHelperWithFolderThatDoesNotExists() : void + public function testMigrationsDirectoryHelperWithFolderThatDoesNotExists(): void { $dir = DIRECTORY_SEPARATOR . 'IDoNotExists'; $configuration = $this->getSqliteConfiguration(); diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/MigrationStatusInfosHelperTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/MigrationStatusInfosHelperTest.php index ee9d515775..772849bbb0 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/MigrationStatusInfosHelperTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Helper/MigrationStatusInfosHelperTest.php @@ -29,7 +29,7 @@ class MigrationStatusInfosHelperTest extends TestCase /** @var MigrationStatusInfosHelper */ private $migrationStatusInfosHelper; - public function testGetMigrationsInfos() : void + public function testGetMigrationsInfos(): void { $this->driver->expects(self::once()) ->method('getName') @@ -92,7 +92,7 @@ public function testGetMigrationsInfos() : void self::assertSame($expected, $infos); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->migrationRepository = $this->createMock(MigrationRepository::class); diff --git a/tests/Doctrine/Migrations/Tests/Tracking/TableDefinitionTest.php b/tests/Doctrine/Migrations/Tests/Tracking/TableDefinitionTest.php index b7367076b9..59d5e249b9 100644 --- a/tests/Doctrine/Migrations/Tests/Tracking/TableDefinitionTest.php +++ b/tests/Doctrine/Migrations/Tests/Tracking/TableDefinitionTest.php @@ -18,27 +18,27 @@ class TableDefinitionTest extends TestCase /** @var TableDefinition */ private $migrationTable; - public function testGetName() : void + public function testGetName(): void { self::assertSame('versions', $this->migrationTable->getName()); } - public function testGetColumnName() : void + public function testGetColumnName(): void { self::assertSame('version_name', $this->migrationTable->getColumnName()); } - public function testGetColumnLength() : void + public function testGetColumnLength(): void { self::assertSame(200, $this->migrationTable->getColumnLength()); } - public function testGetExecutedAtColumnName() : void + public function testGetExecutedAtColumnName(): void { self::assertSame('executed_datetime', $this->migrationTable->getExecutedAtColumnName()); } - public function testGetMigrationsColumn() : void + public function testGetMigrationsColumn(): void { $column = $this->migrationTable->getMigrationsColumn(); @@ -46,7 +46,7 @@ public function testGetMigrationsColumn() : void self::assertSame(200, $column->getLength()); } - public function testGetExecutedAtColumn() : void + public function testGetExecutedAtColumn(): void { $column = $this->migrationTable->getExecutedAtColumn(); @@ -54,12 +54,12 @@ public function testGetExecutedAtColumn() : void self::assertTrue($column->getNotnull()); } - public function testGetColumnNames() : void + public function testGetColumnNames(): void { self::assertSame(['version_name', 'executed_datetime'], $this->migrationTable->getColumnNames()); } - public function testGetDBALTable() : void + public function testGetDBALTable(): void { $schemaConfig = $this->createMock(SchemaConfig::class); @@ -85,7 +85,7 @@ public function testGetDBALTable() : void self::assertFalse($table->getColumn('executed_datetime')->getNotnull()); } - public function testGetNewDBALTable() : void + public function testGetNewDBALTable(): void { $schemaConfig = $this->createMock(SchemaConfig::class); @@ -111,7 +111,7 @@ public function testGetNewDBALTable() : void self::assertTrue($table->getColumn('executed_datetime')->getNotnull()); } - protected function setUp() : void + protected function setUp(): void { $this->schemaManager = $this->createMock(AbstractSchemaManager::class); diff --git a/tests/Doctrine/Migrations/Tests/Tracking/TableManipulatorTest.php b/tests/Doctrine/Migrations/Tests/Tracking/TableManipulatorTest.php index 95971e75de..80bc1fb371 100644 --- a/tests/Doctrine/Migrations/Tests/Tracking/TableManipulatorTest.php +++ b/tests/Doctrine/Migrations/Tests/Tracking/TableManipulatorTest.php @@ -34,7 +34,7 @@ class TableManipulatorTest extends TestCase /** @var TableManipulator */ private $migrationTableManipulator; - public function testCreateMigrationTableAlreadyCreated() : void + public function testCreateMigrationTableAlreadyCreated(): void { $this->configuration->expects(self::once()) ->method('validate'); @@ -54,7 +54,7 @@ public function testCreateMigrationTableAlreadyCreated() : void self::assertFalse($this->migrationTableManipulator->createMigrationTable()); } - public function testCreateMigrationTableNotUpToDate() : void + public function testCreateMigrationTableNotUpToDate(): void { $migrationTableManipulator = $this->getMockBuilder(TableManipulator::class) ->setConstructorArgs([ @@ -92,7 +92,7 @@ public function testCreateMigrationTableNotUpToDate() : void self::assertTrue($migrationTableManipulator->createMigrationTable()); } - public function testCreateMigrationTable() : void + public function testCreateMigrationTable(): void { $this->configuration->expects(self::once()) ->method('validate'); @@ -118,7 +118,7 @@ public function testCreateMigrationTable() : void self::assertTrue($this->migrationTableManipulator->createMigrationTable()); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->schemaManager = $this->createMock(AbstractSchemaManager::class); diff --git a/tests/Doctrine/Migrations/Tests/Tracking/TableStatusTest.php b/tests/Doctrine/Migrations/Tests/Tracking/TableStatusTest.php index 67d393d92c..2ce9ec04b2 100644 --- a/tests/Doctrine/Migrations/Tests/Tracking/TableStatusTest.php +++ b/tests/Doctrine/Migrations/Tests/Tracking/TableStatusTest.php @@ -22,14 +22,14 @@ class TableStatusTest extends TestCase /** @var TableStatus */ private $migrationTableStatus; - public function testSetCreated() : void + public function testSetCreated(): void { $this->migrationTableStatus->setCreated(true); self::assertTrue($this->migrationTableStatus->isCreated()); } - public function testIsCreatedTrue() : void + public function testIsCreatedTrue(): void { $this->migrationTable->expects(self::once()) ->method('getName') @@ -43,7 +43,7 @@ public function testIsCreatedTrue() : void self::assertTrue($this->migrationTableStatus->isCreated()); } - public function testIsCreatedFalse() : void + public function testIsCreatedFalse(): void { $this->migrationTable->expects(self::once()) ->method('getName') @@ -57,14 +57,14 @@ public function testIsCreatedFalse() : void self::assertFalse($this->migrationTableStatus->isCreated()); } - public function testSetUpToDate() : void + public function testSetUpToDate(): void { $this->migrationTableStatus->setUpToDate(true); self::assertTrue($this->migrationTableStatus->isUpToDate()); } - public function testIsUpToDateTrue() : void + public function testIsUpToDateTrue(): void { $this->migrationTable->expects(self::once()) ->method('getName') @@ -97,7 +97,7 @@ public function testIsUpToDateTrue() : void self::assertTrue($this->migrationTableStatus->isUpToDate()); } - public function testIsUpToDateFalse() : void + public function testIsUpToDateFalse(): void { $this->migrationTable->expects(self::once()) ->method('getName') @@ -130,7 +130,7 @@ public function testIsUpToDateFalse() : void self::assertFalse($this->migrationTableStatus->isUpToDate()); } - protected function setUp() : void + protected function setUp(): void { $this->schemaManager = $this->createMock(AbstractSchemaManager::class); $this->migrationTable = $this->createMock(TableDefinition::class); diff --git a/tests/Doctrine/Migrations/Tests/Tracking/TableUpdaterTest.php b/tests/Doctrine/Migrations/Tests/Tracking/TableUpdaterTest.php index 45467f8a10..1035be0e99 100644 --- a/tests/Doctrine/Migrations/Tests/Tracking/TableUpdaterTest.php +++ b/tests/Doctrine/Migrations/Tests/Tracking/TableUpdaterTest.php @@ -35,7 +35,7 @@ class TableUpdaterTest extends TestCase /** @var TableUpdater|MockObject */ private $migrationTableUpdater; - public function testUpdateMigrationTable() : void + public function testUpdateMigrationTable(): void { $this->migrationTable->expects(self::once()) ->method('getName') @@ -109,7 +109,7 @@ public function testUpdateMigrationTable() : void $this->migrationTableUpdater->updateMigrationTable(); } - public function testUpdateMigrationTableRollback() : void + public function testUpdateMigrationTableRollback(): void { $this->expectException(Throwable::class); $this->expectExceptionMessage('Rolling back.'); @@ -187,7 +187,7 @@ public function testUpdateMigrationTableRollback() : void $this->migrationTableUpdater->updateMigrationTable(); } - protected function setUp() : void + protected function setUp(): void { $this->connection = $this->createMock(Connection::class); $this->schemaManager = $this->createMock(AbstractSchemaManager::class); diff --git a/tests/Doctrine/Migrations/Tests/Version/AliasResolverTest.php b/tests/Doctrine/Migrations/Tests/Version/AliasResolverTest.php index 9e6c7b7f81..82384dde5d 100644 --- a/tests/Doctrine/Migrations/Tests/Version/AliasResolverTest.php +++ b/tests/Doctrine/Migrations/Tests/Version/AliasResolverTest.php @@ -25,7 +25,7 @@ public function testResolveVersionAlias( ?string $expectedVersion, ?string $expectedMethod, ?string $expectedArgument - ) : void { + ): void { $this->migrationRepository->expects(self::once()) ->method('hasVersion') ->with($alias) @@ -47,7 +47,7 @@ public function testResolveVersionAlias( /** * @return mixed[][] */ - public function getAliases() : array + public function getAliases(): array { return [ ['first', '0', null, null], @@ -60,7 +60,7 @@ public function getAliases() : array ]; } - public function testResolveVersionAliasHasVersion() : void + public function testResolveVersionAliasHasVersion(): void { $this->migrationRepository->expects(self::once()) ->method('hasVersion') @@ -70,7 +70,7 @@ public function testResolveVersionAliasHasVersion() : void self::assertSame('test', $this->versionAliasResolver->resolveVersionAlias('test')); } - protected function setUp() : void + protected function setUp(): void { $this->migrationRepository = $this->createMock(MigrationRepository::class); diff --git a/tests/Doctrine/Migrations/Tests/Version/ExecutionResultTest.php b/tests/Doctrine/Migrations/Tests/Version/ExecutionResultTest.php index af66b92494..a51c7925f0 100644 --- a/tests/Doctrine/Migrations/Tests/Version/ExecutionResultTest.php +++ b/tests/Doctrine/Migrations/Tests/Version/ExecutionResultTest.php @@ -15,12 +15,12 @@ class ExecutionResultTest extends TestCase /** @var ExecutionResult */ private $versionExecutionResult; - public function testHasSql() : void + public function testHasSql(): void { self::assertTrue($this->versionExecutionResult->hasSql()); } - public function testGetSetSql() : void + public function testGetSetSql(): void { self::assertSame(['SELECT 1'], $this->versionExecutionResult->getSql()); @@ -29,7 +29,7 @@ public function testGetSetSql() : void self::assertSame(['SELECT 2'], $this->versionExecutionResult->getSql()); } - public function testGetSetParams() : void + public function testGetSetParams(): void { self::assertSame([1], $this->versionExecutionResult->getParams()); @@ -38,7 +38,7 @@ public function testGetSetParams() : void self::assertSame([2], $this->versionExecutionResult->getParams()); } - public function testGetTypes() : void + public function testGetTypes(): void { self::assertSame([2], $this->versionExecutionResult->getTypes()); @@ -47,7 +47,7 @@ public function testGetTypes() : void self::assertSame([3], $this->versionExecutionResult->getTypes()); } - public function testGetSetTime() : void + public function testGetSetTime(): void { self::assertNull($this->versionExecutionResult->getTime()); @@ -56,7 +56,7 @@ public function testGetSetTime() : void self::assertSame(5.5, $this->versionExecutionResult->getTime()); } - public function testGetSetMemory() : void + public function testGetSetMemory(): void { self::assertNull($this->versionExecutionResult->getMemory()); @@ -65,7 +65,7 @@ public function testGetSetMemory() : void self::assertSame(555555.0, $this->versionExecutionResult->getMemory()); } - public function testSkipped() : void + public function testSkipped(): void { self::assertFalse($this->versionExecutionResult->isSkipped()); @@ -74,7 +74,7 @@ public function testSkipped() : void self::assertTrue($this->versionExecutionResult->isSkipped()); } - public function testError() : void + public function testError(): void { self::assertFalse($this->versionExecutionResult->hasError()); @@ -83,12 +83,12 @@ public function testError() : void self::assertTrue($this->versionExecutionResult->hasError()); } - public function testExceptionNull() : void + public function testExceptionNull(): void { self::assertNull($this->versionExecutionResult->getException()); } - public function testException() : void + public function testException(): void { $exception = new InvalidArgumentException(); @@ -97,7 +97,7 @@ public function testException() : void self::assertSame($exception, $this->versionExecutionResult->getException()); } - public function testToSchema() : void + public function testToSchema(): void { $toSchema = $this->createMock(Schema::class); @@ -106,7 +106,7 @@ public function testToSchema() : void self::assertSame($toSchema, $this->versionExecutionResult->getToSchema()); } - public function testToSchemaThrowsRuntimExceptionWhenToSchemaIsNull() : void + public function testToSchemaThrowsRuntimExceptionWhenToSchemaIsNull(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage('Cannot call getToSchema() when toSchema is null.'); @@ -114,7 +114,7 @@ public function testToSchemaThrowsRuntimExceptionWhenToSchemaIsNull() : void $this->versionExecutionResult->getToSchema(); } - protected function setUp() : void + protected function setUp(): void { $this->versionExecutionResult = new ExecutionResult( ['SELECT 1'], diff --git a/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php b/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php index 306600d3b5..b8d11b6e13 100644 --- a/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php +++ b/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php @@ -52,7 +52,7 @@ class ExecutorTest extends TestCase /** @var VersionExecutorTestMigration */ private $migration; - public function testAddSql() : void + public function testAddSql(): void { $this->versionExecutor->addSql('SELECT 1', [1], [2]); @@ -61,7 +61,7 @@ public function testAddSql() : void self::assertSame([[2]], $this->versionExecutor->getTypes()); } - public function testExecuteUp() : void + public function testExecuteUp(): void { $this->outputWriter->expects(self::at(0)) ->method('write') @@ -111,7 +111,7 @@ public function testExecuteUp() : void /** * @test */ - public function executeUpShouldAppendDescriptionWhenItIsNotEmpty() : void + public function executeUpShouldAppendDescriptionWhenItIsNotEmpty(): void { $this->outputWriter->expects(self::at(0)) ->method('write') @@ -128,7 +128,7 @@ public function executeUpShouldAppendDescriptionWhenItIsNotEmpty() : void ); } - public function testExecuteDown() : void + public function testExecuteDown(): void { $this->outputWriter->expects(self::at(0)) ->method('write') @@ -178,7 +178,7 @@ public function testExecuteDown() : void /** * @test */ - public function executeDownShouldAppendDescriptionWhenItIsNotEmpty() : void + public function executeDownShouldAppendDescriptionWhenItIsNotEmpty(): void { $this->outputWriter->expects(self::at(0)) ->method('write') @@ -195,7 +195,7 @@ public function executeDownShouldAppendDescriptionWhenItIsNotEmpty() : void ); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->connection = $this->createMock(Connection::class); @@ -276,39 +276,39 @@ public function __construct(Version $version, string $description = '') $this->description = $description; } - public function getDescription() : string + public function getDescription(): string { return $this->description; } - public function preUp(Schema $fromSchema) : void + public function preUp(Schema $fromSchema): void { $this->preUpExecuted = true; } - public function up(Schema $schema) : void + public function up(Schema $schema): void { $this->addSql('SELECT 1', [1], [3]); $this->addSql('SELECT 2', [2], [4]); } - public function postUp(Schema $toSchema) : void + public function postUp(Schema $toSchema): void { $this->postUpExecuted = true; } - public function preDown(Schema $fromSchema) : void + public function preDown(Schema $fromSchema): void { $this->preDownExecuted = true; } - public function down(Schema $schema) : void + public function down(Schema $schema): void { $this->addSql('SELECT 3', [5], [7]); $this->addSql('SELECT 4', [6], [8]); } - public function postDown(Schema $toSchema) : void + public function postDown(Schema $toSchema): void { $this->postDownExecuted = true; } diff --git a/tests/Doctrine/Migrations/Tests/Version/FactoryTest.php b/tests/Doctrine/Migrations/Tests/Version/FactoryTest.php index 766aa3049e..d35fdebf3a 100644 --- a/tests/Doctrine/Migrations/Tests/Version/FactoryTest.php +++ b/tests/Doctrine/Migrations/Tests/Version/FactoryTest.php @@ -22,7 +22,7 @@ final class FactoryTest extends TestCase /** @var Factory */ private $versionFactory; - public function testCreateVersion() : void + public function testCreateVersion(): void { $version = $this->versionFactory->createVersion( '001', @@ -33,7 +33,7 @@ public function testCreateVersion() : void self::assertInstanceOf(VersionFactoryTestMigration::class, $version->getMigration()); } - protected function setUp() : void + protected function setUp(): void { $this->configuration = $this->createMock(Configuration::class); $this->versionExecutor = $this->createMock(ExecutorInterface::class); @@ -47,11 +47,11 @@ protected function setUp() : void class VersionFactoryTestMigration extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { } - public function down(Schema $schema) : void + public function down(Schema $schema): void { } } diff --git a/tests/Doctrine/Migrations/Tests/Version/VersionTest.php b/tests/Doctrine/Migrations/Tests/Version/VersionTest.php index 87b6a63552..384755bdc1 100644 --- a/tests/Doctrine/Migrations/Tests/Version/VersionTest.php +++ b/tests/Doctrine/Migrations/Tests/Version/VersionTest.php @@ -43,7 +43,8 @@ use stdClass; use Symfony\Component\Stopwatch\Stopwatch as SymfonyStopwatch; use Throwable; -use const DIRECTORY_SEPARATOR; + +use function assert; use function current; use function date; use function file_get_contents; @@ -54,15 +55,17 @@ use function trim; use function unlink; +use const DIRECTORY_SEPARATOR; + class VersionTest extends MigrationTestCase { - public function testConstants() : void + public function testConstants(): void { self::assertSame('up', Direction::UP); self::assertSame('down', Direction::DOWN); } - public function testCreateVersion() : void + public function testCreateVersion(): void { $versionName = '003'; @@ -77,7 +80,7 @@ public function testCreateVersion() : void self::assertSame($versionName, $version->getVersion()); } - public function testShowSqlStatementsParameters() : void + public function testShowSqlStatementsParameters(): void { $outputWriter = $this->getOutputWriter(); @@ -100,7 +103,7 @@ public function testShowSqlStatementsParameters() : void self::assertStringContainsString('([456], [tralala], [456])', $this->getOutputStreamContent($this->output)); } - public function testShowSqlStatementsParametersWithTypes() : void + public function testShowSqlStatementsParametersWithTypes(): void { $outputWriter = $this->getOutputWriter(); @@ -128,7 +131,7 @@ public function testShowSqlStatementsParametersWithTypes() : void self::assertStringContainsString('([456, 3, 456])', $this->getOutputStreamContent($this->output)); } - public function testCreateVersionWithCustomName() : void + public function testCreateVersionWithCustomName(): void { $versionName = '003'; $versionDescription = 'My super migration'; @@ -146,7 +149,7 @@ public function testCreateVersionWithCustomName() : void } /** @dataProvider stateProvider */ - public function testGetExecutionState(int $state) : void + public function testGetExecutionState(int $state): void { $configuration = $this->getSqliteConfiguration(); @@ -166,7 +169,7 @@ public function testGetExecutionState(int $state) : void } /** @return mixed[][] */ - public function stateProvider() : array + public function stateProvider(): array { return [ [State::NONE], @@ -177,7 +180,7 @@ public function stateProvider() : array ]; } - public function testAddSql() : void + public function testAddSql(): void { $configuration = $this->getSqliteConfiguration(); @@ -197,7 +200,7 @@ public function testAddSql() : void * * @dataProvider writeSqlFileProvider */ - public function testWriteSqlFile(string $path, string $direction, array $getSqlReturn) : void + public function testWriteSqlFile(string $path, string $direction, array $getSqlReturn): void { $version = '1'; @@ -208,11 +211,11 @@ public function testWriteSqlFile(string $path, string $direction, array $getSqlR $outputWriter->expects(self::atLeastOnce()) ->method('write'); - /** @var Configuration|MockObject $config */ $config = $this->getMockBuilder(Configuration::class) ->disableOriginalConstructor() ->setMethods(['getConnection', 'getOutputWriter', 'getQueryWriter']) ->getMock(); + assert($config instanceof Configuration || $config instanceof MockObject); $config->method('getOutputWriter') ->willReturn($outputWriter); @@ -223,11 +226,11 @@ public function testWriteSqlFile(string $path, string $direction, array $getSqlR $config->method('getQueryWriter') ->willReturn($queryWriter); - /** @var Version|MockObject $version */ $version = $this->getMockBuilder(Version::class) ->setConstructorArgs($this->getMockVersionConstructorArgs($config, $version, TestMigration::class)) ->setMethods(['execute']) ->getMock(); + assert($version instanceof Version || $version instanceof MockObject); $versionExecutionResult = new ExecutionResult($getSqlReturn); @@ -244,7 +247,7 @@ public function testWriteSqlFile(string $path, string $direction, array $getSqlR } /** @return mixed[][] */ - public function writeSqlFileProvider() : array + public function writeSqlFileProvider(): array { return [ [__DIR__, 'up', ['1' => ['SHOW DATABASES;']]], // up @@ -253,7 +256,7 @@ public function writeSqlFileProvider() : array ]; } - public function testWarningWhenNoSqlStatementIsOutputed() : void + public function testWarningWhenNoSqlStatementIsOutputed(): void { $outputWriter = $this->getOutputWriter(); @@ -274,7 +277,7 @@ public function testWarningWhenNoSqlStatementIsOutputed() : void ); } - public function testCatchExceptionDuringMigration() : void + public function testCatchExceptionDuringMigration(): void { $outputWriter = $this->getOutputWriter(); @@ -297,7 +300,7 @@ public function testCatchExceptionDuringMigration() : void } } - public function testReturnTheSql() : void + public function testReturnTheSql(): void { $config = $this->getSqliteConfiguration(); @@ -311,7 +314,7 @@ public function testReturnTheSql() : void self::assertContains('Select 1', $version->execute('down')->getSql()); } - public function testReturnTheSqlWithParams() : void + public function testReturnTheSqlWithParams(): void { $config = $this->getSqliteConfiguration(); @@ -333,7 +336,7 @@ public function testWriteSqlWriteToTheCorrectColumnName( string $tableName, string $columnName, string $executedAtColumnName - ) : void { + ): void { $configuration = $this->getSqliteConfiguration(); $configuration->setMigrationsTableName($tableName); $configuration->setMigrationsColumnName($columnName); @@ -385,7 +388,7 @@ public function testWriteSqlWriteToTheCorrectColumnName( } /** @return string[][] */ - public function sqlWriteProvider() : array + public function sqlWriteProvider(): array { return [ [Direction::UP, 'fkqsdmfjl', 'balalala', 'executed_at'], @@ -395,7 +398,7 @@ public function sqlWriteProvider() : array ]; } - public function testWriteSqlFileShouldUseStandardCommentMarkerInSql() : void + public function testWriteSqlFileShouldUseStandardCommentMarkerInSql(): void { $version = '1'; $direction = Direction::UP; @@ -425,11 +428,11 @@ public function testWriteSqlFileShouldUseStandardCommentMarkerInSql() : void $config->method('getQuotedMigrationsExecutedAtColumnName') ->willReturn('executed_at'); - /** @var Version|MockObject $migration */ $migration = $this->getMockBuilder(Version::class) ->setConstructorArgs($this->getMockVersionConstructorArgs($config, $version, TestMigration::class)) ->setMethods(['execute']) ->getMock(); + assert($migration instanceof Version || $migration instanceof MockObject); $versionExecutionResult = new ExecutionResult(['SHOW DATABASES;']); @@ -442,17 +445,17 @@ public function testWriteSqlFileShouldUseStandardCommentMarkerInSql() : void self::assertRegExp('/^\s*-- Version 1/m', $this->getOutputStreamContent($this->output)); - /** @var vfsStreamFile $sqlMigrationFile */ $sqlMigrationFile = current($sqlFilesDir->getChildren()); + assert($sqlMigrationFile instanceof vfsStreamFile); self::assertNotRegExp('/^\s*#/m', $sqlMigrationFile->getContent()); } - public function testDryRunCausesSqlToBeOutputViaTheOutputWriter() : void + public function testDryRunCausesSqlToBeOutputViaTheOutputWriter(): void { $messages = []; - $ow = new OutputWriter(static function ($msg) use (&$messages) : void { + $ow = new OutputWriter(static function ($msg) use (&$messages): void { $messages[] = trim($msg); }); @@ -472,11 +475,11 @@ public function testDryRunCausesSqlToBeOutputViaTheOutputWriter() : void self::assertStringContainsString('SELECT 1 WHERE 1', $messages[1]); } - public function testDryRunWithQuestionMarkedParamsOutputsParamsWithSqlStatement() : void + public function testDryRunWithQuestionMarkedParamsOutputsParamsWithSqlStatement(): void { $messages = []; - $ow = new OutputWriter(static function ($msg) use (&$messages) : void { + $ow = new OutputWriter(static function ($msg) use (&$messages): void { $messages[] = trim($msg); }); @@ -497,11 +500,11 @@ public function testDryRunWithQuestionMarkedParamsOutputsParamsWithSqlStatement( self::assertStringContainsString('with parameters ([one], [two])', $messages[1]); } - public function testDryRunWithNamedParametersOutputsParamsAndNamesWithSqlStatement() : void + public function testDryRunWithNamedParametersOutputsParamsAndNamesWithSqlStatement(): void { $messages = []; - $ow = new OutputWriter(static function ($msg) use (&$messages) : void { + $ow = new OutputWriter(static function ($msg) use (&$messages): void { $messages[] = trim($msg); }); @@ -523,7 +526,7 @@ public function testDryRunWithNamedParametersOutputsParamsAndNamesWithSqlStateme } /** @return mixed[][] */ - public static function dryRunTypes() : array + public static function dryRunTypes(): array { return [ 'datetime' => [[new DateTime('2016-07-05 01:00:00')], ['datetime'], '[2016-07-05 01:00:00]'], @@ -545,10 +548,10 @@ public function testDryRunWithParametersOfComplexTypesCorrectFormatsParameters( array $value, array $type, string $output - ) : void { + ): void { $messages = []; - $ow = new OutputWriter(static function ($msg) use (&$messages) : void { + $ow = new OutputWriter(static function ($msg) use (&$messages): void { $messages[] = trim($msg); }); @@ -574,11 +577,11 @@ public function testDryRunWithParametersOfComplexTypesCorrectFormatsParameters( self::assertStringContainsString(sprintf('with parameters (%s)', $output), $messages[1]); } - public function testRunWithInsertNullValue() : void + public function testRunWithInsertNullValue(): void { $messages = []; - $ow = new OutputWriter(static function ($msg) use (&$messages) : void { + $ow = new OutputWriter(static function ($msg) use (&$messages): void { $messages[] = trim($msg); }); @@ -608,7 +611,7 @@ public function testRunWithInsertNullValue() : void /** * @dataProvider getExecutedAtTimeZones */ - public function testExecutedAtTimeZone(string $timeZone) : void + public function testExecutedAtTimeZone(string $timeZone): void { $this->iniSet('date.timezone', $timeZone); @@ -638,7 +641,7 @@ public function testExecutedAtTimeZone(string $timeZone) : void /** * @return string[][] */ - public function getExecutedAtTimeZones() : array + public function getExecutedAtTimeZones(): array { return [ ['America/New_York'], @@ -654,7 +657,7 @@ private function getMockVersionConstructorArgs( Configuration $configuration, string $versionName, string $className - ) : array { + ): array { $schemaDiffProvider = $this->createMock(SchemaDiffProviderInterface::class); $parameterFormatter = new ParameterFormatter($configuration->getConnection()); @@ -678,7 +681,7 @@ private function createTestVersion( Configuration $configuration, string $versionName, string $className - ) : Version { + ): Version { $schemaDiffProvider = $this->createMock(SchemaDiffProviderInterface::class); $parameterFormatter = new ParameterFormatter($configuration->getConnection()); @@ -701,11 +704,11 @@ private function createTestVersion( class TestMigration extends AbstractMigration { - public function up(Schema $schema) : void + public function up(Schema $schema): void { } - public function down(Schema $schema) : void + public function down(Schema $schema): void { } } From bb6a5c6ab198929c43a292b41e6f158d981a8bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 12 Nov 2020 20:32:04 +0100 Subject: [PATCH 07/10] Manually fix cs --- tests/Doctrine/Migrations/Tests/MigratorTest.php | 1 - tests/Doctrine/Migrations/Tests/Version/VersionTest.php | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/Doctrine/Migrations/Tests/MigratorTest.php b/tests/Doctrine/Migrations/Tests/MigratorTest.php index 6fad33c204..deff8c12fd 100644 --- a/tests/Doctrine/Migrations/Tests/MigratorTest.php +++ b/tests/Doctrine/Migrations/Tests/MigratorTest.php @@ -181,7 +181,6 @@ public function testWriteSqlFile(string $path, string $from, ?string $to, array $outputWriter->expects(self::atLeastOnce()) ->method('write'); - /** @var Configuration|MockObject $migration */ $config = $this->createMock(Configuration::class); $dependencyFactory = $this->createMock(DependencyFactory::class); diff --git a/tests/Doctrine/Migrations/Tests/Version/VersionTest.php b/tests/Doctrine/Migrations/Tests/Version/VersionTest.php index 384755bdc1..5bb39f3354 100644 --- a/tests/Doctrine/Migrations/Tests/Version/VersionTest.php +++ b/tests/Doctrine/Migrations/Tests/Version/VersionTest.php @@ -405,7 +405,6 @@ public function testWriteSqlFileShouldUseStandardCommentMarkerInSql(): void $connection = $this->getSqliteConnection(); - /** @var Configuration|MockObject $migration */ $config = $this->getMockBuilder(Configuration::class) ->disableOriginalConstructor() ->setMethods([ From a2fb931753a2b4ebb238fe13578a4cd52ca1edfa Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 23 Dec 2020 09:48:00 +0100 Subject: [PATCH 08/10] Migrate to friendsofphp/proxy-manager-lts --- composer.json | 2 +- download-box.sh | 2 +- phpstan.neon.dist | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index d0f3fe75e2..08fc787645 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php": "^7.1 || ^8.0", "composer/package-versions-deprecated": "^1.8", "doctrine/dbal": "^2.9", - "ocramius/proxy-manager": "^2.0.2", + "friendsofphp/proxy-manager-lts": "^1.0", "symfony/console": "^3.4||^4.4.16||^5.0", "symfony/stopwatch": "^3.4||^4.0||^5.0" }, diff --git a/download-box.sh b/download-box.sh index 209275c17d..554a0dc725 100755 --- a/download-box.sh +++ b/download-box.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash if [ ! -f box.phar ]; then - wget https://github.com/box-project/box/releases/download/3.9.0/box.phar -O box.phar + wget https://github.com/box-project/box/releases/download/$(php -r 'echo PHP_VERSION_ID >= 70300 ? "3.11.0" : "3.9.1";')/box.phar -O box.phar fi diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b666732ada..af1642a057 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -12,8 +12,6 @@ parameters: - %currentWorkingDirectory%/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTestSource/Migrations/Version123.php - %currentWorkingDirectory%/tests/Doctrine/Migrations/Tests/realpath.php ignoreErrors: - # Ignore proxy manager magic - - '~ProxyManager\\Proxy\\VirtualProxyInterface~' - '~^Parameter #1 \$files of method Doctrine\\Migrations\\Finder\\Finder::loadMigrationClasses\(\) expects array, array given\.\z~' - '~^Class Doctrine\\Migrations\\Tests\\DoesNotExistAtAll not found\.\z~' - '~^Call to method getVersion\(\) of deprecated class PackageVersions\\Versions\.$~' From e87a47ddb23abeeb0ac92a6c09b5d20ec0aea846 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 23 Dec 2020 12:50:18 +0100 Subject: [PATCH 09/10] Add phpstan baseline --- .github/phpstan-baseline.neon | 664 ++++++++++++++++++++++++++++++++++ phpstan.neon.dist | 8 +- 2 files changed, 669 insertions(+), 3 deletions(-) create mode 100644 .github/phpstan-baseline.neon diff --git a/.github/phpstan-baseline.neon b/.github/phpstan-baseline.neon new file mode 100644 index 0000000000..85e1ede426 --- /dev/null +++ b/.github/phpstan-baseline.neon @@ -0,0 +1,664 @@ +parameters: + ignoreErrors: + - + message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#" + count: 3 + path: ../lib/Doctrine/Migrations/AbstractMigration.php + + - + message: "#^Variable method call on \\$this\\(Doctrine\\\\Migrations\\\\Configuration\\\\AbstractFileConfiguration\\)\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Configuration/AbstractFileConfiguration.php + + - + message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Configuration/Configuration.php + + - + message: "#^Instanceof between Doctrine\\\\DBAL\\\\Connection and Doctrine\\\\DBAL\\\\Connections\\\\MasterSlaveConnection will always evaluate to false\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Configuration/Configuration.php + + - + message: "#^Variable property access on SimpleXMLElement\\.$#" + count: 10 + path: ../lib/Doctrine/Migrations/Configuration/XmlConfiguration.php + + - + message: "#^Method Doctrine\\\\Migrations\\\\Finder\\\\Finder\\:\\:loadMigrationClasses\\(\\) return type with generic class ReflectionClass does not specify its types\\: T$#" + count: 1 + path: ../lib/Doctrine/Migrations/Finder/Finder.php + + - + message: "#^Method Doctrine\\\\Migrations\\\\Finder\\\\Finder\\:\\:isReflectionClassInNamespace\\(\\) has parameter \\$reflectionClass with generic class ReflectionClass but does not specify its types\\: T$#" + count: 1 + path: ../lib/Doctrine/Migrations/Finder/Finder.php + + - + message: "#^Parameter \\#1 \\$files of method Doctrine\\\\Migrations\\\\Finder\\\\Finder\\:\\:loadMigrations\\(\\) expects array\\, array\\\\|false given\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Finder/GlobFinder.php + + - + message: "#^Anonymous function should have native return typehint \"bool\"\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/MigrationPlanCalculator.php + + - + message: + """ + #^Call to deprecated method fetchColumn\\(\\) of class Doctrine\\\\DBAL\\\\Connection\\: + Use fetchOne\\(\\) instead\\.$# + """ + count: 2 + path: ../lib/Doctrine/Migrations/MigrationRepository.php + + - + message: + """ + #^Call to deprecated method fetchAssoc\\(\\) of class Doctrine\\\\DBAL\\\\Connection\\: + Use fetchAssociative\\(\\)$# + """ + count: 1 + path: ../lib/Doctrine/Migrations/MigrationRepository.php + + - + message: + """ + #^Call to deprecated method fetchAll\\(\\) of class Doctrine\\\\DBAL\\\\Connection\\: + Use fetchAllAssociative\\(\\)$# + """ + count: 1 + path: ../lib/Doctrine/Migrations/MigrationRepository.php + + - + message: "#^Call to function is_bool\\(\\) with bool will always evaluate to true\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/ParameterFormatter.php + + - + message: "#^Unreachable statement \\- code above always terminates\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/ParameterFormatter.php + + - + message: "#^Anonymous function should have native return typehint \"bool\"\\.$#" + count: 2 + path: ../lib/Doctrine/Migrations/Provider/LazySchemaDiffProvider.php + + - + message: "#^Anonymous function should have native return typehint \"int\\<\\-1, 1\\>\"\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Provider/OrmSchemaProvider.php + + - + message: "#^Call to function assert\\(\\) with true will always evaluate to true\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/AbstractCommand.php + + - + message: "#^Result of \\|\\| is always true\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/AbstractCommand.php + + - + message: "#^Strict comparison using \\=\\=\\= between null and null will always evaluate to true\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/AbstractCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\DiffCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/DiffCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\DumpSchemaCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/DumpSchemaCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\ExecuteCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\GenerateCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/GenerateCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\LatestCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/LatestCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\MigrateCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\RollupCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\StatusCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/StatusCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\UpToDateCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/UpToDateCommand.php + + - + message: "#^Return type \\(int\\|null\\) of method Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\VersionCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Command/VersionCommand.php + + - + message: "#^Offset 'extension' does not exist on array\\('dirname' \\=\\> string, 'basename' \\=\\> string, 'filename' \\=\\> string, \\?'extension' \\=\\> string\\)\\.$#" + count: 2 + path: ../lib/Doctrine/Migrations/Tools/Console/Helper/ConfigurationHelper.php + + - + message: "#^Call to deprecated method getName\\(\\) of class Doctrine\\\\DBAL\\\\Driver\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Helper/MigrationStatusInfosHelper.php + + - + message: "#^Call to deprecated method getHost\\(\\) of class Doctrine\\\\DBAL\\\\Connection\\.$#" + count: 1 + path: ../lib/Doctrine/Migrations/Tools/Console/Helper/MigrationStatusInfosHelper.php + + - + message: "#^Variable method call on Doctrine\\\\Migrations\\\\AbstractMigration\\.$#" + count: 3 + path: ../lib/Doctrine/Migrations/Version/Executor.php + + - + message: "#^Trying to mock an undefined method ensureConnectedToPrimary\\(\\) on class Doctrine\\\\DBAL\\\\Connections\\\\MasterSlaveConnection\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php + + - + message: "#^Variable method call on Doctrine\\\\Migrations\\\\Configuration\\\\Configuration\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php + + - + message: + """ + #^Call to deprecated method assertRegExp\\(\\) of class PHPUnit\\\\Framework\\\\Assert\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4086$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php + + - + message: + """ + #^Fetching class constant class of deprecated class Doctrine\\\\DBAL\\\\Connections\\\\MasterSlaveConnection\\: + Use PrimaryReadReplicaConnection instead$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php + + - + message: + """ + #^Instantiation of deprecated class Doctrine\\\\DBAL\\\\Driver\\\\IBMDB2\\\\DB2Driver\\: + Use \\{@link Driver\\} instead$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTest.php + + - + message: + """ + #^Call to deprecated method assertRegExp\\(\\) of class PHPUnit\\\\Framework\\\\Assert\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4086$# + """ + count: 10 + path: ../tests/Doctrine/Migrations/Tests/Functional/CliTest.php + + - + message: + """ + #^Instantiation of deprecated class Doctrine\\\\DBAL\\\\Tools\\\\Console\\\\Helper\\\\ConnectionHelper\\: + use a ConnectionProvider instead\\.$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Functional/CliTest.php + + - + message: "#^Parameter \\#1 \\$argument of class ReflectionClass constructor expects class\\-string\\\\|T of object, string\\|false given\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Functional/CliTest.php + + - + message: + """ + #^Call to deprecated method fetchAll\\(\\) of class Doctrine\\\\DBAL\\\\Connection\\: + Use fetchAllAssociative\\(\\)$# + """ + count: 3 + path: ../tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php + + - + message: + """ + #^Call to deprecated method fetchColumn\\(\\) of class Doctrine\\\\DBAL\\\\Connection\\: + Use fetchOne\\(\\) instead\\.$# + """ + count: 2 + path: ../tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php + + - + message: "#^Call to function assert\\(\\) with true will always evaluate to true\\.$#" + count: 2 + path: ../tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php + + - + message: "#^Instanceof between Doctrine\\\\DBAL\\\\Connection and Doctrine\\\\DBAL\\\\Connection will always evaluate to true\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php + + - + message: "#^Instanceof between Doctrine\\\\Migrations\\\\Configuration\\\\Configuration and Doctrine\\\\Migrations\\\\Configuration\\\\Configuration will always evaluate to true\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php + + - + message: + """ + #^Call to deprecated method exec\\(\\) of class Doctrine\\\\DBAL\\\\Connection\\: + Use \\{@link executeStatement\\(\\)\\} instead\\.$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php + + - + message: + """ + #^Call to deprecated method fetchAssoc\\(\\) of class Doctrine\\\\DBAL\\\\Connection\\: + Use fetchAssociative\\(\\)$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Functional/FunctionalTest.php + + - + message: "#^Anonymous function should have native return typehint \"bool\"\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 6 + path: ../tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php + + - + message: "#^Parameter \\#2 \\$input1 of function array_map expects array, array\\\\|false given\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Helper.php + + - + message: "#^Class Doctrine\\\\Migrations\\\\Tests\\\\DoesNotExistAtAll not found\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/MigrationRepositoryTest.php + + - + message: "#^Method Doctrine\\\\Migrations\\\\Tests\\\\MigrationTestCase\\:\\:getSqlFilesList\\(\\) should return array\\ but returns array\\\\|false\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/MigrationTestCase.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 3 + path: ../tests/Doctrine/Migrations/Tests/MigratorTest.php + + - + message: "#^Call to function assert\\(\\) with true will always evaluate to true\\.$#" + count: 2 + path: ../tests/Doctrine/Migrations/Tests/MigratorTest.php + + - + message: "#^Instanceof between \\*NEVER\\* and PHPUnit\\\\Framework\\\\MockObject\\\\MockObject will always evaluate to false\\.$#" + count: 2 + path: ../tests/Doctrine/Migrations/Tests/MigratorTest.php + + - + message: "#^Instanceof between Doctrine\\\\Migrations\\\\Migrator&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject and Doctrine\\\\Migrations\\\\Migrator will always evaluate to true\\.$#" + count: 2 + path: ../tests/Doctrine/Migrations/Tests/MigratorTest.php + + - + message: "#^Result of \\|\\| is always true\\.$#" + count: 2 + path: ../tests/Doctrine/Migrations/Tests/MigratorTest.php + + - + message: + """ + #^Fetching deprecated class constant STRING of class Doctrine\\\\DBAL\\\\Types\\\\Type\\: + Use \\{@see Types\\:\\:STRING\\} instead\\.$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/ParameterFormatterTest.php + + - + message: + """ + #^Fetching deprecated class constant INTEGER of class Doctrine\\\\DBAL\\\\Types\\\\Type\\: + Use \\{@see Types\\:\\:INTEGER\\} instead\\.$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/ParameterFormatterTest.php + + - + message: + """ + #^Fetching deprecated class constant SIMPLE_ARRAY of class Doctrine\\\\DBAL\\\\Types\\\\Type\\: + Use \\{@see Types\\:\\:SIMPLE_ARRAY\\} instead\\.$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/ParameterFormatterTest.php + + - + message: + """ + #^Fetching deprecated class constant BOOLEAN of class Doctrine\\\\DBAL\\\\Types\\\\Type\\: + Use \\{@see Types\\:\\:BOOLEAN\\} instead\\.$# + """ + count: 2 + path: ../tests/Doctrine/Migrations/Tests/ParameterFormatterTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 2 + path: ../tests/Doctrine/Migrations/Tests/SchemaDumperTest.php + + - + message: "#^Call to function assert\\(\\) with true will always evaluate to true\\.$#" + count: 2 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/AbstractCommandTest.php + + - + message: "#^Instanceof between Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\AbstractCommand&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject and Doctrine\\\\Migrations\\\\Tools\\\\Console\\\\Command\\\\AbstractCommand will always evaluate to true\\.$#" + count: 2 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/AbstractCommandTest.php + + - + message: + """ + #^Instantiation of deprecated class Doctrine\\\\DBAL\\\\Tools\\\\Console\\\\Helper\\\\ConnectionHelper\\: + use a ConnectionProvider instead\\.$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/AbstractCommandTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 8 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/AbstractCommandTest.php + + - + message: "#^Call to deprecated method getName\\(\\) of class Doctrine\\\\DBAL\\\\Driver\\.$#" + count: 2 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/AbstractCommandTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 7 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/DiffCommandTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/DiffCommandTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 3 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/DumpSchemaCommandTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 12 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/ExecuteCommandTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/ExecuteCommandTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/GenerateCommandTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 20 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 3 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationStatusTest.php + + - + message: "#^Anonymous function should have native return typehint \"\\?string\"\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationStatusTest.php + + - + message: + """ + #^Call to deprecated method assertRegExp\\(\\) of class PHPUnit\\\\Framework\\\\Assert\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4086$# + """ + count: 7 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationStatusTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrationVersionTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 8 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Command/StatusCommandTest.php + + - + message: "#^Call to an undefined method Doctrine\\\\Migrations\\\\Configuration\\\\Connection\\\\Loader\\\\ConnectionConfigurationChainLoader\\|PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\:\\:expects\\(\\)\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/ConnectionLoaderTest.php + + - + message: "#^Call to method PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\\\:\\:willReturn\\(\\) with incorrect case\\: wilLReturn$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/ConnectionLoaderTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/ConnectionLoaderTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tools/Console/Helper/ConfigurationHelperTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tracking/TableManipulatorTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 4 + path: ../tests/Doctrine/Migrations/Tests/Tracking/TableStatusTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 4 + path: ../tests/Doctrine/Migrations/Tests/Tracking/TableUpdaterTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Tracking/TableUpdaterTest.php + + - + message: + """ + #^Call to deprecated method at\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4297$# + """ + count: 14 + path: ../tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php + + - + message: + """ + #^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder\\: + https\\://github\\.com/sebastianbergmann/phpunit/pull/3687$# + """ + count: 4 + path: ../tests/Doctrine/Migrations/Tests/Version/VersionTest.php + + - + message: "#^Call to function assert\\(\\) with true will always evaluate to true\\.$#" + count: 3 + path: ../tests/Doctrine/Migrations/Tests/Version/VersionTest.php + + - + message: "#^Instanceof between \\*NEVER\\* and PHPUnit\\\\Framework\\\\MockObject\\\\MockObject will always evaluate to false\\.$#" + count: 3 + path: ../tests/Doctrine/Migrations/Tests/Version/VersionTest.php + + - + message: "#^Instanceof between Doctrine\\\\Migrations\\\\Configuration\\\\Configuration&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject and Doctrine\\\\Migrations\\\\Configuration\\\\Configuration will always evaluate to true\\.$#" + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Version/VersionTest.php + + - + message: "#^Result of \\|\\| is always true\\.$#" + count: 3 + path: ../tests/Doctrine/Migrations/Tests/Version/VersionTest.php + + - + message: "#^Instanceof between Doctrine\\\\Migrations\\\\Version\\\\Version&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject and Doctrine\\\\Migrations\\\\Version\\\\Version will always evaluate to true\\.$#" + count: 2 + path: ../tests/Doctrine/Migrations/Tests/Version/VersionTest.php + + - + message: + """ + #^Call to deprecated method assertRegExp\\(\\) of class PHPUnit\\\\Framework\\\\Assert\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4086$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Version/VersionTest.php + + - + message: + """ + #^Call to deprecated method assertNotRegExp\\(\\) of class PHPUnit\\\\Framework\\\\Assert\\: + https\\://github\\.com/sebastianbergmann/phpunit/issues/4089$# + """ + count: 1 + path: ../tests/Doctrine/Migrations/Tests/Version/VersionTest.php + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index af1642a057..0cb29ae4c5 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,6 @@ parameters: level: 7 + reportUnmatchedIgnoredErrors: false paths: - %currentWorkingDirectory%/lib - %currentWorkingDirectory%/tests @@ -12,14 +13,15 @@ parameters: - %currentWorkingDirectory%/tests/Doctrine/Migrations/Tests/Configuration/ConfigurationTestSource/Migrations/Version123.php - %currentWorkingDirectory%/tests/Doctrine/Migrations/Tests/realpath.php ignoreErrors: - - '~^Parameter #1 \$files of method Doctrine\\Migrations\\Finder\\Finder::loadMigrationClasses\(\) expects array, array given\.\z~' - - '~^Class Doctrine\\Migrations\\Tests\\DoesNotExistAtAll not found\.\z~' - - '~^Call to method getVersion\(\) of deprecated class PackageVersions\\Versions\.$~' + - '~Unable to resolve the template type T in call to method static method Doctrine\\DBAL\\DriverManager\:\:getConnection\(\)~' + - '~Call to method getVersion\(\) of deprecated class PackageVersions\\Versions\:.*~' # Drop when bumping to doctrine/dbal 2.11+ - '~^.*PrimaryReadReplicaConnection.*$~' + includes: - vendor/phpstan/phpstan-deprecation-rules/rules.neon - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon + - .github/phpstan-baseline.neon From f646b2505570d3c10574c9a4bc6d31c0b91a4ef2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 23 Dec 2020 14:33:59 +0100 Subject: [PATCH 10/10] Disable "Roave BC Check" --- .github/workflows/bc-check.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/bc-check.yml b/.github/workflows/bc-check.yml index 0b510c7850..a9324d35ad 100644 --- a/.github/workflows/bc-check.yml +++ b/.github/workflows/bc-check.yml @@ -1,19 +1,19 @@ -name: "Backward Compatibility Check" +#name: "Backward Compatibility Check" -on: - pull_request: +#on: +# pull_request: -jobs: - roave_bc_check: - name: "Roave BC Check" - runs-on: "ubuntu-20.04" - steps: - - uses: "actions/checkout@v2" - with: - fetch-depth: 0 +#jobs: +# roave_bc_check: +# name: "Roave BC Check" +# runs-on: "ubuntu-20.04" +# steps: +# - uses: "actions/checkout@v2" +# with: +# fetch-depth: 0 - - name: "Roave BC Check" - uses: "docker://nyholm/roave-bc-check-ga" - with: - args: "--from=${{ github.event.pull_request.base.sha }}" +# - name: "Roave BC Check" +# uses: "docker://nyholm/roave-bc-check-ga" +# with: +# args: "--from=${{ github.event.pull_request.base.sha }}"