-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathColumnFactoryInterface.php
More file actions
90 lines (83 loc) · 3.23 KB
/
ColumnFactoryInterface.php
File metadata and controls
90 lines (83 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Schema\Column;
use Yiisoft\Db\Constant\ColumnInfoSource;
use Yiisoft\Db\Constant\ColumnType;
use Yiisoft\Db\Constant\PseudoType;
use Yiisoft\Db\Constraint\ForeignKey;
/**
* The interface must be implemented by a column factory class. It should create an instance of {@see ColumnInterface}
* for a database column type and initialize column information.
*
* @psalm-type ColumnInfo = array{
* autoIncrement?: bool,
* check?: string|null,
* collation?: string|null,
* column?: ColumnInterface|null,
* columns?: array<string, ColumnInterface>,
* comment?: string|null,
* computed?: bool,
* dbTimezone?: string,
* dbType?: string|null,
* defaultValue?: mixed,
* defaultValueRaw?: string|null,
* dimension?: positive-int,
* extra?: string|null,
* primaryKey?: bool,
* name?: string|null,
* notNull?: bool,
* reference?: ForeignKey|null,
* scale?: int|null,
* schema?: string|null,
* size?: int|null,
* source?: ColumnInfoSource::*,
* table?: string|null,
* type?: ColumnType::*,
* unique?: bool,
* unsigned?: bool,
* values?: array|null,
* }
*/
interface ColumnFactoryInterface
{
/**
* Creates an instance of {@see ColumnInterface} for a database column type and initializes column information.
*
* @param string $dbType The database column type.
* @param array $info The column information. The set of parameters may be different for a specific DBMS.
*
* @psalm-param ColumnInfo $info
*/
public function fromDbType(string $dbType, array $info = []): ColumnInterface;
/**
* Creates an instance of {@see ColumnInterface} for a database column definition and initializes column information.
* The definition string can contain a native database column type or {@see ColumnType abstract} type
* or {@see PseudoType pseudo} type, its size, default value, etc.
*
* For example, `varchar(255) NOT NULL` is `varchar` database type with `255` size and a `NOT NULL` constraint.
*
* @param string $definition The database column definition.
* @param array $info The column information. The set of parameters may be different for a specific DBMS.
*
* @psalm-param ColumnInfo $info
*/
public function fromDefinition(string $definition, array $info = []): ColumnInterface;
/**
* Creates an instance of {@see ColumnInterface} for a pseudo-type and initializes column information.
*
* @param string $pseudoType The pseudo-type.
* @param array $info The column information. The set of parameters may be different for a specific DBMS.
*
* @psalm-param ColumnInfo $info
*/
public function fromPseudoType(string $pseudoType, array $info = []): ColumnInterface;
/**
* Creates an instance of {@see ColumnInterface} for an abstract database type and initializes column information.
*
* @param string $type The abstract database type.
* @param array $info The column information. The set of parameters may be different for a specific DBMS.
*
* @psalm-param ColumnInfo $info
*/
public function fromType(string $type, array $info = []): ColumnInterface;
}