1 | <?php |
||
23 | abstract class AbstractConnection extends Component implements ConnectionInterface |
||
24 | { |
||
25 | const EVENT_AFTER_OPEN = 'afterOpen'; |
||
26 | |||
27 | /** |
||
28 | * @var string to be specified in concrete implementation |
||
29 | */ |
||
30 | public $queryBuilderClass; |
||
31 | |||
32 | public $requestClass = Request::class; |
||
33 | |||
34 | public $commandClass = Command::class; |
||
35 | |||
36 | public $queryClass = Query::class; |
||
37 | |||
38 | public $activeQueryClass = ActiveQuery::class; |
||
39 | |||
40 | public static $dbname = 'hiart'; |
||
41 | |||
42 | public $name = 'hiart'; |
||
43 | |||
44 | public $userAgent = 'HiArt/0.x'; |
||
45 | |||
46 | public $baseUri; |
||
47 | |||
48 | /** |
||
49 | * @var array transport config will be used in Request for handler or proxy request |
||
50 | */ |
||
51 | public $config = []; |
||
52 | |||
53 | /** |
||
54 | * @var object request handler common for all requests of this connection |
||
55 | */ |
||
56 | protected $_handler; |
||
57 | |||
58 | /** |
||
59 | * @var QueryBuilder the query builder for this connection |
||
60 | */ |
||
61 | protected $_builder; |
||
62 | |||
63 | /** |
||
64 | * @var array authorization config |
||
65 | */ |
||
66 | protected $_auth = []; |
||
67 | |||
68 | /** |
||
69 | * @var bool is auth disabled |
||
70 | */ |
||
71 | protected $_disabledAuth = false; |
||
72 | |||
73 | /** |
||
74 | * @var Closure callback to test if API response has error |
||
75 | * The function signature: `function ($response)` |
||
76 | * Must return `null`, if the response does not contain an error |
||
77 | */ |
||
78 | protected $_errorChecker; |
||
79 | |||
80 | public static function getDb($dbname = null) |
||
84 | |||
85 | public function setAuth($auth) |
||
89 | |||
90 | /** |
||
91 | * Returns auth settings. |
||
92 | * @return array |
||
93 | */ |
||
94 | public function getAuth() |
||
105 | |||
106 | public function disableAuth() |
||
110 | |||
111 | public function enableAuth() |
||
115 | |||
116 | /** |
||
117 | * Closes the connection when this component is being serialized. |
||
118 | * @return array |
||
119 | */ |
||
120 | public function __sleep() |
||
124 | |||
125 | /** |
||
126 | * Returns the name of the DB driver for the current [[dsn]]. |
||
127 | * @return string name of the DB driver |
||
128 | */ |
||
129 | public function getDriverName() |
||
133 | |||
134 | /** |
||
135 | * Creates a command for execution. |
||
136 | * @param array $config the configuration for the Command class |
||
137 | * @return Command the DB command |
||
138 | */ |
||
139 | public function createCommand(array $config = []) |
||
145 | |||
146 | /** |
||
147 | * @return QueryBuilder the query builder for this connection |
||
148 | */ |
||
149 | public function getQueryBuilder() |
||
157 | |||
158 | /** |
||
159 | * Handler is created and set by request. |
||
160 | * @see setHandler |
||
161 | * @return object |
||
162 | */ |
||
163 | public function getHandler() |
||
167 | |||
168 | /** |
||
169 | * Requests use this function to keep request handler. |
||
170 | * @param object $handler |
||
171 | */ |
||
172 | public function setHandler($handler) |
||
176 | |||
177 | /** |
||
178 | * @return boolean |
||
179 | */ |
||
180 | public function isDisabledAuth() |
||
184 | |||
185 | /** |
||
186 | * @param boolean $disabledAuth |
||
187 | */ |
||
188 | public function setDisabledAuth($disabledAuth) |
||
192 | |||
193 | /** |
||
194 | * Try to decode error information if it is valid json, return it if not. |
||
195 | * @param $body |
||
196 | * @return mixed |
||
197 | */ |
||
198 | protected function decodeErrorBody($body) |
||
212 | |||
213 | /** |
||
214 | * Setter for errorChecker. |
||
215 | * @param Closure $checker |
||
216 | */ |
||
217 | public function setErrorChecker($checker) |
||
221 | |||
222 | /** |
||
223 | * Checks response with checkError method and raises exception if error. |
||
224 | * @param ResponseInterface $response response data from API |
||
225 | * @throws ErrorResponseException |
||
226 | * @return mixed response data |
||
227 | */ |
||
228 | public function checkResponse(ResponseInterface $response) |
||
238 | |||
239 | /** |
||
240 | * Checks response with errorChecker callback and returns error text if error. |
||
241 | * @param ResponseInterface $response |
||
242 | * @return string|false error text or false |
||
243 | */ |
||
244 | public function checkError(ResponseInterface $response) |
||
252 | |||
253 | /** |
||
254 | * Default error checker. TODO check something in response? |
||
255 | * @param ResponseInterface $response |
||
256 | * @return bool |
||
257 | */ |
||
258 | public function isError(ResponseInterface $response) |
||
262 | |||
263 | /** |
||
264 | * Return API base uri. |
||
265 | * Adds trailing slash if uri is domain only. |
||
266 | * @return string |
||
267 | */ |
||
268 | public function getBaseUri() |
||
280 | |||
281 | public function getUserAgent() |
||
285 | } |
||
286 |
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..