|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Doctrine\Migrations\Version; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Throwable; |
|
10
|
|
|
use function count; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* The ExecutionResult class is responsible for storing the result of a migration version after it executes. |
|
14
|
|
|
* |
|
15
|
|
|
* @internal |
|
16
|
|
|
*/ |
|
17
|
|
|
class ExecutionResult |
|
18
|
|
|
{ |
|
19
|
|
|
/** @var string[] */ |
|
20
|
|
|
private $sql = []; |
|
21
|
|
|
|
|
22
|
|
|
/** @var mixed[] */ |
|
23
|
|
|
private $params = []; |
|
24
|
|
|
|
|
25
|
|
|
/** @var mixed[] */ |
|
26
|
|
|
private $types = []; |
|
27
|
|
|
|
|
28
|
|
|
/** @var float|null */ |
|
29
|
|
|
private $time; |
|
30
|
|
|
|
|
31
|
|
|
/** @var float|null */ |
|
32
|
|
|
private $memory; |
|
33
|
|
|
|
|
34
|
|
|
/** @var bool */ |
|
35
|
|
|
private $skipped = false; |
|
36
|
|
|
|
|
37
|
|
|
/** @var bool */ |
|
38
|
|
|
private $error = false; |
|
39
|
|
|
|
|
40
|
|
|
/** @var Throwable|null */ |
|
41
|
|
|
private $exception; |
|
42
|
|
|
|
|
43
|
|
|
/** @var Schema|null */ |
|
44
|
|
|
private $toSchema; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param string[] $sql |
|
48
|
|
|
* @param mixed[] $params |
|
49
|
|
|
* @param mixed[] $types |
|
50
|
|
|
*/ |
|
51
|
72 |
|
public function __construct(array $sql = [], array $params = [], array $types = []) |
|
52
|
|
|
{ |
|
53
|
72 |
|
$this->sql = $sql; |
|
54
|
72 |
|
$this->params = $params; |
|
55
|
72 |
|
$this->types = $types; |
|
56
|
72 |
|
} |
|
57
|
|
|
|
|
58
|
1 |
|
public function hasSql() : bool |
|
59
|
|
|
{ |
|
60
|
1 |
|
return count($this->sql) !== 0; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return string[] |
|
65
|
|
|
*/ |
|
66
|
40 |
|
public function getSql() : array |
|
67
|
|
|
{ |
|
68
|
40 |
|
return $this->sql; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @param string[] $sql |
|
73
|
|
|
*/ |
|
74
|
53 |
|
public function setSql(array $sql) : void |
|
75
|
|
|
{ |
|
76
|
53 |
|
$this->sql = $sql; |
|
77
|
53 |
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return mixed[] |
|
81
|
|
|
*/ |
|
82
|
12 |
|
public function getParams() : array |
|
83
|
|
|
{ |
|
84
|
12 |
|
return $this->params; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param mixed[] $params |
|
89
|
|
|
*/ |
|
90
|
53 |
|
public function setParams(array $params) : void |
|
91
|
|
|
{ |
|
92
|
53 |
|
$this->params = $params; |
|
93
|
53 |
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @return mixed[] |
|
97
|
|
|
*/ |
|
98
|
3 |
|
public function getTypes() : array |
|
99
|
|
|
{ |
|
100
|
3 |
|
return $this->types; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @param mixed[] $types |
|
105
|
|
|
*/ |
|
106
|
53 |
|
public function setTypes(array $types) : void |
|
107
|
|
|
{ |
|
108
|
53 |
|
$this->types = $types; |
|
109
|
53 |
|
} |
|
110
|
|
|
|
|
111
|
30 |
|
public function getTime() : ?float |
|
112
|
|
|
{ |
|
113
|
30 |
|
return $this->time; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
53 |
|
public function setTime(float $time) : void |
|
117
|
|
|
{ |
|
118
|
53 |
|
$this->time = $time; |
|
119
|
53 |
|
} |
|
120
|
|
|
|
|
121
|
1 |
|
public function getMemory() : ?float |
|
122
|
|
|
{ |
|
123
|
1 |
|
return $this->memory; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
53 |
|
public function setMemory(float $memory) : void |
|
127
|
|
|
{ |
|
128
|
53 |
|
$this->memory = $memory; |
|
129
|
53 |
|
} |
|
130
|
|
|
|
|
131
|
7 |
|
public function setSkipped(bool $skipped) : void |
|
132
|
|
|
{ |
|
133
|
7 |
|
$this->skipped = $skipped; |
|
134
|
7 |
|
} |
|
135
|
|
|
|
|
136
|
28 |
|
public function isSkipped() : bool |
|
137
|
|
|
{ |
|
138
|
28 |
|
return $this->skipped; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
3 |
|
public function setError(bool $error) : void |
|
142
|
|
|
{ |
|
143
|
3 |
|
$this->error = $error; |
|
144
|
3 |
|
} |
|
145
|
|
|
|
|
146
|
1 |
|
public function hasError() : bool |
|
147
|
|
|
{ |
|
148
|
1 |
|
return $this->error; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
3 |
|
public function setException(Throwable $exception) : void |
|
152
|
|
|
{ |
|
153
|
3 |
|
$this->exception = $exception; |
|
154
|
3 |
|
} |
|
155
|
|
|
|
|
156
|
2 |
|
public function getException() : ?Throwable |
|
157
|
|
|
{ |
|
158
|
2 |
|
return $this->exception; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
55 |
|
public function setToSchema(Schema $toSchema) : void |
|
162
|
|
|
{ |
|
163
|
55 |
|
$this->toSchema = $toSchema; |
|
164
|
55 |
|
} |
|
165
|
|
|
|
|
166
|
28 |
|
public function getToSchema() : Schema |
|
167
|
|
|
{ |
|
168
|
28 |
|
if ($this->toSchema === null) { |
|
169
|
1 |
|
throw new RuntimeException('Cannot call getToSchema() when toSchema is null.'); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
27 |
|
return $this->toSchema; |
|
173
|
|
|
} |
|
174
|
|
|
} |
|
175
|
|
|
|