@@ -42,6 +42,6 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | private static function isACustomPharBuild($gitversion) |
| 44 | 44 | { |
| 45 | - return $gitversion !== '@' . 'git-version@'; |
|
| 45 | + return $gitversion !== '@'.'git-version@'; |
|
| 46 | 46 | } |
| 47 | 47 | } |
@@ -187,14 +187,14 @@ discard block |
||
| 187 | 187 | if (is_array($sql)) { |
| 188 | 188 | foreach ($sql as $key => $query) { |
| 189 | 189 | $this->sql[] = $query; |
| 190 | - if ( ! empty($params[$key])) { |
|
| 190 | + if (!empty($params[$key])) { |
|
| 191 | 191 | $queryTypes = isset($types[$key]) ? $types[$key] : []; |
| 192 | 192 | $this->addQueryParams($params[$key], $queryTypes); |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | } else { |
| 196 | 196 | $this->sql[] = $sql; |
| 197 | - if ( ! empty($params)) { |
|
| 197 | + if (!empty($params)) { |
|
| 198 | 198 | $this->addQueryParams($params, $types); |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -223,11 +223,11 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $queries = $this->execute($direction, true); |
| 225 | 225 | |
| 226 | - if ( ! empty($this->params)) { |
|
| 226 | + if (!empty($this->params)) { |
|
| 227 | 227 | throw MigrationException::migrationNotConvertibleToSql($this->class); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $this->outputWriter->write("\n-- Version " . $this->version . "\n"); |
|
| 230 | + $this->outputWriter->write("\n-- Version ".$this->version."\n"); |
|
| 231 | 231 | |
| 232 | 232 | $sqlQueries = [$this->version => $queries]; |
| 233 | 233 | |
@@ -280,12 +280,12 @@ discard block |
||
| 280 | 280 | $this->state = self::STATE_PRE; |
| 281 | 281 | $fromSchema = $this->schemaProvider->createFromSchema(); |
| 282 | 282 | |
| 283 | - $this->migration->{'pre' . ucfirst($direction)}($fromSchema); |
|
| 283 | + $this->migration->{'pre'.ucfirst($direction)}($fromSchema); |
|
| 284 | 284 | |
| 285 | 285 | if ($direction === self::DIRECTION_UP) { |
| 286 | - $this->outputWriter->write("\n" . sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->version) . "\n"); |
|
| 286 | + $this->outputWriter->write("\n".sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->version)."\n"); |
|
| 287 | 287 | } else { |
| 288 | - $this->outputWriter->write("\n" . sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version) . "\n"); |
|
| 288 | + $this->outputWriter->write("\n".sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version)."\n"); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | $this->state = self::STATE_EXEC; |
@@ -298,9 +298,9 @@ discard block |
||
| 298 | 298 | $this->executeRegisteredSql($dryRun, $timeAllQueries); |
| 299 | 299 | |
| 300 | 300 | $this->state = self::STATE_POST; |
| 301 | - $this->migration->{'post' . ucfirst($direction)}($toSchema); |
|
| 301 | + $this->migration->{'post'.ucfirst($direction)}($toSchema); |
|
| 302 | 302 | |
| 303 | - if ( ! $dryRun) { |
|
| 303 | + if (!$dryRun) { |
|
| 304 | 304 | if ($direction === self::DIRECTION_UP) { |
| 305 | 305 | $this->markMigrated(); |
| 306 | 306 | } else { |
@@ -408,13 +408,13 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | private function executeRegisteredSql($dryRun = false, $timeAllQueries = false) |
| 410 | 410 | { |
| 411 | - if ( ! $dryRun) { |
|
| 412 | - if ( ! empty($this->sql)) { |
|
| 411 | + if (!$dryRun) { |
|
| 412 | + if (!empty($this->sql)) { |
|
| 413 | 413 | foreach ($this->sql as $key => $query) { |
| 414 | 414 | $queryStart = microtime(true); |
| 415 | 415 | |
| 416 | - if ( ! isset($this->params[$key])) { |
|
| 417 | - $this->outputWriter->write(' <comment>-></comment> ' . $query); |
|
| 416 | + if (!isset($this->params[$key])) { |
|
| 417 | + $this->outputWriter->write(' <comment>-></comment> '.$query); |
|
| 418 | 418 | $this->connection->executeQuery($query); |
| 419 | 419 | } else { |
| 420 | 420 | $this->outputWriter->write(sprintf(' <comment>-</comment> %s (with parameters)', $query)); |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | |
| 38 | 38 | public function __construct($em) |
| 39 | 39 | { |
| 40 | - if ( ! $this->isEntityManager($em)) { |
|
| 40 | + if (!$this->isEntityManager($em)) { |
|
| 41 | 41 | throw new \InvalidArgumentException(sprintf( |
| 42 | 42 | '$em is not a valid Doctrine ORM Entity Manager, got "%s"', |
| 43 | 43 | is_object($em) ? get_class($em) : gettype($em) |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | return $this->proxyFactory->createProxy( |
| 72 | 72 | Schema::class, |
| 73 | - function (& $wrappedObject, $proxy, $method, array $parameters, & $initializer) use ($originalSchemaManipulator) { |
|
| 73 | + function(& $wrappedObject, $proxy, $method, array $parameters, & $initializer) use ($originalSchemaManipulator) { |
|
| 74 | 74 | $initializer = null; |
| 75 | 75 | $wrappedObject = $originalSchemaManipulator->createFromSchema(); |
| 76 | 76 | |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | $originalSchemaManipulator = $this->originalSchemaManipulator; |
| 89 | 89 | |
| 90 | - if ($fromSchema instanceof LazyLoadingInterface && ! $fromSchema->isProxyInitialized()) { |
|
| 90 | + if ($fromSchema instanceof LazyLoadingInterface && !$fromSchema->isProxyInitialized()) { |
|
| 91 | 91 | return $this->proxyFactory->createProxy( |
| 92 | 92 | Schema::class, |
| 93 | - function (& $wrappedObject, $proxy, $method, array $parameters, & $initializer) use ($originalSchemaManipulator, $fromSchema) { |
|
| 93 | + function(& $wrappedObject, $proxy, $method, array $parameters, & $initializer) use ($originalSchemaManipulator, $fromSchema) { |
|
| 94 | 94 | $initializer = null; |
| 95 | 95 | $wrappedObject = $originalSchemaManipulator->createToSchema($fromSchema); |
| 96 | 96 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | public function getSqlDiffToMigrate(Schema $fromSchema, Schema $toSchema) |
| 112 | 112 | { |
| 113 | 113 | if ($toSchema instanceof LazyLoadingInterface |
| 114 | - && ! $toSchema->isProxyInitialized()) { |
|
| 114 | + && !$toSchema->isProxyInitialized()) { |
|
| 115 | 115 | return []; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $dir = $dir ? $dir : getcwd(); |
| 47 | 47 | $dir = rtrim($dir, '/'); |
| 48 | 48 | |
| 49 | - if ( ! file_exists($dir)) { |
|
| 49 | + if (!file_exists($dir)) { |
|
| 50 | 50 | throw new \InvalidArgumentException(sprintf('Migrations directory "%s" does not exist.', $dir)); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | private function appendDir($dir) |
| 66 | 66 | { |
| 67 | - return DIRECTORY_SEPARATOR . $dir; |
|
| 67 | + return DIRECTORY_SEPARATOR.$dir; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | private function createDirIfNotExists($dir) |
| 71 | 71 | { |
| 72 | - if ( ! file_exists($dir)) { |
|
| 72 | + if (!file_exists($dir)) { |
|
| 73 | 73 | mkdir($dir, 0755, true); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | $name = $configuration->getName(); |
| 79 | 79 | $name = $name ? $name : 'Doctrine Database Migrations'; |
| 80 | - $name = str_repeat(' ', 20) . $name . str_repeat(' ', 20); |
|
| 81 | - $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>'); |
|
| 82 | - $output->writeln('<question>' . $name . '</question>'); |
|
| 83 | - $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>'); |
|
| 80 | + $name = str_repeat(' ', 20).$name.str_repeat(' ', 20); |
|
| 81 | + $output->writeln('<question>'.str_repeat(' ', strlen($name)).'</question>'); |
|
| 82 | + $output->writeln('<question>'.$name.'</question>'); |
|
| 83 | + $output->writeln('<question>'.str_repeat(' ', strlen($name)).'</question>'); |
|
| 84 | 84 | $output->writeln(''); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function getMigrationConfiguration(InputInterface $input, OutputInterface $output) |
| 105 | 105 | { |
| 106 | - if ( ! $this->migrationConfiguration) { |
|
| 106 | + if (!$this->migrationConfiguration) { |
|
| 107 | 107 | if ($this->getHelperSet()->has('configuration') |
| 108 | 108 | && $this->getHelperSet()->get('configuration') instanceof ConfigurationHelper) { |
| 109 | 109 | $configHelper = $this->getHelperSet()->get('configuration'); |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function getOutputWriter(OutputInterface $output) |
| 136 | 136 | { |
| 137 | - if ( ! $this->outputWriter) { |
|
| 138 | - $this->outputWriter = new OutputWriter(function ($message) use ($output) { |
|
| 137 | + if (!$this->outputWriter) { |
|
| 138 | + $this->outputWriter = new OutputWriter(function($message) use ($output) { |
|
| 139 | 139 | return $output->writeln($message); |
| 140 | 140 | }); |
| 141 | 141 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | new ConnectionConfigurationLoader($this->configuration), |
| 164 | 164 | ] |
| 165 | 165 | ); |
| 166 | - $connection = $chainLoader->chosen(); |
|
| 166 | + $connection = $chainLoader->chosen(); |
|
| 167 | 167 | |
| 168 | 168 | if ($connection) { |
| 169 | 169 | return $this->connection = $connection; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $this->configuration = $this->getMigrationConfiguration($input, $output); |
| 94 | 94 | |
| 95 | - if ( ! $input->getOption('add') && ! $input->getOption('delete')) { |
|
| 95 | + if (!$input->getOption('add') && !$input->getOption('delete')) { |
|
| 96 | 96 | throw new \InvalidArgumentException('You must specify whether you want to --add or --delete the specified version.'); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -148,26 +148,26 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | private function mark($version, $all = false) |
| 150 | 150 | { |
| 151 | - if ( ! $this->configuration->hasVersion($version)) { |
|
| 151 | + if (!$this->configuration->hasVersion($version)) { |
|
| 152 | 152 | throw MigrationException::unknownMigrationVersion($version); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | $version = $this->configuration->getVersion($version); |
| 156 | 156 | if ($this->markMigrated && $this->configuration->hasVersionMigrated($version)) { |
| 157 | - if ( ! $all) { |
|
| 157 | + if (!$all) { |
|
| 158 | 158 | throw new \InvalidArgumentException(sprintf('The version "%s" already exists in the version table.', $version)); |
| 159 | 159 | } |
| 160 | 160 | $marked = true; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( ! $this->markMigrated && ! $this->configuration->hasVersionMigrated($version)) { |
|
| 164 | - if ( ! $all) { |
|
| 163 | + if (!$this->markMigrated && !$this->configuration->hasVersionMigrated($version)) { |
|
| 164 | + if (!$all) { |
|
| 165 | 165 | throw new \InvalidArgumentException(sprintf('The version "%s" does not exists in the version table.', $version)); |
| 166 | 166 | } |
| 167 | 167 | $marked = false; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( ! isset($marked)) { |
|
| 170 | + if (!isset($marked)) { |
|
| 171 | 171 | if ($this->markMigrated) { |
| 172 | 172 | $version->markMigrated(); |
| 173 | 173 | } else { |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | $replacements = [ |
| 110 | 110 | $configuration->getMigrationsNamespace(), |
| 111 | 111 | $version, |
| 112 | - $up ? " " . implode("\n ", explode("\n", $up)) : null, |
|
| 113 | - $down ? " " . implode("\n ", explode("\n", $down)) : null, |
|
| 112 | + $up ? " ".implode("\n ", explode("\n", $up)) : null, |
|
| 113 | + $down ? " ".implode("\n ", explode("\n", $down)) : null, |
|
| 114 | 114 | ]; |
| 115 | 115 | |
| 116 | 116 | $code = str_replace($placeHolders, $replacements, $this->getTemplate()); |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $directoryHelper = new MigrationDirectoryHelper($configuration); |
| 120 | 120 | $dir = $directoryHelper->getMigrationDirectory(); |
| 121 | - $path = $dir . '/Version' . $version . '.php'; |
|
| 121 | + $path = $dir.'/Version'.$version.'.php'; |
|
| 122 | 122 | |
| 123 | 123 | file_put_contents($path, $code); |
| 124 | 124 | |
| 125 | 125 | if ($editorCmd = $input->getOption('editor-cmd')) { |
| 126 | - proc_open($editorCmd . ' ' . escapeshellarg($path), [], $pipes); |
|
| 126 | + proc_open($editorCmd.' '.escapeshellarg($path), [], $pipes); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return $path; |
@@ -93,16 +93,16 @@ discard block |
||
| 93 | 93 | $toSchema = $this->getSchemaProvider()->createSchema(); |
| 94 | 94 | |
| 95 | 95 | //Not using value from options, because filters can be set from config.yml |
| 96 | - if ( ! $isDbalOld && $filterExpr = $conn->getConfiguration()->getFilterSchemaAssetsExpression()) { |
|
| 96 | + if (!$isDbalOld && $filterExpr = $conn->getConfiguration()->getFilterSchemaAssetsExpression()) { |
|
| 97 | 97 | foreach ($toSchema->getTables() as $table) { |
| 98 | 98 | $tableName = $table->getName(); |
| 99 | - if ( ! preg_match($filterExpr, $this->resolveTableName($tableName))) { |
|
| 99 | + if (!preg_match($filterExpr, $this->resolveTableName($tableName))) { |
|
| 100 | 100 | $toSchema->dropTable($tableName); |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $up = $this->buildCodeFromSql( |
|
| 105 | + $up = $this->buildCodeFromSql( |
|
| 106 | 106 | $configuration, |
| 107 | 107 | $fromSchema->getMigrateToSql($toSchema, $platform), |
| 108 | 108 | $input->getOption('formatted'), |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $input->getOption('line-length') |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - if ( ! $up && ! $down) { |
|
| 118 | + if (!$up && !$down) { |
|
| 119 | 119 | $output->writeln('No changes detected in your mapping information.'); |
| 120 | 120 | |
| 121 | 121 | return; |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | if ($formatted) { |
| 141 | - if ( ! class_exists('\SqlFormatter')) { |
|
| 141 | + if (!class_exists('\SqlFormatter')) { |
|
| 142 | 142 | throw new \InvalidArgumentException( |
| 143 | - 'The "--formatted" option can only be used if the sql formatter is installed.' . |
|
| 143 | + 'The "--formatted" option can only be used if the sql formatter is installed.'. |
|
| 144 | 144 | 'Please run "composer require jdorn/sql-formatter".' |
| 145 | 145 | ); |
| 146 | 146 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $code[] = sprintf("\$this->addSql(%s);", var_export($query, true)); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if ( ! empty($code)) { |
|
| 158 | + if (!empty($code)) { |
|
| 159 | 159 | array_unshift( |
| 160 | 160 | $code, |
| 161 | 161 | sprintf( |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | private function getSchemaProvider() |
| 174 | 174 | { |
| 175 | - if ( ! $this->schemaProvider) { |
|
| 175 | + if (!$this->schemaProvider) { |
|
| 176 | 176 | $this->schemaProvider = new OrmSchemaProvider($this->getHelper('entityManager')->getEntityManager()); |
| 177 | 177 | } |
| 178 | 178 | |