@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | ? $this->dbname |
60 | 60 | : |
61 | 61 | (!is_null($this->dbport) && !empty($this->dbport)) |
62 | - ? $this->dbhost .":". $this->dbport ."/". $this->dbname |
|
63 | - : $this->dbhost ."/". $this->dbname; |
|
62 | + ? $this->dbhost . ":" . $this->dbport . "/" . $this->dbname |
|
63 | + : $this->dbhost . "/" . $this->dbname; |
|
64 | 64 | |
65 | - $conn = @oci_connect($this->dbuser, $this->dbpass, $connection_string, $this->dbchar); |
|
65 | + $conn = @oci_connect($this->dbuser, $this->dbpass, $connection_string, $this->dbchar); |
|
66 | 66 | |
67 | 67 | if ($conn === false) |
68 | 68 | { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $prev_error_handler = set_error_handler(['\Drone\Error\ErrorHandler', 'errorControlOperator'], E_ALL); |
132 | 132 | |
133 | 133 | // may be throw a Fatal error (Ex: Maximum execution time) |
134 | - $r = ($this->transac_mode) ? oci_execute($stid, OCI_NO_AUTO_COMMIT) : oci_execute($stid, OCI_COMMIT_ON_SUCCESS); |
|
134 | + $r = ($this->transac_mode) ? oci_execute($stid, OCI_NO_AUTO_COMMIT) : oci_execute($stid, OCI_COMMIT_ON_SUCCESS); |
|
135 | 135 | |
136 | 136 | set_error_handler($prev_error_handler); |
137 | 137 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $this->numFields = oci_num_fields($stid); |
153 | 153 | |
154 | 154 | if ($this->transac_mode) |
155 | - $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid; |
|
155 | + $this->transac_result = is_null($this->transac_result) ? $stid : $this->transac_result && $stid; |
|
156 | 156 | |
157 | 157 | $this->result = $stid; |
158 | 158 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | if ($this->result) |
199 | 199 | { |
200 | - while ( ($row = @oci_fetch_array($this->result, OCI_BOTH + OCI_RETURN_NULLS)) !== false ) |
|
200 | + while (($row = @oci_fetch_array($this->result, OCI_BOTH + OCI_RETURN_NULLS)) !== false) |
|
201 | 201 | { |
202 | 202 | $data[] = $row; |
203 | 203 | } |
@@ -33,15 +33,17 @@ discard block |
||
33 | 33 | { |
34 | 34 | $this->driverName = 'Oci8'; |
35 | 35 | |
36 | - if (!array_key_exists("dbchar", $options)) |
|
37 | - $options["dbchar"] = "AL32UTF8"; |
|
36 | + if (!array_key_exists("dbchar", $options)) { |
|
37 | + $options["dbchar"] = "AL32UTF8"; |
|
38 | + } |
|
38 | 39 | |
39 | 40 | parent::__construct($options); |
40 | 41 | |
41 | 42 | $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true; |
42 | 43 | |
43 | - if ($auto_connect) |
|
44 | - $this->connect(); |
|
44 | + if ($auto_connect) { |
|
45 | + $this->connect(); |
|
46 | + } |
|
45 | 47 | } |
46 | 48 | |
47 | 49 | /** |
@@ -54,8 +56,9 @@ discard block |
||
54 | 56 | */ |
55 | 57 | public function connect() |
56 | 58 | { |
57 | - if (!extension_loaded('oci8')) |
|
58 | - throw new \RuntimeException("The Oci8 extension is not loaded"); |
|
59 | + if (!extension_loaded('oci8')) { |
|
60 | + throw new \RuntimeException("The Oci8 extension is not loaded"); |
|
61 | + } |
|
59 | 62 | |
60 | 63 | $connection_string = (is_null($this->dbhost) || empty($this->dbhost)) |
61 | 64 | ? $this->dbname |
@@ -108,14 +111,15 @@ discard block |
||
108 | 111 | ]; |
109 | 112 | |
110 | 113 | $this->error($error["message"]); |
114 | + } else { |
|
115 | + $this->error($error["code"], $error["message"]); |
|
111 | 116 | } |
112 | - else |
|
113 | - $this->error($error["code"], $error["message"]); |
|
114 | 117 | |
115 | - if (array_key_exists("code", $error)) |
|
116 | - throw new Exception\InvalidQueryException($error["message"], $error["code"]); |
|
117 | - else |
|
118 | - throw new Exception\InvalidQueryException($error["message"]); |
|
118 | + if (array_key_exists("code", $error)) { |
|
119 | + throw new Exception\InvalidQueryException($error["message"], $error["code"]); |
|
120 | + } else { |
|
121 | + throw new Exception\InvalidQueryException($error["message"]); |
|
122 | + } |
|
119 | 123 | } |
120 | 124 | |
121 | 125 | # Bound variables |
@@ -155,8 +159,9 @@ discard block |
||
155 | 159 | $this->numRows = count($rows); |
156 | 160 | $this->numFields = oci_num_fields($stid); |
157 | 161 | |
158 | - if ($this->transac_mode) |
|
159 | - $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid; |
|
162 | + if ($this->transac_mode) { |
|
163 | + $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid; |
|
164 | + } |
|
160 | 165 | |
161 | 166 | $this->result = $stid; |
162 | 167 | |
@@ -205,9 +210,8 @@ discard block |
||
205 | 210 | { |
206 | 211 | $data[] = $row; |
207 | 212 | } |
208 | - } |
|
209 | - else |
|
210 | - /* |
|
213 | + } else { |
|
214 | + /* |
|
211 | 215 | * "This kind of exception should lead directly to a fix in your code" |
212 | 216 | * So much production tests tell us this error is throwed because developers |
213 | 217 | * execute toArray() before execute(). |
@@ -215,6 +219,7 @@ discard block |
||
215 | 219 | * Ref: http://php.net/manual/en/class.logicexception.php |
216 | 220 | */ |
217 | 221 | throw new \LogicException('There are not data in the buffer!'); |
222 | + } |
|
218 | 223 | |
219 | 224 | $this->arrayResult = $data; |
220 | 225 | |
@@ -228,7 +233,8 @@ discard block |
||
228 | 233 | */ |
229 | 234 | public function __destruct() |
230 | 235 | { |
231 | - if ($this->dbconn) |
|
232 | - oci_close($this->dbconn); |
|
236 | + if ($this->dbconn) { |
|
237 | + oci_close($this->dbconn); |
|
238 | + } |
|
233 | 239 | } |
234 | 240 | } |
235 | 241 | \ No newline at end of file |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | else |
133 | 133 | { |
134 | 134 | if ($isSelectStm) |
135 | - $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET )); |
|
135 | + $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array("Scrollable" => SQLSRV_CURSOR_KEYSET)); |
|
136 | 136 | else |
137 | 137 | $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params); |
138 | 138 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $this->rowsAffected = sqlsrv_rows_affected($this->result); |
159 | 159 | |
160 | 160 | if ($this->transac_mode) |
161 | - $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
161 | + $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result; |
|
162 | 162 | |
163 | 163 | return $this->result; |
164 | 164 | } |
@@ -33,15 +33,17 @@ discard block |
||
33 | 33 | { |
34 | 34 | $this->driverName = 'Sqlsrv'; |
35 | 35 | |
36 | - if (!array_key_exists("dbchar", $options)) |
|
37 | - $options["dbchar"] = "UTF-8"; |
|
36 | + if (!array_key_exists("dbchar", $options)) { |
|
37 | + $options["dbchar"] = "UTF-8"; |
|
38 | + } |
|
38 | 39 | |
39 | 40 | parent::__construct($options); |
40 | 41 | |
41 | 42 | $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true; |
42 | 43 | |
43 | - if ($auto_connect) |
|
44 | - $this->connect(); |
|
44 | + if ($auto_connect) { |
|
45 | + $this->connect(); |
|
46 | + } |
|
45 | 47 | } |
46 | 48 | |
47 | 49 | /** |
@@ -54,11 +56,13 @@ discard block |
||
54 | 56 | */ |
55 | 57 | public function connect() |
56 | 58 | { |
57 | - if (!extension_loaded('sqlsrv')) |
|
58 | - throw new \RuntimeException("The Sqlsrv extension is not loaded"); |
|
59 | + if (!extension_loaded('sqlsrv')) { |
|
60 | + throw new \RuntimeException("The Sqlsrv extension is not loaded"); |
|
61 | + } |
|
59 | 62 | |
60 | - if (!is_null($this->dbport) && !empty($this->dbport)) |
|
61 | - $this->dbhost .= ', ' . $this->dbport; |
|
63 | + if (!is_null($this->dbport) && !empty($this->dbport)) { |
|
64 | + $this->dbhost .= ', ' . $this->dbport; |
|
65 | + } |
|
62 | 66 | |
63 | 67 | $db_info = array("Database" => $this->dbname, "UID" => $this->dbuser, "PWD" => $this->dbpass, "CharacterSet" => $this->dbchar); |
64 | 68 | $conn = sqlsrv_connect($this->dbhost, $db_info); |
@@ -139,13 +143,13 @@ discard block |
||
139 | 143 | } |
140 | 144 | |
141 | 145 | $exec = sqlsrv_execute($stmt); |
142 | - } |
|
143 | - else |
|
146 | + } else |
|
144 | 147 | { |
145 | - if ($isSelectStm) |
|
146 | - $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET )); |
|
147 | - else |
|
148 | - $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params); |
|
148 | + if ($isSelectStm) { |
|
149 | + $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET )); |
|
150 | + } else { |
|
151 | + $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params); |
|
152 | + } |
|
149 | 153 | } |
150 | 154 | |
151 | 155 | if ($exec === false) |
@@ -165,11 +169,13 @@ discard block |
||
165 | 169 | $this->numRows = sqlsrv_has_rows($this->result) ? sqlsrv_num_rows($this->result) : $this->numRows; |
166 | 170 | $this->numFields = sqlsrv_num_fields($this->result); |
167 | 171 | |
168 | - if ($isInsertStm || $isUpdateStm || $isDeleteStm) |
|
169 | - $this->rowsAffected = sqlsrv_rows_affected($this->result); |
|
172 | + if ($isInsertStm || $isUpdateStm || $isDeleteStm) { |
|
173 | + $this->rowsAffected = sqlsrv_rows_affected($this->result); |
|
174 | + } |
|
170 | 175 | |
171 | - if ($this->transac_mode) |
|
172 | - $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
176 | + if ($this->transac_mode) { |
|
177 | + $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
178 | + } |
|
173 | 179 | |
174 | 180 | return $this->result; |
175 | 181 | } |
@@ -236,9 +242,8 @@ discard block |
||
236 | 242 | { |
237 | 243 | $data[] = $row; |
238 | 244 | } |
239 | - } |
|
240 | - else |
|
241 | - /* |
|
245 | + } else { |
|
246 | + /* |
|
242 | 247 | * "This kind of exception should lead directly to a fix in your code" |
243 | 248 | * So much production tests tell us this error is throwed because developers |
244 | 249 | * execute toArray() before execute(). |
@@ -246,6 +251,7 @@ discard block |
||
246 | 251 | * Ref: http://php.net/manual/en/class.logicexception.php |
247 | 252 | */ |
248 | 253 | throw new \LogicException('There are not data in the buffer!'); |
254 | + } |
|
249 | 255 | |
250 | 256 | $this->arrayResult = $data; |
251 | 257 | |
@@ -259,7 +265,8 @@ discard block |
||
259 | 265 | */ |
260 | 266 | public function __destruct() |
261 | 267 | { |
262 | - if ($this->dbconn) |
|
263 | - sqlsrv_close($this->dbconn); |
|
268 | + if ($this->dbconn) { |
|
269 | + sqlsrv_close($this->dbconn); |
|
270 | + } |
|
264 | 271 | } |
265 | 272 | } |
266 | 273 | \ No newline at end of file |
@@ -141,13 +141,11 @@ |
||
141 | 141 | try |
142 | 142 | { |
143 | 143 | $shell->cp('foo2', 'foo3'); |
144 | - } |
|
145 | - catch (\Exception $e) |
|
144 | + } catch (\Exception $e) |
|
146 | 145 | { |
147 | 146 | # omitting directory |
148 | 147 | $errorObject = ($e instanceof \RuntimeException); |
149 | - } |
|
150 | - finally |
|
148 | + } finally |
|
151 | 149 | { |
152 | 150 | $this->assertTrue($errorObject, $e->getMessage()); |
153 | 151 | } |
@@ -194,7 +194,7 @@ |
||
194 | 194 | $this->assertTrue(is_dir('foo4/foo2')); |
195 | 195 | $this->assertTrue(file_exists('foo4/foo2/new3.txt')); |
196 | 196 | $this->assertTrue(file_exists('foo4/foo2/new4.txt')); |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Tests removing files |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | { |
119 | 119 | if (is_string($param_values[$i])) |
120 | 120 | $bind_types .= 's'; |
121 | - else if(is_float($param_values[$i])) |
|
121 | + else if (is_float($param_values[$i])) |
|
122 | 122 | $bind_types .= 'd'; |
123 | 123 | # [POSSIBLE BUG] - To Future revision (What about non-string and non-decimal types ?) |
124 | 124 | else |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $this->numFields = $this->dbconn->field_count; |
179 | 179 | |
180 | 180 | if ($this->transac_mode) |
181 | - $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
181 | + $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result; |
|
182 | 182 | |
183 | 183 | /* |
184 | 184 | * Because mysqli_query() returns FALSE on failure, a mysqli_result object for SELECT, SHOW, DESCRIBE or EXPLAIN queries, |
@@ -33,15 +33,17 @@ discard block |
||
33 | 33 | { |
34 | 34 | $this->driverName = 'Mysqli'; |
35 | 35 | |
36 | - if (!array_key_exists("dbchar", $options)) |
|
37 | - $options["dbchar"] = "utf8"; |
|
36 | + if (!array_key_exists("dbchar", $options)) { |
|
37 | + $options["dbchar"] = "utf8"; |
|
38 | + } |
|
38 | 39 | |
39 | 40 | parent::__construct($options); |
40 | 41 | |
41 | 42 | $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true; |
42 | 43 | |
43 | - if ($auto_connect) |
|
44 | - $this->connect(); |
|
44 | + if ($auto_connect) { |
|
45 | + $this->connect(); |
|
46 | + } |
|
45 | 47 | } |
46 | 48 | |
47 | 49 | /** |
@@ -54,13 +56,15 @@ discard block |
||
54 | 56 | */ |
55 | 57 | public function connect() |
56 | 58 | { |
57 | - if (!extension_loaded('mysqli')) |
|
58 | - throw new \RuntimeException("The Mysqli extension is not loaded"); |
|
59 | + if (!extension_loaded('mysqli')) { |
|
60 | + throw new \RuntimeException("The Mysqli extension is not loaded"); |
|
61 | + } |
|
59 | 62 | |
60 | - if (!is_null($this->dbport) && !empty($this->dbport)) |
|
61 | - $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport); |
|
62 | - else |
|
63 | - $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname); |
|
63 | + if (!is_null($this->dbport) && !empty($this->dbport)) { |
|
64 | + $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport); |
|
65 | + } else { |
|
66 | + $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname); |
|
67 | + } |
|
64 | 68 | |
65 | 69 | if ($conn->connect_errno) |
66 | 70 | { |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | * the warning message "Property access is not allowed yet". |
71 | 75 | */ |
72 | 76 | throw new Exception\ConnectionException(mysqli_connect_error(), mysqli_connect_errno()); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | $this->dbconn = $conn; |
77 | 80 | $this->dbconn->set_charset($this->dbchar); |
@@ -118,13 +121,15 @@ discard block |
||
118 | 121 | |
119 | 122 | for ($i = 0; $i < $n_params; $i++) |
120 | 123 | { |
121 | - if (is_string($param_values[$i])) |
|
122 | - $bind_types .= 's'; |
|
123 | - else if(is_float($param_values[$i])) |
|
124 | - $bind_types .= 'd'; |
|
124 | + if (is_string($param_values[$i])) { |
|
125 | + $bind_types .= 's'; |
|
126 | + } else if(is_float($param_values[$i])) { |
|
127 | + $bind_types .= 'd'; |
|
128 | + } |
|
125 | 129 | # [POSSIBLE BUG] - To Future revision (What about non-string and non-decimal types ?) |
126 | - else |
|
127 | - $bind_types .= 's'; |
|
130 | + else { |
|
131 | + $bind_types .= 's'; |
|
132 | + } |
|
128 | 133 | |
129 | 134 | $bind_values[] = '$param_values[' . $i . ']'; |
130 | 135 | } |
@@ -137,8 +142,7 @@ discard block |
||
137 | 142 | if ($r) |
138 | 143 | { |
139 | 144 | } |
140 | - } |
|
141 | - else |
|
145 | + } else |
|
142 | 146 | { |
143 | 147 | $prev_error_handler = set_error_handler(['\Drone\Error\ErrorHandler', 'errorControlOperator'], E_ALL); |
144 | 148 | |
@@ -167,28 +171,33 @@ discard block |
||
167 | 171 | * It is useful to prevent rollback transactions on insert statements because |
168 | 172 | * insert statement do not free results. |
169 | 173 | */ |
170 | - if ($res) |
|
171 | - $this->result = $res; |
|
174 | + if ($res) { |
|
175 | + $this->result = $res; |
|
176 | + } |
|
172 | 177 | } |
173 | 178 | |
174 | 179 | # identify SELECT, SHOW, DESCRIBE or EXPLAIN queries |
175 | - if (is_object($this->result) && property_exists($this->result, 'num_rows')) |
|
176 | - $this->numRows = $this->result->num_rows; |
|
177 | - else |
|
180 | + if (is_object($this->result) && property_exists($this->result, 'num_rows')) { |
|
181 | + $this->numRows = $this->result->num_rows; |
|
182 | + } else |
|
178 | 183 | { |
179 | - if (property_exists($this->dbconn, 'affected_rows') && !$is_stmt_result) |
|
180 | - $this->rowsAffected = $this->dbconn->affected_rows; |
|
184 | + if (property_exists($this->dbconn, 'affected_rows') && !$is_stmt_result) { |
|
185 | + $this->rowsAffected = $this->dbconn->affected_rows; |
|
186 | + } |
|
181 | 187 | } |
182 | 188 | |
183 | 189 | # affected_rows return the same of num_rows on select statements! |
184 | - if ($this->numRows > 0) |
|
185 | - $this->rowsAffected = 0; |
|
190 | + if ($this->numRows > 0) { |
|
191 | + $this->rowsAffected = 0; |
|
192 | + } |
|
186 | 193 | |
187 | - if (property_exists($this->dbconn, 'field_count')) |
|
188 | - $this->numFields = $this->dbconn->field_count; |
|
194 | + if (property_exists($this->dbconn, 'field_count')) { |
|
195 | + $this->numFields = $this->dbconn->field_count; |
|
196 | + } |
|
189 | 197 | |
190 | - if ($this->transac_mode) |
|
191 | - $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
198 | + if ($this->transac_mode) { |
|
199 | + $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
200 | + } |
|
192 | 201 | |
193 | 202 | /* |
194 | 203 | * Because mysqli_query() returns FALSE on failure, a mysqli_result object for SELECT, SHOW, DESCRIBE or EXPLAIN queries, |
@@ -257,9 +266,8 @@ discard block |
||
257 | 266 | { |
258 | 267 | $data[] = $row; |
259 | 268 | } |
260 | - } |
|
261 | - else |
|
262 | - /* |
|
269 | + } else { |
|
270 | + /* |
|
263 | 271 | * "This kind of exception should lead directly to a fix in your code" |
264 | 272 | * So much production tests tell us this error is throwed because developers |
265 | 273 | * execute toArray() before execute(). |
@@ -267,6 +275,7 @@ discard block |
||
267 | 275 | * Ref: http://php.net/manual/en/class.logicexception.php |
268 | 276 | */ |
269 | 277 | throw new \LogicException('There are not data in the buffer!'); |
278 | + } |
|
270 | 279 | |
271 | 280 | $this->arrayResult = $data; |
272 | 281 | |
@@ -281,7 +290,8 @@ discard block |
||
281 | 290 | public function __destruct() |
282 | 291 | { |
283 | 292 | # prevent "Property access is not allowed yet" with @ on failure connections |
284 | - if ($this->dbconn !== false && !is_null($this->dbconn)) |
|
285 | - @$this->dbconn->close(); |
|
293 | + if ($this->dbconn !== false && !is_null($this->dbconn)) { |
|
294 | + @$this->dbconn->close(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | } |
288 | 298 | \ No newline at end of file |
@@ -92,28 +92,28 @@ discard block |
||
92 | 92 | { |
93 | 93 | foreach ($contents as $i) |
94 | 94 | { |
95 | - if (is_file($directory.'/'.$i)) |
|
95 | + if (is_file($directory . '/' . $i)) |
|
96 | 96 | { |
97 | 97 | $allContents[] = $i; |
98 | 98 | |
99 | - $this->buffer = $directory.'/'.$i; |
|
99 | + $this->buffer = $directory . '/' . $i; |
|
100 | 100 | call_user_func($fileCallback, $this); |
101 | 101 | } |
102 | - else if (is_dir($directory.'/'.$i)) |
|
102 | + else if (is_dir($directory . '/' . $i)) |
|
103 | 103 | { |
104 | - $directory_name = basename($directory).'/'.$i; |
|
104 | + $directory_name = basename($directory) . '/' . $i; |
|
105 | 105 | |
106 | 106 | if (strpos($directory_name, './') === 0) |
107 | 107 | { |
108 | 108 | $from = './'; |
109 | - $from = '/'.preg_quote($from, '/').'/'; |
|
109 | + $from = '/' . preg_quote($from, '/') . '/'; |
|
110 | 110 | $directory_name = preg_replace($from, "", $directory_name, 1); |
111 | 111 | } |
112 | 112 | |
113 | 113 | $allContents[$directory_name] = |
114 | - $this->getContents($directory.'/'.$i, $fileCallback, $dirCallback); |
|
114 | + $this->getContents($directory . '/' . $i, $fileCallback, $dirCallback); |
|
115 | 115 | |
116 | - $this->buffer = $directory.'/'.$i; |
|
116 | + $this->buffer = $directory . '/' . $i; |
|
117 | 117 | call_user_func($dirCallback, $this); |
118 | 118 | } |
119 | 119 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | if (!empty($path)) |
188 | 188 | if (!strlen(stristr($item, $path)) > 0) |
189 | 189 | continue; |
190 | - if (strstr($item,'~') === false && $item != '.' && $item != '..') |
|
190 | + if (strstr($item, '~') === false && $item != '.' && $item != '..') |
|
191 | 191 | $filesToReturn[] = $item; |
192 | 192 | } |
193 | 193 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | { |
332 | 332 | foreach ($files["folders"] as $folder) |
333 | 333 | { |
334 | - if (!file_exists($dest.'/'.$folder)) |
|
334 | + if (!file_exists($dest . '/' . $folder)) |
|
335 | 335 | mkdir("$dest/$folder", 0777, true); |
336 | 336 | } |
337 | 337 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | foreach ($files["files"] as $item) |
341 | 341 | { |
342 | 342 | if (!file_exists("$dest/$item")) |
343 | - copy($item, $dest.'/'.$item); |
|
343 | + copy($item, $dest . '/' . $item); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | array_shift($files["folders"]); |
351 | 351 | |
352 | 352 | $from = "$file/"; |
353 | - $from = '/'.preg_quote($from, '/').'/'; |
|
353 | + $from = '/' . preg_quote($from, '/') . '/'; |
|
354 | 354 | |
355 | 355 | if (count($files["folders"])) |
356 | 356 | { |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | { |
359 | 359 | $_folder = preg_replace($from, "", $folder, 1); |
360 | 360 | |
361 | - if (!file_exists($dest.'/'.$_folder)) |
|
361 | + if (!file_exists($dest . '/' . $_folder)) |
|
362 | 362 | mkdir("$dest/$_folder", 0777, true); |
363 | 363 | } |
364 | 364 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $_item = preg_replace($from, "", $item, 1); |
371 | 371 | |
372 | 372 | if (!file_exists("$dest/$_item")) |
373 | - copy($item, $dest.'/'.$_item); |
|
373 | + copy($item, $dest . '/' . $_item); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | } |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | |
381 | 381 | } |
382 | 382 | else if (is_dir($dest)) |
383 | - copy($file, $dest.'/'.$file); |
|
383 | + copy($file, $dest . '/' . $file); |
|
384 | 384 | else |
385 | 385 | copy($file, $dest); |
386 | 386 | |
@@ -401,12 +401,12 @@ discard block |
||
401 | 401 | throw new \InvalidArgumentException("Missing parameters"); |
402 | 402 | |
403 | 403 | if (is_dir($newfile)) |
404 | - $newfile .= '/'.basename($oldfile); |
|
404 | + $newfile .= '/' . basename($oldfile); |
|
405 | 405 | |
406 | 406 | if ($oldfile == $newfile) |
407 | 407 | throw new \Exception("'$oldfile' and '$newfile' are the same file"); |
408 | 408 | |
409 | - if(!rename($oldfile, $newfile)) |
|
409 | + if (!rename($oldfile, $newfile)) |
|
410 | 410 | return false; |
411 | 411 | |
412 | 412 | return true; |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | else { |
437 | 437 | if (!is_dir($dir)) |
438 | 438 | { |
439 | - if(!mkdir("$dir", 0777)) |
|
439 | + if (!mkdir("$dir", 0777)) |
|
440 | 440 | return false; |
441 | 441 | } |
442 | 442 | } |
@@ -84,8 +84,9 @@ discard block |
||
84 | 84 | { |
85 | 85 | foreach ($this->ls($directory) as $item) |
86 | 86 | { |
87 | - if ($item != '.' && $item != '..') |
|
88 | - $contents[] = $item; |
|
87 | + if ($item != '.' && $item != '..') { |
|
88 | + $contents[] = $item; |
|
89 | + } |
|
89 | 90 | } |
90 | 91 | |
91 | 92 | if (count($contents) > 0) |
@@ -98,8 +99,7 @@ discard block |
||
98 | 99 | |
99 | 100 | $this->buffer = $directory.'/'.$i; |
100 | 101 | call_user_func($fileCallback, $this); |
101 | - } |
|
102 | - else if (is_dir($directory.'/'.$i)) |
|
102 | + } else if (is_dir($directory.'/'.$i)) |
|
103 | 103 | { |
104 | 104 | $directory_name = basename($directory).'/'.$i; |
105 | 105 | |
@@ -118,14 +118,15 @@ discard block |
||
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
121 | + } else if (is_file($directory)) { |
|
122 | + throw new \InvalidArgumentException("'$directory' is actually a file"); |
|
123 | + } else { |
|
124 | + throw new \InvalidArgumentException("The directory '$directory' does not exists"); |
|
121 | 125 | } |
122 | - else if (is_file($directory)) |
|
123 | - throw new \InvalidArgumentException("'$directory' is actually a file"); |
|
124 | - else |
|
125 | - throw new \InvalidArgumentException("The directory '$directory' does not exists"); |
|
126 | 126 | |
127 | - if (!is_null($callback)) |
|
128 | - call_user_func($callback, $this); |
|
127 | + if (!is_null($callback)) { |
|
128 | + call_user_func($callback, $this); |
|
129 | + } |
|
129 | 130 | |
130 | 131 | return $allContents; |
131 | 132 | } |
@@ -137,10 +138,11 @@ discard block |
||
137 | 138 | */ |
138 | 139 | public function pwd() |
139 | 140 | { |
140 | - if (getcwd()) |
|
141 | - $this->buffer = getcwd(); |
|
142 | - else |
|
143 | - return false; |
|
141 | + if (getcwd()) { |
|
142 | + $this->buffer = getcwd(); |
|
143 | + } else { |
|
144 | + return false; |
|
145 | + } |
|
144 | 146 | |
145 | 147 | return $this->buffer; |
146 | 148 | } |
@@ -159,36 +161,38 @@ discard block |
||
159 | 161 | |
160 | 162 | $path = (is_null($path) || empty($path)) ? '.' : $path; |
161 | 163 | |
162 | - if (is_file($path)) |
|
163 | - $filesToReturn = array($path); |
|
164 | - else if (is_dir($path)) |
|
164 | + if (is_file($path)) { |
|
165 | + $filesToReturn = array($path); |
|
166 | + } else if (is_dir($path)) |
|
165 | 167 | { |
166 | 168 | $pathIns = dir($path); |
167 | 169 | |
168 | - if ($recursive) |
|
169 | - $filesToReturn = $this->getContents($path); |
|
170 | - else |
|
170 | + if ($recursive) { |
|
171 | + $filesToReturn = $this->getContents($path); |
|
172 | + } else |
|
171 | 173 | { |
172 | 174 | while (($item = $pathIns->read()) !== false) |
173 | 175 | { |
174 | - if ($item != '.' && $item != '..') |
|
175 | - $filesToReturn[] = $item; |
|
176 | + if ($item != '.' && $item != '..') { |
|
177 | + $filesToReturn[] = $item; |
|
178 | + } |
|
176 | 179 | } |
177 | 180 | |
178 | 181 | $pathIns->close(); |
179 | 182 | } |
180 | - } |
|
181 | - else { |
|
183 | + } else { |
|
182 | 184 | |
183 | 185 | $contents = $this->ls(); |
184 | 186 | |
185 | 187 | foreach ($contents as $item) |
186 | 188 | { |
187 | - if (!empty($path)) |
|
188 | - if (!strlen(stristr($item, $path)) > 0) |
|
189 | + if (!empty($path)) { |
|
190 | + if (!strlen(stristr($item, $path)) > 0) |
|
189 | 191 | continue; |
190 | - if (strstr($item,'~') === false && $item != '.' && $item != '..') |
|
191 | - $filesToReturn[] = $item; |
|
192 | + } |
|
193 | + if (strstr($item,'~') === false && $item != '.' && $item != '..') { |
|
194 | + $filesToReturn[] = $item; |
|
195 | + } |
|
192 | 196 | } |
193 | 197 | } |
194 | 198 | |
@@ -208,8 +212,9 @@ discard block |
||
208 | 212 | |
209 | 213 | if (is_dir($path)) |
210 | 214 | { |
211 | - if (chdir($path)) |
|
212 | - return true; |
|
215 | + if (chdir($path)) { |
|
216 | + return true; |
|
217 | + } |
|
213 | 218 | } |
214 | 219 | |
215 | 220 | return false; |
@@ -249,12 +254,13 @@ discard block |
||
249 | 254 | */ |
250 | 255 | public function rm($file, $recursive = false) |
251 | 256 | { |
252 | - if (is_null($file)) |
|
253 | - throw new \InvalidArgumentException("Missing first parameter"); |
|
257 | + if (is_null($file)) { |
|
258 | + throw new \InvalidArgumentException("Missing first parameter"); |
|
259 | + } |
|
254 | 260 | |
255 | - if (file_exists($file) && !$recursive) |
|
256 | - unlink($file); |
|
257 | - elseif (is_dir($file) && $recursive) |
|
261 | + if (file_exists($file) && !$recursive) { |
|
262 | + unlink($file); |
|
263 | + } elseif (is_dir($file) && $recursive) |
|
258 | 264 | { |
259 | 265 | $that = $this; |
260 | 266 | |
@@ -291,11 +297,13 @@ discard block |
||
291 | 297 | */ |
292 | 298 | public function cp($file, $dest, $recursive = false) |
293 | 299 | { |
294 | - if (empty($file) || empty($dest)) |
|
295 | - throw new \InvalidArgumentException("Missing parameters"); |
|
300 | + if (empty($file) || empty($dest)) { |
|
301 | + throw new \InvalidArgumentException("Missing parameters"); |
|
302 | + } |
|
296 | 303 | |
297 | - if (is_dir($file) && !$recursive) |
|
298 | - throw new \RuntimeException("Ommiting directory <<$foo>>"); |
|
304 | + if (is_dir($file) && !$recursive) { |
|
305 | + throw new \RuntimeException("Ommiting directory <<$foo>>"); |
|
306 | + } |
|
299 | 307 | |
300 | 308 | $dest_exists = file_exists($dest); |
301 | 309 | |
@@ -308,8 +316,9 @@ discard block |
||
308 | 316 | |
309 | 317 | $files["folders"][] = is_dir($dest) ? basename($file) : $dest; |
310 | 318 | |
311 | - if (!$dest_exists) |
|
312 | - mkdir($dest); |
|
319 | + if (!$dest_exists) { |
|
320 | + mkdir($dest); |
|
321 | + } |
|
313 | 322 | |
314 | 323 | $that = $this; |
315 | 324 | |
@@ -331,20 +340,21 @@ discard block |
||
331 | 340 | { |
332 | 341 | foreach ($files["folders"] as $folder) |
333 | 342 | { |
334 | - if (!file_exists($dest.'/'.$folder)) |
|
335 | - mkdir("$dest/$folder", 0777, true); |
|
343 | + if (!file_exists($dest.'/'.$folder)) { |
|
344 | + mkdir("$dest/$folder", 0777, true); |
|
345 | + } |
|
336 | 346 | } |
337 | 347 | |
338 | 348 | if (count($files["files"])) |
339 | 349 | { |
340 | 350 | foreach ($files["files"] as $item) |
341 | 351 | { |
342 | - if (!file_exists("$dest/$item")) |
|
343 | - copy($item, $dest.'/'.$item); |
|
352 | + if (!file_exists("$dest/$item")) { |
|
353 | + copy($item, $dest.'/'.$item); |
|
354 | + } |
|
344 | 355 | } |
345 | 356 | } |
346 | - } |
|
347 | - else |
|
357 | + } else |
|
348 | 358 | { |
349 | 359 | # directory previoulsy created |
350 | 360 | array_shift($files["folders"]); |
@@ -358,8 +368,9 @@ discard block |
||
358 | 368 | { |
359 | 369 | $_folder = preg_replace($from, "", $folder, 1); |
360 | 370 | |
361 | - if (!file_exists($dest.'/'.$_folder)) |
|
362 | - mkdir("$dest/$_folder", 0777, true); |
|
371 | + if (!file_exists($dest.'/'.$_folder)) { |
|
372 | + mkdir("$dest/$_folder", 0777, true); |
|
373 | + } |
|
363 | 374 | } |
364 | 375 | } |
365 | 376 | |
@@ -369,8 +380,9 @@ discard block |
||
369 | 380 | { |
370 | 381 | $_item = preg_replace($from, "", $item, 1); |
371 | 382 | |
372 | - if (!file_exists("$dest/$_item")) |
|
373 | - copy($item, $dest.'/'.$_item); |
|
383 | + if (!file_exists("$dest/$_item")) { |
|
384 | + copy($item, $dest.'/'.$_item); |
|
385 | + } |
|
374 | 386 | } |
375 | 387 | } |
376 | 388 | } |
@@ -378,11 +390,11 @@ discard block |
||
378 | 390 | ); |
379 | 391 | |
380 | 392 | |
393 | + } else if (is_dir($dest)) { |
|
394 | + copy($file, $dest.'/'.$file); |
|
395 | + } else { |
|
396 | + copy($file, $dest); |
|
381 | 397 | } |
382 | - else if (is_dir($dest)) |
|
383 | - copy($file, $dest.'/'.$file); |
|
384 | - else |
|
385 | - copy($file, $dest); |
|
386 | 398 | |
387 | 399 | return true; |
388 | 400 | } |
@@ -397,17 +409,21 @@ discard block |
||
397 | 409 | */ |
398 | 410 | public function mv($oldfile, $newfile) |
399 | 411 | { |
400 | - if (empty($oldfile) || empty($newfile)) |
|
401 | - throw new \InvalidArgumentException("Missing parameters"); |
|
412 | + if (empty($oldfile) || empty($newfile)) { |
|
413 | + throw new \InvalidArgumentException("Missing parameters"); |
|
414 | + } |
|
402 | 415 | |
403 | - if (is_dir($newfile)) |
|
404 | - $newfile .= '/'.basename($oldfile); |
|
416 | + if (is_dir($newfile)) { |
|
417 | + $newfile .= '/'.basename($oldfile); |
|
418 | + } |
|
405 | 419 | |
406 | - if ($oldfile == $newfile) |
|
407 | - throw new \Exception("'$oldfile' and '$newfile' are the same file"); |
|
420 | + if ($oldfile == $newfile) { |
|
421 | + throw new \Exception("'$oldfile' and '$newfile' are the same file"); |
|
422 | + } |
|
408 | 423 | |
409 | - if(!rename($oldfile, $newfile)) |
|
410 | - return false; |
|
424 | + if(!rename($oldfile, $newfile)) { |
|
425 | + return false; |
|
426 | + } |
|
411 | 427 | |
412 | 428 | return true; |
413 | 429 | } |
@@ -423,21 +439,24 @@ discard block |
||
423 | 439 | */ |
424 | 440 | public function mkdir($dir, $dest = null, $recursive = null) |
425 | 441 | { |
426 | - if (empty($dir)) |
|
427 | - throw new \InvalidArgumentException("Missing first parameter"); |
|
442 | + if (empty($dir)) { |
|
443 | + throw new \InvalidArgumentException("Missing first parameter"); |
|
444 | + } |
|
428 | 445 | |
429 | - if (empty($dest)) |
|
430 | - $dest = '.'; |
|
446 | + if (empty($dest)) { |
|
447 | + $dest = '.'; |
|
448 | + } |
|
431 | 449 | |
432 | 450 | $recursive = (is_null($recursive)) ? false : $recursive; |
433 | 451 | |
434 | - if ($recursive) |
|
435 | - mkdir("$dest/$dir", 0777, true); |
|
436 | - else { |
|
452 | + if ($recursive) { |
|
453 | + mkdir("$dest/$dir", 0777, true); |
|
454 | + } else { |
|
437 | 455 | if (!is_dir($dir)) |
438 | 456 | { |
439 | - if(!mkdir("$dir", 0777)) |
|
440 | - return false; |
|
457 | + if(!mkdir("$dir", 0777)) { |
|
458 | + return false; |
|
459 | + } |
|
441 | 460 | } |
442 | 461 | } |
443 | 462 | return true; |
@@ -452,12 +471,14 @@ discard block |
||
452 | 471 | */ |
453 | 472 | public function rmdir($dir) |
454 | 473 | { |
455 | - if (is_null($dir) || empty($dir)) |
|
456 | - throw new \RuntimeException("Missing first parameter"); |
|
474 | + if (is_null($dir) || empty($dir)) { |
|
475 | + throw new \RuntimeException("Missing first parameter"); |
|
476 | + } |
|
457 | 477 | |
458 | - if (rmdir($dir)) |
|
459 | - return true; |
|
460 | - else |
|
461 | - return false; |
|
478 | + if (rmdir($dir)) { |
|
479 | + return true; |
|
480 | + } else { |
|
481 | + return false; |
|
482 | + } |
|
462 | 483 | } |
463 | 484 | } |
464 | 485 | \ No newline at end of file |
@@ -74,7 +74,7 @@ |
||
74 | 74 | public function listen(Array $eventHandlers = array()) |
75 | 75 | { |
76 | 76 | $event = $eventHandlers; |
77 | - $clousure = function(){}; |
|
77 | + $clousure = function() {}; |
|
78 | 78 | |
79 | 79 | if (!array_key_exists('success', $event)) |
80 | 80 | $event["success"] = $clousure; |
@@ -76,11 +76,13 @@ discard block |
||
76 | 76 | $event = $eventHandlers; |
77 | 77 | $clousure = function(){}; |
78 | 78 | |
79 | - if (!array_key_exists('success', $event)) |
|
80 | - $event["success"] = $clousure; |
|
79 | + if (!array_key_exists('success', $event)) { |
|
80 | + $event["success"] = $clousure; |
|
81 | + } |
|
81 | 82 | |
82 | - if (!array_key_exists('error', $event)) |
|
83 | - $event["error"] = $clousure; |
|
83 | + if (!array_key_exists('error', $event)) { |
|
84 | + $event["error"] = $clousure; |
|
85 | + } |
|
84 | 86 | |
85 | 87 | $listener = false; |
86 | 88 | |
@@ -90,8 +92,7 @@ discard block |
||
90 | 92 | $this->error($errno, socket_strerror($errno)); |
91 | 93 | |
92 | 94 | throw new \RuntimeException("Could not set socket to listen"); |
93 | - } |
|
94 | - else { |
|
95 | + } else { |
|
95 | 96 | |
96 | 97 | echo "\n"; |
97 | 98 | echo "Server Started : " . date('Y-m-d H:i:s') . "\n"; |
@@ -114,8 +115,9 @@ discard block |
||
114 | 115 | socket_close($spawn); |
115 | 116 | } |
116 | 117 | |
117 | - if (!$listener) |
|
118 | - call_user_func($event["error"], $this->getLastError()); |
|
118 | + if (!$listener) { |
|
119 | + call_user_func($event["error"], $this->getLastError()); |
|
120 | + } |
|
119 | 121 | |
120 | 122 | return $listener; |
121 | 123 | } |
@@ -84,12 +84,10 @@ discard block |
||
84 | 84 | |
85 | 85 | try { |
86 | 86 | $conn->disconnect(); |
87 | - } |
|
88 | - catch (\Exception $e) |
|
87 | + } catch (\Exception $e) |
|
89 | 88 | { |
90 | 89 | $errorObject = ($e instanceof \LogicException); |
91 | - } |
|
92 | - finally |
|
90 | + } finally |
|
93 | 91 | { |
94 | 92 | $this->assertNotTrue($conn->isConnected()); |
95 | 93 | $this->assertTrue($errorObject, $e->getMessage()); |
@@ -125,12 +123,10 @@ discard block |
||
125 | 123 | |
126 | 124 | try { |
127 | 125 | $conn->reconnect(); |
128 | - } |
|
129 | - catch (\Exception $e) |
|
126 | + } catch (\Exception $e) |
|
130 | 127 | { |
131 | 128 | $errorObject = ($e instanceof \LogicException); |
132 | - } |
|
133 | - finally |
|
129 | + } finally |
|
134 | 130 | { |
135 | 131 | $this->assertTrue($errorObject, $e->getMessage()); |
136 | 132 | $this->assertNotTrue($conn->isConnected()); |
@@ -156,13 +152,11 @@ discard block |
||
156 | 152 | try |
157 | 153 | { |
158 | 154 | $conn->connect(); |
159 | - } |
|
160 | - catch (\Exception $e) |
|
155 | + } catch (\Exception $e) |
|
161 | 156 | { |
162 | 157 | $errorObject = ($e instanceof ConnectionException); |
163 | 158 | $message = $e->getMessage(); |
164 | - } |
|
165 | - finally |
|
159 | + } finally |
|
166 | 160 | { |
167 | 161 | $this->assertTrue($errorObject, $message); |
168 | 162 | $this->assertNotTrue($conn->isConnected()); |
@@ -242,13 +236,11 @@ discard block |
||
242 | 236 | { |
243 | 237 | $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('Hello world!')"; |
244 | 238 | $conn->execute($sql); |
245 | - } |
|
246 | - catch (\Exception $e) |
|
239 | + } catch (\Exception $e) |
|
247 | 240 | { |
248 | 241 | $errorObject = ($e instanceof InvalidQueryException); |
249 | 242 | $message = $e->getMessage(); |
250 | - } |
|
251 | - finally |
|
243 | + } finally |
|
252 | 244 | { |
253 | 245 | $this->assertTrue($errorObject, $message); |
254 | 246 | } |
@@ -517,8 +509,7 @@ discard block |
||
517 | 509 | |
518 | 510 | $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')"; |
519 | 511 | $conn->execute($sql); |
520 | - } |
|
521 | - catch (InvalidQueryException $e) |
|
512 | + } catch (InvalidQueryException $e) |
|
522 | 513 | { |
523 | 514 | $message = $e->getMessage(); |
524 | 515 | #·not necessary! |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | public function testCannotStablishConnection() |
146 | 146 | { |
147 | 147 | $options = $this->options; |
148 | - $options["dbhost"] = 'myserver'; // this server does not exists |
|
148 | + $options["dbhost"] = 'myserver'; // this server does not exists |
|
149 | 149 | |
150 | 150 | $conn = new MySQL($options); |
151 | 151 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $this->assertEquals(2, $conn->getNumFields()); |
275 | 275 | $this->assertEquals(0, $conn->getRowsAffected()); |
276 | 276 | |
277 | - $rowset = $conn->getArrayResult(); # array with results |
|
277 | + $rowset = $conn->getArrayResult(); # array with results |
|
278 | 278 | $row = array_shift($rowset); |
279 | 279 | |
280 | 280 | $this->assertArrayHasKey("ID", $row); |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | $conn->execute($sql); |
302 | 302 | $rowcount = count($conn->getArrayResult()); |
303 | 303 | |
304 | - $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
304 | + $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
305 | 305 | |
306 | 306 | # properties modified by execute() method |
307 | 307 | $this->assertEquals(1, $conn->getNumRows()); |
308 | 308 | $this->assertEquals(2, $conn->getNumFields()); |
309 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
309 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
310 | 310 | |
311 | 311 | $this->assertTrue($conn->commit()); |
312 | 312 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $conn->execute($sql); |
316 | 316 | $rowcount = count($conn->getArrayResult()); |
317 | 317 | |
318 | - $this->assertTrue(($rowcount === 1)); # the row is available |
|
318 | + $this->assertTrue(($rowcount === 1)); # the row is available |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -338,12 +338,12 @@ discard block |
||
338 | 338 | $conn->execute($sql); |
339 | 339 | $rowcount = count($conn->getArrayResult()); |
340 | 340 | |
341 | - $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
341 | + $this->assertTrue(($rowcount === 1)); # the row is available for now |
|
342 | 342 | |
343 | 343 | # properties modified by execute() method |
344 | 344 | $this->assertEquals(1, $conn->getNumRows()); |
345 | 345 | $this->assertEquals(2, $conn->getNumFields()); |
346 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
346 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
347 | 347 | |
348 | 348 | $this->assertTrue($conn->rollback()); |
349 | 349 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $conn->execute($sql); |
353 | 353 | $rowcount = count($conn->getArrayResult()); |
354 | 354 | |
355 | - $this->assertNotTrue(($rowcount === 1)); # the row is not available |
|
355 | + $this->assertNotTrue(($rowcount === 1)); # the row is not available |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -384,12 +384,12 @@ discard block |
||
384 | 384 | $conn->execute($sql); |
385 | 385 | $rowcount = count($conn->getArrayResult()); |
386 | 386 | |
387 | - $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
387 | + $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
388 | 388 | |
389 | 389 | # properties modified by execute() method |
390 | 390 | $this->assertEquals(4, $conn->getNumRows()); |
391 | 391 | $this->assertEquals(2, $conn->getNumFields()); |
392 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
392 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
393 | 393 | |
394 | 394 | $this->assertTrue($conn->commit()); |
395 | 395 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $conn->execute($sql); |
399 | 399 | $rowcount = count($conn->getArrayResult()); |
400 | 400 | |
401 | - $this->assertTrue(($rowcount === 4)); # the rows are available |
|
401 | + $this->assertTrue(($rowcount === 4)); # the rows are available |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | $conn->execute($sql); |
431 | 431 | $rowcount = count($conn->getArrayResult()); |
432 | 432 | |
433 | - $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
433 | + $this->assertTrue(($rowcount === 4)); # the rows are available for now |
|
434 | 434 | |
435 | 435 | # properties modified by execute() method |
436 | 436 | $this->assertEquals(4, $conn->getNumRows()); |
437 | 437 | $this->assertEquals(2, $conn->getNumFields()); |
438 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
438 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
439 | 439 | |
440 | 440 | $this->assertTrue($conn->rollback()); |
441 | 441 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $conn->execute($sql); |
445 | 445 | $rowcount = count($conn->getArrayResult()); |
446 | 446 | |
447 | - $this->assertNotTrue(($rowcount === 4)); # the rows are not available |
|
447 | + $this->assertNotTrue(($rowcount === 4)); # the rows are not available |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | $conn->execute($sql); |
476 | 476 | $rowcount = count($conn->getArrayResult()); |
477 | 477 | |
478 | - $this->assertTrue(($rowcount === 2)); # the rows are available for now |
|
478 | + $this->assertTrue(($rowcount === 2)); # the rows are available for now |
|
479 | 479 | |
480 | 480 | # properties modified by execute() method |
481 | 481 | $this->assertEquals(2, $conn->getNumRows()); |
482 | 482 | $this->assertEquals(2, $conn->getNumFields()); |
483 | - $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
483 | + $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false) |
|
484 | 484 | |
485 | 485 | # ends the transaction |
486 | 486 | $conn->endTransaction(); |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | $conn->execute($sql); |
491 | 491 | $rowcount = count($conn->getArrayResult()); |
492 | 492 | |
493 | - $this->assertTrue(($rowcount === 2)); # the row is available |
|
493 | + $this->assertTrue(($rowcount === 2)); # the row is available |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $conn->execute($sql); |
535 | 535 | $rowcount = count($conn->getArrayResult()); |
536 | 536 | |
537 | - $this->assertNotTrue(($rowcount === 0)); # the rows are not available |
|
537 | + $this->assertNotTrue(($rowcount === 0)); # the rows are not available |
|
538 | 538 | |
539 | 539 | # remove all work |
540 | 540 | $conn->execute("DROP TABLE MYTABLE"); |
@@ -127,8 +127,9 @@ |
||
127 | 127 | { |
128 | 128 | $codes = $this->httpStatusCodes; |
129 | 129 | |
130 | - if (!in_array($code, array_keys($codes))) |
|
131 | - throw new \RuntimeException("Status code not supported"); |
|
130 | + if (!in_array($code, array_keys($codes))) { |
|
131 | + throw new \RuntimeException("Status code not supported"); |
|
132 | + } |
|
132 | 133 | |
133 | 134 | return $this->httpStatusCodes[$code]; |
134 | 135 | } |
@@ -56,13 +56,11 @@ |
||
56 | 56 | try |
57 | 57 | { |
58 | 58 | $text = $http->getStatusText(65431); |
59 | - } |
|
60 | - catch (\Exception $e) |
|
59 | + } catch (\Exception $e) |
|
61 | 60 | { |
62 | 61 | $errorObject = ($e instanceof \RuntimeException); |
63 | 62 | $message = $e->getMessage(); |
64 | - } |
|
65 | - finally |
|
63 | + } finally |
|
66 | 64 | { |
67 | 65 | $this->assertTrue($errorObject, $message); |
68 | 66 | } |