Passed
Push — master ( 9a6d60...09efdf )
by Morris
12:40 queued 01:53
created
lib/private/RichObjectStrings/Validator.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -34,81 +34,81 @@
 block discarded – undo
34 34
  */
35 35
 class Validator implements IValidator {
36 36
 
37
-	/** @var Definitions */
38
-	protected $definitions;
39
-
40
-	/** @var array[] */
41
-	protected $requiredParameters = [];
42
-
43
-	/**
44
-	 * Constructor
45
-	 *
46
-	 * @param Definitions $definitions
47
-	 */
48
-	public function __construct(Definitions $definitions) {
49
-		$this->definitions = $definitions;
50
-	}
51
-
52
-	/**
53
-	 * @param string $subject
54
-	 * @param array[] $parameters
55
-	 * @throws InvalidObjectExeption
56
-	 * @since 11.0.0
57
-	 */
58
-	public function validate($subject, array $parameters) {
59
-		$matches = [];
60
-		$result = preg_match_all('/\{([a-z0-9]+)\}/i', $subject, $matches);
61
-
62
-		if ($result === false) {
63
-			throw new InvalidObjectExeption();
64
-		}
65
-
66
-		if (!empty($matches[1])) {
67
-			foreach ($matches[1] as $parameter) {
68
-				if (!isset($parameters[$parameter])) {
69
-					throw new InvalidObjectExeption('Parameter is undefined');
70
-				} else {
71
-					$this->validateParameter($parameters[$parameter]);
72
-				}
73
-			}
74
-		}
75
-	}
76
-
77
-	/**
78
-	 * @param array $parameter
79
-	 * @throws InvalidObjectExeption
80
-	 */
81
-	protected function validateParameter(array $parameter) {
82
-		if (!isset($parameter['type'])) {
83
-			throw new InvalidObjectExeption('Object type is undefined');
84
-		}
85
-
86
-		$definition = $this->definitions->getDefinition($parameter['type']);
87
-		$requiredParameters = $this->getRequiredParameters($parameter['type'], $definition);
88
-
89
-		$missingKeys = array_diff($requiredParameters, array_keys($parameter));
90
-		if (!empty($missingKeys)) {
91
-			throw new InvalidObjectExeption('Object is invalid');
92
-		}
93
-	}
94
-
95
-	/**
96
-	 * @param string $type
97
-	 * @param array $definition
98
-	 * @return string[]
99
-	 */
100
-	protected function getRequiredParameters($type, array $definition) {
101
-		if (isset($this->requiredParameters[$type])) {
102
-			return $this->requiredParameters[$type];
103
-		}
104
-
105
-		$this->requiredParameters[$type] = [];
106
-		foreach ($definition['parameters'] as $parameter => $data) {
107
-			if ($data['required']) {
108
-				$this->requiredParameters[$type][] = $parameter;
109
-			}
110
-		}
111
-
112
-		return $this->requiredParameters[$type];
113
-	}
37
+    /** @var Definitions */
38
+    protected $definitions;
39
+
40
+    /** @var array[] */
41
+    protected $requiredParameters = [];
42
+
43
+    /**
44
+     * Constructor
45
+     *
46
+     * @param Definitions $definitions
47
+     */
48
+    public function __construct(Definitions $definitions) {
49
+        $this->definitions = $definitions;
50
+    }
51
+
52
+    /**
53
+     * @param string $subject
54
+     * @param array[] $parameters
55
+     * @throws InvalidObjectExeption
56
+     * @since 11.0.0
57
+     */
58
+    public function validate($subject, array $parameters) {
59
+        $matches = [];
60
+        $result = preg_match_all('/\{([a-z0-9]+)\}/i', $subject, $matches);
61
+
62
+        if ($result === false) {
63
+            throw new InvalidObjectExeption();
64
+        }
65
+
66
+        if (!empty($matches[1])) {
67
+            foreach ($matches[1] as $parameter) {
68
+                if (!isset($parameters[$parameter])) {
69
+                    throw new InvalidObjectExeption('Parameter is undefined');
70
+                } else {
71
+                    $this->validateParameter($parameters[$parameter]);
72
+                }
73
+            }
74
+        }
75
+    }
76
+
77
+    /**
78
+     * @param array $parameter
79
+     * @throws InvalidObjectExeption
80
+     */
81
+    protected function validateParameter(array $parameter) {
82
+        if (!isset($parameter['type'])) {
83
+            throw new InvalidObjectExeption('Object type is undefined');
84
+        }
85
+
86
+        $definition = $this->definitions->getDefinition($parameter['type']);
87
+        $requiredParameters = $this->getRequiredParameters($parameter['type'], $definition);
88
+
89
+        $missingKeys = array_diff($requiredParameters, array_keys($parameter));
90
+        if (!empty($missingKeys)) {
91
+            throw new InvalidObjectExeption('Object is invalid');
92
+        }
93
+    }
94
+
95
+    /**
96
+     * @param string $type
97
+     * @param array $definition
98
+     * @return string[]
99
+     */
100
+    protected function getRequiredParameters($type, array $definition) {
101
+        if (isset($this->requiredParameters[$type])) {
102
+            return $this->requiredParameters[$type];
103
+        }
104
+
105
+        $this->requiredParameters[$type] = [];
106
+        foreach ($definition['parameters'] as $parameter => $data) {
107
+            if ($data['required']) {
108
+                $this->requiredParameters[$type][] = $parameter;
109
+            }
110
+        }
111
+
112
+        return $this->requiredParameters[$type];
113
+    }
114 114
 }
Please login to merge, or discard this patch.
lib/private/DB/AdapterOCI8.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 		}
34 34
 		if ($table !== null) {
35 35
 			$suffix = '_SEQ';
36
-			$table = '"' . $table . $suffix . '"';
36
+			$table = '"'.$table.$suffix.'"';
37 37
 		}
38 38
 		return $this->conn->realLastInsertId($table);
39 39
 	}
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -27,24 +27,24 @@
 block discarded – undo
27 27
 namespace OC\DB;
28 28
 
29 29
 class AdapterOCI8 extends Adapter {
30
-	public function lastInsertId($table) {
31
-		if (is_null($table)) {
32
-			throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()');
33
-		}
34
-		if ($table !== null) {
35
-			$suffix = '_SEQ';
36
-			$table = '"' . $table . $suffix . '"';
37
-		}
38
-		return $this->conn->realLastInsertId($table);
39
-	}
30
+    public function lastInsertId($table) {
31
+        if (is_null($table)) {
32
+            throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()');
33
+        }
34
+        if ($table !== null) {
35
+            $suffix = '_SEQ';
36
+            $table = '"' . $table . $suffix . '"';
37
+        }
38
+        return $this->conn->realLastInsertId($table);
39
+    }
40 40
 
41
-	const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
41
+    const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
42 42
 
43
-	public function fixupStatement($statement) {
44
-		$statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement);
45
-		$statement = str_replace('`', '"', $statement);
46
-		$statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement);
47
-		$statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement);
48
-		return $statement;
49
-	}
43
+    public function fixupStatement($statement) {
44
+        $statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement);
45
+        $statement = str_replace('`', '"', $statement);
46
+        $statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement);
47
+        $statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement);
48
+        return $statement;
49
+    }
50 50
 }
Please login to merge, or discard this patch.
lib/private/DB/MySQLMigrator.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -29,28 +29,28 @@
 block discarded – undo
29 29
 use Doctrine\DBAL\Schema\Table;
30 30
 
31 31
 class MySQLMigrator extends Migrator {
32
-	/**
33
-	 * @param Schema $targetSchema
34
-	 * @param \Doctrine\DBAL\Connection $connection
35
-	 * @return \Doctrine\DBAL\Schema\SchemaDiff
36
-	 */
37
-	protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
38
-		$platform = $connection->getDatabasePlatform();
39
-		$platform->registerDoctrineTypeMapping('enum', 'string');
40
-		$platform->registerDoctrineTypeMapping('bit', 'string');
32
+    /**
33
+     * @param Schema $targetSchema
34
+     * @param \Doctrine\DBAL\Connection $connection
35
+     * @return \Doctrine\DBAL\Schema\SchemaDiff
36
+     */
37
+    protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
38
+        $platform = $connection->getDatabasePlatform();
39
+        $platform->registerDoctrineTypeMapping('enum', 'string');
40
+        $platform->registerDoctrineTypeMapping('bit', 'string');
41 41
 
42
-		$schemaDiff = parent::getDiff($targetSchema, $connection);
42
+        $schemaDiff = parent::getDiff($targetSchema, $connection);
43 43
 
44
-		// identifiers need to be quoted for mysql
45
-		foreach ($schemaDiff->changedTables as $tableDiff) {
46
-			$tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
47
-			foreach ($tableDiff->changedColumns as $column) {
48
-				$column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
49
-			}
50
-		}
44
+        // identifiers need to be quoted for mysql
45
+        foreach ($schemaDiff->changedTables as $tableDiff) {
46
+            $tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
47
+            foreach ($tableDiff->changedColumns as $column) {
48
+                $column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
49
+            }
50
+        }
51 51
 
52
-		return $schemaDiff;
53
-	}
52
+        return $schemaDiff;
53
+    }
54 54
 	
55 55
         /**
56 56
          * Speed up migration test by disabling autocommit and unique indexes check
Please login to merge, or discard this patch.
lib/private/DB/OCSqlitePlatform.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -23,27 +23,27 @@
 block discarded – undo
23 23
 namespace OC\DB;
24 24
 
25 25
 class OCSqlitePlatform extends \Doctrine\DBAL\Platforms\SqlitePlatform {
26
-	/**
27
-	 * {@inheritDoc}
28
-	 */
29
-	public function getColumnDeclarationSQL($name, array $field) {
30
-		$def = parent::getColumnDeclarationSQL($name, $field);
31
-		if (!empty($field['autoincrement'])) {
32
-			$def .= ' PRIMARY KEY AUTOINCREMENT';
33
-		}
34
-		return $def;
35
-	}
26
+    /**
27
+     * {@inheritDoc}
28
+     */
29
+    public function getColumnDeclarationSQL($name, array $field) {
30
+        $def = parent::getColumnDeclarationSQL($name, $field);
31
+        if (!empty($field['autoincrement'])) {
32
+            $def .= ' PRIMARY KEY AUTOINCREMENT';
33
+        }
34
+        return $def;
35
+    }
36 36
 
37
-	/**
38
-	 * {@inheritDoc}
39
-	 */
40
-	protected function _getCreateTableSQL($name, array $columns, array $options = array()){
41
-		// if auto increment is set the column is already defined as primary key
42
-		foreach ($columns as $column) {
43
-			if (!empty($column['autoincrement'])) {
44
-				$options['primary'] = null;
45
-			}
46
-		}
47
-		return parent::_getCreateTableSQL($name, $columns, $options);
48
-	}
37
+    /**
38
+     * {@inheritDoc}
39
+     */
40
+    protected function _getCreateTableSQL($name, array $columns, array $options = array()){
41
+        // if auto increment is set the column is already defined as primary key
42
+        foreach ($columns as $column) {
43
+            if (!empty($column['autoincrement'])) {
44
+                $options['primary'] = null;
45
+            }
46
+        }
47
+        return parent::_getCreateTableSQL($name, $columns, $options);
48
+    }
49 49
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
 	/**
38 38
 	 * {@inheritDoc}
39 39
 	 */
40
-	protected function _getCreateTableSQL($name, array $columns, array $options = array()){
40
+	protected function _getCreateTableSQL($name, array $columns, array $options = array()) {
41 41
 		// if auto increment is set the column is already defined as primary key
42 42
 		foreach ($columns as $column) {
43 43
 			if (!empty($column['autoincrement'])) {
Please login to merge, or discard this patch.
lib/private/DB/QueryBuilder/QueryFunction.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
 use OCP\DB\QueryBuilder\IQueryFunction;
26 26
 
27 27
 class QueryFunction implements IQueryFunction {
28
-	/** @var string */
29
-	protected $function;
28
+    /** @var string */
29
+    protected $function;
30 30
 
31
-	public function __construct($function) {
32
-		$this->function = $function;
33
-	}
31
+    public function __construct($function) {
32
+        $this->function = $function;
33
+    }
34 34
 
35
-	/**
36
-	 * @return string
37
-	 */
38
-	public function __toString() {
39
-		return (string) $this->function;
40
-	}
35
+    /**
36
+     * @return string
37
+     */
38
+    public function __toString() {
39
+        return (string) $this->function;
40
+    }
41 41
 }
Please login to merge, or discard this patch.
lib/private/DB/QueryBuilder/CompositeExpression.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -25,69 +25,69 @@
 block discarded – undo
25 25
 use OCP\DB\QueryBuilder\ICompositeExpression;
26 26
 
27 27
 class CompositeExpression implements ICompositeExpression, \Countable {
28
-	/** @var \Doctrine\DBAL\Query\Expression\CompositeExpression */
29
-	protected $compositeExpression;
28
+    /** @var \Doctrine\DBAL\Query\Expression\CompositeExpression */
29
+    protected $compositeExpression;
30 30
 
31
-	/**
32
-	 * Constructor.
33
-	 *
34
-	 * @param \Doctrine\DBAL\Query\Expression\CompositeExpression $compositeExpression
35
-	 */
36
-	public function __construct(\Doctrine\DBAL\Query\Expression\CompositeExpression $compositeExpression) {
37
-		$this->compositeExpression = $compositeExpression;
38
-	}
31
+    /**
32
+     * Constructor.
33
+     *
34
+     * @param \Doctrine\DBAL\Query\Expression\CompositeExpression $compositeExpression
35
+     */
36
+    public function __construct(\Doctrine\DBAL\Query\Expression\CompositeExpression $compositeExpression) {
37
+        $this->compositeExpression = $compositeExpression;
38
+    }
39 39
 
40
-	/**
41
-	 * Adds multiple parts to composite expression.
42
-	 *
43
-	 * @param array $parts
44
-	 *
45
-	 * @return \OCP\DB\QueryBuilder\ICompositeExpression
46
-	 */
47
-	public function addMultiple(array $parts = array()) {
48
-		$this->compositeExpression->addMultiple($parts);
40
+    /**
41
+     * Adds multiple parts to composite expression.
42
+     *
43
+     * @param array $parts
44
+     *
45
+     * @return \OCP\DB\QueryBuilder\ICompositeExpression
46
+     */
47
+    public function addMultiple(array $parts = array()) {
48
+        $this->compositeExpression->addMultiple($parts);
49 49
 
50
-		return $this;
51
-	}
50
+        return $this;
51
+    }
52 52
 
53
-	/**
54
-	 * Adds an expression to composite expression.
55
-	 *
56
-	 * @param mixed $part
57
-	 *
58
-	 * @return \OCP\DB\QueryBuilder\ICompositeExpression
59
-	 */
60
-	public function add($part) {
61
-		$this->compositeExpression->add($part);
53
+    /**
54
+     * Adds an expression to composite expression.
55
+     *
56
+     * @param mixed $part
57
+     *
58
+     * @return \OCP\DB\QueryBuilder\ICompositeExpression
59
+     */
60
+    public function add($part) {
61
+        $this->compositeExpression->add($part);
62 62
 
63
-		return $this;
64
-	}
63
+        return $this;
64
+    }
65 65
 
66
-	/**
67
-	 * Retrieves the amount of expressions on composite expression.
68
-	 *
69
-	 * @return integer
70
-	 */
71
-	public function count() {
72
-		return $this->compositeExpression->count();
73
-	}
66
+    /**
67
+     * Retrieves the amount of expressions on composite expression.
68
+     *
69
+     * @return integer
70
+     */
71
+    public function count() {
72
+        return $this->compositeExpression->count();
73
+    }
74 74
 
75
-	/**
76
-	 * Returns the type of this composite expression (AND/OR).
77
-	 *
78
-	 * @return string
79
-	 */
80
-	public function getType() {
81
-		return $this->compositeExpression->getType();
82
-	}
75
+    /**
76
+     * Returns the type of this composite expression (AND/OR).
77
+     *
78
+     * @return string
79
+     */
80
+    public function getType() {
81
+        return $this->compositeExpression->getType();
82
+    }
83 83
 
84
-	/**
85
-	 * Retrieves the string representation of this composite expression.
86
-	 *
87
-	 * @return string
88
-	 */
89
-	public function __toString()
90
-	{
91
-		return (string) $this->compositeExpression;
92
-	}
84
+    /**
85
+     * Retrieves the string representation of this composite expression.
86
+     *
87
+     * @return string
88
+     */
89
+    public function __toString()
90
+    {
91
+        return (string) $this->compositeExpression;
92
+    }
93 93
 }
Please login to merge, or discard this patch.
lib/private/DB/QueryBuilder/Literal.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
 use OCP\DB\QueryBuilder\ILiteral;
26 26
 
27 27
 class Literal implements ILiteral{
28
-	/** @var mixed */
29
-	protected $literal;
28
+    /** @var mixed */
29
+    protected $literal;
30 30
 
31
-	public function __construct($literal) {
32
-		$this->literal = $literal;
33
-	}
31
+    public function __construct($literal) {
32
+        $this->literal = $literal;
33
+    }
34 34
 
35
-	/**
36
-	 * @return string
37
-	 */
38
-	public function __toString() {
39
-		return (string) $this->literal;
40
-	}
35
+    /**
36
+     * @return string
37
+     */
38
+    public function __toString() {
39
+        return (string) $this->literal;
40
+    }
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
 use OCP\DB\QueryBuilder\ILiteral;
26 26
 
27
-class Literal implements ILiteral{
27
+class Literal implements ILiteral {
28 28
 	/** @var mixed */
29 29
 	protected $literal;
30 30
 
Please login to merge, or discard this patch.
lib/private/DB/QueryBuilder/Parameter.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
 use OCP\DB\QueryBuilder\IParameter;
26 26
 
27 27
 class Parameter implements IParameter {
28
-	/** @var mixed */
29
-	protected $name;
28
+    /** @var mixed */
29
+    protected $name;
30 30
 
31
-	public function __construct($name) {
32
-		$this->name = $name;
33
-	}
31
+    public function __construct($name) {
32
+        $this->name = $name;
33
+    }
34 34
 
35
-	/**
36
-	 * @return string
37
-	 */
38
-	public function __toString() {
39
-		return (string) $this->name;
40
-	}
35
+    /**
36
+     * @return string
37
+     */
38
+    public function __toString() {
39
+        return (string) $this->name;
40
+    }
41 41
 }
Please login to merge, or discard this patch.
lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 	public function iLike($x, $y, $type = null) {
49 49
 		$x = $this->helper->quoteColumnName($x);
50 50
 		$y = $this->helper->quoteColumnName($y);
51
-		return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->charset . '_general_ci LIKE', $y);
51
+		return $this->expressionBuilder->comparison($x, ' COLLATE '.$this->charset.'_general_ci LIKE', $y);
52 52
 	}
53 53
 
54 54
 }
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,27 +30,27 @@
 block discarded – undo
30 30
 
31 31
 class MySqlExpressionBuilder extends ExpressionBuilder {
32 32
 
33
-	/** @var string */
34
-	protected $charset;
35
-
36
-	/**
37
-	 * @param \OCP\IDBConnection|Connection $connection
38
-	 * @param IQueryBuilder $queryBuilder
39
-	 */
40
-	public function __construct(IDBConnection $connection, IQueryBuilder $queryBuilder) {
41
-		parent::__construct($connection, $queryBuilder);
42
-
43
-		$params = $connection->getParams();
44
-		$this->charset = isset($params['charset']) ? $params['charset'] : 'utf8';
45
-	}
46
-
47
-	/**
48
-	 * @inheritdoc
49
-	 */
50
-	public function iLike($x, $y, $type = null) {
51
-		$x = $this->helper->quoteColumnName($x);
52
-		$y = $this->helper->quoteColumnName($y);
53
-		return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->charset . '_general_ci LIKE', $y);
54
-	}
33
+    /** @var string */
34
+    protected $charset;
35
+
36
+    /**
37
+     * @param \OCP\IDBConnection|Connection $connection
38
+     * @param IQueryBuilder $queryBuilder
39
+     */
40
+    public function __construct(IDBConnection $connection, IQueryBuilder $queryBuilder) {
41
+        parent::__construct($connection, $queryBuilder);
42
+
43
+        $params = $connection->getParams();
44
+        $this->charset = isset($params['charset']) ? $params['charset'] : 'utf8';
45
+    }
46
+
47
+    /**
48
+     * @inheritdoc
49
+     */
50
+    public function iLike($x, $y, $type = null) {
51
+        $x = $this->helper->quoteColumnName($x);
52
+        $y = $this->helper->quoteColumnName($y);
53
+        return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->charset . '_general_ci LIKE', $y);
54
+    }
55 55
 
56 56
 }
Please login to merge, or discard this patch.