@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | ]); |
48 | 48 | |
49 | 49 | $form->fill([ |
50 | - "username" => 'jobs', # wrong because of minlength attr |
|
50 | + "username" => 'jobs', # wrong because of minlength attr |
|
51 | 51 | "password" => 'jVi7Qp4X', |
52 | 52 | "email" => 'j@' # wrong because of type and minlength attr |
53 | 53 | ]); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | ]); |
199 | 199 | |
200 | 200 | $form->fill([ |
201 | - "username" => 'jobs', # wrong because of minlength attr |
|
201 | + "username" => 'jobs', # wrong because of minlength attr |
|
202 | 202 | ]); |
203 | 203 | |
204 | 204 | $validator = new FormValidator($form, 'en'); |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | $form->fill([ |
244 | 244 | "product" => [ |
245 | 245 | "optical mouse", |
246 | - "-", # wrong name |
|
246 | + "-", # wrong name |
|
247 | 247 | "78" # another wrong name |
248 | 248 | ], |
249 | 249 | "price" => [ |
250 | 250 | 10, |
251 | - 0, # wrong price |
|
251 | + 0, # wrong price |
|
252 | 252 | 0 # another wrong price |
253 | 253 | ] |
254 | 254 | ]); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | ]); |
306 | 306 | |
307 | 307 | $form->fill([ |
308 | - "username" => 'steave jobs', # wrong because of minlength attr |
|
308 | + "username" => 'steave jobs', # wrong because of minlength attr |
|
309 | 309 | "password" => 'jVi7Qp4X', |
310 | 310 | "type" => 'moderator' # wrong because moderator is not a valid needle |
311 | 311 | ]); |
@@ -48,11 +48,13 @@ |
||
48 | 48 | { |
49 | 49 | $child = $this->getChild($label); |
50 | 50 | |
51 | - if (is_null($child)) |
|
52 | - throw new Exception\ChildNotFoundException("The child '$label' does not exists inside the form element"); |
|
51 | + if (is_null($child)) { |
|
52 | + throw new Exception\ChildNotFoundException("The child '$label' does not exists inside the form element"); |
|
53 | + } |
|
53 | 54 | |
54 | - if (!$child->isFormControl()) |
|
55 | - throw new Exception\NotFormControlException("The child '$label' is not a form control"); |
|
55 | + if (!$child->isFormControl()) { |
|
56 | + throw new Exception\NotFormControlException("The child '$label' is not a form control"); |
|
57 | + } |
|
56 | 58 | |
57 | 59 | $child->setAttribute(new Attribute("value", $value)); |
58 | 60 | } |
@@ -110,8 +110,9 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function hasChild($label) |
112 | 112 | { |
113 | - if (array_key_exists($label, $this->children)) |
|
114 | - return true; |
|
113 | + if (array_key_exists($label, $this->children)) { |
|
114 | + return true; |
|
115 | + } |
|
115 | 116 | |
116 | 117 | return false; |
117 | 118 | } |
@@ -125,8 +126,9 @@ discard block |
||
125 | 126 | */ |
126 | 127 | public function getChild($label) |
127 | 128 | { |
128 | - if (array_key_exists($label, $this->children)) |
|
129 | - return $this->children[$label]; |
|
129 | + if (array_key_exists($label, $this->children)) { |
|
130 | + return $this->children[$label]; |
|
131 | + } |
|
130 | 132 | |
131 | 133 | return null; |
132 | 134 | } |
@@ -155,10 +157,11 @@ discard block |
||
155 | 157 | */ |
156 | 158 | public function removeChild($label) |
157 | 159 | { |
158 | - if (array_key_exists($label, $this->children)) |
|
159 | - unset($this->children[$label]); |
|
160 | - else |
|
161 | - throw new Exception\ChildNotFoundException("The child to remove does not exists"); |
|
160 | + if (array_key_exists($label, $this->children)) { |
|
161 | + unset($this->children[$label]); |
|
162 | + } else { |
|
163 | + throw new Exception\ChildNotFoundException("The child to remove does not exists"); |
|
164 | + } |
|
162 | 165 | } |
163 | 166 | |
164 | 167 | /** |
@@ -174,8 +177,9 @@ discard block |
||
174 | 177 | { |
175 | 178 | foreach ($this->attributes as $attrib) |
176 | 179 | { |
177 | - if ($attrib->getName() == $name) |
|
178 | - return true; |
|
180 | + if ($attrib->getName() == $name) { |
|
181 | + return true; |
|
182 | + } |
|
179 | 183 | } |
180 | 184 | } |
181 | 185 | |
@@ -195,8 +199,9 @@ discard block |
||
195 | 199 | { |
196 | 200 | foreach ($this->attributes as $attrib) |
197 | 201 | { |
198 | - if ($attrib->getName() == $name) |
|
199 | - return $attrib; |
|
202 | + if ($attrib->getName() == $name) { |
|
203 | + return $attrib; |
|
204 | + } |
|
200 | 205 | } |
201 | 206 | } |
202 | 207 | |
@@ -218,12 +223,13 @@ discard block |
||
218 | 223 | { |
219 | 224 | foreach ($this->attributes as $key => $_attrib) |
220 | 225 | { |
221 | - if ($_attrib->getName() == $attrib->getName()) |
|
222 | - $this->attributes[$key] = $attribute; |
|
226 | + if ($_attrib->getName() == $attrib->getName()) { |
|
227 | + $this->attributes[$key] = $attribute; |
|
228 | + } |
|
223 | 229 | } |
230 | + } else { |
|
231 | + $this->attributes[] = $attribute; |
|
224 | 232 | } |
225 | - else |
|
226 | - $this->attributes[] = $attribute; |
|
227 | 233 | } |
228 | 234 | |
229 | 235 | /** |
@@ -241,8 +247,9 @@ discard block |
||
241 | 247 | { |
242 | 248 | foreach ($this->attributes as $key => $attrib) |
243 | 249 | { |
244 | - if ($attrib->getName() == $name) |
|
245 | - unset($this->attributes[$key]); |
|
250 | + if ($attrib->getName() == $name) { |
|
251 | + unset($this->attributes[$key]); |
|
252 | + } |
|
246 | 253 | } |
247 | 254 | } |
248 | 255 | |
@@ -260,8 +267,7 @@ discard block |
||
260 | 267 | { |
261 | 268 | $this->startTag = "<" .strtolower(static::NODE_NAME). ">"; |
262 | 269 | $this->endTag = "</" .strtolower(static::NODE_NAME). ">"; |
263 | - } |
|
264 | - else |
|
270 | + } else |
|
265 | 271 | { |
266 | 272 | $this->startTag = "<" .strtolower(static::NODE_NAME); |
267 | 273 | $this->endTag = "/>"; |
@@ -275,8 +281,9 @@ discard block |
||
275 | 281 | */ |
276 | 282 | public function isFormControl() |
277 | 283 | { |
278 | - if (in_array(static::NODE_NAME, ['INPUT'])) |
|
279 | - return true; |
|
284 | + if (in_array(static::NODE_NAME, ['INPUT'])) { |
|
285 | + return true; |
|
286 | + } |
|
280 | 287 | |
281 | 288 | return false; |
282 | 289 | } |
@@ -92,29 +92,32 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function _error($code, $message = null) |
94 | 94 | { |
95 | - if (!is_null($code) && !is_integer($code) && !is_string($code)) |
|
96 | - throw new \InvalidArgumentException("Invalid type given. Integer or string expected"); |
|
95 | + if (!is_null($code) && !is_integer($code) && !is_string($code)) { |
|
96 | + throw new \InvalidArgumentException("Invalid type given. Integer or string expected"); |
|
97 | + } |
|
97 | 98 | |
98 | - if (is_null($code)) |
|
99 | - $code = preg_replace('/=|\/|\+/', "", base64_encode($message)); |
|
100 | - else |
|
99 | + if (is_null($code)) { |
|
100 | + $code = preg_replace('/=|\/|\+/', "", base64_encode($message)); |
|
101 | + } else |
|
101 | 102 | { |
102 | - if (!array_key_exists($code, $this->standardErrors) && empty($message)) |
|
103 | - /* |
|
103 | + if (!array_key_exists($code, $this->standardErrors) && empty($message)) { |
|
104 | + /* |
|
104 | 105 | * Non-standard errors must have a message to describe the error, make sure |
105 | 106 | * you execute the error() method with a message as the second parameter. |
106 | 107 | */ |
107 | 108 | throw new \LogicException('The message does not be empty in non-standard errors!'); |
109 | + } |
|
108 | 110 | } |
109 | 111 | |
110 | - if (!array_key_exists($code, $this->errors)) |
|
111 | - $this->errors[$code] = (array_key_exists($code, $this->standardErrors)) |
|
112 | + if (!array_key_exists($code, $this->errors)) { |
|
113 | + $this->errors[$code] = (array_key_exists($code, $this->standardErrors)) |
|
112 | 114 | ? |
113 | 115 | is_null($message) |
114 | 116 | ? preg_replace('/\s\'%[a-zA-Z]*%\'/', $message, $this->standardErrors[$code]) |
115 | 117 | # if $message is not null it will replace the %file% wildcard |
116 | 118 | : preg_replace('/%[a-zA-Z]*%/', $message, $this->standardErrors[$code]) |
117 | 119 | : $message; |
120 | + } |
|
118 | 121 | } |
119 | 122 | |
120 | 123 | function __call($method, $arguments) |
@@ -124,10 +127,11 @@ discard block |
||
124 | 127 | switch (count($arguments)) |
125 | 128 | { |
126 | 129 | case 1: |
127 | - if (is_integer($arguments[0])) |
|
128 | - return call_user_func([$this, '_error'], array_shift($arguments)); |
|
129 | - else |
|
130 | - return call_user_func([$this, '_error'], null, array_shift($arguments)); |
|
130 | + if (is_integer($arguments[0])) { |
|
131 | + return call_user_func([$this, '_error'], array_shift($arguments)); |
|
132 | + } else { |
|
133 | + return call_user_func([$this, '_error'], null, array_shift($arguments)); |
|
134 | + } |
|
131 | 135 | break; |
132 | 136 | case 2: |
133 | 137 | return call_user_func([$this, '_error'], $arguments[0], $arguments[1]); |
@@ -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,10 +242,10 @@ discard block |
||
236 | 242 | { |
237 | 243 | $data[] = $row; |
238 | 244 | } |
239 | - } |
|
240 | - else |
|
241 | - # This error is thrown because of 'execute' method has not been executed. |
|
245 | + } else { |
|
246 | + # This error is thrown because of 'execute' method has not been executed. |
|
242 | 247 | throw new \LogicException('There are not data in the buffer!'); |
248 | + } |
|
243 | 249 | |
244 | 250 | $this->arrayResult = $data; |
245 | 251 | |
@@ -253,7 +259,8 @@ discard block |
||
253 | 259 | */ |
254 | 260 | public function __destruct() |
255 | 261 | { |
256 | - if ($this->dbconn) |
|
257 | - sqlsrv_close($this->dbconn); |
|
262 | + if ($this->dbconn) { |
|
263 | + sqlsrv_close($this->dbconn); |
|
264 | + } |
|
258 | 265 | } |
259 | 266 | } |
260 | 267 | \ No newline at end of file |
@@ -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,10 +210,10 @@ discard block |
||
205 | 210 | { |
206 | 211 | $data[] = $row; |
207 | 212 | } |
208 | - } |
|
209 | - else |
|
210 | - # This error is thrown because of 'execute' method has not been executed. |
|
213 | + } else { |
|
214 | + # This error is thrown because of 'execute' method has not been executed. |
|
211 | 215 | throw new \LogicException('There are not data in the buffer!'); |
216 | + } |
|
212 | 217 | |
213 | 218 | $this->arrayResult = $data; |
214 | 219 | |
@@ -222,7 +227,8 @@ discard block |
||
222 | 227 | */ |
223 | 228 | public function __destruct() |
224 | 229 | { |
225 | - if ($this->dbconn) |
|
226 | - oci_close($this->dbconn); |
|
230 | + if ($this->dbconn) { |
|
231 | + oci_close($this->dbconn); |
|
232 | + } |
|
227 | 233 | } |
228 | 234 | } |
229 | 235 | \ No newline at end of file |
@@ -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 | } |
@@ -133,8 +138,7 @@ discard block |
||
133 | 138 | eval('$stmt->bind_param(\'' . $bind_types . '\', ' . $values . ');'); |
134 | 139 | |
135 | 140 | $r = $stmt->execute(); |
136 | - } |
|
137 | - else |
|
141 | + } else |
|
138 | 142 | { |
139 | 143 | $prev_error_handler = set_error_handler(['\Drone\Error\ErrorHandler', 'errorControlOperator'], E_ALL); |
140 | 144 | |
@@ -163,28 +167,33 @@ discard block |
||
163 | 167 | * It is useful to prevent rollback transactions on insert statements because |
164 | 168 | * insert statement do not free results. |
165 | 169 | */ |
166 | - if ($res) |
|
167 | - $this->result = $res; |
|
170 | + if ($res) { |
|
171 | + $this->result = $res; |
|
172 | + } |
|
168 | 173 | } |
169 | 174 | |
170 | 175 | # identify SELECT, SHOW, DESCRIBE or EXPLAIN queries |
171 | - if (is_object($this->result) && property_exists($this->result, 'num_rows')) |
|
172 | - $this->numRows = $this->result->num_rows; |
|
173 | - else |
|
176 | + if (is_object($this->result) && property_exists($this->result, 'num_rows')) { |
|
177 | + $this->numRows = $this->result->num_rows; |
|
178 | + } else |
|
174 | 179 | { |
175 | - if (property_exists($this->dbconn, 'affected_rows') && !$is_stmt_result) |
|
176 | - $this->rowsAffected = $this->dbconn->affected_rows; |
|
180 | + if (property_exists($this->dbconn, 'affected_rows') && !$is_stmt_result) { |
|
181 | + $this->rowsAffected = $this->dbconn->affected_rows; |
|
182 | + } |
|
177 | 183 | } |
178 | 184 | |
179 | 185 | # affected_rows return the same of num_rows on select statements! |
180 | - if ($this->numRows > 0) |
|
181 | - $this->rowsAffected = 0; |
|
186 | + if ($this->numRows > 0) { |
|
187 | + $this->rowsAffected = 0; |
|
188 | + } |
|
182 | 189 | |
183 | - if (property_exists($this->dbconn, 'field_count')) |
|
184 | - $this->numFields = $this->dbconn->field_count; |
|
190 | + if (property_exists($this->dbconn, 'field_count')) { |
|
191 | + $this->numFields = $this->dbconn->field_count; |
|
192 | + } |
|
185 | 193 | |
186 | - if ($this->transac_mode) |
|
187 | - $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
194 | + if ($this->transac_mode) { |
|
195 | + $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
196 | + } |
|
188 | 197 | /* |
189 | 198 | * Because mysqli_query() returns FALSE on failure, a mysqli_result object for SELECT, SHOW, DESCRIBE or EXPLAIN queries, |
190 | 199 | * and TRUE for other successful queries, it should be handled to return only objects or resources. |
@@ -252,10 +261,10 @@ discard block |
||
252 | 261 | { |
253 | 262 | $data[] = $row; |
254 | 263 | } |
255 | - } |
|
256 | - else |
|
257 | - # This error is thrown because of 'execute' method has not been executed. |
|
264 | + } else { |
|
265 | + # This error is thrown because of 'execute' method has not been executed. |
|
258 | 266 | throw new \LogicException('There are not data in the buffer!'); |
267 | + } |
|
259 | 268 | |
260 | 269 | $this->arrayResult = $data; |
261 | 270 | |
@@ -270,7 +279,8 @@ discard block |
||
270 | 279 | public function __destruct() |
271 | 280 | { |
272 | 281 | # prevent "Property access is not allowed yet" with @ on failure connections |
273 | - if ($this->dbconn !== false && !is_null($this->dbconn)) |
|
274 | - @$this->dbconn->close(); |
|
282 | + if ($this->dbconn !== false && !is_null($this->dbconn)) { |
|
283 | + @$this->dbconn->close(); |
|
284 | + } |
|
275 | 285 | } |
276 | 286 | } |
277 | 287 | \ No newline at end of file |
@@ -304,7 +304,7 @@ |
||
304 | 304 | { |
305 | 305 | foreach ($validator->getMessages() as $message) |
306 | 306 | { |
307 | - $this->error($label ."-~-". (count($this->getErrors()) + 1), $message); |
|
307 | + $this->error($label . "-~-" . (count($this->getErrors()) + 1), $message); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | } |
@@ -69,9 +69,10 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function isValid() |
71 | 71 | { |
72 | - if (is_null($this->valid)) |
|
73 | - # This error is thrown because of 'setValid' method has not been executed. |
|
72 | + if (is_null($this->valid)) { |
|
73 | + # This error is thrown because of 'setValid' method has not been executed. |
|
74 | 74 | throw new \LogicException('No validation has been executed!'); |
75 | + } |
|
75 | 76 | |
76 | 77 | return $this->valid; |
77 | 78 | } |
@@ -136,8 +137,9 @@ discard block |
||
136 | 137 | |
137 | 138 | foreach ($elements as $label => $element) |
138 | 139 | { |
139 | - if (!$element->isFormControl()) |
|
140 | - continue; |
|
140 | + if (!$element->isFormControl()) { |
|
141 | + continue; |
|
142 | + } |
|
141 | 143 | |
142 | 144 | $attribs = $element->getAttributes(); |
143 | 145 | |
@@ -206,19 +208,21 @@ discard block |
||
206 | 208 | |
207 | 209 | case 'min': |
208 | 210 | |
209 | - if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) |
|
210 | - $validator = new GreaterThan(['min' => $value, 'inclusive' => true]); |
|
211 | - else |
|
212 | - throw new \LogicException("The input type must be 'range' or 'number'"); |
|
211 | + if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) { |
|
212 | + $validator = new GreaterThan(['min' => $value, 'inclusive' => true]); |
|
213 | + } else { |
|
214 | + throw new \LogicException("The input type must be 'range' or 'number'"); |
|
215 | + } |
|
213 | 216 | |
214 | 217 | break; |
215 | 218 | |
216 | 219 | case 'max': |
217 | 220 | |
218 | - if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) |
|
219 | - $validator = new LessThan(['max' => $value, 'inclusive' => true]); |
|
220 | - else |
|
221 | - throw new \LogicException("The input type must be 'range' or 'number'"); |
|
221 | + if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['number', 'range'])) { |
|
222 | + $validator = new LessThan(['max' => $value, 'inclusive' => true]); |
|
223 | + } else { |
|
224 | + throw new \LogicException("The input type must be 'range' or 'number'"); |
|
225 | + } |
|
222 | 226 | |
223 | 227 | break; |
224 | 228 | |
@@ -226,17 +230,19 @@ discard block |
||
226 | 230 | |
227 | 231 | $baseValue = (array_key_exists('min', $all_attribs)) ? $all_attribs['min'] : 0; |
228 | 232 | |
229 | - if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range'])) |
|
230 | - $validator = new Step(['baseValue' => $baseValue, 'step' => $value]); |
|
231 | - else |
|
232 | - throw new \LogicException("The input type must be 'range'"); |
|
233 | + if (array_key_exists('type', $all_attribs) && in_array($all_attribs['type'], ['range'])) { |
|
234 | + $validator = new Step(['baseValue' => $baseValue, 'step' => $value]); |
|
235 | + } else { |
|
236 | + throw new \LogicException("The input type must be 'range'"); |
|
237 | + } |
|
233 | 238 | |
234 | 239 | break; |
235 | 240 | |
236 | 241 | case 'data-validators': |
237 | 242 | |
238 | - if (!is_array($value)) |
|
239 | - throw new \InvalidArgumentException("Invalid type given. Array expected in 'data-validators' attribute."); |
|
243 | + if (!is_array($value)) { |
|
244 | + throw new \InvalidArgumentException("Invalid type given. Array expected in 'data-validators' attribute."); |
|
245 | + } |
|
240 | 246 | |
241 | 247 | foreach ($value as $class => $params) |
242 | 248 | { |
@@ -246,8 +252,9 @@ discard block |
||
246 | 252 | { |
247 | 253 | $className = "\Zend\I18n\Validator\\" . $class; |
248 | 254 | |
249 | - if (!class_exists($className)) |
|
250 | - throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists"); |
|
255 | + if (!class_exists($className)) { |
|
256 | + throw new \RuntimeException("The class '$userInputClass' or '$className' does not exists"); |
|
257 | + } |
|
251 | 258 | } |
252 | 259 | |
253 | 260 | $validator = new $className($params); |
@@ -294,8 +301,9 @@ discard block |
||
294 | 301 | $v->setTranslator($this->translator); |
295 | 302 | $notEmpty = $v->isValid($val); |
296 | 303 | |
297 | - if (!$required && !$notEmpty) |
|
298 | - return null; |
|
304 | + if (!$required && !$notEmpty) { |
|
305 | + return null; |
|
306 | + } |
|
299 | 307 | |
300 | 308 | $valid = $validator->isValid($val); |
301 | 309 | $this->setValid($valid); |
@@ -307,8 +315,7 @@ discard block |
||
307 | 315 | $this->error($label ."-~-". (count($this->getErrors()) + 1), $message); |
308 | 316 | } |
309 | 317 | } |
310 | - } |
|
311 | - else |
|
318 | + } else |
|
312 | 319 | { |
313 | 320 | foreach ($form_value as $val) |
314 | 321 | { |
@@ -333,8 +340,9 @@ discard block |
||
333 | 340 | $errorLbl = explode("-~-", $key); |
334 | 341 | $label = array_shift($errorLbl); |
335 | 342 | |
336 | - if (!array_key_exists($label, $errors)) |
|
337 | - $errors[$label] = []; |
|
343 | + if (!array_key_exists($label, $errors)) { |
|
344 | + $errors[$label] = []; |
|
345 | + } |
|
338 | 346 | |
339 | 347 | $errors[$label][] = $value; |
340 | 348 | } |