@@ -333,11 +333,11 @@ discard block |
||
333 | 333 | return $this->formatDatetime($this->getAbstractType(), $this->defaultValue); |
334 | 334 | } |
335 | 335 | |
336 | - return match ($this->getType()) { |
|
337 | - 'int' => (int) $this->defaultValue, |
|
338 | - 'float' => (float) $this->defaultValue, |
|
336 | + return match($this->getType()) { |
|
337 | + 'int' => (int)$this->defaultValue, |
|
338 | + 'float' => (float)$this->defaultValue, |
|
339 | 339 | 'bool' => \is_string($this->defaultValue) && strtolower($this->defaultValue) === 'false' |
340 | - ? false : (bool) $this->defaultValue, |
|
340 | + ? false : (bool)$this->defaultValue, |
|
341 | 341 | default => (string)$this->defaultValue |
342 | 342 | }; |
343 | 343 | } |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @param array|string $values Enum values (array or comma separated). String values only. |
508 | 508 | */ |
509 | - public function enum(string|array $values): self |
|
509 | + public function enum(string | array $values): self |
|
510 | 510 | { |
511 | 511 | $this->type('enum'); |
512 | 512 | $this->enumValues = array_map( |
@@ -654,10 +654,10 @@ discard block |
||
654 | 654 | ); |
655 | 655 | } |
656 | 656 | |
657 | - return match ($this->getType()) { |
|
657 | + return match($this->getType()) { |
|
658 | 658 | 'bool' => $defaultValue ? 'TRUE' : 'FALSE', |
659 | 659 | 'float' => sprintf('%F', $defaultValue), |
660 | - 'int' => (string) $defaultValue, |
|
660 | + 'int' => (string)$defaultValue, |
|
661 | 661 | default => $driver->quote($defaultValue) |
662 | 662 | }; |
663 | 663 | } |
@@ -671,8 +671,8 @@ discard block |
||
671 | 671 | */ |
672 | 672 | protected function formatDatetime( |
673 | 673 | string $type, |
674 | - string|int|\DateTimeInterface $value |
|
675 | - ): \DateTimeInterface|FragmentInterface|string { |
|
674 | + string | int | \DateTimeInterface $value |
|
675 | + ): \DateTimeInterface | FragmentInterface | string { |
|
676 | 676 | if ($value === static::DATETIME_NOW) { |
677 | 677 | //Dynamic default value |
678 | 678 | return new Fragment($value); |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | } |
691 | 691 | } |
692 | 692 | |
693 | - return match ($type) { |
|
693 | + return match($type) { |
|
694 | 694 | 'datetime', 'timestamp' => $datetime, |
695 | 695 | 'time' => $datetime->format(static::TIME_FORMAT), |
696 | 696 | 'date' => $datetime->format(static::DATE_FORMAT), |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $self = $this; |
79 | 79 | return array_map( |
80 | - static fn (string $column): string => ($order = $self->sort[$column] ?? null) ? "$column $order" : $column, |
|
80 | + static fn(string $column): string => ($order = $self->sort[$column] ?? null) ? "$column $order" : $column, |
|
81 | 81 | $this->columns |
82 | 82 | ); |
83 | 83 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return self |
106 | 106 | */ |
107 | - public function columns(string|array $columns): self |
|
107 | + public function columns(string | array $columns): self |
|
108 | 108 | { |
109 | 109 | if (!\is_array($columns)) { |
110 | 110 | $columns = func_get_args(); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | /** |
176 | 176 | * Parse column name and order from column expression |
177 | 177 | */ |
178 | - public static function parseColumn(array|string $column): array |
|
178 | + public static function parseColumn(array | string $column): array |
|
179 | 179 | { |
180 | 180 | if (\is_array($column)) { |
181 | 181 | return $column; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * $insert->columns("name", "email"); |
50 | 50 | * $insert->columns("name, email"); |
51 | 51 | */ |
52 | - public function columns(array|string ...$columns): self |
|
52 | + public function columns(array | string ...$columns): self |
|
53 | 53 | { |
54 | 54 | $this->columns = $this->fetchIdentifiers($columns); |
55 | 55 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | protected array $tables = []; |
46 | 46 | protected array $unionTokens = []; |
47 | - protected bool|string|array $distinct = false; |
|
47 | + protected bool | string | array $distinct = false; |
|
48 | 48 | protected array $columns = ['*']; |
49 | 49 | /** @var FragmentInterface[][]|string[][] */ |
50 | 50 | protected array $orderBy = []; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param bool|FragmentInterface|string $distinct You are only allowed to use string value for |
73 | 73 | * Postgres databases. |
74 | 74 | */ |
75 | - public function distinct(bool|string|FragmentInterface $distinct = true): self |
|
75 | + public function distinct(bool | string | FragmentInterface $distinct = true): self |
|
76 | 76 | { |
77 | 77 | $this->distinct = $distinct; |
78 | 78 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param array|string $expression |
134 | 134 | * @param string $direction Sorting direction, ASC|DESC. |
135 | 135 | */ |
136 | - public function orderBy(string|FragmentInterface|array $expression, string $direction = self::SORT_ASC): self |
|
136 | + public function orderBy(string | FragmentInterface | array $expression, string $direction = self::SORT_ASC): self |
|
137 | 137 | { |
138 | 138 | if (!\is_array($expression)) { |
139 | 139 | $this->addOrder($expression, $direction); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * Column or expression to group query by. |
152 | 152 | */ |
153 | - public function groupBy(string|Fragment|Expression $expression): self |
|
153 | + public function groupBy(string | Fragment | Expression $expression): self |
|
154 | 154 | { |
155 | 155 | $this->groupBy[] = $expression; |
156 | 156 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return $this|self |
357 | 357 | */ |
358 | - private function addOrder(string|FragmentInterface $field, string $order): self |
|
358 | + private function addOrder(string | FragmentInterface $field, string $order): self |
|
359 | 359 | { |
360 | 360 | if (!\is_string($field)) { |
361 | 361 | $this->orderBy[] = [$field, $order]; |
@@ -39,9 +39,9 @@ |
||
39 | 39 | * |
40 | 40 | * @return non-empty-string|null |
41 | 41 | */ |
42 | - public static function read(string $haystack, array|string $needle): ?string |
|
42 | + public static function read(string $haystack, array | string $needle): ?string |
|
43 | 43 | { |
44 | - $needle = \array_map(static fn (string $item): string => \preg_quote($item), (array)$needle); |
|
44 | + $needle = \array_map(static fn(string $item) : string => \preg_quote($item), (array)$needle); |
|
45 | 45 | $pattern = \sprintf('/\b(?:%s)=([^;]+)/i', \implode('|', $needle)); |
46 | 46 | |
47 | 47 | if (\preg_match($pattern, $haystack, $matches)) { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function __construct( |
44 | 44 | ConnectionConfig $connection, |
45 | - iterable|string $schema = self::DEFAULT_SCHEMA, |
|
45 | + iterable | string $schema = self::DEFAULT_SCHEMA, |
|
46 | 46 | string $driver = PostgresDriver::class, |
47 | 47 | bool $reconnect = true, |
48 | 48 | string $timezone = 'UTC', |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return array<non-empty-string> |
71 | 71 | */ |
72 | - private function bootSchema(iterable|string $schema): array |
|
72 | + private function bootSchema(iterable | string $schema): array |
|
73 | 73 | { |
74 | 74 | // Cast any schema config variants to array |
75 | - $schema = match (true) { |
|
75 | + $schema = match(true) { |
|
76 | 76 | $schema instanceof \Traversable => \iterator_to_array($schema), |
77 | 77 | \is_string($schema) => [$schema], |
78 | 78 | default => $schema |
@@ -36,9 +36,9 @@ |
||
36 | 36 | if ($columns !== []) { |
37 | 37 | foreach ($columns as $column) { |
38 | 38 | // We only need key columns |
39 | - if ((int) ($column['cid']) > -1) { |
|
39 | + if ((int)($column['cid']) > -1) { |
|
40 | 40 | $index->columns[] = $column['name']; |
41 | - if ((int) ($column['desc']) === 1) { |
|
41 | + if ((int)($column['desc']) === 1) { |
|
42 | 42 | $index->sort[$column['name']] = 'DESC'; |
43 | 43 | } |
44 | 44 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | //Fetching enum values |
207 | 207 | if ($options !== [] && $column->getAbstractType() === 'enum') { |
208 | - $column->enumValues = array_map(static fn ($value) => trim($value, $value[0]), $options); |
|
208 | + $column->enumValues = array_map(static fn($value) => trim($value, $value[0]), $options); |
|
209 | 209 | |
210 | 210 | return $column; |
211 | 211 | } |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | */ |
237 | 237 | protected function formatDatetime( |
238 | 238 | string $type, |
239 | - string|int|\DateTimeInterface $value |
|
240 | - ): \DateTimeInterface|FragmentInterface|string { |
|
239 | + string | int | \DateTimeInterface $value |
|
240 | + ): \DateTimeInterface | FragmentInterface | string { |
|
241 | 241 | if ($value === 'current_timestamp()') { |
242 | 242 | $value = self::DATETIME_NOW; |
243 | 243 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | return $this->type('bigPrimary'); |
163 | 163 | } |
164 | 164 | |
165 | - public function enum(string|array $values): AbstractColumn |
|
165 | + public function enum(string | array $values): AbstractColumn |
|
166 | 166 | { |
167 | 167 | $this->enumValues = array_map('strval', \is_array($values) ? $values : \func_get_args()); |
168 | 168 | |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | return $column; |
300 | 300 | } |
301 | 301 | |
302 | - if (str_contains($column->type, 'char') && (int) $schema['character_maximum_length']) { |
|
302 | + if (str_contains($column->type, 'char') && (int)$schema['character_maximum_length']) { |
|
303 | 303 | $column->size = $schema['character_maximum_length']; |
304 | 304 | } |
305 | 305 | |
306 | 306 | if ($column->type === 'numeric') { |
307 | - $column->precision = (int) $schema['numeric_precision']; |
|
308 | - $column->scale = (int) $schema['numeric_scale']; |
|
307 | + $column->precision = (int)$schema['numeric_precision']; |
|
308 | + $column->scale = (int)$schema['numeric_scale']; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | if ($column->type === 'USER-DEFINED' && $schema['typtype'] === 'e') { |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | return true; |
335 | 335 | } |
336 | 336 | |
337 | - return (bool) ( |
|
337 | + return (bool)( |
|
338 | 338 | in_array($this->getAbstractType(), ['primary', 'bigPrimary']) |
339 | 339 | && $initial->getDefaultValue() != $this->getDefaultValue() |
340 | 340 | ) |