Skip to content

Commit b25c4ee

Browse files
authored
Merge pull request #9072 from nextcloud/carl/fix-psalm
fix: Mark tableName and columnName as non-empty-string
2 parents cc5493c + b92edff commit b25c4ee

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

lib/Migration/Version030201Date20201116110353.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@
1111

1212
use Closure;
1313
use OCP\DB\ISchemaWrapper;
14-
use OCP\IConfig;
14+
use OCP\IDBConnection;
1515
use OCP\Migration\IOutput;
1616
use OCP\Migration\SimpleMigrationStep;
1717

1818
class Version030201Date20201116110353 extends SimpleMigrationStep {
19+
private readonly bool $isOracle;
1920

20-
/** @var bool */
21-
private $isOracle;
22-
23-
public function __construct(IConfig $config) {
24-
$this->isOracle = $config->getSystemValue('dbtype', 'sqlite') === 'oci';
21+
public function __construct(IDBConnection $connection) {
22+
$this->isOracle = $connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE;
2523
}
2624

2725
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
@@ -50,6 +48,10 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
5048
return $schema;
5149
}
5250

51+
/**
52+
* @param non-empty-string $tableName
53+
* @param non-empty-string $columnName
54+
*/
5355
protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool {
5456
$table = $schema->getTable($tableName);
5557
$column = $table->getColumn($columnName);

lib/Migration/Version030201Date20201116123153.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
use Closure;
1313
use OCP\DB\ISchemaWrapper;
1414
use OCP\DB\Types;
15-
use OCP\IConfig;
15+
use OCP\IDBConnection;
1616
use OCP\Migration\IOutput;
1717
use OCP\Migration\SimpleMigrationStep;
1818

1919
class Version030201Date20201116123153 extends SimpleMigrationStep {
20+
private readonly bool $isOracle;
2021

21-
/** @var bool */
22-
private $isOracle;
23-
24-
public function __construct(IConfig $config) {
25-
$this->isOracle = $config->getSystemValue('dbtype', 'sqlite') === 'oci';
22+
public function __construct(IDBConnection $connection) {
23+
$this->isOracle = $connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE;
2624
}
2725

2826
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {

0 commit comments

Comments
 (0)