@@ -51,7 +51,7 @@ |
||
| 51 | 51 | ($value !== $this->getBoolean(true) && $value !== $this->getBoolean(false)) |
| 52 | 52 | ) { |
| 53 | 53 | // value is not boolean, not int and (not string OR string value for boolean) |
| 54 | - return new NoBoolean([ 'value' => (string) $value ]); |
|
| 54 | + return new NoBoolean(['value' => (string) $value]); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | public function validate($value) |
| 24 | 24 | { |
| 25 | 25 | if (!is_int($value) && !is_double($value) && (!is_string($value) || !is_numeric($value))) { |
| 26 | - return new NoNumber([ 'value' => (string) $value ]); |
|
| 26 | + return new NoNumber(['value' => (string) $value]); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | return true; |
@@ -35,8 +35,7 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | $this->precision = (int) $precision; |
| 37 | 37 | $this->regex = $dateOnly ? |
| 38 | - '/^' . self::DATE_REGEX . '([ T]' . self::TIME_REGEX . self::ZONE_REGEX . ')?$/' : |
|
| 39 | - '/^' . self::DATE_REGEX . '[ T]' . self::TIME_REGEX . self::ZONE_REGEX . '$/'; |
|
| 38 | + '/^' . self::DATE_REGEX . '([ T]' . self::TIME_REGEX . self::ZONE_REGEX . ')?$/' : '/^' . self::DATE_REGEX . '[ T]' . self::TIME_REGEX . self::ZONE_REGEX . '$/'; |
|
| 40 | 39 | } |
| 41 | 40 | |
| 42 | 41 | public static function factory(Dbal $dbal, array $columnDefinition) |
@@ -56,7 +55,7 @@ discard block |
||
| 56 | 55 | public function validate($value) |
| 57 | 56 | { |
| 58 | 57 | if (!$value instanceof \DateTime && (!is_string($value) || !preg_match($this->regex, $value))) { |
| 59 | - return new NoDateTime([ 'value' => (string) $value ]); |
|
| 58 | + return new NoDateTime(['value' => (string) $value]); |
|
| 60 | 59 | } |
| 61 | 60 | |
| 62 | 61 | return true; |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | return new Error([], 'DATETIME', 'DateTime is not allowed for time'); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - return new NoTime([ 'value' => (string) $value ]); |
|
| 35 | + return new NoTime(['value' => (string) $value]); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return true; |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | $statement = 'UPDATE ' . $this->escapeIdentifier($entity::getTableName()) . ' ' . |
| 167 | - 'SET ' . implode(',', $set) . ' ' . |
|
| 168 | - 'WHERE ' . implode(' AND ', $where); |
|
| 167 | + 'SET ' . implode(',', $set) . ' ' . |
|
| 168 | + 'WHERE ' . implode(' AND ', $where); |
|
| 169 | 169 | $this->entityManager->getConnection()->query($statement); |
| 170 | 170 | |
| 171 | 171 | return $this->entityManager->sync($entity, true); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | $statement = 'DELETE FROM ' . $this->escapeIdentifier($entity::getTableName()) . ' ' . |
| 192 | - 'WHERE ' . implode(' AND ', $where); |
|
| 192 | + 'WHERE ' . implode(' AND ', $where); |
|
| 193 | 193 | $this->entityManager->getConnection()->query($statement); |
| 194 | 194 | |
| 195 | 195 | return true; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | ); |
| 221 | 221 | |
| 222 | 222 | $statement = 'INSERT INTO ' . $this->escapeIdentifier($entity::getTableName()) . ' ' . |
| 223 | - '(' . implode(',', $cols) . ') VALUES (' . implode(',', $values) . ')'; |
|
| 223 | + '(' . implode(',', $cols) . ') VALUES (' . implode(',', $values) . ')'; |
|
| 224 | 224 | |
| 225 | 225 | return $statement; |
| 226 | 226 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | public function escapeValue($value) |
| 97 | 97 | { |
| 98 | 98 | $type = is_object($value) ? get_class($value) : gettype($value); |
| 99 | - $method = [ $this, 'escape' . ucfirst($type) ]; |
|
| 99 | + $method = [$this, 'escape' . ucfirst($type)]; |
|
| 100 | 100 | |
| 101 | 101 | if (is_callable($method)) { |
| 102 | 102 | return call_user_func($method, $value); |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $var = $entity::getPrimaryKeyVars()[0]; |
| 237 | 237 | $column = $entity::getColumnName($var); |
| 238 | 238 | |
| 239 | - $entity->setOriginalData(array_merge($entity->getData(), [ $column => $value ])); |
|
| 239 | + $entity->setOriginalData(array_merge($entity->getData(), [$column => $value])); |
|
| 240 | 240 | $entity->__set($var, $value); |
| 241 | 241 | } |
| 242 | 242 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | protected static function getRegisteredType(array $columnDefinition) |
| 42 | 42 | { |
| 43 | 43 | foreach (self::$registeredTypes as $class) { |
| 44 | - if (call_user_func([ $class, 'fits' ], $columnDefinition)) { |
|
| 44 | + if (call_user_func([$class, 'fits'], $columnDefinition)) { |
|
| 45 | 45 | return $class; |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | $class = $this->columnDefinition['type']; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if ($class === null || !is_callable([ $class, 'factory' ])) { |
|
| 155 | + if ($class === null || !is_callable([$class, 'factory'])) { |
|
| 156 | 156 | $class = Type\Text::class; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $this->type = call_user_func([ $class, 'factory' ], $this->dbal, $this->columnDefinition); |
|
| 159 | + $this->type = call_user_func([$class, 'factory'], $this->dbal, $this->columnDefinition); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | return $this->type; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | if ($useAutoIncrement && $entity::isAutoIncremented()) { |
| 51 | 51 | $statement .= ' RETURNING ' . $entity::getColumnName($entity::getPrimaryKeyVars()[0]); |
| 52 | - $result = $pdo->query($statement); |
|
| 52 | + $result = $pdo->query($statement); |
|
| 53 | 53 | $this->updateAutoincrement($entity, $result->fetchColumn()); |
| 54 | 54 | } else { |
| 55 | 55 | $pdo->query($statement); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function describe($schemaTable) |
| 62 | 62 | { |
| 63 | 63 | $table = explode($this->identifierDivider, $schemaTable); |
| 64 | - list($schema, $table) = count($table) === 2 ? $table : [ 'public', $table[0] ]; |
|
| 64 | + list($schema, $table) = count($table) === 2 ? $table : ['public', $table[0]]; |
|
| 65 | 65 | |
| 66 | 66 | $query = new QueryBuilder('INFORMATION_SCHEMA.COLUMNS', '', $this->entityManager); |
| 67 | 67 | $query->where('table_name', $table)->andWhere('table_schema', $schema); |
@@ -92,8 +92,7 @@ |
||
| 92 | 92 | |
| 93 | 93 | $definition['column_name'] = $rawColumn['Field']; |
| 94 | 94 | $definition['is_nullable'] = $rawColumn['Null'] === 'YES'; |
| 95 | - $definition['column_default'] = $rawColumn['Default'] !== null ? $rawColumn['Default'] : |
|
| 96 | - ($rawColumn['Extra'] === 'auto_increment' ? 'sequence(AUTO_INCREMENT)' : null); |
|
| 95 | + $definition['column_default'] = $rawColumn['Default'] !== null ? $rawColumn['Default'] : ($rawColumn['Extra'] === 'auto_increment' ? 'sequence(AUTO_INCREMENT)' : null); |
|
| 97 | 96 | $definition['character_maximum_length'] = null; |
| 98 | 97 | $definition['datetime_precision'] = null; |
| 99 | 98 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | public function describe($schemaTable) |
| 54 | 54 | { |
| 55 | 55 | $table = explode($this->identifierDivider, $schemaTable); |
| 56 | - list($schema, $table) = count($table) === 2 ? $table : [ null, $table[ 0 ] ]; |
|
| 56 | + list($schema, $table) = count($table) === 2 ? $table : [null, $table[0]]; |
|
| 57 | 57 | $schema = $schema !== null ? $this->escapeIdentifier($schema) . '.' : ''; |
| 58 | 58 | |
| 59 | 59 | $result = $this->entityManager->getConnection()->query( |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | return count(array_filter(array_map( |
| 87 | 87 | function ($rawColumn) { |
| 88 | - return $rawColumn[ 'pk' ]; |
|
| 88 | + return $rawColumn['pk']; |
|
| 89 | 89 | }, |
| 90 | 90 | $rawColumns |
| 91 | 91 | ))) > 1; |