Completed
Push — master ( 1dac85...36b017 )
by Thomas
16s
created

Version20181022150134::sql()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 14
cp 0
rs 9.7333
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
/**
3
 * @author Vincent Petry <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2018, ownCloud GmbH
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
22
namespace OCA\activity\Migrations;
23
24
use OCP\Migration\ISqlMigration;
25
use Doctrine\DBAL\Platforms\MySqlPlatform;
26
use Doctrine\DBAL\Platforms\SqlitePlatform;
27
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
28
use OCP\IDBConnection;
29
30
/**
31
 * Adds migrations that were missing when running update.
32
 *
33
 * - set type to "longtext" for "subjectparams" and "messageparams" by increasing length
34
 *
35
 */
36
class Version20181022150134 implements ISqlMigration {
37
38
	/**
39
	 * @param Schema $schema
0 ignored issues
show
Bug introduced by
There is no parameter named $schema. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
40
	 * @param array $options
0 ignored issues
show
Bug introduced by
There is no parameter named $options. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
41
	 */
42
	public function sql(IDBConnection $connection) {
43
		$platform = $connection->getDatabasePlatform();
44
		$tableName = "*PREFIX*activity";
45
		$tableName = $connection->getDatabasePlatform()->quoteIdentifier($tableName);
46
		
47
		if ($platform instanceof MySqlPlatform) {
0 ignored issues
show
Bug introduced by
The class Doctrine\DBAL\Platforms\MySqlPlatform does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
48
			$sqls = [
49
				"ALTER TABLE $tableName MODIFY COLUMN `subjectparams` LONGTEXT NOT NULL",
50
				"ALTER TABLE $tableName MODIFY COLUMN `messageparams` LONGTEXT NULL",
51
			];
52
		} else {
53
			$sqls = [];
54
		}
55
56
		return $sqls;
57
	}
58
}
59