1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
6
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
7
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
8
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
9
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
10
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
11
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
12
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
13
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
14
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
15
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace Ytake\PrestoClient; |
19
|
|
|
|
20
|
|
|
use Ramsey\Uuid\UuidInterface; |
21
|
|
|
use Ytake\PrestoClient\Session\Property; |
22
|
|
|
use Ytake\PrestoClient\Session\PreparedStatement; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class PrestoSession |
26
|
|
|
* |
27
|
|
|
* @author Yuuki Takezawa <[email protected]> |
28
|
|
|
*/ |
29
|
|
|
class ClientSession |
30
|
|
|
{ |
31
|
|
|
/** @var string */ |
32
|
|
|
protected $host; |
33
|
|
|
|
34
|
|
|
/** @var string */ |
35
|
|
|
protected $catalog; |
36
|
|
|
|
37
|
|
|
/** @var UuidInterface */ |
38
|
|
|
protected $transactionId; |
39
|
|
|
|
40
|
|
|
/** @var string */ |
41
|
|
|
protected $schema = 'default'; |
42
|
|
|
|
43
|
|
|
/** @var string */ |
44
|
|
|
protected $header = []; |
45
|
|
|
|
46
|
|
|
/** @var string */ |
47
|
|
|
protected $user = 'presto'; |
48
|
|
|
|
49
|
|
|
/** @var string */ |
50
|
|
|
protected $source = PrestoHeaders::PRESTO_SOURCE_VALUE; |
51
|
|
|
|
52
|
|
|
/** @var Property[] */ |
53
|
|
|
protected $property = []; |
54
|
|
|
|
55
|
|
|
/** @var PreparedStatement[] */ |
56
|
|
|
protected $preparedStatement = []; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* PrestoSession constructor. |
60
|
|
|
* |
61
|
|
|
* @param string $host |
62
|
|
|
* @param string $catalog |
63
|
|
|
*/ |
64
|
|
|
public function __construct(string $host, string $catalog) |
65
|
|
|
{ |
66
|
|
|
$this->host = $host; |
67
|
|
|
$this->catalog = $catalog; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param string $schema |
72
|
|
|
*/ |
73
|
|
|
public function setSchema(string $schema) |
74
|
|
|
{ |
75
|
|
|
$this->schema = $schema; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param array $header |
80
|
|
|
*/ |
81
|
|
|
public function setHeader(array $header) |
82
|
|
|
{ |
83
|
|
|
$this->header = $header; |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param string $user |
88
|
|
|
*/ |
89
|
|
|
public function setUser(string $user) |
90
|
|
|
{ |
91
|
|
|
$this->user = $user; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $source |
96
|
|
|
*/ |
97
|
|
|
public function setSource(string $source) |
98
|
|
|
{ |
99
|
|
|
$this->source = $source; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param UuidInterface $transactionId |
104
|
|
|
*/ |
105
|
|
|
public function setTransactionId(UuidInterface $transactionId) |
106
|
|
|
{ |
107
|
|
|
$this->transactionId = $transactionId; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param Property $property |
112
|
|
|
*/ |
113
|
|
|
public function setProperty(Property $property) |
114
|
|
|
{ |
115
|
|
|
$this->property[] = $property; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param PreparedStatement $preparedStatement |
120
|
|
|
*/ |
121
|
|
|
public function setPreparedStatement(PreparedStatement $preparedStatement) |
122
|
|
|
{ |
123
|
|
|
$this->preparedStatement[] = $preparedStatement; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return Property[] |
128
|
|
|
*/ |
129
|
|
|
public function getProperty(): array |
130
|
|
|
{ |
131
|
|
|
return $this->property; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return PreparedStatement[] |
136
|
|
|
*/ |
137
|
|
|
public function getPreparedStatement(): array |
138
|
|
|
{ |
139
|
|
|
return $this->preparedStatement; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @return string |
144
|
|
|
*/ |
145
|
|
|
public function getHost(): string |
146
|
|
|
{ |
147
|
|
|
return $this->host; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return string |
152
|
|
|
*/ |
153
|
|
|
public function getCatalog(): string |
154
|
|
|
{ |
155
|
|
|
return $this->catalog; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @return array |
160
|
|
|
*/ |
161
|
|
|
public function getHeader(): array |
162
|
|
|
{ |
163
|
|
|
return $this->header; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return string |
168
|
|
|
*/ |
169
|
|
|
public function getSchema(): string |
170
|
|
|
{ |
171
|
|
|
return $this->schema; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @return string |
176
|
|
|
*/ |
177
|
|
|
public function getUser(): string |
178
|
|
|
{ |
179
|
|
|
return $this->user; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @return string |
184
|
|
|
*/ |
185
|
|
|
public function getSource(): string |
186
|
|
|
{ |
187
|
|
|
return $this->source; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @return UuidInterface|null |
192
|
|
|
*/ |
193
|
|
|
public function getTransactionId() |
194
|
|
|
{ |
195
|
|
|
return $this->transactionId; |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..