@@ -57,7 +57,7 @@ |
||
| 57 | 57 | $rawColumns = $result->fetchAll(\PDO::FETCH_ASSOC); |
| 58 | 58 | |
| 59 | 59 | if (count($rawColumns) === 0) { |
| 60 | - throw new Exception('Unknown table ' . $table); |
|
| 60 | + throw new Exception('Unknown table ' . $table); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $hasMultiplePrimaryKey = $this->hasMultiplePrimaryKey($rawColumns); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @param Entity $entity |
| 390 | 390 | * @param bool $useAutoIncrement |
| 391 | - * @return mixed |
|
| 391 | + * @return boolean |
|
| 392 | 392 | * @internal |
| 393 | 393 | */ |
| 394 | 394 | public function insert(Entity $entity, $useAutoIncrement = true) |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | * |
| 462 | 462 | * Without $primaryKey it creates an entityFetcher and returns this. |
| 463 | 463 | * |
| 464 | - * @param string|Entity $class The entity class you want to fetch |
|
| 464 | + * @param string $class The entity class you want to fetch |
|
| 465 | 465 | * @param mixed $primaryKey The primary key of the entity you want to fetch |
| 466 | 466 | * @return Entity|EntityFetcher |
| 467 | 467 | * @throws IncompletePrimaryKey |
@@ -10,8 +10,6 @@ |
||
| 10 | 10 | use ORM\Exception\InvalidConfiguration; |
| 11 | 11 | use ORM\Exception\NoConnection; |
| 12 | 12 | use ORM\Exception\NoEntity; |
| 13 | -use ORM\Exception\NotScalar; |
|
| 14 | -use ORM\Exception\UnsupportedDriver; |
|
| 15 | 13 | |
| 16 | 14 | /** |
| 17 | 15 | * The EntityManager that manages the instances of Entities. |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | $statement = 'UPDATE ' . $this->escapeIdentifier($entity::getTableName()) . ' ' . |
| 145 | - 'SET ' . implode(',', $set) . ' ' . |
|
| 146 | - 'WHERE ' . implode(' AND ', $where); |
|
| 145 | + 'SET ' . implode(',', $set) . ' ' . |
|
| 146 | + 'WHERE ' . implode(' AND ', $where); |
|
| 147 | 147 | $this->entityManager->getConnection()->query($statement); |
| 148 | 148 | |
| 149 | 149 | return true; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $statement = 'DELETE FROM ' . $this->escapeIdentifier($entity::getTableName()) . ' ' . |
| 170 | - 'WHERE ' . implode(' AND ', $where); |
|
| 170 | + 'WHERE ' . implode(' AND ', $where); |
|
| 171 | 171 | $this->entityManager->getConnection()->query($statement); |
| 172 | 172 | |
| 173 | 173 | return true; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | }, array_values($data)); |
| 257 | 257 | |
| 258 | 258 | $statement = 'INSERT INTO ' . $this->escapeIdentifier($entity::getTableName()) . ' ' . |
| 259 | - '(' . implode(',', $cols) . ') VALUES (' . implode(',', $values) . ')'; |
|
| 259 | + '(' . implode(',', $cols) . ') VALUES (' . implode(',', $values) . ')'; |
|
| 260 | 260 | |
| 261 | 261 | return $statement; |
| 262 | 262 | } |
@@ -91,8 +91,7 @@ |
||
| 91 | 91 | |
| 92 | 92 | $definition['column_name'] = $rawColumn['Field']; |
| 93 | 93 | $definition['is_nullable'] = $rawColumn['Null'] === 'YES'; |
| 94 | - $definition['column_default'] = $rawColumn['Default'] !== null ? $rawColumn['Default'] : |
|
| 95 | - ($rawColumn['Extra'] === 'auto_increment' ? 'sequence(AUTO_INCREMENT)' : null); |
|
| 94 | + $definition['column_default'] = $rawColumn['Default'] !== null ? $rawColumn['Default'] : ($rawColumn['Extra'] === 'auto_increment' ? 'sequence(AUTO_INCREMENT)' : null); |
|
| 96 | 95 | $definition['character_maximum_length'] = null; |
| 97 | 96 | $definition['datetime_precision'] = null; |
| 98 | 97 | |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | $result = $this->entityManager->getConnection()->query($query->getQuery()); |
| 73 | 73 | $rawColumns = $result->fetchAll(PDO::FETCH_ASSOC); |
| 74 | 74 | if (count($rawColumns) === 0) { |
| 75 | - throw new Exception('Unknown table ' . $schemaTable); |
|
| 75 | + throw new Exception('Unknown table ' . $schemaTable); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $cols = array_map(function ($columnDefinition) { |
@@ -18,12 +18,12 @@ |
||
| 18 | 18 | public function validate($value) |
| 19 | 19 | { |
| 20 | 20 | if (!is_string($value)) { |
| 21 | - return new NoString([ 'type' => 'set' ]); |
|
| 21 | + return new NoString(['type' => 'set']); |
|
| 22 | 22 | } else { |
| 23 | 23 | $values = explode(',', $value); |
| 24 | 24 | foreach ($values as $value) { |
| 25 | 25 | if (!in_array($value, $this->allowedValues)) { |
| 26 | - return new NotAllowed([ 'value' => $value, 'type' => 'set' ]); |
|
| 26 | + return new NotAllowed(['value' => $value, 'type' => 'set']); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | return new Error([], 'DATETIME', 'DateTime is not allowed for time'); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return new NoTime([ 'value' => (string)$value ]); |
|
| 29 | + return new NoTime(['value' => (string) $value]); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return true; |
@@ -32,10 +32,9 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function __construct($precision = null, $dateOnly = false) |
| 34 | 34 | { |
| 35 | - $this->precision = (int)$precision; |
|
| 35 | + $this->precision = (int) $precision; |
|
| 36 | 36 | $this->regex = $dateOnly ? |
| 37 | - '/^' . self::DATE_REGEX . '([ T]' . self::TIME_REGEX . self::ZONE_REGEX . ')?$/' : |
|
| 38 | - '/^' . self::DATE_REGEX . '[ T]' . self::TIME_REGEX . self::ZONE_REGEX . '$/'; |
|
| 37 | + '/^' . self::DATE_REGEX . '([ T]' . self::TIME_REGEX . self::ZONE_REGEX . ')?$/' : '/^' . self::DATE_REGEX . '[ T]' . self::TIME_REGEX . self::ZONE_REGEX . '$/'; |
|
| 39 | 38 | } |
| 40 | 39 | |
| 41 | 40 | public static function factory(Dbal $dbal, array $columnDefinition) |
@@ -49,7 +48,7 @@ discard block |
||
| 49 | 48 | public function validate($value) |
| 50 | 49 | { |
| 51 | 50 | if (!$value instanceof \DateTime && (!is_string($value) || !preg_match($this->regex, $value))) { |
| 52 | - return new NoDateTime([ 'value' => (string)$value ]); |
|
| 51 | + return new NoDateTime(['value' => (string) $value]); |
|
| 53 | 52 | } |
| 54 | 53 | |
| 55 | 54 | return true; |
@@ -41,9 +41,9 @@ |
||
| 41 | 41 | public function validate($value) |
| 42 | 42 | { |
| 43 | 43 | if (!is_string($value)) { |
| 44 | - return new NoString([ 'type' => 'enum' ]); |
|
| 44 | + return new NoString(['type' => 'enum']); |
|
| 45 | 45 | } elseif (!in_array($value, $this->allowedValues)) { |
| 46 | - return new NotAllowed([ 'value' => $value, 'type' => 'enum' ]); |
|
| 46 | + return new NotAllowed(['value' => $value, 'type' => 'enum']); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | return true; |