diff --git a/src/Phinx/Config/Config.php b/src/Phinx/Config/Config.php index 4b38d31d4..2b143c669 100644 --- a/src/Phinx/Config/Config.php +++ b/src/Phinx/Config/Config.php @@ -82,7 +82,7 @@ public static function fromYaml(string $configFilePath): ConfigInterface if (!is_array($configArray)) { throw new RuntimeException(sprintf( 'File \'%s\' must be valid YAML', - $configFilePath + $configFilePath, )); } @@ -108,7 +108,7 @@ public static function fromJson(string $configFilePath): ConfigInterface if (!is_array($configArray)) { throw new RuntimeException(sprintf( 'File \'%s\' must be valid JSON', - $configFilePath + $configFilePath, )); } @@ -134,7 +134,7 @@ public static function fromPhp(string $configFilePath): ConfigInterface if (!is_array($configArray)) { throw new RuntimeException(sprintf( 'PHP file \'%s\' must return an array', - $configFilePath + $configFilePath, )); } @@ -212,7 +212,7 @@ public function getDefaultEnvironment(): string throw new RuntimeException(sprintf( 'The environment configuration (read from $PHINX_ENVIRONMENT) for \'%s\' is missing', - $env + $env, )); } @@ -231,7 +231,7 @@ public function getDefaultEnvironment(): string throw new RuntimeException(sprintf( 'The environment configuration for \'%s\' is missing', - $this->values['environments']['default_environment'] + $this->values['environments']['default_environment'], )); } diff --git a/src/Phinx/Console/Command/AbstractCommand.php b/src/Phinx/Console/Command/AbstractCommand.php index de5722654..88cafc424 100644 --- a/src/Phinx/Console/Command/AbstractCommand.php +++ b/src/Phinx/Console/Command/AbstractCommand.php @@ -371,14 +371,14 @@ protected function verifyMigrationDirectory(string $path): void if (!is_dir($path)) { throw new InvalidArgumentException(sprintf( 'Migration directory "%s" does not exist', - $path + $path, )); } if (!is_writable($path)) { throw new InvalidArgumentException(sprintf( 'Migration directory "%s" is not writable', - $path + $path, )); } } @@ -395,14 +395,14 @@ protected function verifySeedDirectory(string $path): void if (!is_dir($path)) { throw new InvalidArgumentException(sprintf( 'Seed directory "%s" does not exist', - $path + $path, )); } if (!is_writable($path)) { throw new InvalidArgumentException(sprintf( 'Seed directory "%s" is not writable', - $path + $path, )); } } diff --git a/src/Phinx/Console/Command/Breakpoint.php b/src/Phinx/Console/Command/Breakpoint.php index 14e7112d8..caf0f7656 100644 --- a/src/Phinx/Console/Command/Breakpoint.php +++ b/src/Phinx/Console/Command/Breakpoint.php @@ -48,7 +48,7 @@ protected function configure(): void phinx breakpoint -e development phinx breakpoint -e development -t 20110103081132 phinx breakpoint -e development -r -EOT +EOT, ); } diff --git a/src/Phinx/Console/Command/Create.php b/src/Phinx/Console/Command/Create.php index 8dcd3b63e..c28253115 100644 --- a/src/Phinx/Console/Command/Create.php +++ b/src/Phinx/Console/Command/Create.php @@ -59,7 +59,7 @@ protected function configure(): void ->setHelp(sprintf( '%sCreates a new database migration%s', PHP_EOL, - PHP_EOL + PHP_EOL, )); // An alternative template. @@ -127,7 +127,7 @@ protected function getMigrationPath(InputInterface $input, OutputInterface $outp throw new Exception( 'You probably used curly braces to define migration path in your Phinx configuration file, ' . 'but no directories have been matched using this pattern. ' . - 'You need to create a migration directory manually.' + 'You need to create a migration directory manually.', ); } @@ -179,7 +179,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($className !== null && in_array(strtolower($className), $this->keywords)) { throw new InvalidArgumentException(sprintf( 'The migration class name "%s" is a reserved PHP keyword. Please choose a different class name.', - $className + $className, )); } @@ -195,7 +195,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!Util::isValidPhinxClassName($className)) { throw new InvalidArgumentException(sprintf( 'The migration class name "%s" is invalid. Please use CamelCase format.', - $className + $className, )); } @@ -207,7 +207,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int throw new InvalidArgumentException(sprintf( 'The migration class name "%s%s" already exists', $namespace ? $namespace . '\\' : '', - $className + $className, )); } @@ -216,7 +216,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (is_file($filePath)) { throw new InvalidArgumentException(sprintf( 'The file "%s" already exists', - $filePath + $filePath, )); } @@ -253,7 +253,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($altTemplate && !is_file($altTemplate)) { throw new InvalidArgumentException(sprintf( 'The alternative template file "%s" does not exist', - $altTemplate + $altTemplate, )); } @@ -267,12 +267,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int throw new InvalidArgumentException(sprintf( 'The class "%s" via the alias "%s" does not exist', $aliasedClassName, - $creationClassName + $creationClassName, )); } elseif (!$aliasedClassName) { throw new InvalidArgumentException(sprintf( 'The class "%s" does not exist', - $creationClassName + $creationClassName, )); } } @@ -282,14 +282,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int throw new InvalidArgumentException(sprintf( 'The class "%s" does not implement the required interface "%s"', $creationClassName, - self::CREATION_INTERFACE + self::CREATION_INTERFACE, )); } elseif ($aliasedClassName && !is_subclass_of($aliasedClassName, self::CREATION_INTERFACE)) { throw new InvalidArgumentException(sprintf( 'The class "%s" via the alias "%s" does not implement the required interface "%s"', $aliasedClassName, $creationClassName, - self::CREATION_INTERFACE + self::CREATION_INTERFACE, )); } } @@ -321,7 +321,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (file_put_contents($filePath, $contents) === false) { throw new RuntimeException(sprintf( 'The file "%s" could not be written to', - $path + $path, )); } diff --git a/src/Phinx/Console/Command/Init.php b/src/Phinx/Console/Command/Init.php index eca96b518..3b634f72d 100644 --- a/src/Phinx/Console/Command/Init.php +++ b/src/Phinx/Console/Command/Init.php @@ -50,13 +50,13 @@ protected function configure(): void '-f', InputArgument::OPTIONAL, 'What format should we use to initialize?', - AbstractCommand::FORMAT_DEFAULT + AbstractCommand::FORMAT_DEFAULT, ) ->addArgument('path', InputArgument::OPTIONAL, 'Which path should we initialize for Phinx?') ->setHelp(sprintf( '%sInitializes the application for Phinx%s', PHP_EOL, - PHP_EOL + PHP_EOL, )); } @@ -94,7 +94,7 @@ protected function resolvePath(InputInterface $input, string $format): string if (!in_array($format, static::$supportedFormats, true)) { throw new InvalidArgumentException(sprintf( 'Invalid format "%s". Format must be either ' . implode(', ', static::$supportedFormats) . '.', - $format + $format, )); } @@ -118,14 +118,14 @@ protected function resolvePath(InputInterface $input, string $format): string if (is_file($path)) { throw new InvalidArgumentException(sprintf( 'Config file "%s" already exists.', - $path + $path, )); } // Dir is invalid throw new InvalidArgumentException(sprintf( 'Invalid path "%s" for config file.', - $path + $path, )); } @@ -145,7 +145,7 @@ protected function writeConfig(string $path, string $format = AbstractCommand::F if (!is_writable($dirname)) { throw new InvalidArgumentException(sprintf( 'The directory "%s" is not writable', - $dirname + $dirname, )); } @@ -159,14 +159,14 @@ protected function writeConfig(string $path, string $format = AbstractCommand::F } else { throw new RuntimeException(sprintf( 'Could not find template for format "%s".', - $format + $format, )); } if (file_put_contents($path, $contents) === false) { throw new RuntimeException(sprintf( 'The file "%s" could not be written to', - $path + $path, )); } } diff --git a/src/Phinx/Console/Command/ListAliases.php b/src/Phinx/Console/Command/ListAliases.php index 1f02f2fdc..f7b757db9 100644 --- a/src/Phinx/Console/Command/ListAliases.php +++ b/src/Phinx/Console/Command/ListAliases.php @@ -63,17 +63,17 @@ function ($alias, $class) use ($maxAliasLength, $maxClassLength) { return sprintf('%s %s', str_pad($alias, $maxAliasLength), str_pad($class, $maxClassLength)); }, array_keys($aliases), - $aliases - ) + $aliases, + ), ), - $this->verbosityLevel + $this->verbosityLevel, ); } else { $output->writeln( 'warning no aliases defined in ' . Util::relativePath( - $this->config->getConfigFilePath() + $this->config->getConfigFilePath(), ), - $this->verbosityLevel + $this->verbosityLevel, ); } diff --git a/src/Phinx/Console/Command/Migrate.php b/src/Phinx/Console/Command/Migrate.php index 699fa4a62..52daf90d9 100644 --- a/src/Phinx/Console/Command/Migrate.php +++ b/src/Phinx/Console/Command/Migrate.php @@ -49,7 +49,7 @@ protected function configure(): void phinx migrate -e development -d 20110103 phinx migrate -e development -v -EOT +EOT, ); } diff --git a/src/Phinx/Console/Command/Rollback.php b/src/Phinx/Console/Command/Rollback.php index 2c4b6bb05..ff78f04a9 100644 --- a/src/Phinx/Console/Command/Rollback.php +++ b/src/Phinx/Console/Command/Rollback.php @@ -58,7 +58,7 @@ protected function configure(): void This can be used to allow the rolling back of the last executed migration instead of the last created one, or combined with the -d|--date option to rollback to a certain date using the migration start times to order them. -EOT +EOT, ); } diff --git a/src/Phinx/Console/Command/SeedCreate.php b/src/Phinx/Console/Command/SeedCreate.php index 34e9f7dd6..3b0fe3bbe 100644 --- a/src/Phinx/Console/Command/SeedCreate.php +++ b/src/Phinx/Console/Command/SeedCreate.php @@ -45,7 +45,7 @@ protected function configure(): void ->setHelp(sprintf( '%sCreates a new database seeder%s', PHP_EOL, - PHP_EOL + PHP_EOL, )); // An alternative template. @@ -104,7 +104,7 @@ protected function getSeedPath(InputInterface $input, OutputInterface $output): throw new Exception( 'You probably used curly braces to define seed path in your Phinx configuration file, ' . 'but no directories have been matched using this pattern. ' . - 'You need to create a seed directory manually.' + 'You need to create a seed directory manually.', ); } @@ -155,7 +155,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!Util::isValidPhinxClassName($className)) { throw new InvalidArgumentException(sprintf( 'The seed class name "%s" is invalid. Please use CamelCase format', - $className + $className, )); } @@ -165,7 +165,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (is_file($filePath)) { throw new InvalidArgumentException(sprintf( 'The file "%s" already exists', - basename($filePath) + basename($filePath), )); } @@ -176,7 +176,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($altTemplate && !is_file($altTemplate)) { throw new InvalidArgumentException(sprintf( 'The template file "%s" does not exist', - $altTemplate + $altTemplate, )); } @@ -187,7 +187,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!is_null($altTemplate) && !is_file($altTemplate)) { throw new InvalidArgumentException(sprintf( 'The template file `%s` from config does not exist', - $altTemplate + $altTemplate, )); } } @@ -209,7 +209,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (file_put_contents($filePath, $contents) === false) { throw new RuntimeException(sprintf( 'The file "%s" could not be written to', - $path + $path, )); } diff --git a/src/Phinx/Console/Command/SeedRun.php b/src/Phinx/Console/Command/SeedRun.php index ee38f66c7..343221152 100644 --- a/src/Phinx/Console/Command/SeedRun.php +++ b/src/Phinx/Console/Command/SeedRun.php @@ -45,7 +45,7 @@ protected function configure(): void phinx seed:run -e development -s UserSeeder -s PermissionSeeder -s LogSeeder phinx seed:run -e development -v -EOT +EOT, ); } diff --git a/src/Phinx/Console/Command/Status.php b/src/Phinx/Console/Command/Status.php index d2ac5b452..ca09eb457 100644 --- a/src/Phinx/Console/Command/Status.php +++ b/src/Phinx/Console/Command/Status.php @@ -43,7 +43,7 @@ protected function configure(): void phinx status -e development -f json The version_order configuration option is used to determine the order of the status migrations. -EOT +EOT, ); } diff --git a/src/Phinx/Console/Command/Test.php b/src/Phinx/Console/Command/Test.php index d555ee574..7391add3e 100644 --- a/src/Phinx/Console/Command/Test.php +++ b/src/Phinx/Console/Command/Test.php @@ -45,7 +45,7 @@ protected function configure(): void phinx test -e development If the environment option is set, it will test that phinx can connect to the DB associated with that environment -EOT +EOT, ); } @@ -68,13 +68,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Verify the migrations path(s) array_map( [$this, 'verifyMigrationDirectory'], - Util::globAll($this->getConfig()->getMigrationPaths()) + Util::globAll($this->getConfig()->getMigrationPaths()), ); // Verify the seed path(s) array_map( [$this, 'verifySeedDirectory'], - Util::globAll($this->getConfig()->getSeedPaths()) + Util::globAll($this->getConfig()->getSeedPaths()), ); $envName = $input->getOption('environment'); @@ -82,14 +82,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$this->getConfig()->hasEnvironment($envName)) { throw new InvalidArgumentException(sprintf( 'The environment "%s" does not exist', - $envName + $envName, )); } $output->writeln(sprintf('validating environment %s', $envName), $this->verbosityLevel); $environment = new Environment( $envName, - $this->getConfig()->getEnvironment($envName) + $this->getConfig()->getEnvironment($envName), ); // validate environment connection $environment->getAdapter()->connect(); diff --git a/src/Phinx/Db/Adapter/AbstractAdapter.php b/src/Phinx/Db/Adapter/AbstractAdapter.php index 97f993293..abc223ddb 100644 --- a/src/Phinx/Db/Adapter/AbstractAdapter.php +++ b/src/Phinx/Db/Adapter/AbstractAdapter.php @@ -225,7 +225,7 @@ public function setDataDomain(array $dataDomain) if (!isset($options['type'])) { throw new InvalidArgumentException(sprintf( 'You must specify a type for data domain type "%s".', - $type + $type, )); } @@ -238,7 +238,7 @@ public function setDataDomain(array $dataDomain) throw new InvalidArgumentException(sprintf( 'An invalid column type "%s" was specified for data domain type "%s".', $options['type'], - $type + $type, )); } @@ -257,7 +257,7 @@ public function setDataDomain(array $dataDomain) throw new InvalidArgumentException(sprintf( 'An invalid limit value "%s" was specified for data domain type "%s".', $options['limit'], - $type + $type, )); } @@ -318,7 +318,7 @@ public function createSchemaTable(): void throw new InvalidArgumentException( 'There was a problem creating the schema table: ' . $exception->getMessage(), (int)$exception->getCode(), - $exception + $exception, ); } } diff --git a/src/Phinx/Db/Adapter/AdapterFactory.php b/src/Phinx/Db/Adapter/AdapterFactory.php index d5a3f2fd5..7413c4c13 100644 --- a/src/Phinx/Db/Adapter/AdapterFactory.php +++ b/src/Phinx/Db/Adapter/AdapterFactory.php @@ -73,7 +73,7 @@ public function registerAdapter(string $name, object|string $class) if (!is_subclass_of($class, 'Phinx\Db\Adapter\AdapterInterface')) { throw new RuntimeException(sprintf( 'Adapter class "%s" must implement Phinx\\Db\\Adapter\\AdapterInterface', - is_string($class) ? $class : get_class($class) + is_string($class) ? $class : get_class($class), )); } $this->adapters[$name] = $class; @@ -94,7 +94,7 @@ protected function getClass(string $name): object|string if (empty($this->adapters[$name])) { throw new RuntimeException(sprintf( 'Adapter "%s" has not been registered', - $name + $name, )); } @@ -128,7 +128,7 @@ public function registerWrapper(string $name, object|string $class) if (!is_subclass_of($class, 'Phinx\Db\Adapter\WrapperInterface')) { throw new RuntimeException(sprintf( 'Wrapper class "%s" must be implement Phinx\\Db\\Adapter\\WrapperInterface', - is_string($class) ? $class : get_class($class) + is_string($class) ? $class : get_class($class), )); } $this->wrappers[$name] = $class; @@ -148,7 +148,7 @@ protected function getWrapperClass(string $name): WrapperInterface|string if (empty($this->wrappers[$name])) { throw new RuntimeException(sprintf( 'Wrapper "%s" has not been registered', - $name + $name, )); } diff --git a/src/Phinx/Db/Adapter/MysqlAdapter.php b/src/Phinx/Db/Adapter/MysqlAdapter.php index 9fbcbcb0a..419156875 100644 --- a/src/Phinx/Db/Adapter/MysqlAdapter.php +++ b/src/Phinx/Db/Adapter/MysqlAdapter.php @@ -252,7 +252,7 @@ protected function hasTableWithSchema(string $schema, string $tableName): bool FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'", $schema, - $tableName + $tableName, )); return !empty($result); @@ -272,7 +272,7 @@ public function createTable(Table $table, array $columns = [], array $indexes = $options = array_merge( $defaultOptions, array_intersect_key($this->getOptions(), $defaultOptions), - $table->getOptions() + $table->getOptions(), ); // Add the default primary key @@ -385,7 +385,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A } else { throw new InvalidArgumentException(sprintf( 'Invalid value for primary key: %s', - json_encode($newColumns) + json_encode($newColumns), )); } $sql .= ')'; @@ -419,7 +419,7 @@ protected function getRenameTableInstructions(string $tableName, string $newTabl $sql = sprintf( 'RENAME TABLE %s TO %s', $this->quoteTableName($tableName), - $this->quoteTableName($newTableName) + $this->quoteTableName($newTableName), ); return new AlterInstructions([], [$sql]); @@ -443,7 +443,7 @@ public function truncateTable(string $tableName): void { $sql = sprintf( 'TRUNCATE TABLE %s', - $this->quoteTableName($tableName) + $this->quoteTableName($tableName), ); $this->execute($sql); @@ -487,8 +487,8 @@ public function getColumns(string $tableName): array $column->getType(), array_merge( static::PHINX_TYPES_GEOSPATIAL, - [static::PHINX_TYPE_BLOB, static::PHINX_TYPE_JSON, static::PHINX_TYPE_TEXT] - ) + [static::PHINX_TYPE_BLOB, static::PHINX_TYPE_JSON, static::PHINX_TYPE_TEXT], + ), ) ) { // The default that comes back from MySQL for these types prefixes the collation type and @@ -528,7 +528,7 @@ protected function getAddColumnInstructions(Table $table, Column $column): Alter $alter = sprintf( 'ADD %s %s', $this->quoteColumnName($column->getName()), - $this->getColumnSqlDefinition($column) + $this->getColumnSqlDefinition($column), ); $alter .= $this->afterClause($column); @@ -589,7 +589,7 @@ protected function getRenameColumnInstructions(string $tableName, string $column 'CHANGE COLUMN %s %s %s', $this->quoteColumnName($columnName), $this->quoteColumnName($newColumnName), - $definition + $definition, ); return new AlterInstructions([$alter]); @@ -598,7 +598,7 @@ protected function getRenameColumnInstructions(string $tableName, string $column throw new InvalidArgumentException(sprintf( "The specified column doesn't exist: " . - $columnName + $columnName, )); } @@ -612,7 +612,7 @@ protected function getChangeColumnInstructions(string $tableName, string $column $this->quoteColumnName($columnName), $this->quoteColumnName($newColumn->getName()), $this->getColumnSqlDefinition($newColumn), - $this->afterClause($newColumn) + $this->afterClause($newColumn), ); return new AlterInstructions([$alter]); @@ -698,14 +698,14 @@ protected function getAddIndexInstructions(Table $table, Index $index): AlterIns $alter = sprintf( 'ALTER TABLE %s ADD %s', $this->quoteTableName($table->getName()), - $this->getIndexSqlDefinition($index) + $this->getIndexSqlDefinition($index), ); $instructions->addPostStep($alter); } else { $alter = sprintf( 'ADD %s', - $this->getIndexSqlDefinition($index) + $this->getIndexSqlDefinition($index), ); $instructions->addAlter($alter); @@ -732,14 +732,14 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns if ($columns == $index['columns']) { return new AlterInstructions([sprintf( 'DROP INDEX %s', - $this->quoteColumnName($indexName) + $this->quoteColumnName($indexName), )]); } } throw new InvalidArgumentException(sprintf( "The specified index on columns '%s' does not exist", - implode(',', $columns) + implode(',', $columns), )); } @@ -756,14 +756,14 @@ protected function getDropIndexByNameInstructions(string $tableName, $indexName) if ($name === $indexName) { return new AlterInstructions([sprintf( 'DROP INDEX %s', - $this->quoteColumnName($indexName) + $this->quoteColumnName($indexName), )]); } } throw new InvalidArgumentException(sprintf( "The specified index name '%s' does not exist", - $indexName + $indexName, )); } @@ -809,7 +809,7 @@ public function getPrimaryKey(string $tableName): array AND t.TABLE_SCHEMA='%s' AND t.TABLE_NAME='%s'", $options['name'], - $tableName + $tableName, )); $primaryKey = [ @@ -874,7 +874,7 @@ protected function getForeignKeys(string $tableName): array AND TABLE_NAME = '%s' ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", empty($schema) ? 'DATABASE()' : "'$schema'", - $tableName + $tableName, )); foreach ($rows as $row) { $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME']; @@ -893,7 +893,7 @@ protected function getAddForeignKeyInstructions(Table $table, ForeignKey $foreig { $alter = sprintf( 'ADD %s', - $this->getForeignKeySqlDefinition($foreignKey) + $this->getForeignKeySqlDefinition($foreignKey), ); return new AlterInstructions([$alter]); @@ -906,7 +906,7 @@ protected function getDropForeignKeyInstructions(string $tableName, string $cons { $alter = sprintf( 'DROP FOREIGN KEY %s', - $constraint + $constraint, ); return new AlterInstructions([$alter]); @@ -934,13 +934,13 @@ protected function getDropForeignKeyByColumnsInstructions(string $tableName, arr if (empty($matches)) { throw new InvalidArgumentException(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', $columns) + implode(', ', $columns), )); } foreach ($matches as $name) { $instructions->merge( - $this->getDropForeignKeyInstructions($tableName, $name) + $this->getDropForeignKeyInstructions($tableName, $name), ); } @@ -1304,7 +1304,7 @@ public function createDatabase(string $name, array $options = []): void 'CREATE DATABASE %s DEFAULT CHARACTER SET `%s` COLLATE `%s`', $this->quoteColumnName($name), $charset, - $options['collation'] + $options['collation'], )); } else { $this->execute(sprintf('CREATE DATABASE %s DEFAULT CHARACTER SET `%s`', $this->quoteColumnName($name), $charset)); @@ -1319,8 +1319,8 @@ public function hasDatabase(string $name): bool $rows = $this->fetchAll( sprintf( 'SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = \'%s\'', - $name - ) + $name, + ), ); foreach ($rows as $row) { @@ -1395,8 +1395,8 @@ protected function getColumnSqlDefinition(Column $column): string $column->getType(), array_merge( static::PHINX_TYPES_GEOSPATIAL, - [static::PHINX_TYPE_BLOB, static::PHINX_TYPE_JSON, static::PHINX_TYPE_TEXT] - ) + [static::PHINX_TYPE_BLOB, static::PHINX_TYPE_JSON, static::PHINX_TYPE_TEXT], + ), ) ) { $default = Literal::from('(' . $this->getConnection()->quote($column->getDefault()) . ')'); @@ -1520,7 +1520,7 @@ public function describeTable(string $tableName): array WHERE table_schema = '%s' AND table_name = '%s'", $options['name'], - $tableName + $tableName, ); $table = $this->fetchRow($sql); diff --git a/src/Phinx/Db/Adapter/PdoAdapter.php b/src/Phinx/Db/Adapter/PdoAdapter.php index 28997e9b5..4b025805a 100644 --- a/src/Phinx/Db/Adapter/PdoAdapter.php +++ b/src/Phinx/Db/Adapter/PdoAdapter.php @@ -92,7 +92,7 @@ protected function createPdoConnection( ?string $username = null, #[SensitiveParameter] ?string $password = null, - array $options = [] + array $options = [], ): PDO { $adapterOptions = $this->getOptions() + [ 'attr_errmode' => PDO::ERRMODE_EXCEPTION, @@ -113,7 +113,7 @@ protected function createPdoConnection( } catch (PDOException $e) { throw new InvalidArgumentException(sprintf( 'There was a problem connecting to the database: %s', - $e->getMessage() + $e->getMessage(), ), 0, $e); } @@ -154,7 +154,7 @@ public function setConnection(PDO $connection): AdapterInterface ->addColumn( 'migration_name', 'string', - ['limit' => 100, 'after' => 'version', 'default' => null, 'null' => true] + ['limit' => 100, 'after' => 'version', 'default' => null, 'null' => true], ) ->save(); } @@ -249,7 +249,7 @@ public function getQueryBuilder(string $type): Query Query::TYPE_UPDATE => $this->getDecoratedConnection()->updateQuery(), Query::TYPE_DELETE => $this->getDecoratedConnection()->deleteQuery(), default => throw new InvalidArgumentException( - 'Query type must be one of: `select`, `insert`, `update`, `delete`.' + 'Query type must be one of: `select`, `insert`, `update`, `delete`.', ) }; } @@ -326,7 +326,7 @@ public function insert(Table $table, array $row): void { $sql = sprintf( 'INSERT INTO %s ', - $this->quoteTableName($table->getName()) + $this->quoteTableName($table->getName()), ); $columns = array_keys($row); $sql .= '(' . implode(', ', array_map([$this, 'quoteColumnName'], $columns)) . ') ' . $this->getInsertOverride() . 'VALUES '; @@ -401,7 +401,7 @@ public function bulkinsert(Table $table, array $rows): void { $sql = sprintf( 'INSERT INTO %s ', - $this->quoteTableName($table->getName()) + $this->quoteTableName($table->getName()), ); $current = current($rows); $keys = array_keys($current); @@ -519,7 +519,7 @@ public function migrated(MigrationInterface $migration, string $direction, strin substr($migration->getName(), 0, 100), $startTime, $endTime, - $this->castToBool(false) + $this->castToBool(false), ); $this->execute($sql); @@ -529,7 +529,7 @@ public function migrated(MigrationInterface $migration, string $direction, strin "DELETE FROM %s WHERE %s = '%s'", $this->quoteTableName($this->getSchemaTableName()), $this->quoteColumnName('version'), - $migration->getVersion() + $migration->getVersion(), ); $this->execute($sql); @@ -552,8 +552,8 @@ public function toggleBreakpoint(MigrationInterface $migration): AdapterInterfac $this->castToBool(false), $this->quoteColumnName('version'), $migration->getVersion(), - $this->quoteColumnName('start_time') - ) + $this->quoteColumnName('start_time'), + ), ); return $this; @@ -570,8 +570,8 @@ public function resetAllBreakpoints(): int $this->quoteTableName($this->getSchemaTableName()), $this->quoteColumnName('breakpoint'), $this->castToBool(false), - $this->quoteColumnName('start_time') - ) + $this->quoteColumnName('start_time'), + ), ); } @@ -612,8 +612,8 @@ protected function markBreakpoint(MigrationInterface $migration, bool $state): A $this->castToBool($state), $this->quoteColumnName('start_time'), $this->quoteColumnName('version'), - $migration->getVersion() - ) + $migration->getVersion(), + ), ); return $this; @@ -1012,7 +1012,7 @@ public function executeActions(Table $table, array $actions): void $instructions->merge($this->getChangeColumnInstructions( $table->getName(), $action->getColumnName(), - $action->getColumn() + $action->getColumn(), )); break; @@ -1020,7 +1020,7 @@ public function executeActions(Table $table, array $actions): void /** @var \Phinx\Db\Action\DropForeignKey $action */ $instructions->merge($this->getDropForeignKeyByColumnsInstructions( $table->getName(), - $action->getForeignKey()->getColumns() + $action->getForeignKey()->getColumns(), )); break; @@ -1028,7 +1028,7 @@ public function executeActions(Table $table, array $actions): void /** @var \Phinx\Db\Action\DropForeignKey $action */ $instructions->merge($this->getDropForeignKeyInstructions( $table->getName(), - $action->getForeignKey()->getConstraint() + $action->getForeignKey()->getConstraint(), )); break; @@ -1036,7 +1036,7 @@ public function executeActions(Table $table, array $actions): void /** @var \Phinx\Db\Action\DropIndex $action */ $instructions->merge($this->getDropIndexByNameInstructions( $table->getName(), - $action->getIndex()->getName() + $action->getIndex()->getName(), )); break; @@ -1044,14 +1044,14 @@ public function executeActions(Table $table, array $actions): void /** @var \Phinx\Db\Action\DropIndex $action */ $instructions->merge($this->getDropIndexByColumnsInstructions( $table->getName(), - $action->getIndex()->getColumns() + $action->getIndex()->getColumns(), )); break; case $action instanceof DropTable: /** @var \Phinx\Db\Action\DropTable $action */ $instructions->merge($this->getDropTableInstructions( - $table->getName() + $table->getName(), )); break; @@ -1059,7 +1059,7 @@ public function executeActions(Table $table, array $actions): void /** @var \Phinx\Db\Action\RemoveColumn $action */ $instructions->merge($this->getDropColumnInstructions( $table->getName(), - $action->getColumn()->getName() + $action->getColumn()->getName(), )); break; @@ -1068,7 +1068,7 @@ public function executeActions(Table $table, array $actions): void $instructions->merge($this->getRenameColumnInstructions( $table->getName(), $action->getColumn()->getName(), - $action->getNewName() + $action->getNewName(), )); break; @@ -1076,7 +1076,7 @@ public function executeActions(Table $table, array $actions): void /** @var \Phinx\Db\Action\RenameTable $action */ $instructions->merge($this->getRenameTableInstructions( $table->getName(), - $action->getNewName() + $action->getNewName(), )); break; @@ -1084,7 +1084,7 @@ public function executeActions(Table $table, array $actions): void /** @var \Phinx\Db\Action\ChangePrimaryKey $action */ $instructions->merge($this->getChangePrimaryKeyInstructions( $table, - $action->getNewColumns() + $action->getNewColumns(), )); break; @@ -1092,13 +1092,13 @@ public function executeActions(Table $table, array $actions): void /** @var \Phinx\Db\Action\ChangeComment $action */ $instructions->merge($this->getChangeCommentInstructions( $table, - $action->getNewComment() + $action->getNewComment(), )); break; default: throw new InvalidArgumentException( - sprintf("Don't know how to execute action: '%s'", get_class($action)) + sprintf("Don't know how to execute action: '%s'", get_class($action)), ); } } diff --git a/src/Phinx/Db/Adapter/PostgresAdapter.php b/src/Phinx/Db/Adapter/PostgresAdapter.php index af6ab83a0..865d36ba0 100644 --- a/src/Phinx/Db/Adapter/PostgresAdapter.php +++ b/src/Phinx/Db/Adapter/PostgresAdapter.php @@ -141,7 +141,7 @@ public function connect(): void throw new InvalidArgumentException( sprintf('Schema does not exists: %s', $options['schema']), 0, - $exception + $exception, ); } @@ -235,8 +235,8 @@ public function hasTable(string $tableName): bool WHERE table_schema = %s AND table_name = %s', $this->getConnection()->quote($parts['schema']), - $this->getConnection()->quote($parts['table']) - ) + $this->getConnection()->quote($parts['table']), + ), ); return $result->rowCount() === 1; @@ -325,7 +325,7 @@ public function createTable(Table $table, array $columns = [], array $indexes = $queries[] = sprintf( 'COMMENT ON TABLE %s IS %s', $this->quoteTableName($table->getName()), - $this->getConnection()->quote($options['comment']) + $this->getConnection()->quote($options['comment']), ); } @@ -352,7 +352,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A if (!empty($primaryKey['constraint'])) { $sql = sprintf( 'DROP CONSTRAINT %s', - $this->quoteColumnName($primaryKey['constraint']) + $this->quoteColumnName($primaryKey['constraint']), ); $instructions->addAlter($sql); } @@ -361,7 +361,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A if (!empty($newColumns)) { $sql = sprintf( 'ADD CONSTRAINT %s PRIMARY KEY (', - $this->quoteColumnName($parts['table'] . '_pkey') + $this->quoteColumnName($parts['table'] . '_pkey'), ); if (is_string($newColumns)) { // handle primary_key => 'id' $sql .= $this->quoteColumnName($newColumns); @@ -370,7 +370,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A } else { throw new InvalidArgumentException(sprintf( 'Invalid value for primary key: %s', - json_encode($newColumns) + json_encode($newColumns), )); } $sql .= ')'; @@ -394,7 +394,7 @@ protected function getChangeCommentInstructions(Table $table, ?string $newCommen $sql = sprintf( 'COMMENT ON TABLE %s IS %s', $this->quoteTableName($table->getName()), - $newComment + $newComment, ); $instructions->addPostStep($sql); @@ -410,7 +410,7 @@ protected function getRenameTableInstructions(string $tableName, string $newTabl $sql = sprintf( 'ALTER TABLE %s RENAME TO %s', $this->quoteTableName($tableName), - $this->quoteColumnName($newTableName) + $this->quoteColumnName($newTableName), ); return new AlterInstructions([], [$sql]); @@ -434,7 +434,7 @@ public function truncateTable(string $tableName): void { $sql = sprintf( 'TRUNCATE TABLE %s RESTART IDENTITY', - $this->quoteTableName($tableName) + $this->quoteTableName($tableName), ); $this->execute($sql); @@ -457,7 +457,7 @@ public function getColumns(string $tableName): array ORDER BY ordinal_position', $this->useIdentity ? ', identity_generation' : '', $this->getConnection()->quote($parts['schema']), - $this->getConnection()->quote($parts['table']) + $this->getConnection()->quote($parts['table']), ); $columnsInfo = $this->fetchAll($sql); foreach ($columnsInfo as $columnInfo) { @@ -530,7 +530,7 @@ public function hasColumn(string $tableName, string $columnName): bool WHERE table_schema = %s AND table_name = %s AND column_name = %s', $this->getConnection()->quote($parts['schema']), $this->getConnection()->quote($parts['table']), - $this->getConnection()->quote($columnName) + $this->getConnection()->quote($columnName), ); $result = $this->fetchRow($sql); @@ -549,7 +549,7 @@ protected function getAddColumnInstructions(Table $table, Column $column): Alter $this->quoteColumnName($column->getName()), $this->getColumnSqlDefinition($column), $column->isIdentity() && $column->getGenerated() !== null && $this->useIdentity ? - sprintf('GENERATED %s AS IDENTITY', $column->getGenerated()) : '' + sprintf('GENERATED %s AS IDENTITY', $column->getGenerated()) : '', )); if ($column->getComment()) { @@ -567,7 +567,7 @@ protected function getAddColumnInstructions(Table $table, Column $column): Alter protected function getRenameColumnInstructions( string $tableName, string $columnName, - string $newColumnName + string $newColumnName, ): AlterInstructions { $parts = $this->getSchemaName($tableName); $sql = sprintf( @@ -576,7 +576,7 @@ protected function getRenameColumnInstructions( WHERE table_schema = %s AND table_name = %s AND column_name = %s', $this->getConnection()->quote($parts['schema']), $this->getConnection()->quote($parts['table']), - $this->getConnection()->quote($columnName) + $this->getConnection()->quote($columnName), ); $result = $this->fetchRow($sql); @@ -590,8 +590,8 @@ protected function getRenameColumnInstructions( 'ALTER TABLE %s RENAME COLUMN %s TO %s', $this->quoteTableName($tableName), $this->quoteColumnName($columnName), - $this->quoteColumnName($newColumnName) - ) + $this->quoteColumnName($newColumnName), + ), ); return $instructions; @@ -603,7 +603,7 @@ protected function getRenameColumnInstructions( protected function getChangeColumnInstructions( string $tableName, string $columnName, - Column $newColumn + Column $newColumn, ): AlterInstructions { $quotedColumnName = $this->quoteColumnName($columnName); $instructions = new AlterInstructions(); @@ -614,18 +614,18 @@ protected function getChangeColumnInstructions( $sql = sprintf( 'ALTER COLUMN %s TYPE %s', $quotedColumnName, - $this->getColumnSqlDefinition($newColumn) + $this->getColumnSqlDefinition($newColumn), ); if (in_array($newColumn->getType(), ['smallinteger', 'integer', 'biginteger'], true)) { $sql .= sprintf( ' USING (%s::bigint)', - $quotedColumnName + $quotedColumnName, ); } if ($newColumn->getType() === 'uuid') { $sql .= sprintf( ' USING (%s::uuid)', - $quotedColumnName + $quotedColumnName, ); } //NULL and DEFAULT cannot be set while changing column type @@ -637,7 +637,7 @@ protected function getChangeColumnInstructions( $sql .= sprintf( ' USING (CASE WHEN %s IS NULL THEN NULL WHEN %s::int=0 THEN FALSE ELSE TRUE END)', $quotedColumnName, - $quotedColumnName + $quotedColumnName, ); } $instructions->addAlter($sql); @@ -648,7 +648,7 @@ protected function getChangeColumnInstructions( // process identity $sql = sprintf( 'ALTER COLUMN %s', - $quotedColumnName + $quotedColumnName, ); if ($newColumn->isIdentity() && $newColumn->getGenerated() !== null) { if ($column->isIdentity()) { @@ -665,7 +665,7 @@ protected function getChangeColumnInstructions( // process null $sql = sprintf( 'ALTER COLUMN %s', - $quotedColumnName + $quotedColumnName, ); if (!$newColumn->getIdentity() && !$column->getIdentity() && $newColumn->isNull()) { @@ -680,13 +680,13 @@ protected function getChangeColumnInstructions( $instructions->addAlter(sprintf( 'ALTER COLUMN %s SET %s', $quotedColumnName, - $this->getDefaultValueDefinition($newColumn->getDefault(), $newColumn->getType()) + $this->getDefaultValueDefinition($newColumn->getDefault(), $newColumn->getType()), )); } elseif (!$newColumn->getIdentity()) { //drop default $instructions->addAlter(sprintf( 'ALTER COLUMN %s DROP DEFAULT', - $quotedColumnName + $quotedColumnName, )); } @@ -696,7 +696,7 @@ protected function getChangeColumnInstructions( 'ALTER TABLE %s RENAME COLUMN %s TO %s', $this->quoteTableName($tableName), $quotedColumnName, - $this->quoteColumnName($newColumn->getName()) + $this->quoteColumnName($newColumn->getName()), )); } @@ -732,7 +732,7 @@ protected function getDropColumnInstructions(string $tableName, string $columnNa { $alter = sprintf( 'DROP COLUMN %s', - $this->quoteColumnName($columnName) + $this->quoteColumnName($columnName), ); return new AlterInstructions([$alter]); @@ -772,7 +772,7 @@ protected function getIndexes(string $tableName): array t.relname, i.relname", $this->getConnection()->quote($parts['schema']), - $this->getConnection()->quote($parts['table']) + $this->getConnection()->quote($parts['table']), ); $rows = $this->fetchAll($sql); foreach ($rows as $row) { @@ -848,14 +848,14 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns if (empty($a)) { return new AlterInstructions([], [sprintf( 'DROP INDEX IF EXISTS %s', - '"' . ($parts['schema'] . '".' . $this->quoteColumnName($indexName)) + '"' . ($parts['schema'] . '".' . $this->quoteColumnName($indexName)), )]); } } throw new InvalidArgumentException(sprintf( "The specified index on columns '%s' does not exist", - implode(',', $columns) + implode(',', $columns), )); } @@ -868,7 +868,7 @@ protected function getDropIndexByNameInstructions(string $tableName, string $ind $sql = sprintf( 'DROP INDEX IF EXISTS %s', - '"' . ($parts['schema'] . '".' . $this->quoteColumnName($indexName)) + '"' . ($parts['schema'] . '".' . $this->quoteColumnName($indexName)), ); return new AlterInstructions([], [$sql]); @@ -913,7 +913,7 @@ public function getPrimaryKey(string $tableName): array AND tc.table_name = %s ORDER BY kcu.position_in_unique_constraint", $this->getConnection()->quote($parts['schema']), - $this->getConnection()->quote($parts['table']) + $this->getConnection()->quote($parts['table']), )); $primaryKey = [ @@ -977,7 +977,7 @@ protected function getForeignKeys(string $tableName): array WHERE constraint_type = 'FOREIGN KEY' AND tc.table_schema = %s AND tc.table_name = %s ORDER BY kcu.ordinal_position", $this->getConnection()->quote($parts['schema']), - $this->getConnection()->quote($parts['table']) + $this->getConnection()->quote($parts['table']), )); foreach ($rows as $row) { $foreignKeys[$row['constraint_name']]['table'] = $row['table_name']; @@ -1000,7 +1000,7 @@ protected function getAddForeignKeyInstructions(Table $table, ForeignKey $foreig { $alter = sprintf( 'ADD %s', - $this->getForeignKeySqlDefinition($foreignKey, $table->getName()) + $this->getForeignKeySqlDefinition($foreignKey, $table->getName()), ); return new AlterInstructions([$alter]); @@ -1013,7 +1013,7 @@ protected function getDropForeignKeyInstructions($tableName, $constraint): Alter { $alter = sprintf( 'DROP CONSTRAINT %s', - $this->quoteColumnName($constraint) + $this->quoteColumnName($constraint), ); return new AlterInstructions([$alter]); @@ -1037,13 +1037,13 @@ protected function getDropForeignKeyByColumnsInstructions(string $tableName, arr if (empty($matches)) { throw new InvalidArgumentException(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', $columns) + implode(', ', $columns), )); } foreach ($matches as $name) { $instructions->merge( - $this->getDropForeignKeyInstructions($tableName, $name) + $this->getDropForeignKeyInstructions($tableName, $name), ); } @@ -1186,7 +1186,7 @@ public function getPhinxType(string $sqlType): string return static::PHINX_TYPE_MACADDR; default: throw new UnsupportedColumnTypeException( - 'Column type `' . $sqlType . '` is not supported by Postgresql.' + 'Column type `' . $sqlType . '` is not supported by Postgresql.', ); } } @@ -1251,14 +1251,14 @@ protected function getColumnSqlDefinition(Column $column): string $buffer[] = sprintf( '(%s, %s)', $column->getPrecision() ?: $sqlType['precision'], - $column->getScale() ?: $sqlType['scale'] + $column->getScale() ?: $sqlType['scale'], ); } elseif ($sqlType['name'] === self::PHINX_TYPE_GEOMETRY) { // geography type must be written with geometry type and srid, like this: geography(POLYGON,4326) $buffer[] = sprintf( '(%s,%s)', strtoupper($sqlType['type']), - $column->getSrid() ?: $sqlType['srid'] + $column->getSrid() ?: $sqlType['srid'], ); } elseif (in_array($sqlType['name'], [self::PHINX_TYPE_TIME, self::PHINX_TYPE_TIMESTAMP], true)) { if (is_numeric($column->getPrecision())) { @@ -1312,7 +1312,7 @@ protected function getColumnCommentSqlDefinition(Column $column, string $tableNa 'COMMENT ON COLUMN %s.%s IS %s;', $this->quoteTableName($tableName), $this->quoteColumnName($column->getName()), - $comment + $comment, ); } @@ -1359,7 +1359,7 @@ protected function getIndexSqlDefinition(Index $index, string $tableName): strin $this->quoteColumnName($indexName), $this->quoteTableName($tableName), implode(',', $columnNames), - $includedColumns + $includedColumns, ); } @@ -1455,7 +1455,7 @@ public function hasSchema(string $schemaName): bool 'SELECT count(*) FROM pg_namespace WHERE nspname = %s', - $this->getConnection()->quote($schemaName) + $this->getConnection()->quote($schemaName), ); $result = $this->fetchRow($sql); @@ -1602,8 +1602,8 @@ public function setSearchPath(): void $this->execute( sprintf( 'SET search_path TO %s,"$user",public', - $this->quoteSchemaName($this->schema) - ) + $this->quoteSchemaName($this->schema), + ), ); } diff --git a/src/Phinx/Db/Adapter/ProxyAdapter.php b/src/Phinx/Db/Adapter/ProxyAdapter.php index a20bd27fb..04c3492b4 100644 --- a/src/Phinx/Db/Adapter/ProxyAdapter.php +++ b/src/Phinx/Db/Adapter/ProxyAdapter.php @@ -107,7 +107,7 @@ public function getInvertedCommands(): Intent default: throw new IrreversibleMigrationException(sprintf( 'Cannot reverse a "%s" command', - get_class($command) + get_class($command), )); } } diff --git a/src/Phinx/Db/Adapter/SQLiteAdapter.php b/src/Phinx/Db/Adapter/SQLiteAdapter.php index e25b7ab03..1c7c76561 100644 --- a/src/Phinx/Db/Adapter/SQLiteAdapter.php +++ b/src/Phinx/Db/Adapter/SQLiteAdapter.php @@ -512,7 +512,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A if (!empty($primaryKey)) { $instructions->merge( // FIXME: array access is a hack to make this incomplete implementation work with a correct getPrimaryKey implementation - $this->getDropPrimaryKeyInstructions($table, $primaryKey[0]) + $this->getDropPrimaryKeyInstructions($table, $primaryKey[0]), ); } @@ -521,12 +521,12 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A if (!is_string($newColumns)) { throw new InvalidArgumentException(sprintf( 'Invalid value for primary key: %s', - json_encode($newColumns) + json_encode($newColumns), )); } $instructions->merge( - $this->getAddPrimaryKeyInstructions($table, $newColumns) + $this->getAddPrimaryKeyInstructions($table, $newColumns), ); } @@ -554,7 +554,7 @@ protected function getRenameTableInstructions(string $tableName, string $newTabl $sql = sprintf( 'ALTER TABLE %s RENAME TO %s', $this->quoteTableName($tableName), - $this->quoteTableName($newTableName) + $this->quoteTableName($newTableName), ); return new AlterInstructions([], [$sql]); @@ -581,7 +581,7 @@ public function truncateTable(string $tableName): void $this->execute(sprintf( 'DELETE FROM %s.%s', $this->quoteColumnName($info['schema']), - $this->quoteColumnName($info['table']) + $this->quoteColumnName($info['table']), )); // assuming no error occurred, reset the autoincrement (if any) @@ -590,7 +590,7 @@ public function truncateTable(string $tableName): void 'DELETE FROM %s.%s where name = %s', $this->quoteColumnName($info['schema']), 'sqlite_sequence', - $this->quoteString($info['table']) + $this->quoteString($info['table']), )); } } @@ -777,15 +777,15 @@ protected function getAddColumnInstructions(Table $table, Column $column): Alter $sql = preg_replace( sprintf( "/(%s(?:\/\*.*?\*\/|\([^)]+\)|'[^']*?'|[^,])+)([,)])/", - $this->quoteColumnName($finalColumnName) + $this->quoteColumnName($finalColumnName), ), sprintf( '$1, %s %s$2', $this->quoteColumnName($column->getName()), - $this->getColumnSqlDefinition($column) + $this->getColumnSqlDefinition($column), ), $state['createSQL'], - 1 + 1, ); $this->execute($sql); @@ -887,8 +887,8 @@ protected function bufferIndicesAndTriggers(AlterInstructions $instructions, str AND tbl_name = %s AND sql IS NOT NULL ", - $this->quoteValue($tableName) - ) + $this->quoteValue($tableName), + ), ); $schema = $this->getSchemaName($tableName, true)['schema']; @@ -897,7 +897,7 @@ protected function bufferIndicesAndTriggers(AlterInstructions $instructions, str switch ($row['type']) { case 'index': $info = $this->fetchAll( - sprintf('PRAGMA %sindex_info(%s)', $schema, $this->quoteValue($row['name'])) + sprintf('PRAGMA %sindex_info(%s)', $schema, $this->quoteValue($row['name'])), ); $columns = array_map( @@ -908,7 +908,7 @@ function ($column) { return strtolower($column); }, - array_column($info, 'name') + array_column($info, 'name'), ); $hasExpressions = in_array(null, $columns, true); @@ -941,7 +941,7 @@ function ($column) { */ protected function filterIndicesForRemovedColumn( AlterInstructions $instructions, - string $columnName + string $columnName, ): AlterInstructions { $instructions->addPostStep(function (array $state) use ($columnName): array { foreach ($state['indices'] as $key => $index) { @@ -970,7 +970,7 @@ protected function filterIndicesForRemovedColumn( protected function updateIndicesForRenamedColumn( AlterInstructions $instructions, string $oldColumnName, - string $newColumnName + string $newColumnName, ): AlterInstructions { $instructions->addPostStep(function (array $state) use ($oldColumnName, $newColumnName): array { foreach ($state['indices'] as $key => $index) { @@ -995,7 +995,7 @@ protected function updateIndicesForRenamedColumn( $state['indices'][$key]['sql'] = preg_replace( sprintf($pattern, preg_quote($oldColumnName, '/')), "\\1\\2$newColumnName\\4\\5\\6", - $index['sql'] + $index['sql'], ); } } @@ -1048,7 +1048,7 @@ protected function validateForeignKeys(AlterInstructions $instructions, string $ $otherTables = $this ->query( "SELECT name FROM sqlite_master WHERE type = 'table' AND name != ?", - [$tableName] + [$tableName], ) ->fetchAll(); @@ -1068,7 +1068,7 @@ protected function validateForeignKeys(AlterInstructions $instructions, string $ $schema = $this->getSchemaName($tableToCheck, true)['schema']; $stmt = $this->query( - sprintf('PRAGMA %sforeign_key_check(%s)', $schema, $this->quoteTableName($tableToCheck)) + sprintf('PRAGMA %sforeign_key_check(%s)', $schema, $this->quoteTableName($tableToCheck)), ); $row = $stmt->fetch(); $stmt->closeCursor(); @@ -1076,7 +1076,7 @@ protected function validateForeignKeys(AlterInstructions $instructions, string $ if (is_array($row)) { throw new RuntimeException(sprintf( 'Integrity constraint violation: FOREIGN KEY constraint on `%s` failed.', - $tableToCheck + $tableToCheck, )); } } @@ -1103,7 +1103,7 @@ protected function copyDataToNewTable(string $tableName, string $tmpTableName, a $this->quoteTableName($tableName), implode(', ', $writeColumns), implode(', ', $selectColumns), - $this->quoteTableName($tmpTableName) + $this->quoteTableName($tmpTableName), ); $this->execute($sql); } @@ -1123,14 +1123,14 @@ protected function copyAndDropTmpTable(AlterInstructions $instructions, string $ $state['tmpTableName'], $tableName, $state['writeColumns'], - $state['selectColumns'] + $state['selectColumns'], ); $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tableName))); $this->execute(sprintf( 'ALTER TABLE %s RENAME TO %s', $this->quoteTableName($state['tmpTableName']), - $this->quoteTableName($tableName) + $this->quoteTableName($tableName), )); return $state; @@ -1179,7 +1179,7 @@ protected function calculateNewTableColumns(string $tableName, string|false $col if ($columnName && !$found) { throw new InvalidArgumentException(sprintf( - 'The specified column doesn\'t exist: ' . $columnName + 'The specified column doesn\'t exist: ' . $columnName, )); } @@ -1210,7 +1210,7 @@ protected function beginAlterByCopyTable(string $tableName): AlterInstructions $createSQL = preg_replace( "/^CREATE TABLE .* \(/Ui", '', - $createSQL + $createSQL, ); $createSQL = "CREATE TABLE {$this->quoteTableName($tmpTableName)} ({$createSQL}"; @@ -1239,7 +1239,7 @@ protected function endAlterByCopyTable( string $tableName, ?string $renamedOrRemovedColumnName = null, ?string $newColumnName = null, - bool $validateForeignKeys = true + bool $validateForeignKeys = true, ): AlterInstructions { $instructions = $this->bufferIndicesAndTriggers($instructions, $tableName); @@ -1285,7 +1285,7 @@ protected function getRenameColumnInstructions(string $tableName, string $column $sql = str_replace( $this->quoteColumnName($columnName), $this->quoteColumnName($newColumnName), - $state['createSQL'] + $state['createSQL'], ); $this->execute($sql); @@ -1314,7 +1314,7 @@ protected function getChangeColumnInstructions(string $tableName, string $column sprintf("/%s(?:\/\*.*?\*\/|\([^)]+\)|'[^']*?'|[^,])+([,)])/", $this->quoteColumnName($columnName)), sprintf('%s %s$1', $this->quoteColumnName($newColumn->getName()), $this->getColumnSqlDefinition($newColumn)), $state['createSQL'], - 1 + 1, ); $this->execute($sql); @@ -1347,7 +1347,7 @@ protected function getDropColumnInstructions(string $tableName, string $columnNa $sql = preg_replace( sprintf("/%s\s%s.*(,\s(?!')|\)$)/U", preg_quote($this->quoteColumnName($columnName)), preg_quote($state['columnType'])), '', - $state['createSQL'] + $state['createSQL'], ); if (substr($sql, -2) === ', ') { @@ -1448,7 +1448,7 @@ protected function getAddIndexInstructions(Table $table, Index $index): AlterIns 'CREATE %s ON %s (%s)', $this->getIndexSqlDefinition($table, $index), $this->quoteTableName($table->getName()), - $indexColumns + $indexColumns, ); return new AlterInstructions([], [$sql]); @@ -1467,7 +1467,7 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns $instructions->addPostStep(sprintf( 'DROP INDEX %s%s', $schema, - $this->quoteColumnName($indexName) + $this->quoteColumnName($indexName), )); } } @@ -1497,7 +1497,7 @@ protected function getDropIndexByNameInstructions(string $tableName, string $ind $instructions->addPostStep(sprintf( 'DROP INDEX %s%s', $schema, - $this->quoteColumnName($indexName) + $this->quoteColumnName($indexName), )); } @@ -1554,7 +1554,7 @@ public function hasForeignKey(string $tableName, $columns, ?string $constraint = if ($constraint !== null) { return preg_match( "/,?\s*CONSTRAINT\s*" . $this->possiblyQuotedIdentifierRegex($constraint) . '\s*FOREIGN\s+KEY/is', - $this->getDeclaringSql($tableName) + $this->getDeclaringSql($tableName), ) === 1; } @@ -1685,13 +1685,13 @@ protected function getAddForeignKeyInstructions(Table $table, ForeignKey $foreig $sql .= sprintf( 'DROP INDEX %s%s; ', $schema, - $this->quoteColumnName($indexName) + $this->quoteColumnName($indexName), ); $createIndexSQL = $this->getDeclaringIndexSQL($tableName, $indexName); $sql .= preg_replace( "/\b{$tableName}\b/", $tmpTableName, - $createIndexSQL + $createIndexSQL, ); } } @@ -1734,7 +1734,7 @@ protected function getDropForeignKeyByColumnsInstructions(string $tableName, arr if (!$this->hasForeignKey($tableName, $columns)) { throw new InvalidArgumentException(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', $columns) + implode(', ', $columns), )); } @@ -1746,9 +1746,9 @@ protected function getDropForeignKeyByColumnsInstructions(string $tableName, arr implode( '\s*,\s*', array_map( - fn ($column) => $this->possiblyQuotedIdentifierRegex($column, false), - $columns - ) + fn($column) => $this->possiblyQuotedIdentifierRegex($column, false), + $columns, + ), ), ); $sql = preg_replace($search, '', $state['createSQL']); diff --git a/src/Phinx/Db/Adapter/SqlServerAdapter.php b/src/Phinx/Db/Adapter/SqlServerAdapter.php index 8ac894398..37b4bfd5e 100644 --- a/src/Phinx/Db/Adapter/SqlServerAdapter.php +++ b/src/Phinx/Db/Adapter/SqlServerAdapter.php @@ -151,7 +151,7 @@ protected function connectDblib(): void } catch (PDOException $exception) { throw new InvalidArgumentException(sprintf( 'There was a problem connecting to the database: %s', - $exception->getMessage() + $exception->getMessage(), ), 0, $exception); } @@ -313,7 +313,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A if (!empty($primaryKey['constraint'])) { $sql = sprintf( 'DROP CONSTRAINT %s', - $this->quoteColumnName($primaryKey['constraint']) + $this->quoteColumnName($primaryKey['constraint']), ); $instructions->addAlter($sql); } @@ -323,7 +323,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A $sql = sprintf( 'ALTER TABLE %s ADD CONSTRAINT %s PRIMARY KEY (', $this->quoteTableName($table->getName()), - $this->quoteColumnName('PK_' . $table->getName()) + $this->quoteColumnName('PK_' . $table->getName()), ); if (is_string($newColumns)) { // handle primary_key => 'id' $sql .= $this->quoteColumnName($newColumns); @@ -332,7 +332,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A } else { throw new InvalidArgumentException(sprintf( 'Invalid value for primary key: %s', - json_encode($newColumns) + json_encode($newColumns), )); } $sql .= ')'; @@ -374,7 +374,7 @@ protected function getColumnCommentSqlDefinition(Column $column, string $tableNa $comment, $this->schema, $tableName, - $column->getName() + $column->getName(), ); } @@ -387,7 +387,7 @@ protected function getRenameTableInstructions(string $tableName, string $newTabl $sql = sprintf( "EXEC sp_rename '%s', '%s'", $tableName, - $newTableName + $newTableName, ); return new AlterInstructions([], [$sql]); @@ -411,7 +411,7 @@ public function truncateTable(string $tableName): void { $sql = sprintf( 'TRUNCATE TABLE %s', - $this->quoteTableName($tableName) + $this->quoteTableName($tableName), ); $this->execute($sql); @@ -460,7 +460,7 @@ public function getColumns(string $tableName): array FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '%s' ORDER BY ordinal_position", - $tableName + $tableName, ); $rows = $this->fetchAll($sql); foreach ($rows as $columnInfo) { @@ -522,7 +522,7 @@ public function hasColumn(string $tableName, string $columnName): bool FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '%s' AND COLUMN_NAME = '%s'", $tableName, - $columnName + $columnName, ); /** @var array $result */ $result = $this->fetchRow($sql); @@ -539,7 +539,7 @@ protected function getAddColumnInstructions(Table $table, Column $column): Alter 'ALTER TABLE %s ADD %s %s', $table->getName(), $this->quoteColumnName($column->getName()), - $this->getColumnSqlDefinition($column) + $this->getColumnSqlDefinition($column), ); return new AlterInstructions([], [$alter]); @@ -569,14 +569,14 @@ protected function getRenameColumnInstructions(string $tableName, string $column $instructions->addPostStep(sprintf( $sql, $oldConstraintName, - $newConstraintName + $newConstraintName, )); $instructions->addPostStep(sprintf( "EXECUTE sp_rename N'%s.%s', N'%s', 'COLUMN' ", $tableName, $columnName, - $newColumnName + $newColumnName, )); return $instructions; @@ -610,7 +610,7 @@ protected function getChangeDefault(string $tableName, Column $newColumn): Alter $this->quoteTableName($tableName), $constraintName, $default, - $this->quoteColumnName($newColumn->getName()) + $this->quoteColumnName($newColumn->getName()), )); return $instructions; @@ -630,7 +630,7 @@ protected function getChangeColumnInstructions(string $tableName, string $column if ($columnName !== $newColumn->getName()) { $instructions->merge( - $this->getRenameColumnInstructions($tableName, $columnName, $newColumn->getName()) + $this->getRenameColumnInstructions($tableName, $columnName, $newColumn->getName()), ); } @@ -642,7 +642,7 @@ protected function getChangeColumnInstructions(string $tableName, string $column 'ALTER TABLE %s ALTER COLUMN %s %s', $this->quoteTableName($tableName), $this->quoteColumnName($newColumn->getName()), - $this->getColumnSqlDefinition($newColumn, false) + $this->getColumnSqlDefinition($newColumn, false), )); // change column comment if needed if ($newColumn->getComment()) { @@ -666,7 +666,7 @@ protected function getDropColumnInstructions(string $tableName, string $columnNa $instructions->addPostStep(sprintf( 'ALTER TABLE %s DROP COLUMN %s', $this->quoteTableName($tableName), - $this->quoteColumnName($columnName) + $this->quoteColumnName($columnName), )); return $instructions; @@ -838,7 +838,7 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns $instructions->addPostStep(sprintf( 'DROP INDEX %s ON %s', $this->quoteColumnName($indexName), - $this->quoteTableName($tableName) + $this->quoteTableName($tableName), )); return $instructions; @@ -847,7 +847,7 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns throw new InvalidArgumentException(sprintf( "The specified index on columns '%s' does not exist", - implode(',', $columns) + implode(',', $columns), )); } @@ -866,7 +866,7 @@ protected function getDropIndexByNameInstructions(string $tableName, string $ind $instructions->addPostStep(sprintf( 'DROP INDEX %s ON %s', $this->quoteColumnName($indexName), - $this->quoteTableName($tableName) + $this->quoteTableName($tableName), )); return $instructions; @@ -875,7 +875,7 @@ protected function getDropIndexByNameInstructions(string $tableName, string $ind throw new InvalidArgumentException(sprintf( "The specified index name '%s' does not exist", - $indexName + $indexName, )); } @@ -915,7 +915,7 @@ public function getPrimaryKey(string $tableName): array WHERE CONSTRAINT_TYPE = 'PRIMARY KEY' AND tc.TABLE_NAME = '%s' ORDER BY kcu.ORDINAL_POSITION", - $tableName + $tableName, )); $primaryKey = [ @@ -977,7 +977,7 @@ protected function getForeignKeys(string $tableName): array JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS ccu ON ccu.CONSTRAINT_NAME = tc.CONSTRAINT_NAME WHERE CONSTRAINT_TYPE = 'FOREIGN KEY' AND tc.TABLE_NAME = '%s' ORDER BY kcu.ORDINAL_POSITION", - $tableName + $tableName, )); foreach ($rows as $row) { $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME']; @@ -1002,7 +1002,7 @@ protected function getAddForeignKeyInstructions(Table $table, ForeignKey $foreig $instructions->addPostStep(sprintf( 'ALTER TABLE %s ADD %s', $this->quoteTableName($table->getName()), - $this->getForeignKeySqlDefinition($foreignKey, $table->getName()) + $this->getForeignKeySqlDefinition($foreignKey, $table->getName()), )); return $instructions; @@ -1017,7 +1017,7 @@ protected function getDropForeignKeyInstructions(string $tableName, string $cons $instructions->addPostStep(sprintf( 'ALTER TABLE %s DROP CONSTRAINT %s', $this->quoteTableName($tableName), - $this->quoteColumnName($constraint) + $this->quoteColumnName($constraint), )); return $instructions; @@ -1041,13 +1041,13 @@ protected function getDropForeignKeyByColumnsInstructions(string $tableName, arr if (empty($matches)) { throw new InvalidArgumentException(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', $columns) + implode(', ', $columns), )); } foreach ($matches as $name) { $instructions->merge( - $this->getDropForeignKeyInstructions($tableName, $name) + $this->getDropForeignKeyInstructions($tableName, $name), ); } @@ -1192,8 +1192,8 @@ public function hasDatabase(string $name): bool $result = $this->fetchRow( sprintf( "SELECT count(*) as [count] FROM master.dbo.sysdatabases WHERE [name] = '%s'", - $name - ) + $name, + ), ); return $result['count'] > 0; @@ -1241,7 +1241,7 @@ protected function getColumnSqlDefinition(Column $column, bool $create = true): $buffer[] = sprintf( '(%s, %s)', $column->getPrecision() ?: $sqlType['precision'], - $column->getScale() ?: $sqlType['scale'] + $column->getScale() ?: $sqlType['scale'], ); } elseif (!in_array($sqlType['name'], $noLimits) && ($column->getLimit() || isset($sqlType['limit']))) { $buffer[] = sprintf('(%s)', $column->getLimit() ?: $sqlType['limit']); @@ -1304,7 +1304,7 @@ protected function getIndexSqlDefinition(Index $index, string $tableName): strin $indexName, $this->quoteTableName($tableName), implode(',', $columnNames), - $includedColumns + $includedColumns, ); } diff --git a/src/Phinx/Db/Adapter/TablePrefixAdapter.php b/src/Phinx/Db/Adapter/TablePrefixAdapter.php index cce2d5109..afa896003 100644 --- a/src/Phinx/Db/Adapter/TablePrefixAdapter.php +++ b/src/Phinx/Db/Adapter/TablePrefixAdapter.php @@ -59,7 +59,7 @@ public function createTable(Table $table, array $columns = [], array $indexes = { $adapterTable = new Table( $this->getAdapterTableName($table->getName()), - $table->getOptions() + $table->getOptions(), ); parent::createTable($adapterTable, $columns, $indexes); } @@ -79,7 +79,7 @@ public function changePrimaryKey(Table $table, $newColumns): void $adapterTable = new Table( $this->getAdapterTableName($table->getName()), - $table->getOptions() + $table->getOptions(), ); $adapter->changePrimaryKey($adapterTable, $newColumns); } @@ -99,7 +99,7 @@ public function changeComment(Table $table, ?string $newComment): void $adapterTable = new Table( $this->getAdapterTableName($table->getName()), - $table->getOptions() + $table->getOptions(), ); $adapter->changeComment($adapterTable, $newComment); } @@ -483,7 +483,7 @@ public function executeActions(Table $table, array $actions): void default: throw new InvalidArgumentException( - sprintf("Forgot to implement table prefixing for action: '%s'", get_class($action)) + sprintf("Forgot to implement table prefixing for action: '%s'", get_class($action)), ); } } diff --git a/src/Phinx/Db/Adapter/TimedOutputAdapter.php b/src/Phinx/Db/Adapter/TimedOutputAdapter.php index 4fcecbe98..cac673759 100644 --- a/src/Phinx/Db/Adapter/TimedOutputAdapter.php +++ b/src/Phinx/Db/Adapter/TimedOutputAdapter.php @@ -66,7 +66,7 @@ public function writeCommand(string $command, array $args = []): void function ($value) { return '\'' . $value . '\''; }, - $arg + $arg, ); $outArr[] = '[' . implode(', ', $arg) . ']'; continue; @@ -217,7 +217,7 @@ public function addColumn(Table $table, Column $column): void $table->getName(), $column->getName(), $column->getType(), - ] + ], ); $adapter->addColumn($table, $column); $end(); diff --git a/src/Phinx/Db/Plan/Plan.php b/src/Phinx/Db/Plan/Plan.php index 2ee4b74e8..d95221428 100644 --- a/src/Phinx/Db/Plan/Plan.php +++ b/src/Phinx/Db/Plan/Plan.php @@ -199,7 +199,7 @@ protected function resolveConflicts(): void ChangeColumn::class, function (RenameColumn $a, ChangeColumn $b) { return $a->getNewName() === $b->getColumnName(); - } + }, ); $tableUpdates = []; foreach ($this->tableUpdates as $update) { @@ -219,13 +219,13 @@ function (RenameColumn $a, ChangeColumn $b) { AddForeignKey::class, function (DropForeignKey $a, AddForeignKey $b) { return $a->getForeignKey()->getColumns() === $b->getForeignKey()->getColumns(); - } + }, ); $constraints = []; foreach ($this->constraints as $constraint) { $constraints = array_merge( $constraints, - $splitter($this->remapContraintAndIndexConflicts($constraint)) + $splitter($this->remapContraintAndIndexConflicts($constraint)), ); } $this->constraints = $constraints; @@ -271,7 +271,7 @@ protected function remapContraintAndIndexConflicts(AlterTable $alter): AlterTabl [$this->indexes, $dropIndexActions] = $this->forgetDropIndex( $action->getTable(), $action->getForeignKey()->getColumns(), - $this->indexes + $this->indexes, ); foreach ($dropIndexActions as $dropIndexAction) { $newAlter->addAction($dropIndexAction); diff --git a/src/Phinx/Db/Table.php b/src/Phinx/Db/Table.php index 2137acb37..d0e483390 100644 --- a/src/Phinx/Db/Table.php +++ b/src/Phinx/Db/Table.php @@ -235,7 +235,7 @@ public function getColumn(string $name): ?Column $this->getColumns(), function ($column) use ($name) { return $column->getName() === $name; - } + }, ); return array_pop($columns); @@ -315,7 +315,7 @@ public function addColumn(string|Column $columnName, string|Literal|null $type = throw new InvalidArgumentException(sprintf( 'An invalid column type "%s" was specified for column "%s".', $action->getColumn()->getType(), - $action->getColumn()->getName() + $action->getColumn()->getName(), )); } @@ -492,7 +492,7 @@ public function addForeignKeyWithName(string $name, string|array $columns, strin $referencedTable, $referencedColumns, $options, - $name + $name, ); $this->actions->addAction($action); diff --git a/src/Phinx/Migration/AbstractMigration.php b/src/Phinx/Migration/AbstractMigration.php index 050480f59..738303163 100644 --- a/src/Phinx/Migration/AbstractMigration.php +++ b/src/Phinx/Migration/AbstractMigration.php @@ -340,7 +340,7 @@ public function preFlightCheck(): void method_exists($this, MigrationInterface::DOWN) ) { $this->output->writeln(sprintf( - 'warning Migration contains both change() and up()/down() methods. Ignoring up() and down().' + 'warning Migration contains both change() and up()/down() methods. Ignoring up() and down().', )); } } diff --git a/src/Phinx/Migration/Manager.php b/src/Phinx/Migration/Manager.php index 9c1f2a282..6d0b35b58 100644 --- a/src/Phinx/Migration/Manager.php +++ b/src/Phinx/Migration/Manager.php @@ -202,9 +202,9 @@ public function printStatus(string $environment, ?string $format = null): array $migration->getVersion(), ($version ? $version['start_time'] : ''), ($version ? $version['end_time'] : ''), - $migration->getName() + $migration->getName(), ), - $this->verbosityLevel + $this->verbosityLevel, ); if ($version && $version['breakpoint']) { @@ -240,7 +240,7 @@ public function printStatus(string $environment, ?string $format = null): array 'missing_count' => $missingCount, 'total_count' => $migrationCount + $missingCount, 'migrations' => $finalMigrations, - ] + ], )); break; default: @@ -268,7 +268,7 @@ protected function printMissingVersion(array $version, int $maxNameLength): void $version['version'], $version['start_time'], $version['end_time'], - str_pad($version['migration_name'] ?? '', $maxNameLength, ' ') + str_pad($version['migration_name'] ?? '', $maxNameLength, ' '), )); if ($version && $version['breakpoint']) { @@ -326,7 +326,7 @@ public function migrate(string $environment, ?int $version = null, bool $fake = if ($version != 0 && !isset($migrations[$version])) { $this->output->writeln(sprintf( 'warning %s is not a valid version', - $version + $version, )); return; @@ -392,7 +392,7 @@ public function executeMigration(string $name, MigrationInterface $migration, st $this->printMigrationStatus( $migration, ($direction === MigrationInterface::UP ? 'migrated' : 'reverted'), - sprintf('%.4fs', $end - $start) + sprintf('%.4fs', $end - $start), ); } @@ -424,7 +424,7 @@ public function executeSeed(string $name, SeedInterface $seed): void $this->printSeedStatus( $seed, 'seeded', - sprintf('%.4fs', $end - $start) + sprintf('%.4fs', $end - $start), ); } @@ -441,7 +441,7 @@ protected function printMigrationStatus(MigrationInterface $migration, string $s $this->printStatusOutput( $migration->getVersion() . ' ' . $migration->getName(), $status, - $duration + $duration, ); } @@ -458,7 +458,7 @@ protected function printSeedStatus(SeedInterface $seed, string $status, ?string $this->printStatusOutput( $seed->getName(), $status, - $duration + $duration, ); } @@ -476,7 +476,7 @@ protected function printStatusOutput(string $name, string $status, ?string $dura ' ==' . ' ' . $name . ':' . ' ' . $status . ' ' . $duration . '', - $this->verbosityLevel + $this->verbosityLevel, ); } @@ -653,7 +653,7 @@ public function getEnvironment(string $name): Environment if (!$this->getConfig()->hasEnvironment($name)) { throw new InvalidArgumentException(sprintf( 'The environment "%s" does not exist', - $name + $name, )); } @@ -762,8 +762,8 @@ public function getMigrations(string $environment): array function ($phpFile) { return " {$phpFile}"; }, - $phpFiles - ) + $phpFiles, + ), ); } @@ -794,7 +794,7 @@ function ($phpFile) { throw new InvalidArgumentException(sprintf( 'Migration "%s" has the same name as "%s"', basename($filePath), - $fileNames[$class] + $fileNames[$class], )); } @@ -814,7 +814,7 @@ function ($phpFile) { throw new InvalidArgumentException(sprintf( 'Could not find class "%s" in file "%s"', $class, - $filePath + $filePath, )); } @@ -829,7 +829,7 @@ function ($phpFile) { throw new InvalidArgumentException(sprintf( 'The class "%s" in file "%s" must extend \Phinx\Migration\AbstractMigration', $class, - $filePath + $filePath, )); } @@ -947,7 +947,7 @@ public function getSeeds(string $environment): array throw new InvalidArgumentException(sprintf( 'Could not find class "%s" in file "%s"', $class, - $filePath + $filePath, )); } @@ -972,7 +972,7 @@ public function getSeeds(string $environment): array throw new InvalidArgumentException(sprintf( 'The class "%s" in file "%s" must extend \Phinx\Seed\AbstractSeed', $class, - $filePath + $filePath, )); } @@ -1060,7 +1060,7 @@ protected function markBreakpoint(string $environment, ?int $version, int $mark) if ($version != 0 && (!isset($versions[$version]) || !isset($migrations[$version]))) { $this->output->writeln(sprintf( 'warning %s is not a valid version', - $version + $version, )); return; @@ -1087,7 +1087,7 @@ protected function markBreakpoint(string $environment, ?int $version, int $mark) $this->getOutput()->writeln( ' Breakpoint ' . ($versions[$version]['breakpoint'] ? 'set' : 'cleared') . ' for ' . $version . '' . - ' ' . $migrations[$version]->getName() . '' + ' ' . $migrations[$version]->getName() . '', ); } @@ -1101,7 +1101,7 @@ public function removeBreakpoints(string $environment): void { $this->getOutput()->writeln(sprintf( ' %d breakpoints cleared.', - $this->getEnvironment($environment)->getAdapter()->resetAllBreakpoints() + $this->getEnvironment($environment)->getAdapter()->resetAllBreakpoints(), )); } diff --git a/tests/Phinx/Config/ConfigReplaceTokensTest.php b/tests/Phinx/Config/ConfigReplaceTokensTest.php index f37def297..f606ca84f 100644 --- a/tests/Phinx/Config/ConfigReplaceTokensTest.php +++ b/tests/Phinx/Config/ConfigReplaceTokensTest.php @@ -58,15 +58,15 @@ public function testReplaceTokens() $this->assertStringContainsString( static::$server['PHINX_TEST_VAR_1'] . '', // force convert to string - $config->offsetGet('some-var-1') + $config->offsetGet('some-var-1'), ); $this->assertStringNotContainsString( static::$server['NON_PHINX_TEST_VAR_1'] . '', // force convert to string - $config->offsetGet('some-var-2') + $config->offsetGet('some-var-2'), ); $this->assertStringContainsString( static::$server['PHINX_TEST_VAR_2'] . '', // force convert to string - $config->offsetGet('some-var-3') + $config->offsetGet('some-var-3'), ); } @@ -89,15 +89,15 @@ public function testReplaceTokensRecursive() $this->assertStringContainsString( static::$server['PHINX_TEST_VAR_1'] . '', // force convert to string - $folding['some-var-1'] + $folding['some-var-1'], ); $this->assertStringNotContainsString( static::$server['NON_PHINX_TEST_VAR_1'] . '', // force convert to string - $folding['some-var-2'] + $folding['some-var-2'], ); $this->assertStringContainsString( static::$server['PHINX_TEST_VAR_2'] . '', // force convert to string - $folding['some-var-3'] + $folding['some-var-3'], ); } } diff --git a/tests/Phinx/Config/ConfigTest.php b/tests/Phinx/Config/ConfigTest.php index aea8dec59..a189d74f3 100644 --- a/tests/Phinx/Config/ConfigTest.php +++ b/tests/Phinx/Config/ConfigTest.php @@ -361,7 +361,7 @@ public function testConfigReplacesEnvironmentTokens() $this->assertSame( ['adapter' => 'sqlite', 'name' => 'phinx_testing', 'suffix' => 'sqlite3'], - $config->getEnvironment('production') + $config->getEnvironment('production'), ); } finally { unset($_SERVER['PHINX_TEST_CONFIG_ADAPTER']); @@ -383,7 +383,7 @@ public function testSqliteMemorySetsName() ]); $this->assertSame( ['adapter' => 'sqlite', 'memory' => true, 'name' => ':memory:'], - $config->getEnvironment('production') + $config->getEnvironment('production'), ); } @@ -400,7 +400,7 @@ public function testSqliteMemoryOverridesName() ]); $this->assertSame( ['adapter' => 'sqlite', 'memory' => true, 'name' => ':memory:'], - $config->getEnvironment('production') + $config->getEnvironment('production'), ); } @@ -416,7 +416,7 @@ public function testSqliteNonBooleanMemory() ]); $this->assertSame( ['adapter' => 'sqlite', 'memory' => 'yes', 'name' => ':memory:'], - $config->getEnvironment('production') + $config->getEnvironment('production'), ); } diff --git a/tests/Phinx/Console/Command/BreakpointTest.php b/tests/Phinx/Console/Command/BreakpointTest.php index e1e657ced..7bb3a8bbb 100644 --- a/tests/Phinx/Console/Command/BreakpointTest.php +++ b/tests/Phinx/Console/Command/BreakpointTest.php @@ -58,7 +58,7 @@ protected function setUp(): void 'port' => 3006, ], ], - ] + ], ); foreach ($this->config->getMigrationPaths() as $path) { @@ -185,7 +185,7 @@ public function testRemoveAllAndTargetThrowsException() '--remove-all' => true, '--target' => '123456', ], - ['decorated' => false] + ['decorated' => false], ); $this->assertSame(AbstractCommand::CODE_ERROR, $exitCode); } diff --git a/tests/Phinx/Console/Command/CreateTest.php b/tests/Phinx/Console/Command/CreateTest.php index f7cfdce9a..f654d2b33 100644 --- a/tests/Phinx/Console/Command/CreateTest.php +++ b/tests/Phinx/Console/Command/CreateTest.php @@ -60,7 +60,7 @@ protected function setUp(): void 'port' => 3006, ], ], - ] + ], ); foreach ($this->config->getMigrationPaths() as $path) { @@ -582,7 +582,7 @@ public function testCreateMigrationWithExistingTimestamp(): void $commandTester->execute(['command' => $command->getName(), 'name' => 'Foo']); $commandTester->execute(['command' => $command->getName(), 'name' => 'Bar']); - $files = array_map(fn ($file) => basename($file), Util::getFiles($this->config->getMigrationPaths())); + $files = array_map(fn($file) => basename($file), Util::getFiles($this->config->getMigrationPaths())); sort($files); $timestamp = explode('_', $files[0])[0]; $secondTimestamp = (float)$timestamp + (str_ends_with($timestamp, '59') ? 41 : 1); diff --git a/tests/Phinx/Console/Command/InitTest.php b/tests/Phinx/Console/Command/InitTest.php index 968fdee8a..c7cc0134b 100644 --- a/tests/Phinx/Console/Command/InitTest.php +++ b/tests/Phinx/Console/Command/InitTest.php @@ -44,12 +44,12 @@ protected function writeConfig($configName = '') $this->assertStringContainsString( "created $fullPath", - $commandTester->getDisplay() + $commandTester->getDisplay(), ); $this->assertFileExists( $fullPath, - 'Phinx configuration not existent' + 'Phinx configuration not existent', ); } @@ -99,12 +99,12 @@ public function testDefaults() $this->assertEquals(AbstractCommand::CODE_SUCCESS, $exitCode); $this->assertMatchesRegularExpression( "/created (.*)[\/\\\\]phinx\.php\\n/", - $commandTester->getDisplay(true) + $commandTester->getDisplay(true), ); $this->assertFileExists( 'phinx.php', - 'Phinx configuration not existent' + 'Phinx configuration not existent', ); } finally { chdir($current_dir); @@ -128,12 +128,12 @@ public function testYamlFormat() $this->assertEquals(AbstractCommand::CODE_SUCCESS, $exitCode); $this->assertMatchesRegularExpression( "/created (.*)[\/\\\\]phinx.yaml\\n/", - $commandTester->getDisplay(true) + $commandTester->getDisplay(true), ); $this->assertFileExists( 'phinx.yaml', - 'Phinx configuration not existent' + 'Phinx configuration not existent', ); } finally { chdir($current_dir); diff --git a/tests/Phinx/Console/Command/ListAliasesTest.php b/tests/Phinx/Console/Command/ListAliasesTest.php index 27e0b346c..126658ebc 100644 --- a/tests/Phinx/Console/Command/ListAliasesTest.php +++ b/tests/Phinx/Console/Command/ListAliasesTest.php @@ -36,7 +36,7 @@ public function testListingAliases($file, $hasAliases) 'command' => $command->getName(), '--configuration' => realpath(sprintf('%s/../../Config/_files/%s', __DIR__, $file)), ], - ['decorated' => false] + ['decorated' => false], ); $this->assertSame(AbstractCommand::CODE_SUCCESS, $exitCode); diff --git a/tests/Phinx/Console/Command/MigrateTest.php b/tests/Phinx/Console/Command/MigrateTest.php index 7ba4892b5..51dbe33f2 100644 --- a/tests/Phinx/Console/Command/MigrateTest.php +++ b/tests/Phinx/Console/Command/MigrateTest.php @@ -325,7 +325,7 @@ public function testExecuteWithDate(): void $commandTester = new CommandTester($command); $exitCode = $commandTester->execute( ['command' => $command->getName(), '--environment' => 'development', '--date' => 'yesterday'], - ['decorated' => false] + ['decorated' => false], ); $this->assertStringContainsString('using environment development', $commandTester->getDisplay()); @@ -357,7 +357,7 @@ public function testExecuteWithError(): void $commandTester = new CommandTester($command); $exitCode = $commandTester->execute( ['command' => $command->getName(), '--environment' => 'development'], - ['decorated' => false, 'capture_stderr_separately' => true] + ['decorated' => false, 'capture_stderr_separately' => true], ); $this->assertStringContainsString('using environment development', $commandTester->getDisplay()); diff --git a/tests/Phinx/Console/Command/SeedRunTest.php b/tests/Phinx/Console/Command/SeedRunTest.php index 9a6daa479..17ede581a 100644 --- a/tests/Phinx/Console/Command/SeedRunTest.php +++ b/tests/Phinx/Console/Command/SeedRunTest.php @@ -213,7 +213,7 @@ public function testExecuteMultipleSeeders() ->method('seed')->withConsecutive( [$this->identicalTo('development'), $this->identicalTo('One')], [$this->identicalTo('development'), $this->identicalTo('Two')], - [$this->identicalTo('development'), $this->identicalTo('Three')] + [$this->identicalTo('development'), $this->identicalTo('Three')], ); $command->setConfig($this->config); @@ -225,7 +225,7 @@ public function testExecuteMultipleSeeders() 'command' => $command->getName(), '--seed' => ['One', 'Two', 'Three'], ], - ['decorated' => false] + ['decorated' => false], ); $this->assertSame(AbstractCommand::CODE_SUCCESS, $exitCode); @@ -273,7 +273,7 @@ public function testSeedRunMemorySqlite() 'command' => $command->getName(), '--environment' => 'development', ], - ['decorated' => false] + ['decorated' => false], ); $this->assertStringContainsString(implode(PHP_EOL, [ diff --git a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php index acb5fb355..95fba2e77 100644 --- a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php +++ b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php @@ -90,7 +90,7 @@ public function testConnectionWithInvalidCredentials() $this->assertInstanceOf( 'InvalidArgumentException', $e, - 'Expected exception of type InvalidArgumentException, got ' . get_class($e) + 'Expected exception of type InvalidArgumentException, got ' . get_class($e), ); $this->assertStringContainsString('There was a problem connecting to the database', $e->getMessage()); } @@ -184,7 +184,7 @@ public function testCreateTableWithComment() $rows = $this->adapter->fetchAll(sprintf( "SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='ntable'", - MYSQL_DB_CONFIG['name'] + MYSQL_DB_CONFIG['name'], )); $comment = $rows[0]; @@ -212,7 +212,7 @@ public function testCreateTableWithForeignKeys() "SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA='%s' AND REFERENCED_TABLE_NAME='ntable_tag'", - MYSQL_DB_CONFIG['name'] + MYSQL_DB_CONFIG['name'], )); $foreignKey = $rows[0]; @@ -644,8 +644,8 @@ public function testAddComment() WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='%s'", MYSQL_DB_CONFIG['name'], - 'table1' - ) + 'table1', + ), ); $this->assertEquals('comment1', $rows[0]['TABLE_COMMENT']); } @@ -666,8 +666,8 @@ public function testChangeComment() WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='%s'", MYSQL_DB_CONFIG['name'], - 'table1' - ) + 'table1', + ), ); $this->assertEquals('comment2', $rows[0]['TABLE_COMMENT']); } @@ -688,8 +688,8 @@ public function testDropComment() WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='%s'", MYSQL_DB_CONFIG['name'], - 'table1' - ) + 'table1', + ), ); $this->assertEquals('', $rows[0]['TABLE_COMMENT']); } @@ -1015,7 +1015,7 @@ public function testRenamingANonExistentColumn() $this->assertInstanceOf( 'InvalidArgumentException', $e, - 'Expected exception of type InvalidArgumentException, got ' . get_class($e) + 'Expected exception of type InvalidArgumentException, got ' . get_class($e), ); $this->assertEquals('The specified column doesn\'t exist: column2', $e->getMessage()); } @@ -1548,7 +1548,7 @@ public function testAddIndexWithLimit() $this->assertTrue($table->hasIndex('email')); $index_data = $this->adapter->query(sprintf( 'SELECT SUB_PART FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = "%s" AND TABLE_NAME = "table1" AND INDEX_NAME = "email"', - MYSQL_DB_CONFIG['name'] + MYSQL_DB_CONFIG['name'], ))->fetch(PDO::FETCH_ASSOC); $expected_limit = $index_data['SUB_PART']; $this->assertEquals($expected_limit, 50); @@ -1566,13 +1566,13 @@ public function testAddMultiIndexesWithLimitSpecifier() $this->assertTrue($table->hasIndex(['email', 'username'])); $index_data = $this->adapter->query(sprintf( 'SELECT SUB_PART FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = "%s" AND TABLE_NAME = "table1" AND INDEX_NAME = "email" AND COLUMN_NAME = "email"', - MYSQL_DB_CONFIG['name'] + MYSQL_DB_CONFIG['name'], ))->fetch(PDO::FETCH_ASSOC); $expected_limit = $index_data['SUB_PART']; $this->assertEquals($expected_limit, 3); $index_data = $this->adapter->query(sprintf( 'SELECT SUB_PART FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = "%s" AND TABLE_NAME = "table1" AND INDEX_NAME = "email" AND COLUMN_NAME = "username"', - MYSQL_DB_CONFIG['name'] + MYSQL_DB_CONFIG['name'], ))->fetch(PDO::FETCH_ASSOC); $expected_limit = $index_data['SUB_PART']; $this->assertEquals($expected_limit, 2); @@ -1590,7 +1590,7 @@ public function testAddSingleIndexesWithLimitSpecifier() $this->assertTrue($table->hasIndex('email')); $index_data = $this->adapter->query(sprintf( 'SELECT SUB_PART FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = "%s" AND TABLE_NAME = "table1" AND INDEX_NAME = "email" AND COLUMN_NAME = "email"', - MYSQL_DB_CONFIG['name'] + MYSQL_DB_CONFIG['name'], ))->fetch(PDO::FETCH_ASSOC); $expected_limit = $index_data['SUB_PART']; $this->assertEquals($expected_limit, 3); @@ -1751,17 +1751,17 @@ public function testDropForeignKeyWithMultipleColumns() ->addForeignKey( ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->addForeignKey( ['ref_table_field1', 'ref_table_id'], 'ref_table', - ['field1', 'id'] + ['field1', 'id'], ) ->addForeignKey( ['ref_table_id', 'ref_table_field1', 'ref_table_field2'], 'ref_table', - ['id', 'field1', 'field2'] + ['id', 'field1', 'field2'], ) ->save(); @@ -1770,11 +1770,11 @@ public function testDropForeignKeyWithMultipleColumns() $this->assertFalse($this->adapter->hasForeignKey($table->getName(), ['ref_table_id', 'ref_table_field1'])); $this->assertTrue( $this->adapter->hasForeignKey($table->getName(), ['ref_table_id', 'ref_table_field1', 'ref_table_field2']), - 'dropForeignKey() should only affect foreign keys that comprise of exactly the given columns' + 'dropForeignKey() should only affect foreign keys that comprise of exactly the given columns', ); $this->assertTrue( $this->adapter->hasForeignKey($table->getName(), ['ref_table_field1', 'ref_table_id']), - 'dropForeignKey() should only affect foreign keys that comprise of columns in exactly the given order' + 'dropForeignKey() should only affect foreign keys that comprise of columns in exactly the given order', ); $this->assertTrue($this->adapter->hasForeignKey($table->getName(), ['ref_table_field1', 'ref_table_id'])); @@ -1804,7 +1804,7 @@ public function testDropForeignKeyWithIdenticalMultipleColumns() 'ref_table_fk_2', ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->save(); @@ -1848,14 +1848,14 @@ public function testDropForeignKeyByNonExistentKeyColumns(array $columns) ->addForeignKey( ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->save(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', $columns) + implode(', ', $columns), )); $this->adapter->dropForeignKey($table->getName(), $columns); @@ -2064,7 +2064,7 @@ public function testAddColumnWithComment() FROM information_schema.columns WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='table1' ORDER BY ORDINAL_POSITION", - MYSQL_DB_CONFIG['name'] + MYSQL_DB_CONFIG['name'], )); $columnWithComment = $rows[1]; @@ -2485,7 +2485,7 @@ public function testQueryBuilder() $this->assertEquals(1, $stm->rowCount()); $this->assertEquals( ['id' => 2, 'string_col' => 'value2', 'int_col' => '2'], - $stm->fetch('assoc') + $stm->fetch('assoc'), ); $builder = $this->adapter->getQueryBuilder(query::TYPE_DELETE); @@ -2667,7 +2667,7 @@ public function testCreateTableWithPrecisionCurrentTimestamp() $rows = $this->adapter->fetchAll(sprintf( "SELECT COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='%s' AND TABLE_NAME='exampleCurrentTimestamp3'", - MYSQL_DB_CONFIG['name'] + MYSQL_DB_CONFIG['name'], )); $colDef = $rows[0]; $this->assertEqualsIgnoringCase('CURRENT_TIMESTAMP(3)', $colDef['COLUMN_DEFAULT']); diff --git a/tests/Phinx/Db/Adapter/PdoAdapterTest.php b/tests/Phinx/Db/Adapter/PdoAdapterTest.php index b977db70c..dd5b7a07c 100644 --- a/tests/Phinx/Db/Adapter/PdoAdapterTest.php +++ b/tests/Phinx/Db/Adapter/PdoAdapterTest.php @@ -81,7 +81,7 @@ public function testGetVersionLog($versionOrder, $expectedOrderBy) true, true, true, - ['fetchAll', 'getSchemaTableName', 'quoteTableName'] + ['fetchAll', 'getSchemaTableName', 'quoteTableName'], ); $schemaTableName = 'log'; @@ -141,7 +141,7 @@ public function testGetVersionLogInvalidVersionOrderKO() $this->expectExceptionMessage('Invalid version_order configuration option'); $adapter = $this->getMockForAbstractClass( '\Phinx\Db\Adapter\PdoAdapter', - [['version_order' => 'invalid']] + [['version_order' => 'invalid']], ); $this->expectException(RuntimeException::class); @@ -158,7 +158,7 @@ public function testGetVersionLongDryRun() true, true, true, - ['isDryRunEnabled', 'fetchAll', 'getSchemaTableName', 'quoteTableName'] + ['isDryRunEnabled', 'fetchAll', 'getSchemaTableName', 'quoteTableName'], ); $schemaTableName = 'log'; diff --git a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php index caa9f9711..ec4019f89 100644 --- a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php +++ b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php @@ -116,7 +116,7 @@ public function testConnectionWithInvalidCredentials() $this->assertInstanceOf( 'InvalidArgumentException', $e, - 'Expected exception of type InvalidArgumentException, got ' . get_class($e) + 'Expected exception of type InvalidArgumentException, got ' . get_class($e), ); $this->assertStringContainsString('There was a problem connecting to the database', $e->getMessage()); } @@ -498,8 +498,8 @@ public function testAddComment() FROM pg_description JOIN pg_class ON pg_description.objoid = pg_class.oid WHERE relname = '%s'", - 'table1' - ) + 'table1', + ), ); $this->assertEquals('comment1', $rows[0]['description']); } @@ -519,8 +519,8 @@ public function testChangeComment() FROM pg_description JOIN pg_class ON pg_description.objoid = pg_class.oid WHERE relname = '%s'", - 'table1' - ) + 'table1', + ), ); $this->assertEquals('comment2', $rows[0]['description']); } @@ -540,8 +540,8 @@ public function testDropComment() FROM pg_description JOIN pg_class ON pg_description.objoid = pg_class.oid WHERE relname = '%s'", - 'table1' - ) + 'table1', + ), ); $this->assertEmpty($rows); } @@ -782,7 +782,7 @@ public function testAddColumnWithLiteralType() $this->assertEquals( 'citext', (string)$column->getType(), - 'column: ' . $column->getName() + 'column: ' . $column->getName(), ); } } @@ -808,13 +808,13 @@ public function testAddColumnWithComment() FROM information_schema.columns cols WHERE cols.table_catalog=\'' . PGSQL_DB_CONFIG['name'] . '\' AND cols.table_name=\'table1\' - AND cols.column_name = \'email\'' + AND cols.column_name = \'email\'', ); $this->assertEquals( $comment, $row['column_comment'], - 'The column comment was not set when you used addColumn()' + 'The column comment was not set when you used addColumn()', ); } @@ -1003,7 +1003,7 @@ public function testRenamingANonExistentColumn() $this->assertInstanceOf( 'InvalidArgumentException', $e, - 'Expected exception of type InvalidArgumentException, got ' . get_class($e) + 'Expected exception of type InvalidArgumentException, got ' . get_class($e), ); $this->assertEquals('The specified column does not exist: column2', $e->getMessage()); } @@ -1561,7 +1561,7 @@ public function testDropIndexByName() ->addColumn('lname', 'string') ->addIndex( ['fname', 'lname'], - ['name' => 'twocolumnuniqueindex', 'unique' => true] + ['name' => 'twocolumnuniqueindex', 'unique' => true], ) ->save(); $this->assertTrue($table2->hasIndex(['fname', 'lname'])); @@ -1588,7 +1588,7 @@ public function testDropIndexByNameWithSchema() ->addColumn('lname', 'string') ->addIndex( ['fname', 'lname'], - ['name' => 'twocolumnuniqueindex', 'unique' => true] + ['name' => 'twocolumnuniqueindex', 'unique' => true], ) ->save(); $this->assertTrue($table2->hasIndex(['fname', 'lname'])); @@ -1626,7 +1626,7 @@ public function testAddForeignKeyDeferrable() ['id'], [ 'deferrable' => 'DEFERRED', - ] + ], ) ->save(); @@ -1687,17 +1687,17 @@ public function testDropForeignKeyWithMultipleColumns() ->addForeignKey( ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->addForeignKey( ['ref_table_field1', 'ref_table_id'], 'ref_table', - ['field1', 'id'] + ['field1', 'id'], ) ->addForeignKey( ['ref_table_id', 'ref_table_field1', 'ref_table_field2'], 'ref_table', - ['id', 'field1', 'field2'] + ['id', 'field1', 'field2'], ) ->save(); @@ -1706,11 +1706,11 @@ public function testDropForeignKeyWithMultipleColumns() $this->assertFalse($this->adapter->hasForeignKey($table->getName(), ['ref_table_id', 'ref_table_field1'])); $this->assertTrue( $this->adapter->hasForeignKey($table->getName(), ['ref_table_id', 'ref_table_field1', 'ref_table_field2']), - 'dropForeignKey() should only affect foreign keys that comprise of exactly the given columns' + 'dropForeignKey() should only affect foreign keys that comprise of exactly the given columns', ); $this->assertTrue( $this->adapter->hasForeignKey($table->getName(), ['ref_table_field1', 'ref_table_id']), - 'dropForeignKey() should only affect foreign keys that comprise of columns in exactly the given order' + 'dropForeignKey() should only affect foreign keys that comprise of columns in exactly the given order', ); $this->assertTrue($this->adapter->hasForeignKey($table->getName(), ['ref_table_field1', 'ref_table_id'])); @@ -1740,7 +1740,7 @@ public function testDropForeignKeyWithIdenticalMultipleColumns() 'ref_table_fk_2', ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->save(); @@ -1784,14 +1784,14 @@ public function testDropForeignKeyByNonExistentKeyColumns(array $columns) ->addForeignKey( ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->save(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', $columns) + implode(', ', $columns), )); $this->adapter->dropForeignKey($table->getName(), $columns); @@ -1813,7 +1813,7 @@ public function testDropForeignKeyCaseSensitivity() $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', ['ref_table_id']) + implode(', ', ['ref_table_id']), )); $this->adapter->dropForeignKey($table->getName(), ['ref_table_id']); @@ -2040,8 +2040,8 @@ public function testCreateTableWithComment() sprintf( 'SELECT description FROM pg_description JOIN pg_class ON pg_description.objoid = ' . "pg_class.oid WHERE relname = '%s'", - 'ntable' - ) + 'ntable', + ), ); $this->assertEquals($tableComment, $rows[0]['description'], 'Dont set table comment correctly'); @@ -2053,7 +2053,7 @@ public function testCanAddColumnComment() $table->addColumn( 'field1', 'string', - ['comment' => $comment = 'Comments from column "field1"'] + ['comment' => $comment = 'Comments from column "field1"'], )->save(); $row = $this->adapter->fetchRow( @@ -2064,7 +2064,7 @@ public function testCanAddColumnComment() FROM information_schema.columns cols WHERE cols.table_catalog=\'' . PGSQL_DB_CONFIG['name'] . '\' AND cols.table_name=\'table1\' - AND cols.column_name = \'field1\'' + AND cols.column_name = \'field1\'', ); $this->assertEquals($comment, $row['column_comment'], 'Dont set column comment correctly'); @@ -2084,13 +2084,13 @@ public function testCanAddCommentForColumnWithReservedName() FROM information_schema.columns cols WHERE cols.table_catalog=\'' . PGSQL_DB_CONFIG['name'] . '\' AND cols.table_name=\'user\' - AND cols.column_name = \'index\'' + AND cols.column_name = \'index\'', ); $this->assertEquals( $comment, $row['column_comment'], - 'Dont set column comment correctly for tables or columns with reserved names' + 'Dont set column comment correctly for tables or columns with reserved names', ); } @@ -2106,7 +2106,7 @@ public function testCanChangeColumnComment() $table->changeColumn( 'field1', 'string', - ['comment' => $comment = 'New Comments from column "field1"'] + ['comment' => $comment = 'New Comments from column "field1"'], )->save(); $row = $this->adapter->fetchRow( @@ -2117,7 +2117,7 @@ public function testCanChangeColumnComment() FROM information_schema.columns cols WHERE cols.table_catalog=\'' . PGSQL_DB_CONFIG['name'] . '\' AND cols.table_name=\'table1\' - AND cols.column_name = \'field1\'' + AND cols.column_name = \'field1\'', ); $this->assertEquals($comment, $row['column_comment'], 'Dont change column comment correctly'); @@ -2143,7 +2143,7 @@ public function testCanRemoveColumnComment() FROM information_schema.columns cols WHERE cols.table_catalog=\'' . PGSQL_DB_CONFIG['name'] . '\' AND cols.table_name=\'table1\' - AND cols.column_name = \'field1\'' + AND cols.column_name = \'field1\'', ); $this->assertEmpty($row['column_comment'], 'Dont remove column comment correctly'); @@ -2171,7 +2171,7 @@ public function testCanAddMultipleCommentsToOneTable() FROM information_schema.columns cols WHERE cols.table_catalog=\'' . PGSQL_DB_CONFIG['name'] . '\' AND cols.table_name=\'table1\' - AND cols.column_name = \'comment1\'' + AND cols.column_name = \'comment1\'', ); $this->assertEquals($comment1, $row['column_comment'], 'Could not create first column comment'); @@ -2184,7 +2184,7 @@ public function testCanAddMultipleCommentsToOneTable() FROM information_schema.columns cols WHERE cols.table_catalog=\'' . PGSQL_DB_CONFIG['name'] . '\' AND cols.table_name=\'table1\' - AND cols.column_name = \'comment2\'' + AND cols.column_name = \'comment2\'', ); $this->assertEquals($comment2, $row['column_comment'], 'Could not create second column comment'); @@ -2213,7 +2213,7 @@ public function testColumnsAreResetBetweenTables() FROM information_schema.columns cols WHERE cols.table_catalog=\'' . PGSQL_DB_CONFIG['name'] . '\' AND cols.table_name=\'widgets\' - AND cols.column_name = \'transport\'' + AND cols.column_name = \'transport\'', ); $this->assertEquals($comment, $row['column_comment'], 'Could not create column comment'); @@ -2233,7 +2233,7 @@ public function testForeignKeysAreProperlyEscaped() $foreign = new Table( 'sessions', ['id' => $sessionId], - $this->adapter + $this->adapter, ); $foreign->addColumn('user', 'integer') ->addForeignKey('user', 'users', $userId) @@ -2252,14 +2252,14 @@ public function testForeignKeysAreProperlyEscapedWithSchema() $local = new Table( 'schema_users.users', ['id' => $userId], - $this->adapter + $this->adapter, ); $local->create(); $foreign = new Table( 'schema_users.sessions', ['id' => $sessionId], - $this->adapter + $this->adapter, ); $foreign->addColumn('user', 'integer') ->addForeignKey('user', 'schema_users.users', $userId) @@ -2281,14 +2281,14 @@ public function testForeignKeysAreProperlyEscapedWithSchema2() $local = new Table( 'schema_users.users', ['id' => $userId], - $this->adapter + $this->adapter, ); $local->create(); $foreign = new Table( 'schema_sessions.sessions', ['id' => $sessionId], - $this->adapter + $this->adapter, ); $foreign->addColumn('user', 'integer') ->addForeignKey('user', 'schema_users.users', $userId) @@ -2640,7 +2640,7 @@ public function testDumpCreateTable() $this->assertStringContainsString( $expectedOutput, $actualOutput, - 'Passing the --dry-run option does not dump create table query' + 'Passing the --dry-run option does not dump create table query', ); } @@ -2672,7 +2672,7 @@ public function testDumpCreateTableWithSchema() $this->assertStringContainsString( $expectedOutput, $actualOutput, - 'Passing the --dry-run option does not dump create table query' + 'Passing the --dry-run option does not dump create table query', ); } @@ -2724,7 +2724,7 @@ public function testDumpInsert() $this->assertStringContainsString( $expectedOutput, $actualOutput, - 'Passing the --dry-run option doesn\'t dump the insert to the output' + 'Passing the --dry-run option doesn\'t dump the insert to the output', ); $countQuery = $this->adapter->query('SELECT COUNT(*) FROM table1'); @@ -2776,7 +2776,7 @@ public function testDumpBulkinsert() $this->assertStringContainsString( $expectedOutput, $actualOutput, - 'Passing the --dry-run option doesn\'t dump the bulkinsert to the output' + 'Passing the --dry-run option doesn\'t dump the bulkinsert to the output', ); $countQuery = $this->adapter->query('SELECT COUNT(*) FROM table1'); @@ -2873,7 +2873,7 @@ public function testQueryBuilder() $this->assertEquals(1, $stm->rowCount()); $this->assertEquals( ['id' => 2, 'string_col' => 'value2', 'int_col' => '2'], - $stm->fetch('assoc') + $stm->fetch('assoc'), ); $builder = $this->adapter->getQueryBuilder(Query::TYPE_DELETE); diff --git a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php index f44906e29..ebe738af2 100644 --- a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php @@ -77,7 +77,7 @@ public function testBeginTransaction() $this->assertTrue( $this->adapter->getConnection()->inTransaction(), - 'Underlying PDO instance did not detect new transaction' + 'Underlying PDO instance did not detect new transaction', ); } @@ -90,7 +90,7 @@ public function testRollbackTransaction() $this->assertFalse( $this->adapter->getConnection()->inTransaction(), - 'Underlying PDO instance did not detect rolled back transaction' + 'Underlying PDO instance did not detect rolled back transaction', ); } @@ -103,7 +103,7 @@ public function testCommitTransactionTransaction() $this->assertFalse( $this->adapter->getConnection()->inTransaction(), - "Underlying PDO instance didn't detect committed transaction" + "Underlying PDO instance didn't detect committed transaction", ); } @@ -325,7 +325,7 @@ public function testCreateTableWithIndexesAndForeignKey() 'master_id', 'tbl_master', 'id', - ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION', 'constraint' => 'fk_master_id'] + ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION', 'constraint' => 'fk_master_id'], ) ->create(); @@ -334,11 +334,11 @@ public function testCreateTableWithIndexesAndForeignKey() $this->assertTrue($this->adapter->hasForeignKey('tbl_child', ['master_id'])); $row = $this->adapter->fetchRow( - "SELECT * FROM sqlite_master WHERE `type` = 'table' AND `tbl_name` = 'tbl_child'" + "SELECT * FROM sqlite_master WHERE `type` = 'table' AND `tbl_name` = 'tbl_child'", ); $this->assertStringContainsString( 'CONSTRAINT `fk_master_id` FOREIGN KEY (`master_id`) REFERENCES `tbl_master` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION', - $row['sql'] + $row['sql'], ); } @@ -354,18 +354,18 @@ public function testCreateTableWithoutAutoIncrementingPrimaryKeyAndWithForeignKe 'master_id', 'tbl_master', 'id', - ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION', 'constraint' => 'fk_master_id'] + ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION', 'constraint' => 'fk_master_id'], ); $table->create(); $this->assertTrue($this->adapter->hasForeignKey('tbl_child', ['master_id'])); $row = $this->adapter->fetchRow( - "SELECT * FROM sqlite_master WHERE `type` = 'table' AND `tbl_name` = 'tbl_child'" + "SELECT * FROM sqlite_master WHERE `type` = 'table' AND `tbl_name` = 'tbl_child'", ); $this->assertStringContainsString( 'CONSTRAINT `fk_master_id` FOREIGN KEY (`master_id`) REFERENCES `tbl_master` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION', - $row['sql'] + $row['sql'], ); } @@ -1039,7 +1039,7 @@ public function testChangeColumnWithIndex() ->addColumn('indexcol', 'integer') ->addIndex( 'indexcol', - ['unique' => true] + ['unique' => true], ) ->create(); @@ -1067,7 +1067,7 @@ public function testChangeColumnWithTrigger() $this->adapter->execute($triggerSQL); $rows = $this->adapter->fetchAll( - "SELECT * FROM sqlite_master WHERE `type` = 'trigger' AND tbl_name = 't'" + "SELECT * FROM sqlite_master WHERE `type` = 'trigger' AND tbl_name = 't'", ); $this->assertCount(1, $rows); $this->assertEquals('trigger', $rows[0]['type']); @@ -1077,7 +1077,7 @@ public function testChangeColumnWithTrigger() $table->changeColumn('triggercol', 'integer', ['null' => false])->update(); $rows = $this->adapter->fetchAll( - "SELECT * FROM sqlite_master WHERE `type` = 'trigger' AND tbl_name = 't'" + "SELECT * FROM sqlite_master WHERE `type` = 'trigger' AND tbl_name = 't'", ); $this->assertCount(1, $rows); $this->assertEquals('trigger', $rows[0]['type']); @@ -1516,17 +1516,17 @@ public function testDropForeignKeyWithMultipleColumns() ->addForeignKey( ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->addForeignKey( ['ref_table_field1', 'ref_table_id'], 'ref_table', - ['field1', 'id'] + ['field1', 'id'], ) ->addForeignKey( ['ref_table_id', 'ref_table_field1', 'ref_table_field2'], 'ref_table', - ['id', 'field1', 'field2'] + ['id', 'field1', 'field2'], ) ->save(); @@ -1535,11 +1535,11 @@ public function testDropForeignKeyWithMultipleColumns() $this->assertFalse($this->adapter->hasForeignKey($table->getName(), ['ref_table_id', 'ref_table_field1'])); $this->assertTrue( $this->adapter->hasForeignKey($table->getName(), ['ref_table_id', 'ref_table_field1', 'ref_table_field2']), - 'dropForeignKey() should only affect foreign keys that comprise of exactly the given columns' + 'dropForeignKey() should only affect foreign keys that comprise of exactly the given columns', ); $this->assertTrue( $this->adapter->hasForeignKey($table->getName(), ['ref_table_field1', 'ref_table_id']), - 'dropForeignKey() should only affect foreign keys that comprise of columns in exactly the given order' + 'dropForeignKey() should only affect foreign keys that comprise of columns in exactly the given order', ); $this->assertTrue($this->adapter->hasForeignKey($table->getName(), ['ref_table_field1', 'ref_table_id'])); @@ -1569,7 +1569,7 @@ public function testDropForeignKeyWithIdenticalMultipleColumns() 'ref_table_fk_2', ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->save(); @@ -1613,14 +1613,14 @@ public function testDropForeignKeyByNonExistentKeyColumns(array $columns) ->addForeignKey( ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->save(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', $columns) + implode(', ', $columns), )); $this->adapter->dropForeignKey($table->getName(), $columns); @@ -1700,7 +1700,7 @@ public function testPhinxTypeLiteral() 'limit' => null, 'scale' => null, ], - $this->adapter->getPhinxType('fake') + $this->adapter->getPhinxType('fake'), ); } @@ -1754,13 +1754,13 @@ public function testBulkInsertData() [ 'column1' => 'value3', 'column2' => 3, - ] + ], ) ->insert( [ 'column1' => '\'value4\'', 'column2' => null, - ] + ], ) ->save(); $rows = $this->adapter->fetchAll('SELECT * FROM table1'); @@ -1825,13 +1825,13 @@ public function testInsertData() [ 'column1' => 'value3', 'column2' => 3, - ] + ], ) ->insert( [ 'column1' => '\'value4\'', 'column2' => null, - ] + ], ) ->save(); @@ -2109,7 +2109,7 @@ public function testQueryBuilder() $this->assertEquals(0, $stm->rowCount()); $this->assertEquals( ['id' => 2, 'string_col' => 'value2', 'int_col' => '2'], - $stm->fetch('assoc') + $stm->fetch('assoc'), ); $builder = $this->adapter->getQueryBuilder(Query::TYPE_DELETE); diff --git a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php index cdc0e3088..8a5a96c7f 100644 --- a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php @@ -96,7 +96,7 @@ public function testConnectionWithInvalidCredentials() $this->assertInstanceOf( 'InvalidArgumentException', $e, - 'Expected exception of type InvalidArgumentException, got ' . get_class($e) + 'Expected exception of type InvalidArgumentException, got ' . get_class($e), ); $this->assertStringContainsString('There was a problem connecting to the database', $e->getMessage()); } finally { @@ -586,7 +586,7 @@ public function testRenamingANonExistentColumn() $this->assertInstanceOf( 'InvalidArgumentException', $e, - 'Expected exception of type InvalidArgumentException, got ' . get_class($e) + 'Expected exception of type InvalidArgumentException, got ' . get_class($e), ); $this->assertEquals('The specified column does not exist: column2', $e->getMessage()); } @@ -882,7 +882,7 @@ public function testDropIndexByName() ->addColumn('lname', 'string') ->addIndex( ['fname', 'lname'], - ['name' => 'twocolumnuniqueindex', 'unique' => true] + ['name' => 'twocolumnuniqueindex', 'unique' => true], ) ->save(); $this->assertTrue($table2->hasIndex(['fname', 'lname'])); @@ -943,17 +943,17 @@ public function testDropForeignKeyWithMultipleColumns() ->addForeignKey( ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->addForeignKey( ['ref_table_field1', 'ref_table_id'], 'ref_table', - ['field1', 'id'] + ['field1', 'id'], ) ->addForeignKey( ['ref_table_id', 'ref_table_field1', 'ref_table_field2'], 'ref_table', - ['id', 'field1', 'field2'] + ['id', 'field1', 'field2'], ) ->save(); @@ -962,11 +962,11 @@ public function testDropForeignKeyWithMultipleColumns() $this->assertFalse($this->adapter->hasForeignKey($table->getName(), ['ref_table_id', 'ref_table_field1'])); $this->assertTrue( $this->adapter->hasForeignKey($table->getName(), ['ref_table_id', 'ref_table_field1', 'ref_table_field2']), - 'dropForeignKey() should only affect foreign keys that comprise of exactly the given columns' + 'dropForeignKey() should only affect foreign keys that comprise of exactly the given columns', ); $this->assertTrue( $this->adapter->hasForeignKey($table->getName(), ['ref_table_field1', 'ref_table_id']), - 'dropForeignKey() should only affect foreign keys that comprise of columns in exactly the given order' + 'dropForeignKey() should only affect foreign keys that comprise of columns in exactly the given order', ); $this->assertTrue($this->adapter->hasForeignKey($table->getName(), ['ref_table_field1', 'ref_table_id'])); @@ -996,7 +996,7 @@ public function testDropForeignKeyWithIdenticalMultipleColumns() 'ref_table_fk_2', ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->save(); @@ -1040,14 +1040,14 @@ public function testDropForeignKeyByNonExistentKeyColumns(array $columns) ->addForeignKey( ['ref_table_id', 'ref_table_field1'], 'ref_table', - ['id', 'field1'] + ['id', 'field1'], ) ->save(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', $columns) + implode(', ', $columns), )); $this->adapter->dropForeignKey($table->getName(), $columns); @@ -1069,7 +1069,7 @@ public function testDropForeignKeyCaseSensitivity() $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(sprintf( 'No foreign key on column(s) `%s` exists', - implode(', ', ['ref_table_id']) + implode(', ', ['ref_table_id']), )); $this->adapter->dropForeignKey($table->getName(), ['ref_table_id']); @@ -1299,7 +1299,7 @@ public function testBulkInsertData() [ 'column1' => 'value3', 'column2' => 3, - ] + ], ); $this->adapter->bulkinsert($table->getTable(), $table->getData()); $table->reset(); @@ -1364,7 +1364,7 @@ public function testInsertData() [ 'column1' => 'value3', 'column2' => 3, - ] + ], ) ->save(); @@ -1521,7 +1521,7 @@ public function testQueryBuilder() $this->assertEquals(1, $stm->rowCount()); $this->assertEquals( ['id' => 2, 'string_col' => 'value2', 'int_col' => '2'], - $stm->fetch('assoc') + $stm->fetch('assoc'), ); $stm->closeCursor(); diff --git a/tests/Phinx/Db/Adapter/TablePrefixAdapterTest.php b/tests/Phinx/Db/Adapter/TablePrefixAdapterTest.php index e9a638562..4f451b8c2 100644 --- a/tests/Phinx/Db/Adapter/TablePrefixAdapterTest.php +++ b/tests/Phinx/Db/Adapter/TablePrefixAdapterTest.php @@ -50,7 +50,7 @@ protected function setUp(): void ->method('getOption') ->with($this->logicalOr( $this->equalTo('table_prefix'), - $this->equalTo('table_suffix') + $this->equalTo('table_suffix'), )) ->will($this->returnCallback(function ($option) use ($options) { return $options[$option]; @@ -103,7 +103,7 @@ public function testCreateTable() ->with($this->callback( function ($table) { return $table->getName() === 'pre_table_suf'; - } + }, )); $this->adapter->createTable($table); @@ -120,7 +120,7 @@ public function testChangePrimaryKey() ->method('changePrimaryKey') ->with( $this->equalTo($expectedTable), - $this->equalTo($newColumns) + $this->equalTo($newColumns), ); $this->adapter->changePrimaryKey($table, $newColumns); @@ -137,7 +137,7 @@ public function testChangeComment() ->method('changeComment') ->with( $this->equalTo($expectedTable), - $this->equalTo($newComment) + $this->equalTo($newComment), ); $this->adapter->changeComment($table, $newComment); @@ -150,7 +150,7 @@ public function testRenameTable() ->method('renameTable') ->with( $this->equalTo('pre_old_suf'), - $this->equalTo('pre_new_suf') + $this->equalTo('pre_new_suf'), ); $this->adapter->renameTable('old', 'new'); @@ -183,7 +183,7 @@ public function testHasColumn() ->method('hasColumn') ->with( $this->equalTo('pre_table_suf'), - $this->equalTo('column') + $this->equalTo('column'), ); $this->adapter->hasColumn('table', 'column'); @@ -201,7 +201,7 @@ public function testAddColumn() function ($table) { return $table->getName() === 'pre_table_suf'; }, - $this->equalTo($column) + $this->equalTo($column), )); $this->adapter->addColumn($table, $column); @@ -215,7 +215,7 @@ public function testRenameColumn() ->with( $this->equalTo('pre_table_suf'), $this->equalTo('column'), - $this->equalTo('new_column') + $this->equalTo('new_column'), ); $this->adapter->renameColumn('table', 'column', 'new_column'); @@ -231,7 +231,7 @@ public function testChangeColumn() ->with( $this->equalTo('pre_table_suf'), $this->equalTo('column'), - $this->equalTo($newColumn) + $this->equalTo($newColumn), ); $this->adapter->changeColumn('table', 'column', $newColumn); @@ -244,7 +244,7 @@ public function testDropColumn() ->method('dropColumn') ->with( $this->equalTo('pre_table_suf'), - $this->equalTo('column') + $this->equalTo('column'), ); $this->adapter->dropColumn('table', 'column'); @@ -259,7 +259,7 @@ public function testHasIndex() ->method('hasIndex') ->with( $this->equalTo('pre_table_suf'), - $this->equalTo($columns) + $this->equalTo($columns), ); $this->adapter->hasIndex('table', $columns); @@ -274,7 +274,7 @@ public function testDropIndex() ->method('dropIndex') ->with( $this->equalTo('pre_table_suf'), - $this->equalTo($columns) + $this->equalTo($columns), ); $this->adapter->dropIndex('table', $columns); @@ -287,7 +287,7 @@ public function testDropIndexByName() ->method('dropIndexByName') ->with( $this->equalTo('pre_table_suf'), - $this->equalTo('index') + $this->equalTo('index'), ); $this->adapter->dropIndexByName('table', 'index'); @@ -304,7 +304,7 @@ public function testHasPrimaryKey() ->with( $this->equalTo('pre_table_suf'), $this->equalTo($columns), - $this->equalTo($constraint) + $this->equalTo($constraint), ); $this->adapter->hasPrimaryKey('table', $columns, $constraint); @@ -321,7 +321,7 @@ public function testHasForeignKey() ->with( $this->equalTo('pre_table_suf'), $this->equalTo($columns), - $this->equalTo($constraint) + $this->equalTo($constraint), ); $this->adapter->hasForeignKey('table', $columns, $constraint); @@ -339,7 +339,7 @@ public function testAddForeignKey() function ($table) { return $table->getName() === 'pre_table_suf'; }, - $this->equalTo($foreignKey) + $this->equalTo($foreignKey), )); $this->adapter->addForeignKey($table, $foreignKey); @@ -356,7 +356,7 @@ public function testDropForeignKey() ->with( $this->equalTo('pre_table_suf'), $this->equalTo($columns), - $this->equalTo($constraint) + $this->equalTo($constraint), ); $this->adapter->dropForeignKey('table', $columns, $constraint); @@ -373,7 +373,7 @@ public function testInsertData() function ($table) { return $table->getName() === 'pre_table_suf'; }, - $this->equalTo($row) + $this->equalTo($row), )); $table = new Table('table', [], $this->adapter); @@ -417,12 +417,12 @@ public function testExecuteActions($action, $checkReferecedTable = false) if ($action instanceof AddForeignKey) { $this->assertEquals( 'pre_another_table_suf', - $newActions[0]->getForeignKey()->getReferencedTable()->getName() + $newActions[0]->getForeignKey()->getReferencedTable()->getName(), ); } elseif ($action instanceof RenameTable) { $this->assertEquals( 'pre_new_name_suf', - $newActions[0]->getNewName() + $newActions[0]->getNewName(), ); } } diff --git a/tests/Phinx/Db/Table/ForeignKeyTest.php b/tests/Phinx/Db/Table/ForeignKeyTest.php index f33cf1bf8..b0e2db76f 100644 --- a/tests/Phinx/Db/Table/ForeignKeyTest.php +++ b/tests/Phinx/Db/Table/ForeignKeyTest.php @@ -24,7 +24,7 @@ public function testOnDeleteSetNullCanBeSetThroughOptions() { $this->assertEquals( ForeignKey::SET_NULL, - $this->fk->setOptions(['delete' => ForeignKey::SET_NULL])->getOnDelete() + $this->fk->setOptions(['delete' => ForeignKey::SET_NULL])->getOnDelete(), ); } diff --git a/tests/Phinx/Db/TableTest.php b/tests/Phinx/Db/TableTest.php index df35494e4..d10720596 100644 --- a/tests/Phinx/Db/TableTest.php +++ b/tests/Phinx/Db/TableTest.php @@ -37,7 +37,7 @@ public function provideTimestampColumnNames() [$adapter[0], 'created', 'updated', 'created', 'updated', false], [$adapter[0], null, 'amendment_date', 'created_at', 'amendment_date', true], [$adapter[0], 'insertion_date', null, 'insertion_date', 'updated_at', true], - ] + ], ); } @@ -56,7 +56,7 @@ public function testAddColumnWithAnInvalidColumnType() $this->assertInstanceOf( 'InvalidArgumentException', $e, - 'Expected exception of type InvalidArgumentException, got ' . get_class($e) + 'Expected exception of type InvalidArgumentException, got ' . get_class($e), ); $this->assertStringStartsWith('An invalid column type ', $e->getMessage()); } @@ -85,7 +85,7 @@ public function testAddColumnWithNoAdapterSpecified() $this->assertInstanceOf( 'RuntimeException', $e, - 'Expected exception of type RuntimeException, got ' . get_class($e) + 'Expected exception of type RuntimeException, got ' . get_class($e), ); } } diff --git a/tests/Phinx/Migration/AbstractMigrationTest.php b/tests/Phinx/Migration/AbstractMigrationTest.php index 1af5e2121..b125b8a99 100644 --- a/tests/Phinx/Migration/AbstractMigrationTest.php +++ b/tests/Phinx/Migration/AbstractMigrationTest.php @@ -24,7 +24,7 @@ public function testAdapterMethods() $migrationStub->setAdapter($adapterStub); $this->assertInstanceOf( 'Phinx\Db\Adapter\AdapterInterface', - $migrationStub->getAdapter() + $migrationStub->getAdapter(), ); } @@ -258,7 +258,7 @@ public function testTableMethod() $this->assertInstanceOf( 'Phinx\Db\Table', - $migrationStub->table('test_table') + $migrationStub->table('test_table'), ); } diff --git a/tests/Phinx/Migration/ManagerTest.php b/tests/Phinx/Migration/ManagerTest.php index 7e0d5f486..3f5afbd43 100644 --- a/tests/Phinx/Migration/ManagerTest.php +++ b/tests/Phinx/Migration/ManagerTest.php @@ -159,7 +159,7 @@ public function testInstantiation() { $this->assertInstanceOf( 'Symfony\Component\Console\Output\StreamOutput', - $this->manager->getOutput() + $this->manager->getOutput(), ); } @@ -197,7 +197,7 @@ public function testPrintStatusMethod() 'migration_name' => '', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -237,7 +237,7 @@ public function testPrintStatusMethodJsonFormat() 'migration_name' => '', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); $this->manager->getOutput()->setDecorated(false); @@ -274,7 +274,7 @@ public function testPrintStatusMethodWithNamespace() 'migration_name' => '', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -347,7 +347,7 @@ public function testPrintStatusMethodWithMixedNamespace() 'migration_name' => '', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -392,7 +392,7 @@ public function testPrintStatusMethodWithBreakpointSet() 'migration_name' => '', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -454,7 +454,7 @@ public function testPrintStatusMethodWithMissingMigrations() 'migration_name' => 'Example', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -498,7 +498,7 @@ public function testPrintStatusMethodWithMissingMigrationsWithNamespace() 'migration_name' => 'Example', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -543,7 +543,7 @@ public function testPrintStatusMethodWithMissingMigrationsWithMixedNamespace() 'migration_name' => 'Example', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -600,7 +600,7 @@ public function testPrintStatusMethodWithMissingLastMigration() 'migration_name' => 'Example', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -651,7 +651,7 @@ public function testPrintStatusMethodWithMissingLastMigrationWithNamespace() 'migration_name' => 'Example', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -735,7 +735,7 @@ public function testPrintStatusMethodWithMissingLastMigrationWithMixedNamespace( 'migration_name' => 'Example', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -756,7 +756,7 @@ public function testPrintStatusMethodWithMissingLastMigrationWithMixedNamespace( '\s*up 20160111235330 2016-01-16 18:35:40 2016-01-16 18:35:41 Foo\\\\Bar\\\\TestMigration' . PHP_EOL . '\s*up 20160116183504 2016-01-16 18:35:40 2016-01-16 18:35:41 Foo\\\\Bar\\\\TestMigration2' . PHP_EOL . '\s*up 20170120145114 2017-01-20 14:51:14 2017-01-20 14:51:14 Example *\*\* MISSING MIGRATION FILE \*\*/', - $outputStr + $outputStr, ); } @@ -786,7 +786,7 @@ public function testPrintStatusMethodWithMissingMigrationsAndBreakpointSet() 'migration_name' => 'Example', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -892,7 +892,7 @@ public function testPrintStatusMethodWithDownMigrationsWithMixedNamespace() 'migration_name' => '', 'breakpoint' => 0, ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -907,13 +907,13 @@ public function testPrintStatusMethodWithDownMigrationsWithMixedNamespace() '/\s*up 20120111235330 2012-01-16 18:35:40 2012-01-16 18:35:41 TestMigration' . PHP_EOL . '\s*up 20120116183504 2012-01-16 18:35:40 2012-01-16 18:35:41 TestMigration2' . PHP_EOL . '\s*up 20150111235330 2015-01-16 18:35:40 2015-01-16 18:35:41 Baz\\\\TestMigration/', - $outputStr + $outputStr, ); $this->assertMatchesRegularExpression( '/\s*down 20150116183504 Baz\\\\TestMigration2' . PHP_EOL . '\s*down 20160111235330 Foo\\\\Bar\\\\TestMigration' . PHP_EOL . '\s*down 20160116183504 Foo\\\\Bar\\\\TestMigration2/', - $outputStr + $outputStr, ); } @@ -1037,7 +1037,7 @@ public function testNullMigrationNameDoesNotThrowErrors() $this->assertMatchesRegularExpression( '/\s*up 20120103083300 2012-01-11 23:53:36 2012-01-11 23:53:37 *\*\* MISSING MIGRATION FILE \*\*/', - $outputStr + $outputStr, ); } @@ -1290,7 +1290,7 @@ public function testGettingAValidEnvironment() { $this->assertInstanceOf( 'Phinx\Migration\Manager\Environment', - $this->manager->getEnvironment('production') + $this->manager->getEnvironment('production'), ); } @@ -1782,8 +1782,8 @@ public function testRollbackToVersionWithTwoMigrationsDoesNotRollbackBothMigrati [ '20120111235330' => ['version' => '20120111235330', 'migration' => '', 'breakpoint' => 0], '20120116183504' => ['version' => '20120815145812', 'migration' => '', 'breakpoint' => 0], - ] - ) + ], + ), ); $envStub->expects($this->any()) ->method('getVersions') @@ -1792,8 +1792,8 @@ public function testRollbackToVersionWithTwoMigrationsDoesNotRollbackBothMigrati [ 20120111235330, 20120116183504, - ] - ) + ], + ), ); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -1816,8 +1816,8 @@ public function testRollbackToVersionWithTwoMigrationsDoesNotRollbackBothMigrati [ '20160111235330' => ['version' => '20160111235330', 'migration' => '', 'breakpoint' => 0], '20160116183504' => ['version' => '20160815145812', 'migration' => '', 'breakpoint' => 0], - ] - ) + ], + ), ); $envStub->expects($this->any()) ->method('getVersions') @@ -1826,8 +1826,8 @@ public function testRollbackToVersionWithTwoMigrationsDoesNotRollbackBothMigrati [ 20160111235330, 20160116183504, - ] - ) + ], + ), ); $this->manager->setConfig($this->getConfigWithNamespace()); @@ -1851,8 +1851,8 @@ public function testRollbackToVersionWithTwoMigrationsDoesNotRollbackBothMigrati [ '20120111235330' => ['version' => '20120111235330', 'migration' => '', 'breakpoint' => 0], '20150116183504' => ['version' => '20150116183504', 'migration' => '', 'breakpoint' => 0], - ] - ) + ], + ), ); $envStub->expects($this->any()) ->method('getVersions') @@ -1861,8 +1861,8 @@ public function testRollbackToVersionWithTwoMigrationsDoesNotRollbackBothMigrati [ 20120111235330, 20150116183504, - ] - ) + ], + ), ); $this->manager->setConfig($this->getConfigWithMixedNamespace()); @@ -5596,7 +5596,7 @@ public function testReversibleMigrationsWorkAsExpected() $this->assertTrue($adapter->hasColumn('change_direction_test', 'subthing')); $this->assertEquals( 2, - count($adapter->fetchAll('SELECT * FROM change_direction_test WHERE subthing IS NOT NULL')) + count($adapter->fetchAll('SELECT * FROM change_direction_test WHERE subthing IS NOT NULL')), ); // revert all changes to the first @@ -6127,7 +6127,7 @@ public function testInvalidVersionBreakpoint() 'migration_name' => '', 'breakpoint' => '0', ], - ] + ], )); $this->manager->setEnvironments(['mockenv' => $envStub]); diff --git a/tests/Phinx/Seed/AbstractSeedTest.php b/tests/Phinx/Seed/AbstractSeedTest.php index e412011bf..26a9edc2e 100644 --- a/tests/Phinx/Seed/AbstractSeedTest.php +++ b/tests/Phinx/Seed/AbstractSeedTest.php @@ -24,7 +24,7 @@ public function testAdapterMethods() $migrationStub->setAdapter($adapterStub); $this->assertInstanceOf( 'Phinx\Db\Adapter\AdapterInterface', - $migrationStub->getAdapter() + $migrationStub->getAdapter(), ); } } diff --git a/tests/Phinx/TestCase.php b/tests/Phinx/TestCase.php index e86d2e522..cd9473ede 100644 --- a/tests/Phinx/TestCase.php +++ b/tests/Phinx/TestCase.php @@ -35,14 +35,14 @@ public static function assertMatchesRegularExpression(string $pattern, string $s public static function assertDoesNotMatchRegularExpression( string $pattern, string $string, - string $message = '' + string $message = '', ): void { static::assertThat( $string, new LogicalNot( - new RegularExpression($pattern) + new RegularExpression($pattern), ), - $message + $message, ); } }