| Conditions | 10 |
| Paths | 12 |
| Total Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 65 | protected function execute(InputInterface $input, OutputInterface $output): int { |
||
| 66 | $schema = new SchemaWrapper($this->connection); |
||
| 67 | $isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform; |
||
| 68 | $updates = []; |
||
| 69 | |||
| 70 | $tables = $this->getColumnsByTable(); |
||
| 71 | foreach ($tables as $tableName => $columns) { |
||
| 72 | if (!$schema->hasTable($tableName)) { |
||
| 73 | continue; |
||
| 74 | } |
||
| 75 | |||
| 76 | $table = $schema->getTable($tableName); |
||
| 77 | |||
| 78 | foreach ($columns as $columnName) { |
||
| 79 | $column = $table->getColumn($columnName); |
||
| 80 | $isAutoIncrement = $column->getAutoincrement(); |
||
| 81 | $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement; |
||
| 82 | if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) { |
||
| 83 | $column->setType(Type::getType(Types::BIGINT)); |
||
| 84 | $column->setOptions(['length' => 20]); |
||
| 85 | $column->setUnsigned(true); |
||
| 86 | |||
| 87 | $updates[] = '* ' . $tableName . '.' . $columnName; |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } |
||
| 91 | |||
| 92 | if (empty($updates)) { |
||
| 93 | $output->writeln('<info>All tables already up to date!</info>'); |
||
| 94 | return 0; |
||
| 95 | } |
||
| 96 | |||
| 97 | $output->writeln('<comment>Following columns will be updated:</comment>'); |
||
| 98 | $output->writeln(''); |
||
| 99 | $output->writeln($updates); |
||
| 100 | $output->writeln(''); |
||
| 101 | $output->writeln('<comment>This can take up to hours, depending on the number of Collabora WOPI tokens in your instance!</comment>'); |
||
| 102 | |||
| 103 | if ($input->isInteractive()) { |
||
| 104 | $helper = $this->getHelper('question'); |
||
| 105 | $question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false); |
||
| 106 | |||
| 107 | if (!$helper->ask($input, $output, $question)) { |
||
| 108 | return 1; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | |||
| 112 | $this->connection->migrateToSchema($schema->getWrappedSchema()); |
||
| 113 | |||
| 114 | return 0; |
||
| 115 | } |
||
| 116 | } |
||
| 117 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..