Passed
Branch php-cs-fixer (b9836a)
by Fabio
15:58
created
framework/Collections/TPagedList.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function setPageSize($value)
118 118
 	{
119
-		if(($value = TPropertyValue::ensureInteger($value)) > 0)
119
+		if (($value = TPropertyValue::ensureInteger($value)) > 0)
120 120
 			$this->_pageSize = $value;
121 121
 		else
122 122
 			throw new TInvalidDataValueException('pagedlist_pagesize_invalid');
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	public function setCurrentPageIndex($value)
138 138
 	{
139
-		if($this->gotoPage($value = TPropertyValue::ensureInteger($value)) === false)
139
+		if ($this->gotoPage($value = TPropertyValue::ensureInteger($value)) === false)
140 140
 			throw new TInvalidDataValueException('pagedlist_currentpageindex_invalid');
141 141
 	}
142 142
 
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	public function gotoPage($pageIndex)
171 171
 	{
172
-		if($pageIndex === $this->_currentPageIndex)
172
+		if ($pageIndex === $this->_currentPageIndex)
173 173
 			return $pageIndex;
174
-		if($this->_customPaging)
174
+		if ($this->_customPaging)
175 175
 		{
176
-			if($pageIndex >= 0 && ($this->_virtualCount < 0 || $pageIndex < $this->getPageCount()))
176
+			if ($pageIndex >= 0 && ($this->_virtualCount < 0 || $pageIndex < $this->getPageCount()))
177 177
 			{
178 178
 				$param = new TPagedListFetchDataEventParameter($pageIndex, $this->_pageSize * $pageIndex, $this->_pageSize);
179 179
 				$this->onFetchData($param);
180
-				if(($data = $param->getData()) !== null)
180
+				if (($data = $param->getData()) !== null)
181 181
 				{
182 182
 					$this->setReadOnly(false);
183 183
 					$this->copyFrom($data);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		}
196 196
 		else
197 197
 		{
198
-			if($pageIndex >= 0 && $pageIndex < $this->getPageCount())
198
+			if ($pageIndex >= 0 && $pageIndex < $this->getPageCount())
199 199
 			{
200 200
 				$this->_currentPageIndex = $pageIndex;
201 201
 				$this->onPageIndexChanged(null);
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	public function setVirtualCount($value)
239 239
 	{
240
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
240
+		if (($value = TPropertyValue::ensureInteger($value)) < 0)
241 241
 			$value = -1;
242 242
 		$this->_virtualCount = $value;
243 243
 	}
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	public function getPageCount()
249 249
 	{
250
-		if($this->_customPaging)
250
+		if ($this->_customPaging)
251 251
 		{
252
-			if($this->_virtualCount >= 0)
253
-				return (int)(($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize);
252
+			if ($this->_virtualCount >= 0)
253
+				return (int) (($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize);
254 254
 			else
255 255
 				return -1;
256 256
 		}
257 257
 		else
258
-			return (int)((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize);
258
+			return (int) ((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize);
259 259
 	}
260 260
 
261 261
 	/**
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function getCount()
281 281
 	{
282
-		if($this->_customPaging)
282
+		if ($this->_customPaging)
283 283
 			return parent::getCount();
284 284
 		else
285 285
 		{
286
-			if($this->_currentPageIndex === $this->getPageCount() - 1)
286
+			if ($this->_currentPageIndex === $this->getPageCount() - 1)
287 287
 				return parent::getCount() - $this->_pageSize * $this->_currentPageIndex;
288 288
 			else
289 289
 				return $this->_pageSize;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	 */
296 296
 	public function getIterator()
297 297
 	{
298
-		if($this->_customPaging)
298
+		if ($this->_customPaging)
299 299
 			return parent::getIterator();
300 300
 		else
301 301
 		{
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	 */
314 314
 	public function itemAt($index)
315 315
 	{
316
-		if($this->_customPaging)
316
+		if ($this->_customPaging)
317 317
 			return parent::itemAt($index);
318 318
 		else
319 319
 			return parent::itemAt($this->_pageSize * $this->_currentPageIndex + $index);
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
 	public function indexOf($item)
327 327
 	{
328 328
 		$c = $this->getCount();
329
-		for($i = 0;$i < $c;++$i)
330
-			if($this->itemAt($i) === $item)
329
+		for ($i = 0; $i < $c; ++$i)
330
+			if ($this->itemAt($i) === $item)
331 331
 				return $i;
332 332
 		return -1;
333 333
 	}
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	{
363 363
 		$c = $this->getCount();
364 364
 		$array = [];
365
-		for($i = 0;$i < $c;++$i)
365
+		for ($i = 0; $i < $c; ++$i)
366 366
 			$array[$i] = $this->itemAt($i);
367 367
 		return $array;
368 368
 	}
Please login to merge, or discard this patch.
Braces   +50 added lines, -42 removed lines patch added patch discarded remove patch
@@ -116,10 +116,11 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function setPageSize($value)
118 118
 	{
119
-		if(($value = TPropertyValue::ensureInteger($value)) > 0)
120
-			$this->_pageSize = $value;
121
-		else
122
-			throw new TInvalidDataValueException('pagedlist_pagesize_invalid');
119
+		if(($value = TPropertyValue::ensureInteger($value)) > 0) {
120
+					$this->_pageSize = $value;
121
+		} else {
122
+					throw new TInvalidDataValueException('pagedlist_pagesize_invalid');
123
+		}
123 124
 	}
124 125
 
125 126
 	/**
@@ -136,8 +137,9 @@  discard block
 block discarded – undo
136 137
 	 */
137 138
 	public function setCurrentPageIndex($value)
138 139
 	{
139
-		if($this->gotoPage($value = TPropertyValue::ensureInteger($value)) === false)
140
-			throw new TInvalidDataValueException('pagedlist_currentpageindex_invalid');
140
+		if($this->gotoPage($value = TPropertyValue::ensureInteger($value)) === false) {
141
+					throw new TInvalidDataValueException('pagedlist_currentpageindex_invalid');
142
+		}
141 143
 	}
142 144
 
143 145
 	/**
@@ -169,8 +171,9 @@  discard block
 block discarded – undo
169 171
 	 */
170 172
 	public function gotoPage($pageIndex)
171 173
 	{
172
-		if($pageIndex === $this->_currentPageIndex)
173
-			return $pageIndex;
174
+		if($pageIndex === $this->_currentPageIndex) {
175
+					return $pageIndex;
176
+		}
174 177
 		if($this->_customPaging)
175 178
 		{
176 179
 			if($pageIndex >= 0 && ($this->_virtualCount < 0 || $pageIndex < $this->getPageCount()))
@@ -186,23 +189,22 @@  discard block
 block discarded – undo
186 189
 					$this->_currentPageIndex = $pageIndex;
187 190
 					$this->onPageIndexChanged(new TPagedListPageChangedEventParameter($oldPage));
188 191
 					return $pageIndex;
192
+				} else {
193
+									return false;
189 194
 				}
190
-				else
191
-					return false;
195
+			} else {
196
+							return false;
192 197
 			}
193
-			else
194
-				return false;
195
-		}
196
-		else
198
+		} else
197 199
 		{
198 200
 			if($pageIndex >= 0 && $pageIndex < $this->getPageCount())
199 201
 			{
200 202
 				$this->_currentPageIndex = $pageIndex;
201 203
 				$this->onPageIndexChanged(null);
202 204
 				return $pageIndex;
205
+			} else {
206
+							return false;
203 207
 			}
204
-			else
205
-				return false;
206 208
 		}
207 209
 	}
208 210
 
@@ -237,8 +239,9 @@  discard block
 block discarded – undo
237 239
 	 */
238 240
 	public function setVirtualCount($value)
239 241
 	{
240
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
241
-			$value = -1;
242
+		if(($value = TPropertyValue::ensureInteger($value)) < 0) {
243
+					$value = -1;
244
+		}
242 245
 		$this->_virtualCount = $value;
243 246
 	}
244 247
 
@@ -249,13 +252,14 @@  discard block
 block discarded – undo
249 252
 	{
250 253
 		if($this->_customPaging)
251 254
 		{
252
-			if($this->_virtualCount >= 0)
253
-				return (int)(($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize);
254
-			else
255
-				return -1;
255
+			if($this->_virtualCount >= 0) {
256
+							return (int)(($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize);
257
+			} else {
258
+							return -1;
259
+			}
260
+		} else {
261
+					return (int)((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize);
256 262
 		}
257
-		else
258
-			return (int)((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize);
259 263
 	}
260 264
 
261 265
 	/**
@@ -279,14 +283,15 @@  discard block
 block discarded – undo
279 283
 	 */
280 284
 	public function getCount()
281 285
 	{
282
-		if($this->_customPaging)
283
-			return parent::getCount();
284
-		else
286
+		if($this->_customPaging) {
287
+					return parent::getCount();
288
+		} else
285 289
 		{
286
-			if($this->_currentPageIndex === $this->getPageCount() - 1)
287
-				return parent::getCount() - $this->_pageSize * $this->_currentPageIndex;
288
-			else
289
-				return $this->_pageSize;
290
+			if($this->_currentPageIndex === $this->getPageCount() - 1) {
291
+							return parent::getCount() - $this->_pageSize * $this->_currentPageIndex;
292
+			} else {
293
+							return $this->_pageSize;
294
+			}
290 295
 		}
291 296
 	}
292 297
 
@@ -295,9 +300,9 @@  discard block
 block discarded – undo
295 300
 	 */
296 301
 	public function getIterator()
297 302
 	{
298
-		if($this->_customPaging)
299
-			return parent::getIterator();
300
-		else
303
+		if($this->_customPaging) {
304
+					return parent::getIterator();
305
+		} else
301 306
 		{
302 307
 			$data = $this->toArray();
303 308
 			return new \ArrayIterator($data);
@@ -313,10 +318,11 @@  discard block
 block discarded – undo
313 318
 	 */
314 319
 	public function itemAt($index)
315 320
 	{
316
-		if($this->_customPaging)
317
-			return parent::itemAt($index);
318
-		else
319
-			return parent::itemAt($this->_pageSize * $this->_currentPageIndex + $index);
321
+		if($this->_customPaging) {
322
+					return parent::itemAt($index);
323
+		} else {
324
+					return parent::itemAt($this->_pageSize * $this->_currentPageIndex + $index);
325
+		}
320 326
 	}
321 327
 
322 328
 	/**
@@ -326,9 +332,10 @@  discard block
 block discarded – undo
326 332
 	public function indexOf($item)
327 333
 	{
328 334
 		$c = $this->getCount();
329
-		for($i = 0;$i < $c;++$i)
330
-			if($this->itemAt($i) === $item)
335
+		for($i = 0;$i < $c;++$i) {
336
+					if($this->itemAt($i) === $item)
331 337
 				return $i;
338
+		}
332 339
 		return -1;
333 340
 	}
334 341
 
@@ -362,8 +369,9 @@  discard block
 block discarded – undo
362 369
 	{
363 370
 		$c = $this->getCount();
364 371
 		$array = [];
365
-		for($i = 0;$i < $c;++$i)
366
-			$array[$i] = $this->itemAt($i);
372
+		for($i = 0;$i < $c;++$i) {
373
+					$array[$i] = $this->itemAt($i);
374
+		}
367 375
 		return $array;
368 376
 	}
369 377
 }
370 378
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Collections/TList.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function __construct($data = null, $readOnly = false)
69 69
 	{
70
-		if($data !== null)
70
+		if ($data !== null)
71 71
 			$this->copyFrom($data);
72 72
 		$this->setReadOnly($readOnly);
73 73
 	}
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function itemAt($index)
127 127
 	{
128
-		if($index >= 0 && $index < $this->_c)
128
+		if ($index >= 0 && $index < $this->_c)
129 129
 			return $this->_d[$index];
130 130
 		else
131 131
 			throw new TInvalidDataValueException('list_index_invalid', $index);
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public function insertAt($index, $item)
156 156
 	{
157
-		if(!$this->_r)
157
+		if (!$this->_r)
158 158
 		{
159
-			if($index === $this->_c)
159
+			if ($index === $this->_c)
160 160
 				$this->_d[$this->_c++] = $item;
161
-			elseif($index >= 0 && $index < $this->_c)
161
+			elseif ($index >= 0 && $index < $this->_c)
162 162
 			{
163 163
 				array_splice($this->_d, $index, 0, [$item]);
164 164
 				$this->_c++;
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function remove($item)
183 183
 	{
184
-		if(!$this->_r)
184
+		if (!$this->_r)
185 185
 		{
186
-			if(($index = $this->indexOf($item)) >= 0)
186
+			if (($index = $this->indexOf($item)) >= 0)
187 187
 			{
188 188
 				$this->removeAt($index);
189 189
 				return $index;
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	public function removeAt($index)
206 206
 	{
207
-		if(!$this->_r)
207
+		if (!$this->_r)
208 208
 		{
209
-			if($index >= 0 && $index < $this->_c)
209
+			if ($index >= 0 && $index < $this->_c)
210 210
 			{
211 211
 				$this->_c--;
212
-				if($index === $this->_c)
212
+				if ($index === $this->_c)
213 213
 					return array_pop($this->_d);
214 214
 				else
215 215
 				{
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	public function clear()
233 233
 	{
234
-		for($i = $this->_c - 1;$i >= 0;--$i)
234
+		for ($i = $this->_c - 1; $i >= 0; --$i)
235 235
 			$this->removeAt($i);
236 236
 	}
237 237
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function indexOf($item)
252 252
 	{
253
-		if(($index = array_search($item, $this->_d, true)) === false)
253
+		if (($index = array_search($item, $this->_d, true)) === false)
254 254
 			return -1;
255 255
 		else
256 256
 			return $index;
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
 	 */
268 268
 	public function insertBefore($baseitem, $item)
269 269
 	{
270
-		if(!$this->_r)
270
+		if (!$this->_r)
271 271
 		{
272
-			if(($index = $this->indexOf($baseitem)) == -1)
272
+			if (($index = $this->indexOf($baseitem)) == -1)
273 273
 				throw new TInvalidDataValueException('list_item_inexistent');
274 274
 
275 275
 			$this->insertAt($index, $item);
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	public function insertAfter($baseitem, $item)
293 293
 	{
294
-		if(!$this->_r)
294
+		if (!$this->_r)
295 295
 		{
296
-			if(($index = $this->indexOf($baseitem)) == -1)
296
+			if (($index = $this->indexOf($baseitem)) == -1)
297 297
 				throw new TInvalidDataValueException('list_item_inexistent');
298 298
 
299 299
 			$this->insertAt($index + 1, $item);
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public function copyFrom($data)
322 322
 	{
323
-		if(is_array($data) || ($data instanceof \Traversable))
323
+		if (is_array($data) || ($data instanceof \Traversable))
324 324
 		{
325
-			if($this->_c > 0)
325
+			if ($this->_c > 0)
326 326
 				$this->clear();
327
-			foreach($data as $item)
327
+			foreach ($data as $item)
328 328
 				$this->add($item);
329 329
 		}
330
-		elseif($data !== null)
330
+		elseif ($data !== null)
331 331
 			throw new TInvalidDataTypeException('list_data_not_iterable');
332 332
 	}
333 333
 
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
 	 */
340 340
 	public function mergeWith($data)
341 341
 	{
342
-		if(is_array($data) || ($data instanceof \Traversable))
342
+		if (is_array($data) || ($data instanceof \Traversable))
343 343
 		{
344
-			foreach($data as $item)
344
+			foreach ($data as $item)
345 345
 				$this->add($item);
346 346
 		}
347
-		elseif($data !== null)
347
+		elseif ($data !== null)
348 348
 			throw new TInvalidDataTypeException('list_data_not_iterable');
349 349
 	}
350 350
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	 */
380 380
 	public function offsetSet($offset, $item)
381 381
 	{
382
-		if($offset === null || $offset === $this->_c)
382
+		if ($offset === null || $offset === $this->_c)
383 383
 			$this->insertAt($this->_c, $item);
384 384
 		else
385 385
 		{
Please login to merge, or discard this patch.
Braces   +60 added lines, -51 removed lines patch added patch discarded remove patch
@@ -67,8 +67,9 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function __construct($data = null, $readOnly = false)
69 69
 	{
70
-		if($data !== null)
71
-			$this->copyFrom($data);
70
+		if($data !== null) {
71
+					$this->copyFrom($data);
72
+		}
72 73
 		$this->setReadOnly($readOnly);
73 74
 	}
74 75
 
@@ -125,10 +126,11 @@  discard block
 block discarded – undo
125 126
 	 */
126 127
 	public function itemAt($index)
127 128
 	{
128
-		if($index >= 0 && $index < $this->_c)
129
-			return $this->_d[$index];
130
-		else
131
-			throw new TInvalidDataValueException('list_index_invalid', $index);
129
+		if($index >= 0 && $index < $this->_c) {
130
+					return $this->_d[$index];
131
+		} else {
132
+					throw new TInvalidDataValueException('list_index_invalid', $index);
133
+		}
132 134
 	}
133 135
 
134 136
 	/**
@@ -156,18 +158,18 @@  discard block
 block discarded – undo
156 158
 	{
157 159
 		if(!$this->_r)
158 160
 		{
159
-			if($index === $this->_c)
160
-				$this->_d[$this->_c++] = $item;
161
-			elseif($index >= 0 && $index < $this->_c)
161
+			if($index === $this->_c) {
162
+							$this->_d[$this->_c++] = $item;
163
+			} elseif($index >= 0 && $index < $this->_c)
162 164
 			{
163 165
 				array_splice($this->_d, $index, 0, [$item]);
164 166
 				$this->_c++;
167
+			} else {
168
+							throw new TInvalidDataValueException('list_index_invalid', $index);
165 169
 			}
166
-			else
167
-				throw new TInvalidDataValueException('list_index_invalid', $index);
170
+		} else {
171
+					throw new TInvalidOperationException('list_readonly', get_class($this));
168 172
 		}
169
-		else
170
-			throw new TInvalidOperationException('list_readonly', get_class($this));
171 173
 	}
172 174
 
173 175
 	/**
@@ -187,12 +189,12 @@  discard block
 block discarded – undo
187 189
 			{
188 190
 				$this->removeAt($index);
189 191
 				return $index;
192
+			} else {
193
+							throw new TInvalidDataValueException('list_item_inexistent');
190 194
 			}
191
-			else
192
-				throw new TInvalidDataValueException('list_item_inexistent');
195
+		} else {
196
+					throw new TInvalidOperationException('list_readonly', get_class($this));
193 197
 		}
194
-		else
195
-			throw new TInvalidOperationException('list_readonly', get_class($this));
196 198
 	}
197 199
 
198 200
 	/**
@@ -209,20 +211,20 @@  discard block
 block discarded – undo
209 211
 			if($index >= 0 && $index < $this->_c)
210 212
 			{
211 213
 				$this->_c--;
212
-				if($index === $this->_c)
213
-					return array_pop($this->_d);
214
-				else
214
+				if($index === $this->_c) {
215
+									return array_pop($this->_d);
216
+				} else
215 217
 				{
216 218
 					$item = $this->_d[$index];
217 219
 					array_splice($this->_d, $index, 1);
218 220
 					return $item;
219 221
 				}
222
+			} else {
223
+							throw new TInvalidDataValueException('list_index_invalid', $index);
220 224
 			}
221
-			else
222
-				throw new TInvalidDataValueException('list_index_invalid', $index);
225
+		} else {
226
+					throw new TInvalidOperationException('list_readonly', get_class($this));
223 227
 		}
224
-		else
225
-			throw new TInvalidOperationException('list_readonly', get_class($this));
226 228
 	}
227 229
 
228 230
 	/**
@@ -231,8 +233,9 @@  discard block
 block discarded – undo
231 233
 	 */
232 234
 	public function clear()
233 235
 	{
234
-		for($i = $this->_c - 1;$i >= 0;--$i)
235
-			$this->removeAt($i);
236
+		for($i = $this->_c - 1;$i >= 0;--$i) {
237
+					$this->removeAt($i);
238
+		}
236 239
 	}
237 240
 
238 241
 	/**
@@ -250,10 +253,11 @@  discard block
 block discarded – undo
250 253
 	 */
251 254
 	public function indexOf($item)
252 255
 	{
253
-		if(($index = array_search($item, $this->_d, true)) === false)
254
-			return -1;
255
-		else
256
-			return $index;
256
+		if(($index = array_search($item, $this->_d, true)) === false) {
257
+					return -1;
258
+		} else {
259
+					return $index;
260
+		}
257 261
 	}
258 262
 
259 263
 	/**
@@ -269,15 +273,16 @@  discard block
 block discarded – undo
269 273
 	{
270 274
 		if(!$this->_r)
271 275
 		{
272
-			if(($index = $this->indexOf($baseitem)) == -1)
273
-				throw new TInvalidDataValueException('list_item_inexistent');
276
+			if(($index = $this->indexOf($baseitem)) == -1) {
277
+							throw new TInvalidDataValueException('list_item_inexistent');
278
+			}
274 279
 
275 280
 			$this->insertAt($index, $item);
276 281
 
277 282
 			return $index;
283
+		} else {
284
+					throw new TInvalidOperationException('list_readonly', get_class($this));
278 285
 		}
279
-		else
280
-			throw new TInvalidOperationException('list_readonly', get_class($this));
281 286
 	}
282 287
 
283 288
 	/**
@@ -293,15 +298,16 @@  discard block
 block discarded – undo
293 298
 	{
294 299
 		if(!$this->_r)
295 300
 		{
296
-			if(($index = $this->indexOf($baseitem)) == -1)
297
-				throw new TInvalidDataValueException('list_item_inexistent');
301
+			if(($index = $this->indexOf($baseitem)) == -1) {
302
+							throw new TInvalidDataValueException('list_item_inexistent');
303
+			}
298 304
 
299 305
 			$this->insertAt($index + 1, $item);
300 306
 
301 307
 			return $index + 1;
308
+		} else {
309
+					throw new TInvalidOperationException('list_readonly', get_class($this));
302 310
 		}
303
-		else
304
-			throw new TInvalidOperationException('list_readonly', get_class($this));
305 311
 	}
306 312
 
307 313
 	/**
@@ -322,13 +328,15 @@  discard block
 block discarded – undo
322 328
 	{
323 329
 		if(is_array($data) || ($data instanceof \Traversable))
324 330
 		{
325
-			if($this->_c > 0)
326
-				$this->clear();
327
-			foreach($data as $item)
328
-				$this->add($item);
331
+			if($this->_c > 0) {
332
+							$this->clear();
333
+			}
334
+			foreach($data as $item) {
335
+							$this->add($item);
336
+			}
337
+		} elseif($data !== null) {
338
+					throw new TInvalidDataTypeException('list_data_not_iterable');
329 339
 		}
330
-		elseif($data !== null)
331
-			throw new TInvalidDataTypeException('list_data_not_iterable');
332 340
 	}
333 341
 
334 342
 	/**
@@ -341,11 +349,12 @@  discard block
 block discarded – undo
341 349
 	{
342 350
 		if(is_array($data) || ($data instanceof \Traversable))
343 351
 		{
344
-			foreach($data as $item)
345
-				$this->add($item);
352
+			foreach($data as $item) {
353
+							$this->add($item);
354
+			}
355
+		} elseif($data !== null) {
356
+					throw new TInvalidDataTypeException('list_data_not_iterable');
346 357
 		}
347
-		elseif($data !== null)
348
-			throw new TInvalidDataTypeException('list_data_not_iterable');
349 358
 	}
350 359
 
351 360
 	/**
@@ -379,9 +388,9 @@  discard block
 block discarded – undo
379 388
 	 */
380 389
 	public function offsetSet($offset, $item)
381 390
 	{
382
-		if($offset === null || $offset === $this->_c)
383
-			$this->insertAt($this->_c, $item);
384
-		else
391
+		if($offset === null || $offset === $this->_c) {
392
+					$this->insertAt($this->_c, $item);
393
+		} else
385 394
 		{
386 395
 			$this->removeAt($offset);
387 396
 			$this->insertAt($offset, $item);
Please login to merge, or discard this patch.
framework/Xml/TXmlElementList.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function insertAt($index, $item)
59 59
 	{
60
-		if($item instanceof TXmlElement)
60
+		if ($item instanceof TXmlElement)
61 61
 		{
62 62
 			parent::insertAt($index, $item);
63
-			if($item->getParent() !== null)
63
+			if ($item->getParent() !== null)
64 64
 				$item->getParent()->getElements()->remove($item);
65 65
 			$item->setParent($this->_o);
66 66
 		}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	public function removeAt($index)
79 79
 	{
80 80
 		$item = parent::removeAt($index);
81
-		if($item instanceof TXmlElement)
81
+		if ($item instanceof TXmlElement)
82 82
 			$item->setParent(null);
83 83
 		return $item;
84 84
 	}
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,12 +60,13 @@  discard block
 block discarded – undo
60 60
 		if($item instanceof TXmlElement)
61 61
 		{
62 62
 			parent::insertAt($index, $item);
63
-			if($item->getParent() !== null)
64
-				$item->getParent()->getElements()->remove($item);
63
+			if($item->getParent() !== null) {
64
+							$item->getParent()->getElements()->remove($item);
65
+			}
65 66
 			$item->setParent($this->_o);
67
+		} else {
68
+					throw new TInvalidDataTypeException('xmlelementlist_xmlelement_required');
66 69
 		}
67
-		else
68
-			throw new TInvalidDataTypeException('xmlelementlist_xmlelement_required');
69 70
 	}
70 71
 
71 72
 	/**
@@ -78,8 +79,9 @@  discard block
 block discarded – undo
78 79
 	public function removeAt($index)
79 80
 	{
80 81
 		$item = parent::removeAt($index);
81
-		if($item instanceof TXmlElement)
82
-			$item->setParent(null);
82
+		if($item instanceof TXmlElement) {
83
+					$item->setParent(null);
84
+		}
83 85
 		return $item;
84 86
 	}
85 87
 }
86 88
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Xml/TXmlDocument.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function loadFromFile($file)
127 127
 	{
128
-		if(($str = @file_get_contents($file)) !== false)
128
+		if (($str = @file_get_contents($file)) !== false)
129 129
 			return $this->loadFromString($str);
130 130
 		else
131 131
 			throw new TIOException('xmldocument_file_read_failed', $file);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	{
142 142
 		// TODO: since PHP 5.1, we can get parsing errors and throw them as exception
143 143
 		$doc = new \DOMDocument();
144
-		if($doc->loadXML($string) === false)
144
+		if ($doc->loadXML($string) === false)
145 145
 			return false;
146 146
 
147 147
 		$this->setEncoding($doc->encoding);
@@ -156,28 +156,28 @@  discard block
 block discarded – undo
156 156
 		$attributes->clear();
157 157
 
158 158
 		static $bSimpleXml;
159
-		if($bSimpleXml === null)
160
-			$bSimpleXml = (boolean)function_exists('simplexml_load_string');
159
+		if ($bSimpleXml === null)
160
+			$bSimpleXml = (boolean) function_exists('simplexml_load_string');
161 161
 
162
-		if($bSimpleXml)
162
+		if ($bSimpleXml)
163 163
 		{
164 164
 			$simpleDoc = simplexml_load_string($string);
165 165
 			$docNamespaces = $simpleDoc->getDocNamespaces(false);
166 166
 			$simpleDoc = null;
167
-			foreach($docNamespaces as $prefix => $uri)
167
+			foreach ($docNamespaces as $prefix => $uri)
168 168
 			{
169
-				if($prefix === '')
169
+				if ($prefix === '')
170 170
 					$attributes->add('xmlns', $uri);
171 171
 				else
172
-					$attributes->add('xmlns:' . $prefix, $uri);
172
+					$attributes->add('xmlns:'.$prefix, $uri);
173 173
 			}
174 174
 		}
175 175
 
176
-		foreach($element->attributes as $name => $attr)
177
-			$attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
178
-		foreach($element->childNodes as $child)
176
+		foreach ($element->attributes as $name => $attr)
177
+			$attributes->add(($attr->prefix === '' ? '' : $attr->prefix.':').$name, $attr->value);
178
+		foreach ($element->childNodes as $child)
179 179
 		{
180
-			if($child instanceof \DOMElement)
180
+			if ($child instanceof \DOMElement)
181 181
 				$elements->add($this->buildElement($child));
182 182
 		}
183 183
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	public function saveToFile($file)
193 193
 	{
194
-		if(($fw = fopen($file, 'w')) !== false)
194
+		if (($fw = fopen($file, 'w')) !== false)
195 195
 		{
196 196
 			fwrite($fw, $this->saveToString());
197 197
 			fclose($fw);
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function saveToString()
208 208
 	{
209
-		$version = empty($this->_version)?' version="1.0"':' version="' . $this->_version . '"';
210
-		$encoding = empty($this->_encoding)?'':' encoding="' . $this->_encoding . '"';
211
-		return "<?xml{$version}{$encoding}?>\n" . $this->toString(0);
209
+		$version = empty($this->_version) ? ' version="1.0"' : ' version="'.$this->_version.'"';
210
+		$encoding = empty($this->_encoding) ? '' : ' encoding="'.$this->_encoding.'"';
211
+		return "<?xml{$version}{$encoding}?>\n".$this->toString(0);
212 212
 	}
213 213
 
214 214
 	/**
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
 	{
241 241
 		$element = new TXmlElement($node->tagName);
242 242
 		$element->setValue($node->nodeValue);
243
-		foreach($node->attributes as $name => $attr)
244
-			$element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
243
+		foreach ($node->attributes as $name => $attr)
244
+			$element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix.':').$name, $attr->value);
245 245
 
246
-		foreach($node->childNodes as $child)
246
+		foreach ($node->childNodes as $child)
247 247
 		{
248
-			if($child instanceof \DOMElement)
248
+			if ($child instanceof \DOMElement)
249 249
 				$element->getElements()->add($this->buildElement($child));
250 250
 		}
251 251
 		return $element;
Please login to merge, or discard this patch.
Braces   +30 added lines, -22 removed lines patch added patch discarded remove patch
@@ -125,10 +125,11 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function loadFromFile($file)
127 127
 	{
128
-		if(($str = @file_get_contents($file)) !== false)
129
-			return $this->loadFromString($str);
130
-		else
131
-			throw new TIOException('xmldocument_file_read_failed', $file);
128
+		if(($str = @file_get_contents($file)) !== false) {
129
+					return $this->loadFromString($str);
130
+		} else {
131
+					throw new TIOException('xmldocument_file_read_failed', $file);
132
+		}
132 133
 	}
133 134
 
134 135
 	/**
@@ -141,8 +142,9 @@  discard block
 block discarded – undo
141 142
 	{
142 143
 		// TODO: since PHP 5.1, we can get parsing errors and throw them as exception
143 144
 		$doc = new \DOMDocument();
144
-		if($doc->loadXML($string) === false)
145
-			return false;
145
+		if($doc->loadXML($string) === false) {
146
+					return false;
147
+		}
146 148
 
147 149
 		$this->setEncoding($doc->encoding);
148 150
 		$this->setVersion($doc->xmlVersion);
@@ -156,8 +158,9 @@  discard block
 block discarded – undo
156 158
 		$attributes->clear();
157 159
 
158 160
 		static $bSimpleXml;
159
-		if($bSimpleXml === null)
160
-			$bSimpleXml = (boolean)function_exists('simplexml_load_string');
161
+		if($bSimpleXml === null) {
162
+					$bSimpleXml = (boolean)function_exists('simplexml_load_string');
163
+		}
161 164
 
162 165
 		if($bSimpleXml)
163 166
 		{
@@ -166,19 +169,22 @@  discard block
 block discarded – undo
166 169
 			$simpleDoc = null;
167 170
 			foreach($docNamespaces as $prefix => $uri)
168 171
 			{
169
-				if($prefix === '')
170
-					$attributes->add('xmlns', $uri);
171
-				else
172
-					$attributes->add('xmlns:' . $prefix, $uri);
172
+				if($prefix === '') {
173
+									$attributes->add('xmlns', $uri);
174
+				} else {
175
+									$attributes->add('xmlns:' . $prefix, $uri);
176
+				}
173 177
 			}
174 178
 		}
175 179
 
176
-		foreach($element->attributes as $name => $attr)
177
-			$attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
180
+		foreach($element->attributes as $name => $attr) {
181
+					$attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
182
+		}
178 183
 		foreach($element->childNodes as $child)
179 184
 		{
180
-			if($child instanceof \DOMElement)
181
-				$elements->add($this->buildElement($child));
185
+			if($child instanceof \DOMElement) {
186
+							$elements->add($this->buildElement($child));
187
+			}
182 188
 		}
183 189
 
184 190
 		return true;
@@ -195,9 +201,9 @@  discard block
 block discarded – undo
195 201
 		{
196 202
 			fwrite($fw, $this->saveToString());
197 203
 			fclose($fw);
204
+		} else {
205
+					throw new TIOException('xmldocument_file_write_failed', $file);
198 206
 		}
199
-		else
200
-			throw new TIOException('xmldocument_file_write_failed', $file);
201 207
 	}
202 208
 
203 209
 	/**
@@ -240,13 +246,15 @@  discard block
 block discarded – undo
240 246
 	{
241 247
 		$element = new TXmlElement($node->tagName);
242 248
 		$element->setValue($node->nodeValue);
243
-		foreach($node->attributes as $name => $attr)
244
-			$element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
249
+		foreach($node->attributes as $name => $attr) {
250
+					$element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
251
+		}
245 252
 
246 253
 		foreach($node->childNodes as $child)
247 254
 		{
248
-			if($child instanceof \DOMElement)
249
-				$element->getElements()->add($this->buildElement($child));
255
+			if($child instanceof \DOMElement) {
256
+							$element->getElements()->add($this->buildElement($child));
257
+			}
250 258
 		}
251 259
 		return $element;
252 260
 	}
Please login to merge, or discard this patch.
framework/Xml/TXmlElement.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function getAttribute($name)
133 133
 	{
134
-		if($this->_attributes !== null)
134
+		if ($this->_attributes !== null)
135 135
 			return $this->_attributes->itemAt($name);
136 136
 		else
137 137
 			return null;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public function getElements()
153 153
 	{
154
-		if(!$this->_elements)
154
+		if (!$this->_elements)
155 155
 			$this->_elements = new TXmlElementList($this);
156 156
 		return $this->_elements;
157 157
 	}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	public function getAttributes()
163 163
 	{
164
-		if(!$this->_attributes)
164
+		if (!$this->_attributes)
165 165
 			$this->_attributes = new TMap;
166 166
 		return $this->_attributes;
167 167
 	}
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public function getElementByTagName($tagName)
173 173
 	{
174
-		if($this->_elements)
174
+		if ($this->_elements)
175 175
 		{
176
-			foreach($this->_elements as $element)
177
-				if($element->_tagName === $tagName)
176
+			foreach ($this->_elements as $element)
177
+				if ($element->_tagName === $tagName)
178 178
 					return $element;
179 179
 		}
180 180
 		return null;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 	public function getElementsByTagName($tagName)
187 187
 	{
188 188
 		$list = new TList;
189
-		if($this->_elements)
189
+		if ($this->_elements)
190 190
 		{
191
-			foreach($this->_elements as $element)
192
-				if($element->_tagName === $tagName)
191
+			foreach ($this->_elements as $element)
192
+				if ($element->_tagName === $tagName)
193 193
 					$list->add($element);
194 194
 		}
195 195
 		return $list;
@@ -201,30 +201,30 @@  discard block
 block discarded – undo
201 201
 	public function toString($indent = 0)
202 202
 	{
203 203
 		$attr = '';
204
-		if($this->_attributes !== null)
204
+		if ($this->_attributes !== null)
205 205
 		{
206
-			foreach($this->_attributes as $name => $value)
206
+			foreach ($this->_attributes as $name => $value)
207 207
 			{
208 208
 				$value = $this->xmlEncode($value);
209 209
 				$attr .= " $name=\"$value\"";
210 210
 			}
211 211
 		}
212 212
 		$prefix = str_repeat(' ', $indent * 4);
213
-		if($this->getHasElement())
213
+		if ($this->getHasElement())
214 214
 		{
215
-			$str = $prefix . "<{$this->_tagName}$attr>\n";
216
-			foreach($this->getElements() as $element)
217
-				$str .= $element->toString($indent + 1) . "\n";
218
-			$str .= $prefix . "</{$this->_tagName}>";
215
+			$str = $prefix."<{$this->_tagName}$attr>\n";
216
+			foreach ($this->getElements() as $element)
217
+				$str .= $element->toString($indent + 1)."\n";
218
+			$str .= $prefix."</{$this->_tagName}>";
219 219
 			return $str;
220 220
 		}
221
-		elseif(($value = $this->getValue()) !== '')
221
+		elseif (($value = $this->getValue()) !== '')
222 222
 		{
223 223
 			$value = $this->xmlEncode($value);
224
-			return $prefix . "<{$this->_tagName}$attr>$value</{$this->_tagName}>";
224
+			return $prefix."<{$this->_tagName}$attr>$value</{$this->_tagName}>";
225 225
 		}
226 226
 		else
227
-			return $prefix . "<{$this->_tagName}$attr />";
227
+			return $prefix."<{$this->_tagName}$attr />";
228 228
 	}
229 229
 
230 230
 	/**
Please login to merge, or discard this patch.
Braces   +23 added lines, -18 removed lines patch added patch discarded remove patch
@@ -131,10 +131,11 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function getAttribute($name)
133 133
 	{
134
-		if($this->_attributes !== null)
135
-			return $this->_attributes->itemAt($name);
136
-		else
137
-			return null;
134
+		if($this->_attributes !== null) {
135
+					return $this->_attributes->itemAt($name);
136
+		} else {
137
+					return null;
138
+		}
138 139
 	}
139 140
 
140 141
 	/**
@@ -151,8 +152,9 @@  discard block
 block discarded – undo
151 152
 	 */
152 153
 	public function getElements()
153 154
 	{
154
-		if(!$this->_elements)
155
-			$this->_elements = new TXmlElementList($this);
155
+		if(!$this->_elements) {
156
+					$this->_elements = new TXmlElementList($this);
157
+		}
156 158
 		return $this->_elements;
157 159
 	}
158 160
 
@@ -161,8 +163,9 @@  discard block
 block discarded – undo
161 163
 	 */
162 164
 	public function getAttributes()
163 165
 	{
164
-		if(!$this->_attributes)
165
-			$this->_attributes = new TMap;
166
+		if(!$this->_attributes) {
167
+					$this->_attributes = new TMap;
168
+		}
166 169
 		return $this->_attributes;
167 170
 	}
168 171
 
@@ -173,9 +176,10 @@  discard block
 block discarded – undo
173 176
 	{
174 177
 		if($this->_elements)
175 178
 		{
176
-			foreach($this->_elements as $element)
177
-				if($element->_tagName === $tagName)
179
+			foreach($this->_elements as $element) {
180
+							if($element->_tagName === $tagName)
178 181
 					return $element;
182
+			}
179 183
 		}
180 184
 		return null;
181 185
 	}
@@ -188,9 +192,10 @@  discard block
 block discarded – undo
188 192
 		$list = new TList;
189 193
 		if($this->_elements)
190 194
 		{
191
-			foreach($this->_elements as $element)
192
-				if($element->_tagName === $tagName)
195
+			foreach($this->_elements as $element) {
196
+							if($element->_tagName === $tagName)
193 197
 					$list->add($element);
198
+			}
194 199
 		}
195 200
 		return $list;
196 201
 	}
@@ -213,18 +218,18 @@  discard block
 block discarded – undo
213 218
 		if($this->getHasElement())
214 219
 		{
215 220
 			$str = $prefix . "<{$this->_tagName}$attr>\n";
216
-			foreach($this->getElements() as $element)
217
-				$str .= $element->toString($indent + 1) . "\n";
221
+			foreach($this->getElements() as $element) {
222
+							$str .= $element->toString($indent + 1) . "\n";
223
+			}
218 224
 			$str .= $prefix . "</{$this->_tagName}>";
219 225
 			return $str;
220
-		}
221
-		elseif(($value = $this->getValue()) !== '')
226
+		} elseif(($value = $this->getValue()) !== '')
222 227
 		{
223 228
 			$value = $this->xmlEncode($value);
224 229
 			return $prefix . "<{$this->_tagName}$attr>$value</{$this->_tagName}>";
230
+		} else {
231
+					return $prefix . "<{$this->_tagName}$attr />";
225 232
 		}
226
-		else
227
-			return $prefix . "<{$this->_tagName}$attr />";
228 233
 	}
229 234
 
230 235
 	/**
Please login to merge, or discard this patch.
framework/PradoBase.php 2 patches
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 /**
26 26
  * Defines the PRADO framework installation path.
27 27
  */
28
-if(!defined('PRADO_DIR'))
28
+if (!defined('PRADO_DIR'))
29 29
 	define('PRADO_DIR', __DIR__);
30 30
 /**
31 31
  * Defines the default permission for writable directories and files
32 32
  */
33
-if(!defined('PRADO_CHMOD'))
33
+if (!defined('PRADO_CHMOD'))
34 34
 	define('PRADO_CHMOD', 0777);
35 35
 /**
36 36
  * Defines the Composer's vendor/ path.
37 37
  */
38
-if(!defined('PRADO_VENDORDIR'))
38
+if (!defined('PRADO_VENDORDIR'))
39 39
 {
40 40
 	$reflector = new \ReflectionClass('\Composer\Autoload\ClassLoader');
41 41
 	define('PRADO_VENDORDIR', dirname(dirname($reflector->getFileName())));
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public static function initAutoloader()
111 111
 	{
112
-		self::$classMap = require(__DIR__ . '/classes.php');
112
+		self::$classMap = require(__DIR__.'/classes.php');
113 113
 
114 114
 		spl_autoload_register([get_called_class(), 'autoload']);
115 115
 	}
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
 		/**
125 125
 		 * Sets error handler to be Prado::phpErrorHandler
126 126
 		 */
127
-		set_error_handler(['\Prado\PradoBase','phpErrorHandler']);
127
+		set_error_handler(['\Prado\PradoBase', 'phpErrorHandler']);
128 128
 		/**
129 129
 		 * Sets shutdown function to be Prado::phpFatalErrorHandler
130 130
 		 */
131
-		register_shutdown_function(['PradoBase','phpFatalErrorHandler']);
131
+		register_shutdown_function(['PradoBase', 'phpFatalErrorHandler']);
132 132
 		/**
133 133
 		 * Sets exception handler to be Prado::exceptionHandler
134 134
 		 */
135
-		set_exception_handler(['\Prado\PradoBase','exceptionHandler']);
135
+		set_exception_handler(['\Prado\PradoBase', 'exceptionHandler']);
136 136
 		/**
137 137
 		 * Disable php's builtin error reporting to avoid duplicated reports
138 138
 		 */
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public static function poweredByPrado($logoType = 0)
157 157
 	{
158
-		$logoName = $logoType == 1?'powered2':'powered';
159
-		if(self::$_application !== null)
158
+		$logoName = $logoType == 1 ? 'powered2' : 'powered';
159
+		if (self::$_application !== null)
160 160
 		{
161 161
 			$am = self::$_application->getAssetManager();
162
-			$url = $am->publishFilePath(self::getPathOfNamespace('Prado\\' . $logoName, '.gif'));
162
+			$url = $am->publishFilePath(self::getPathOfNamespace('Prado\\'.$logoName, '.gif'));
163 163
 		}
164 164
 		else
165
-			$url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif';
166
-		return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="' . $url . '" style="border-width:0px;" alt="Powered by PRADO" /></a>';
165
+			$url = 'http://pradosoft.github.io/docs/'.$logoName.'.gif';
166
+		return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>';
167 167
 	}
168 168
 
169 169
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	public static function phpErrorHandler($errno, $errstr, $errfile, $errline)
180 180
 	{
181
-		if(error_reporting() & $errno)
181
+		if (error_reporting() & $errno)
182 182
 			throw new TPhpErrorException($errno, $errstr, $errfile, $errline);
183 183
 	}
184 184
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	public static function phpFatalErrorHandler()
192 192
 	{
193 193
 		$error = error_get_last();
194
-		if($error &&
194
+		if ($error &&
195 195
 			TPhpErrorException::isFatalError($error) &&
196 196
 			error_reporting() & $error['type'])
197 197
 		{
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public static function exceptionHandler($exception)
212 212
 	{
213
-		if(self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null)
213
+		if (self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null)
214 214
 		{
215 215
 			$errorHandler->handleError(null, $exception);
216 216
 		}
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	public static function setApplication($application)
234 234
 	{
235
-		if(self::$_application !== null && !defined('PRADO_TEST_RUN'))
235
+		if (self::$_application !== null && !defined('PRADO_TEST_RUN'))
236 236
 			throw new TInvalidOperationException('prado_application_singleton_required');
237 237
 		self::$_application = $application;
238 238
 	}
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 
262 262
 	protected static function prado3NamespaceToPhpNamespace($type)
263 263
 	{
264
-		if(substr($type, 0, 6) === 'System')
265
-			$type = 'Prado' . substr($type, 6);
264
+		if (substr($type, 0, 6) === 'System')
265
+			$type = 'Prado'.substr($type, 6);
266 266
 
267
-		if(false === strpos($type, '\\'))
267
+		if (false === strpos($type, '\\'))
268 268
 			return str_replace('.', '\\', $type);
269 269
 		else
270 270
 			return $type;
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
 	public static function createComponent($requestedType)
287 287
 	{
288 288
 		$type = static::prado3NamespaceToPhpNamespace($requestedType);
289
-		if(!isset(self::$classExists[$type]))
289
+		if (!isset(self::$classExists[$type]))
290 290
 			self::$classExists[$type] = class_exists($type, false);
291 291
 
292
-		if(!isset(self::$_usings[$type]) && !self::$classExists[$type]) {
292
+		if (!isset(self::$_usings[$type]) && !self::$classExists[$type]) {
293 293
 			static::using($type);
294 294
 			self::$classExists[$type] = class_exists($type, false);
295 295
 		}
@@ -301,13 +301,13 @@  discard block
 block discarded – undo
301 301
 		 * \Application\Common\MyDataModule)
302 302
 		 * Skip this if the class is inside the Prado\* namespace, since all Prado classes are now namespaced
303 303
 		 */
304
-		if(($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0)
304
+		if (($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0)
305 305
 			$type = substr($type, $pos + 1);
306 306
 
307
-		if(($n = func_num_args()) > 1)
307
+		if (($n = func_num_args()) > 1)
308 308
 		{
309 309
 			$args = func_get_args();
310
-			switch($n) {
310
+			switch ($n) {
311 311
 				case 2:
312 312
 					return new $type($args[1]);
313 313
 				break;
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 				break;
323 323
 				default:
324 324
 					$s = '$args[1]';
325
-					for($i = 2;$i < $n;++$i)
325
+					for ($i = 2; $i < $n; ++$i)
326 326
 						$s .= ",\$args[$i]";
327 327
 					eval("\$component=new $type($s);");
328 328
 					return $component;
@@ -346,58 +346,58 @@  discard block
 block discarded – undo
346 346
 	{
347 347
 		$namespace = static::prado3NamespaceToPhpNamespace($namespace);
348 348
 
349
-		if(isset(self::$_usings[$namespace]) || class_exists($namespace, false))
349
+		if (isset(self::$_usings[$namespace]) || class_exists($namespace, false))
350 350
 			return;
351 351
 
352
-		if(array_key_exists($namespace, self::$classMap))
352
+		if (array_key_exists($namespace, self::$classMap))
353 353
 		{
354 354
 			// fast autoload a Prado3 class name
355 355
 			$phpNamespace = self::$classMap[$namespace];
356
-			if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true))
356
+			if (class_exists($phpNamespace, true) || interface_exists($phpNamespace, true))
357 357
 			{
358
-				if(!class_exists($namespace) && !interface_exists($namespace))
358
+				if (!class_exists($namespace) && !interface_exists($namespace))
359 359
 					class_alias($phpNamespace, $namespace);
360 360
 				return;
361 361
 			}
362
-		} elseif(($pos = strrpos($namespace, '\\')) === false) {
362
+		} elseif (($pos = strrpos($namespace, '\\')) === false) {
363 363
 			// trying to autoload an old class name
364
-			foreach(self::$_usings as $k => $v)
364
+			foreach (self::$_usings as $k => $v)
365 365
 			{
366
-				$path = $v . DIRECTORY_SEPARATOR . $namespace . self::CLASS_FILE_EXT;
367
-				if(file_exists($path))
366
+				$path = $v.DIRECTORY_SEPARATOR.$namespace.self::CLASS_FILE_EXT;
367
+				if (file_exists($path))
368 368
 				{
369
-					$phpNamespace = '\\' . $k . '\\' . $namespace;
370
-					if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true))
369
+					$phpNamespace = '\\'.$k.'\\'.$namespace;
370
+					if (class_exists($phpNamespace, true) || interface_exists($phpNamespace, true))
371 371
 					{
372
-						if(!class_exists($namespace) && !interface_exists($namespace))
372
+						if (!class_exists($namespace) && !interface_exists($namespace))
373 373
 							class_alias($phpNamespace, $namespace);
374 374
 						return;
375 375
 					}
376 376
 				}
377 377
 			}
378 378
 
379
-			if($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false))
379
+			if ($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false))
380 380
 				throw new TInvalidOperationException('prado_component_unknown', $namespace, '');
381
-		} elseif(($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null) {
381
+		} elseif (($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null) {
382 382
 			$className = substr($namespace, $pos + 1);
383
-			if($className === '*')  // a directory
383
+			if ($className === '*')  // a directory
384 384
 			{
385 385
 				self::$_usings[substr($namespace, 0, $pos)] = $path;
386 386
 			}
387 387
 			else  // a file
388 388
 			{
389 389
 				//self::$_usings[$namespace]=$path;
390
-				if(!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false)))
390
+				if (!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false)))
391 391
 				{
392 392
 					try
393 393
 					{
394 394
 						include_once($path);
395
-						if(class_exists($namespace, false) || interface_exists($namespace, false))
395
+						if (class_exists($namespace, false) || interface_exists($namespace, false))
396 396
 							class_alias($namespace, $className);
397 397
 					}
398
-					catch(\Exception $e)
398
+					catch (\Exception $e)
399 399
 					{
400
-						if($checkClassExistence && !class_exists($className, false))
400
+						if ($checkClassExistence && !class_exists($className, false))
401 401
 							throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage());
402 402
 						else
403 403
 							throw $e;
@@ -423,20 +423,20 @@  discard block
 block discarded – undo
423 423
 	{
424 424
 		$namespace = static::prado3NamespaceToPhpNamespace($namespace);
425 425
 
426
-		if(self::CLASS_FILE_EXT === $ext || empty($ext))
426
+		if (self::CLASS_FILE_EXT === $ext || empty($ext))
427 427
 		{
428
-			if(isset(self::$_usings[$namespace]))
428
+			if (isset(self::$_usings[$namespace]))
429 429
 				return self::$_usings[$namespace];
430 430
 
431
-			if(isset(self::$_aliases[$namespace]))
431
+			if (isset(self::$_aliases[$namespace]))
432 432
 				return self::$_aliases[$namespace];
433 433
 		}
434 434
 
435 435
 		$segs = explode('\\', $namespace);
436 436
 		$alias = array_shift($segs);
437 437
 
438
-		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
439
-			return rtrim($root . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $segs), '/\\') . (($file === '*') ? '' : DIRECTORY_SEPARATOR . $file . $ext);
438
+		if (null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
439
+			return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $segs), '/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext);
440 440
 
441 441
 		return null;
442 442
 	}
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	 */
448 448
 	public static function getPathOfAlias($alias)
449 449
 	{
450
-		return isset(self::$_aliases[$alias])?self::$_aliases[$alias]:null;
450
+		return isset(self::$_aliases[$alias]) ?self::$_aliases[$alias] : null;
451 451
 	}
452 452
 
453 453
 	protected static function getPathAliases()
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
 	 */
464 464
 	public static function setPathOfAlias($alias, $path)
465 465
 	{
466
-		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
466
+		if (isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
467 467
 			throw new TInvalidOperationException('prado_alias_redefined', $alias);
468
-		elseif(($rp = realpath($path)) !== false && is_dir($rp))
468
+		elseif (($rp = realpath($path)) !== false && is_dir($rp))
469 469
 		{
470
-			if(strpos($alias, '.') === false)
470
+			if (strpos($alias, '.') === false)
471 471
 				self::$_aliases[$alias] = $rp;
472 472
 			else
473 473
 				throw new TInvalidDataValueException('prado_aliasname_invalid', $alias);
@@ -485,45 +485,45 @@  discard block
 block discarded – undo
485 485
 	public static function fatalError($msg)
486 486
 	{
487 487
 		echo '<h1>Fatal Error</h1>';
488
-		echo '<p>' . $msg . '</p>';
489
-		if(!function_exists('debug_backtrace'))
488
+		echo '<p>'.$msg.'</p>';
489
+		if (!function_exists('debug_backtrace'))
490 490
 			return;
491 491
 		echo '<h2>Debug Backtrace</h2>';
492 492
 		echo '<pre>';
493 493
 		$index = -1;
494
-		foreach(debug_backtrace() as $t)
494
+		foreach (debug_backtrace() as $t)
495 495
 		{
496 496
 			$index++;
497
-			if($index == 0)  // hide the backtrace of this function
497
+			if ($index == 0)  // hide the backtrace of this function
498 498
 				continue;
499
-			echo '#' . $index . ' ';
500
-			if(isset($t['file']))
501
-				echo basename($t['file']) . ':' . $t['line'];
499
+			echo '#'.$index.' ';
500
+			if (isset($t['file']))
501
+				echo basename($t['file']).':'.$t['line'];
502 502
 			else
503 503
 				 echo '<PHP inner-code>';
504 504
 			echo ' -- ';
505
-			if(isset($t['class']))
506
-				echo $t['class'] . $t['type'];
507
-			echo $t['function'] . '(';
508
-			if(isset($t['args']) && count($t['args']) > 0)
505
+			if (isset($t['class']))
506
+				echo $t['class'].$t['type'];
507
+			echo $t['function'].'(';
508
+			if (isset($t['args']) && count($t['args']) > 0)
509 509
 			{
510 510
 				$count = 0;
511
-				foreach($t['args'] as $item)
511
+				foreach ($t['args'] as $item)
512 512
 				{
513
-					if(is_string($item))
513
+					if (is_string($item))
514 514
 					{
515 515
 						$str = htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
516 516
 						if (strlen($item) > 70)
517
-							echo "'" . substr($str, 0, 70) . "...'";
517
+							echo "'".substr($str, 0, 70)."...'";
518 518
 						else
519
-							echo "'" . $str . "'";
519
+							echo "'".$str."'";
520 520
 					}
521 521
 					elseif (is_int($item) || is_float($item))
522 522
 						echo $item;
523 523
 					elseif (is_object($item))
524 524
 						echo get_class($item);
525 525
 					elseif (is_array($item))
526
-						echo 'array(' . count($item) . ')';
526
+						echo 'array('.count($item).')';
527 527
 					elseif (is_bool($item))
528 528
 						echo $item ? 'true' : 'false';
529 529
 					elseif ($item === null)
@@ -551,21 +551,21 @@  discard block
 block discarded – undo
551 551
 	public static function getUserLanguages()
552 552
 	{
553 553
 		static $languages = null;
554
-		if($languages === null)
554
+		if ($languages === null)
555 555
 		{
556
-			if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
556
+			if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
557 557
 				$languages[0] = 'en';
558 558
 			else
559 559
 			{
560 560
 				$languages = [];
561
-				foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
561
+				foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
562 562
 				{
563 563
 					$array = explode(';q=', trim($language));
564
-					$languages[trim($array[0])] = isset($array[1])?(float)$array[1]:1.0;
564
+					$languages[trim($array[0])] = isset($array[1]) ? (float) $array[1] : 1.0;
565 565
 				}
566 566
 				arsort($languages);
567 567
 				$languages = array_keys($languages);
568
-				if(empty($languages))
568
+				if (empty($languages))
569 569
 					$languages[0] = 'en';
570 570
 			}
571 571
 		}
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
 	public static function getPreferredLanguage()
580 580
 	{
581 581
 		static $language = null;
582
-		if($language === null)
582
+		if ($language === null)
583 583
 		{
584 584
 			$langs = Prado::getUserLanguages();
585 585
 			$lang = explode('-', $langs[0]);
586
-			if(empty($lang[0]) || !ctype_alpha($lang[0]))
586
+			if (empty($lang[0]) || !ctype_alpha($lang[0]))
587 587
 				$language = 'en';
588 588
 			else
589 589
 				$language = $lang[0];
@@ -605,12 +605,12 @@  discard block
 block discarded – undo
605 605
 	 */
606 606
 	public static function trace($msg, $category = 'Uncategorized', $ctl = null)
607 607
 	{
608
-		if(self::$_application && self::$_application->getMode() === TApplicationMode::Performance)
608
+		if (self::$_application && self::$_application->getMode() === TApplicationMode::Performance)
609 609
 			return;
610
-		if(!self::$_application || self::$_application->getMode() === TApplicationMode::Debug)
610
+		if (!self::$_application || self::$_application->getMode() === TApplicationMode::Debug)
611 611
 		{
612 612
 			$trace = debug_backtrace();
613
-			if(isset($trace[0]['file']) && isset($trace[0]['line']))
613
+			if (isset($trace[0]['file']) && isset($trace[0]['line']))
614 614
 				$msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})";
615 615
 			$level = TLogger::DEBUG;
616 616
 		}
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 	 */
634 634
 	public static function log($msg, $level = TLogger::INFO, $category = 'Uncategorized', $ctl = null)
635 635
 	{
636
-		if(self::$_logger === null)
636
+		if (self::$_logger === null)
637 637
 			self::$_logger = new TLogger;
638 638
 		self::$_logger->log($msg, $level, $category, $ctl);
639 639
 	}
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 	 */
644 644
 	public static function getLogger()
645 645
 	{
646
-		if(self::$_logger === null)
646
+		if (self::$_logger === null)
647 647
 			self::$_logger = new TLogger;
648 648
 		return self::$_logger;
649 649
 	}
@@ -677,15 +677,15 @@  discard block
 block discarded – undo
677 677
 		$app = Prado::getApplication()->getGlobalization(false);
678 678
 
679 679
 		$params = [];
680
-		foreach($parameters as $key => $value)
681
-			$params['{' . $key . '}'] = $value;
680
+		foreach ($parameters as $key => $value)
681
+			$params['{'.$key.'}'] = $value;
682 682
 
683 683
 		//no translation handler provided
684
-		if($app === null || ($config = $app->getTranslationConfiguration()) === null)
684
+		if ($app === null || ($config = $app->getTranslationConfiguration()) === null)
685 685
 			return strtr($text, $params);
686 686
 
687 687
 		if ($catalogue === null)
688
-			$catalogue = isset($config['catalogue'])?$config['catalogue']:'messages';
688
+			$catalogue = isset($config['catalogue']) ? $config['catalogue'] : 'messages';
689 689
 
690 690
 		Translation::init($catalogue);
691 691
 
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 		$defaultCharset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset();
697 697
 
698 698
 		//fall back
699
-		if(empty($charset)) $charset = $appCharset;
700
-		if(empty($charset)) $charset = $defaultCharset;
699
+		if (empty($charset)) $charset = $appCharset;
700
+		if (empty($charset)) $charset = $defaultCharset;
701 701
 
702 702
 		return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset);
703 703
 	}
Please login to merge, or discard this patch.
Braces   +149 added lines, -111 removed lines patch added patch discarded remove patch
@@ -25,13 +25,15 @@  discard block
 block discarded – undo
25 25
 /**
26 26
  * Defines the PRADO framework installation path.
27 27
  */
28
-if(!defined('PRADO_DIR'))
28
+if(!defined('PRADO_DIR')) {
29 29
 	define('PRADO_DIR', __DIR__);
30
+}
30 31
 /**
31 32
  * Defines the default permission for writable directories and files
32 33
  */
33
-if(!defined('PRADO_CHMOD'))
34
+if(!defined('PRADO_CHMOD')) {
34 35
 	define('PRADO_CHMOD', 0777);
36
+}
35 37
 /**
36 38
  * Defines the Composer's vendor/ path.
37 39
  */
@@ -160,9 +162,9 @@  discard block
 block discarded – undo
160 162
 		{
161 163
 			$am = self::$_application->getAssetManager();
162 164
 			$url = $am->publishFilePath(self::getPathOfNamespace('Prado\\' . $logoName, '.gif'));
165
+		} else {
166
+					$url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif';
163 167
 		}
164
-		else
165
-			$url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif';
166 168
 		return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="' . $url . '" style="border-width:0px;" alt="Powered by PRADO" /></a>';
167 169
 	}
168 170
 
@@ -178,8 +180,9 @@  discard block
 block discarded – undo
178 180
 	 */
179 181
 	public static function phpErrorHandler($errno, $errstr, $errfile, $errline)
180 182
 	{
181
-		if(error_reporting() & $errno)
182
-			throw new TPhpErrorException($errno, $errstr, $errfile, $errline);
183
+		if(error_reporting() & $errno) {
184
+					throw new TPhpErrorException($errno, $errstr, $errfile, $errline);
185
+		}
183 186
 	}
184 187
 
185 188
 	/**
@@ -213,8 +216,7 @@  discard block
 block discarded – undo
213 216
 		if(self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null)
214 217
 		{
215 218
 			$errorHandler->handleError(null, $exception);
216
-		}
217
-		else
219
+		} else
218 220
 		{
219 221
 			echo $exception;
220 222
 		}
@@ -232,8 +234,9 @@  discard block
 block discarded – undo
232 234
 	 */
233 235
 	public static function setApplication($application)
234 236
 	{
235
-		if(self::$_application !== null && !defined('PRADO_TEST_RUN'))
236
-			throw new TInvalidOperationException('prado_application_singleton_required');
237
+		if(self::$_application !== null && !defined('PRADO_TEST_RUN')) {
238
+					throw new TInvalidOperationException('prado_application_singleton_required');
239
+		}
237 240
 		self::$_application = $application;
238 241
 	}
239 242
 
@@ -261,13 +264,15 @@  discard block
 block discarded – undo
261 264
 
262 265
 	protected static function prado3NamespaceToPhpNamespace($type)
263 266
 	{
264
-		if(substr($type, 0, 6) === 'System')
265
-			$type = 'Prado' . substr($type, 6);
267
+		if(substr($type, 0, 6) === 'System') {
268
+					$type = 'Prado' . substr($type, 6);
269
+		}
266 270
 
267
-		if(false === strpos($type, '\\'))
268
-			return str_replace('.', '\\', $type);
269
-		else
270
-			return $type;
271
+		if(false === strpos($type, '\\')) {
272
+					return str_replace('.', '\\', $type);
273
+		} else {
274
+					return $type;
275
+		}
271 276
 	}
272 277
 
273 278
 	/**
@@ -286,8 +291,9 @@  discard block
 block discarded – undo
286 291
 	public static function createComponent($requestedType)
287 292
 	{
288 293
 		$type = static::prado3NamespaceToPhpNamespace($requestedType);
289
-		if(!isset(self::$classExists[$type]))
290
-			self::$classExists[$type] = class_exists($type, false);
294
+		if(!isset(self::$classExists[$type])) {
295
+					self::$classExists[$type] = class_exists($type, false);
296
+		}
291 297
 
292 298
 		if(!isset(self::$_usings[$type]) && !self::$classExists[$type]) {
293 299
 			static::using($type);
@@ -301,8 +307,9 @@  discard block
 block discarded – undo
301 307
 		 * \Application\Common\MyDataModule)
302 308
 		 * Skip this if the class is inside the Prado\* namespace, since all Prado classes are now namespaced
303 309
 		 */
304
-		if(($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0)
305
-			$type = substr($type, $pos + 1);
310
+		if(($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0) {
311
+					$type = substr($type, $pos + 1);
312
+		}
306 313
 
307 314
 		if(($n = func_num_args()) > 1)
308 315
 		{
@@ -322,15 +329,16 @@  discard block
 block discarded – undo
322 329
 				break;
323 330
 				default:
324 331
 					$s = '$args[1]';
325
-					for($i = 2;$i < $n;++$i)
326
-						$s .= ",\$args[$i]";
332
+					for($i = 2;$i < $n;++$i) {
333
+											$s .= ",\$args[$i]";
334
+					}
327 335
 					eval("\$component=new $type($s);");
328 336
 					return $component;
329 337
 				break;
330 338
 			}
339
+		} else {
340
+					return new $type;
331 341
 		}
332
-		else
333
-			return new $type;
334 342
 	}
335 343
 
336 344
 	/**
@@ -346,8 +354,9 @@  discard block
 block discarded – undo
346 354
 	{
347 355
 		$namespace = static::prado3NamespaceToPhpNamespace($namespace);
348 356
 
349
-		if(isset(self::$_usings[$namespace]) || class_exists($namespace, false))
350
-			return;
357
+		if(isset(self::$_usings[$namespace]) || class_exists($namespace, false)) {
358
+					return;
359
+		}
351 360
 
352 361
 		if(array_key_exists($namespace, self::$classMap))
353 362
 		{
@@ -355,8 +364,9 @@  discard block
 block discarded – undo
355 364
 			$phpNamespace = self::$classMap[$namespace];
356 365
 			if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true))
357 366
 			{
358
-				if(!class_exists($namespace) && !interface_exists($namespace))
359
-					class_alias($phpNamespace, $namespace);
367
+				if(!class_exists($namespace) && !interface_exists($namespace)) {
368
+									class_alias($phpNamespace, $namespace);
369
+				}
360 370
 				return;
361 371
 			}
362 372
 		} elseif(($pos = strrpos($namespace, '\\')) === false) {
@@ -369,22 +379,25 @@  discard block
 block discarded – undo
369 379
 					$phpNamespace = '\\' . $k . '\\' . $namespace;
370 380
 					if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true))
371 381
 					{
372
-						if(!class_exists($namespace) && !interface_exists($namespace))
373
-							class_alias($phpNamespace, $namespace);
382
+						if(!class_exists($namespace) && !interface_exists($namespace)) {
383
+													class_alias($phpNamespace, $namespace);
384
+						}
374 385
 						return;
375 386
 					}
376 387
 				}
377 388
 			}
378 389
 
379
-			if($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false))
380
-				throw new TInvalidOperationException('prado_component_unknown', $namespace, '');
390
+			if($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false)) {
391
+							throw new TInvalidOperationException('prado_component_unknown', $namespace, '');
392
+			}
381 393
 		} elseif(($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null) {
382 394
 			$className = substr($namespace, $pos + 1);
383
-			if($className === '*')  // a directory
395
+			if($className === '*') {
396
+				// a directory
384 397
 			{
385 398
 				self::$_usings[substr($namespace, 0, $pos)] = $path;
386 399
 			}
387
-			else  // a file
400
+			} else  // a file
388 401
 			{
389 402
 				//self::$_usings[$namespace]=$path;
390 403
 				if(!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false)))
@@ -392,15 +405,16 @@  discard block
 block discarded – undo
392 405
 					try
393 406
 					{
394 407
 						include_once($path);
395
-						if(class_exists($namespace, false) || interface_exists($namespace, false))
396
-							class_alias($namespace, $className);
397
-					}
398
-					catch(\Exception $e)
408
+						if(class_exists($namespace, false) || interface_exists($namespace, false)) {
409
+													class_alias($namespace, $className);
410
+						}
411
+					} catch(\Exception $e)
399 412
 					{
400
-						if($checkClassExistence && !class_exists($className, false))
401
-							throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage());
402
-						else
403
-							throw $e;
413
+						if($checkClassExistence && !class_exists($className, false)) {
414
+													throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage());
415
+						} else {
416
+													throw $e;
417
+						}
404 418
 					}
405 419
 				}
406 420
 			}
@@ -425,18 +439,21 @@  discard block
 block discarded – undo
425 439
 
426 440
 		if(self::CLASS_FILE_EXT === $ext || empty($ext))
427 441
 		{
428
-			if(isset(self::$_usings[$namespace]))
429
-				return self::$_usings[$namespace];
442
+			if(isset(self::$_usings[$namespace])) {
443
+							return self::$_usings[$namespace];
444
+			}
430 445
 
431
-			if(isset(self::$_aliases[$namespace]))
432
-				return self::$_aliases[$namespace];
446
+			if(isset(self::$_aliases[$namespace])) {
447
+							return self::$_aliases[$namespace];
448
+			}
433 449
 		}
434 450
 
435 451
 		$segs = explode('\\', $namespace);
436 452
 		$alias = array_shift($segs);
437 453
 
438
-		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
439
-			return rtrim($root . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $segs), '/\\') . (($file === '*') ? '' : DIRECTORY_SEPARATOR . $file . $ext);
454
+		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) {
455
+					return rtrim($root . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $segs), '/\\') . (($file === '*') ? '' : DIRECTORY_SEPARATOR . $file . $ext);
456
+		}
440 457
 
441 458
 		return null;
442 459
 	}
@@ -463,17 +480,18 @@  discard block
 block discarded – undo
463 480
 	 */
464 481
 	public static function setPathOfAlias($alias, $path)
465 482
 	{
466
-		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
467
-			throw new TInvalidOperationException('prado_alias_redefined', $alias);
468
-		elseif(($rp = realpath($path)) !== false && is_dir($rp))
483
+		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) {
484
+					throw new TInvalidOperationException('prado_alias_redefined', $alias);
485
+		} elseif(($rp = realpath($path)) !== false && is_dir($rp))
469 486
 		{
470
-			if(strpos($alias, '.') === false)
471
-				self::$_aliases[$alias] = $rp;
472
-			else
473
-				throw new TInvalidDataValueException('prado_aliasname_invalid', $alias);
487
+			if(strpos($alias, '.') === false) {
488
+							self::$_aliases[$alias] = $rp;
489
+			} else {
490
+							throw new TInvalidDataValueException('prado_aliasname_invalid', $alias);
491
+			}
492
+		} else {
493
+					throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path);
474 494
 		}
475
-		else
476
-			throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path);
477 495
 	}
478 496
 
479 497
 	/**
@@ -486,24 +504,29 @@  discard block
 block discarded – undo
486 504
 	{
487 505
 		echo '<h1>Fatal Error</h1>';
488 506
 		echo '<p>' . $msg . '</p>';
489
-		if(!function_exists('debug_backtrace'))
490
-			return;
507
+		if(!function_exists('debug_backtrace')) {
508
+					return;
509
+		}
491 510
 		echo '<h2>Debug Backtrace</h2>';
492 511
 		echo '<pre>';
493 512
 		$index = -1;
494 513
 		foreach(debug_backtrace() as $t)
495 514
 		{
496 515
 			$index++;
497
-			if($index == 0)  // hide the backtrace of this function
516
+			if($index == 0) {
517
+				// hide the backtrace of this function
498 518
 				continue;
519
+			}
499 520
 			echo '#' . $index . ' ';
500
-			if(isset($t['file']))
501
-				echo basename($t['file']) . ':' . $t['line'];
502
-			else
503
-				 echo '<PHP inner-code>';
521
+			if(isset($t['file'])) {
522
+							echo basename($t['file']) . ':' . $t['line'];
523
+			} else {
524
+							 echo '<PHP inner-code>';
525
+			}
504 526
 			echo ' -- ';
505
-			if(isset($t['class']))
506
-				echo $t['class'] . $t['type'];
527
+			if(isset($t['class'])) {
528
+							echo $t['class'] . $t['type'];
529
+			}
507 530
 			echo $t['function'] . '(';
508 531
 			if(isset($t['args']) && count($t['args']) > 0)
509 532
 			{
@@ -513,26 +536,28 @@  discard block
 block discarded – undo
513 536
 					if(is_string($item))
514 537
 					{
515 538
 						$str = htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
516
-						if (strlen($item) > 70)
517
-							echo "'" . substr($str, 0, 70) . "...'";
518
-						else
519
-							echo "'" . $str . "'";
539
+						if (strlen($item) > 70) {
540
+													echo "'" . substr($str, 0, 70) . "...'";
541
+						} else {
542
+													echo "'" . $str . "'";
543
+						}
544
+					} elseif (is_int($item) || is_float($item)) {
545
+											echo $item;
546
+					} elseif (is_object($item)) {
547
+											echo get_class($item);
548
+					} elseif (is_array($item)) {
549
+											echo 'array(' . count($item) . ')';
550
+					} elseif (is_bool($item)) {
551
+											echo $item ? 'true' : 'false';
552
+					} elseif ($item === null) {
553
+											echo 'NULL';
554
+					} elseif (is_resource($item)) {
555
+											echo get_resource_type($item);
520 556
 					}
521
-					elseif (is_int($item) || is_float($item))
522
-						echo $item;
523
-					elseif (is_object($item))
524
-						echo get_class($item);
525
-					elseif (is_array($item))
526
-						echo 'array(' . count($item) . ')';
527
-					elseif (is_bool($item))
528
-						echo $item ? 'true' : 'false';
529
-					elseif ($item === null)
530
-						echo 'NULL';
531
-					elseif (is_resource($item))
532
-						echo get_resource_type($item);
533 557
 					$count++;
534
-					if (count($t['args']) > $count)
535
-						echo ', ';
558
+					if (count($t['args']) > $count) {
559
+											echo ', ';
560
+					}
536 561
 				}
537 562
 			}
538 563
 			echo ")\n";
@@ -553,9 +578,9 @@  discard block
 block discarded – undo
553 578
 		static $languages = null;
554 579
 		if($languages === null)
555 580
 		{
556
-			if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
557
-				$languages[0] = 'en';
558
-			else
581
+			if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
582
+							$languages[0] = 'en';
583
+			} else
559 584
 			{
560 585
 				$languages = [];
561 586
 				foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
@@ -565,8 +590,9 @@  discard block
 block discarded – undo
565 590
 				}
566 591
 				arsort($languages);
567 592
 				$languages = array_keys($languages);
568
-				if(empty($languages))
569
-					$languages[0] = 'en';
593
+				if(empty($languages)) {
594
+									$languages[0] = 'en';
595
+				}
570 596
 			}
571 597
 		}
572 598
 		return $languages;
@@ -583,10 +609,11 @@  discard block
 block discarded – undo
583 609
 		{
584 610
 			$langs = Prado::getUserLanguages();
585 611
 			$lang = explode('-', $langs[0]);
586
-			if(empty($lang[0]) || !ctype_alpha($lang[0]))
587
-				$language = 'en';
588
-			else
589
-				$language = $lang[0];
612
+			if(empty($lang[0]) || !ctype_alpha($lang[0])) {
613
+							$language = 'en';
614
+			} else {
615
+							$language = $lang[0];
616
+			}
590 617
 		}
591 618
 		return $language;
592 619
 	}
@@ -605,17 +632,19 @@  discard block
 block discarded – undo
605 632
 	 */
606 633
 	public static function trace($msg, $category = 'Uncategorized', $ctl = null)
607 634
 	{
608
-		if(self::$_application && self::$_application->getMode() === TApplicationMode::Performance)
609
-			return;
635
+		if(self::$_application && self::$_application->getMode() === TApplicationMode::Performance) {
636
+					return;
637
+		}
610 638
 		if(!self::$_application || self::$_application->getMode() === TApplicationMode::Debug)
611 639
 		{
612 640
 			$trace = debug_backtrace();
613
-			if(isset($trace[0]['file']) && isset($trace[0]['line']))
614
-				$msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})";
641
+			if(isset($trace[0]['file']) && isset($trace[0]['line'])) {
642
+							$msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})";
643
+			}
615 644
 			$level = TLogger::DEBUG;
645
+		} else {
646
+					$level = TLogger::INFO;
616 647
 		}
617
-		else
618
-			$level = TLogger::INFO;
619 648
 		self::log($msg, $level, $category, $ctl);
620 649
 	}
621 650
 
@@ -633,8 +662,9 @@  discard block
 block discarded – undo
633 662
 	 */
634 663
 	public static function log($msg, $level = TLogger::INFO, $category = 'Uncategorized', $ctl = null)
635 664
 	{
636
-		if(self::$_logger === null)
637
-			self::$_logger = new TLogger;
665
+		if(self::$_logger === null) {
666
+					self::$_logger = new TLogger;
667
+		}
638 668
 		self::$_logger->log($msg, $level, $category, $ctl);
639 669
 	}
640 670
 
@@ -643,8 +673,9 @@  discard block
 block discarded – undo
643 673
 	 */
644 674
 	public static function getLogger()
645 675
 	{
646
-		if(self::$_logger === null)
647
-			self::$_logger = new TLogger;
676
+		if(self::$_logger === null) {
677
+					self::$_logger = new TLogger;
678
+		}
648 679
 		return self::$_logger;
649 680
 	}
650 681
 
@@ -677,15 +708,18 @@  discard block
 block discarded – undo
677 708
 		$app = Prado::getApplication()->getGlobalization(false);
678 709
 
679 710
 		$params = [];
680
-		foreach($parameters as $key => $value)
681
-			$params['{' . $key . '}'] = $value;
711
+		foreach($parameters as $key => $value) {
712
+					$params['{' . $key . '}'] = $value;
713
+		}
682 714
 
683 715
 		//no translation handler provided
684
-		if($app === null || ($config = $app->getTranslationConfiguration()) === null)
685
-			return strtr($text, $params);
716
+		if($app === null || ($config = $app->getTranslationConfiguration()) === null) {
717
+					return strtr($text, $params);
718
+		}
686 719
 
687
-		if ($catalogue === null)
688
-			$catalogue = isset($config['catalogue'])?$config['catalogue']:'messages';
720
+		if ($catalogue === null) {
721
+					$catalogue = isset($config['catalogue'])?$config['catalogue']:'messages';
722
+		}
689 723
 
690 724
 		Translation::init($catalogue);
691 725
 
@@ -696,8 +730,12 @@  discard block
 block discarded – undo
696 730
 		$defaultCharset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset();
697 731
 
698 732
 		//fall back
699
-		if(empty($charset)) $charset = $appCharset;
700
-		if(empty($charset)) $charset = $defaultCharset;
733
+		if(empty($charset)) {
734
+			$charset = $appCharset;
735
+		}
736
+		if(empty($charset)) {
737
+			$charset = $defaultCharset;
738
+		}
701 739
 
702 740
 		return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset);
703 741
 	}
Please login to merge, or discard this patch.
framework/TComponentReflection.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function __construct($component)
49 49
 	{
50
-		if(is_string($component) && class_exists($component, false))
50
+		if (is_string($component) && class_exists($component, false))
51 51
 			$this->_className = $component;
52
-		elseif(is_object($component))
52
+		elseif (is_object($component))
53 53
 			$this->_className = get_class($component);
54 54
 		else
55 55
 			throw new TInvalidDataTypeException('componentreflection_class_invalid');
@@ -78,41 +78,41 @@  discard block
 block discarded – undo
78 78
 		$events = [];
79 79
 		$methods = [];
80 80
 		$isComponent = is_subclass_of($this->_className, 'TComponent') || strcasecmp($this->_className, 'TComponent') === 0;
81
-		foreach($class->getMethods() as $method)
81
+		foreach ($class->getMethods() as $method)
82 82
 		{
83
-			if($method->isPublic() || $method->isProtected())
83
+			if ($method->isPublic() || $method->isProtected())
84 84
 			{
85 85
 				$methodName = $method->getName();
86
-				if(!$method->isStatic() && $isComponent)
86
+				if (!$method->isStatic() && $isComponent)
87 87
 				{
88
-					if($this->isPropertyMethod($method))
88
+					if ($this->isPropertyMethod($method))
89 89
 						$properties[substr($methodName, 3)] = $method;
90
-					elseif($this->isEventMethod($method))
90
+					elseif ($this->isEventMethod($method))
91 91
 					{
92 92
 						$methodName[0] = 'O';
93 93
 						$events[$methodName] = $method;
94 94
 					}
95 95
 				}
96
-				if(strncmp($methodName, '__', 2) !== 0)
96
+				if (strncmp($methodName, '__', 2) !== 0)
97 97
 					$methods[$methodName] = $method;
98 98
 			}
99 99
 		}
100 100
 		$reserved = [];
101 101
 		ksort($properties);
102
-		foreach($properties as $name => $method)
102
+		foreach ($properties as $name => $method)
103 103
 		{
104 104
 			$this->_properties[$name] = [
105 105
 				'type' => $this->determinePropertyType($method),
106
-				'readonly' => !$class->hasMethod('set' . $name),
106
+				'readonly' => !$class->hasMethod('set'.$name),
107 107
 				'protected' => $method->isProtected(),
108 108
 				'class' => $method->getDeclaringClass()->getName(),
109 109
 				'comments' => $method->getDocComment()
110 110
 			];
111
-			$reserved['get' . strtolower($name)] = 1;
112
-			$reserved['set' . strtolower($name)] = 1;
111
+			$reserved['get'.strtolower($name)] = 1;
112
+			$reserved['set'.strtolower($name)] = 1;
113 113
 		}
114 114
 		ksort($events);
115
-		foreach($events as $name => $method)
115
+		foreach ($events as $name => $method)
116 116
 		{
117 117
 			$this->_events[$name] = [
118 118
 				'class' => $method->getDeclaringClass()->getName(),
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 			$reserved[strtolower($name)] = 1;
123 123
 		}
124 124
 		ksort($methods);
125
-		foreach($methods as $name => $method)
125
+		foreach ($methods as $name => $method)
126 126
 		{
127
-			if(!isset($reserved[strtolower($name)]))
127
+			if (!isset($reserved[strtolower($name)]))
128 128
 				$this->_methods[$name] = [
129 129
 					'class' => $method->getDeclaringClass()->getName(),
130 130
 					'protected' => $method->isProtected(),
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	protected function determinePropertyType($method)
144 144
 	{
145 145
 		$comment = $method->getDocComment();
146
-		if(preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches))
146
+		if (preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches))
147 147
 			return $matches[1];
148 148
 		else
149 149
 			return '{unknown}';
Please login to merge, or discard this patch.
Braces   +21 added lines, -17 removed lines patch added patch discarded remove patch
@@ -47,12 +47,13 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function __construct($component)
49 49
 	{
50
-		if(is_string($component) && class_exists($component, false))
51
-			$this->_className = $component;
52
-		elseif(is_object($component))
53
-			$this->_className = get_class($component);
54
-		else
55
-			throw new TInvalidDataTypeException('componentreflection_class_invalid');
50
+		if(is_string($component) && class_exists($component, false)) {
51
+					$this->_className = $component;
52
+		} elseif(is_object($component)) {
53
+					$this->_className = get_class($component);
54
+		} else {
55
+					throw new TInvalidDataTypeException('componentreflection_class_invalid');
56
+		}
56 57
 		$this->reflect();
57 58
 	}
58 59
 
@@ -85,16 +86,17 @@  discard block
 block discarded – undo
85 86
 				$methodName = $method->getName();
86 87
 				if(!$method->isStatic() && $isComponent)
87 88
 				{
88
-					if($this->isPropertyMethod($method))
89
-						$properties[substr($methodName, 3)] = $method;
90
-					elseif($this->isEventMethod($method))
89
+					if($this->isPropertyMethod($method)) {
90
+											$properties[substr($methodName, 3)] = $method;
91
+					} elseif($this->isEventMethod($method))
91 92
 					{
92 93
 						$methodName[0] = 'O';
93 94
 						$events[$methodName] = $method;
94 95
 					}
95 96
 				}
96
-				if(strncmp($methodName, '__', 2) !== 0)
97
-					$methods[$methodName] = $method;
97
+				if(strncmp($methodName, '__', 2) !== 0) {
98
+									$methods[$methodName] = $method;
99
+				}
98 100
 			}
99 101
 		}
100 102
 		$reserved = [];
@@ -124,13 +126,14 @@  discard block
 block discarded – undo
124 126
 		ksort($methods);
125 127
 		foreach($methods as $name => $method)
126 128
 		{
127
-			if(!isset($reserved[strtolower($name)]))
128
-				$this->_methods[$name] = [
129
+			if(!isset($reserved[strtolower($name)])) {
130
+							$this->_methods[$name] = [
129 131
 					'class' => $method->getDeclaringClass()->getName(),
130 132
 					'protected' => $method->isProtected(),
131 133
 					'static' => $method->isStatic(),
132 134
 					'comments' => $method->getDocComment()
133 135
 				];
136
+			}
134 137
 		}
135 138
 	}
136 139
 
@@ -143,10 +146,11 @@  discard block
 block discarded – undo
143 146
 	protected function determinePropertyType($method)
144 147
 	{
145 148
 		$comment = $method->getDocComment();
146
-		if(preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches))
147
-			return $matches[1];
148
-		else
149
-			return '{unknown}';
149
+		if(preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches)) {
150
+					return $matches[1];
151
+		} else {
152
+					return '{unknown}';
153
+		}
150 154
 	}
151 155
 
152 156
 	/**
Please login to merge, or discard this patch.
framework/Exceptions/TException.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 		array_shift($args);
56 56
 		$n = count($args);
57 57
 		$tokens = [];
58
-		for($i = 0;$i < $n;++$i)
59
-			$tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]);
58
+		for ($i = 0; $i < $n; ++$i)
59
+			$tokens['{'.$i.'}'] = TPropertyValue::ensureString($args[$i]);
60 60
 		parent::__construct(strtr($errorMessage, $tokens));
61 61
 	}
62 62
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 		// Cache messages
73 73
 		if (!isset(self::$_messageCache[$msgFile]))
74 74
 		{
75
-			if(($entries = @file($msgFile)) !== false)
75
+			if (($entries = @file($msgFile)) !== false)
76 76
 			{
77
-				foreach($entries as $entry)
77
+				foreach ($entries as $entry)
78 78
 				{
79
-					list($code, $message) = array_merge(explode('=', $entry, 2), [ '' ]);
79
+					list($code, $message) = array_merge(explode('=', $entry, 2), ['']);
80 80
 					self::$_messageCache[$msgFile][trim($code)] = trim($message);
81 81
 				}
82 82
 			}
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	protected function getErrorMessageFile()
91 91
 	{
92 92
 		$lang = Prado::getPreferredLanguage();
93
-		$msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages-' . $lang . '.txt';
94
-		if(!is_file($msgFile))
95
-			$msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages.txt';
93
+		$msgFile = Prado::getFrameworkPath().'/Exceptions/messages/messages-'.$lang.'.txt';
94
+		if (!is_file($msgFile))
95
+			$msgFile = Prado::getFrameworkPath().'/Exceptions/messages/messages.txt';
96 96
 		return $msgFile;
97 97
 	}
98 98
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,8 +55,9 @@  discard block
 block discarded – undo
55 55
 		array_shift($args);
56 56
 		$n = count($args);
57 57
 		$tokens = [];
58
-		for($i = 0;$i < $n;++$i)
59
-			$tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]);
58
+		for($i = 0;$i < $n;++$i) {
59
+					$tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]);
60
+		}
60 61
 		parent::__construct(strtr($errorMessage, $tokens));
61 62
 	}
62 63
 
@@ -91,8 +92,9 @@  discard block
 block discarded – undo
91 92
 	{
92 93
 		$lang = Prado::getPreferredLanguage();
93 94
 		$msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages-' . $lang . '.txt';
94
-		if(!is_file($msgFile))
95
-			$msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages.txt';
95
+		if(!is_file($msgFile)) {
96
+					$msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages.txt';
97
+		}
96 98
 		return $msgFile;
97 99
 	}
98 100
 
Please login to merge, or discard this patch.
framework/Exceptions/TErrorHandler.php 2 patches
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function getErrorTemplatePath()
93 93
 	{
94
-		if($this->_templatePath === null)
95
-			$this->_templatePath = Prado::getFrameworkPath() . '/Exceptions/templates';
94
+		if ($this->_templatePath === null)
95
+			$this->_templatePath = Prado::getFrameworkPath().'/Exceptions/templates';
96 96
 		return $this->_templatePath;
97 97
 	}
98 98
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function setErrorTemplatePath($value)
106 106
 	{
107
-		if(($templatePath = Prado::getPathOfNamespace($value)) !== null && is_dir($templatePath))
107
+		if (($templatePath = Prado::getPathOfNamespace($value)) !== null && is_dir($templatePath))
108 108
 			$this->_templatePath = $templatePath;
109 109
 		else
110 110
 			throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value);
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
 		restore_error_handler();
129 129
 		restore_exception_handler();
130 130
 		// ensure that we do not enter infinite loop of error handling
131
-		if($handling)
131
+		if ($handling)
132 132
 			$this->handleRecursiveError($param);
133 133
 		else
134 134
 		{
135 135
 			$handling = true;
136
-			if(($response = $this->getResponse()) !== null)
136
+			if (($response = $this->getResponse()) !== null)
137 137
 				$response->clear();
138
-			if(!headers_sent())
138
+			if (!headers_sent())
139 139
 				header('Content-Type: text/html; charset=UTF-8');
140
-			if($param instanceof THttpException)
140
+			if ($param instanceof THttpException)
141 141
 				$this->handleExternalError($param->getStatusCode(), $param);
142
-			elseif($this->getApplication()->getMode() === TApplicationMode::Debug)
142
+			elseif ($this->getApplication()->getMode() === TApplicationMode::Debug)
143 143
 				$this->displayException($param);
144 144
 			else
145 145
 				$this->handleExternalError(500, $param);
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 	protected static function hideSecurityRelated($value, $exception = null)
157 157
 	{
158 158
 		$aRpl = [];
159
-		if($exception !== null && $exception instanceof \Exception)
159
+		if ($exception !== null && $exception instanceof \Exception)
160 160
 		{
161
-			if($exception instanceof TPhpFatalErrorException &&
161
+			if ($exception instanceof TPhpFatalErrorException &&
162 162
 				function_exists('xdebug_get_function_stack'))
163 163
 			{
164 164
 				$aTrace = array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1);
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 				$aTrace = $exception->getTrace();
167 167
 			}
168 168
 
169
-			foreach($aTrace as $item)
169
+			foreach ($aTrace as $item)
170 170
 			{
171
-				if(isset($item['file']))
172
-					$aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR;
171
+				if (isset($item['file']))
172
+					$aRpl[dirname($item['file']).DIRECTORY_SEPARATOR] = '<hidden>'.DIRECTORY_SEPARATOR;
173 173
 			}
174 174
 		}
175 175
 		$aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}';
176 176
 		$aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}';
177
-		$aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR;
178
-		if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]);
177
+		$aRpl[PRADO_DIR.DIRECTORY_SEPARATOR] = '${PradoFramework}'.DIRECTORY_SEPARATOR;
178
+		if (isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]);
179 179
 		$aRpl = array_reverse($aRpl, true);
180 180
 
181 181
 		return str_replace(array_keys($aRpl), $aRpl, $value);
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
 	 */
191 191
 	protected function handleExternalError($statusCode, $exception)
192 192
 	{
193
-		if(!($exception instanceof THttpException))
193
+		if (!($exception instanceof THttpException))
194 194
 			error_log($exception->__toString());
195 195
 
196 196
 		$content = $this->getErrorTemplate($statusCode, $exception);
197 197
 
198
-		$serverAdmin = isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:'';
198
+		$serverAdmin = isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : '';
199 199
 
200 200
 		$isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug;
201 201
 
202 202
 		$errorMessage = $exception->getMessage();
203
-		if($isDebug)
204
-			$version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion();
203
+		if ($isDebug)
204
+			$version = $_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
205 205
 		else
206 206
 		{
207 207
 			$version = '';
@@ -229,16 +229,16 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	protected function handleRecursiveError($exception)
231 231
 	{
232
-		if($this->getApplication()->getMode() === TApplicationMode::Debug)
232
+		if ($this->getApplication()->getMode() === TApplicationMode::Debug)
233 233
 		{
234 234
 			echo "<html><head><title>Recursive Error</title></head>\n";
235 235
 			echo "<body><h1>Recursive Error</h1>\n";
236
-			echo "<pre>" . $exception->__toString() . "</pre>\n";
236
+			echo "<pre>".$exception->__toString()."</pre>\n";
237 237
 			echo "</body></html>";
238 238
 		}
239 239
 		else
240 240
 		{
241
-			error_log("Error happened while processing an existing error:\n" . $exception->__toString());
241
+			error_log("Error happened while processing an existing error:\n".$exception->__toString());
242 242
 			header('HTTP/1.0 500 Internal Error');
243 243
 		}
244 244
 	}
@@ -252,25 +252,25 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	protected function displayException($exception)
254 254
 	{
255
-		if(php_sapi_name() === 'cli')
255
+		if (php_sapi_name() === 'cli')
256 256
 		{
257
-			echo $exception->getMessage() . "\n";
257
+			echo $exception->getMessage()."\n";
258 258
 			echo $this->getExactTraceAsString($exception);
259 259
 			return;
260 260
 		}
261 261
 
262
-		if($exception instanceof TTemplateException)
262
+		if ($exception instanceof TTemplateException)
263 263
 		{
264 264
 			$fileName = $exception->getTemplateFile();
265
-			$lines = empty($fileName)?explode("\n", $exception->getTemplateSource()):@file($fileName);
265
+			$lines = empty($fileName) ?explode("\n", $exception->getTemplateSource()) : @file($fileName);
266 266
 			$source = $this->getSourceCode($lines, $exception->getLineNumber());
267
-			if($fileName === '')
267
+			if ($fileName === '')
268 268
 				$fileName = '---embedded template---';
269 269
 			$errorLine = $exception->getLineNumber();
270 270
 		}
271 271
 		else
272 272
 		{
273
-			if(($trace = $this->getExactTrace($exception)) !== null)
273
+			if (($trace = $this->getExactTrace($exception)) !== null)
274 274
 			{
275 275
 				$fileName = $trace['file'];
276 276
 				$errorLine = $trace['line'];
@@ -283,15 +283,15 @@  discard block
 block discarded – undo
283 283
 			$source = $this->getSourceCode(@file($fileName), $errorLine);
284 284
 		}
285 285
 
286
-		if($this->getApplication()->getMode() === TApplicationMode::Debug)
287
-			$version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion();
286
+		if ($this->getApplication()->getMode() === TApplicationMode::Debug)
287
+			$version = $_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
288 288
 		else
289 289
 			$version = '';
290 290
 
291 291
 		$tokens = [
292 292
 			'%%ErrorType%%' => get_class($exception),
293 293
 			'%%ErrorMessage%%' => $this->addLink(htmlspecialchars($exception->getMessage())),
294
-			'%%SourceFile%%' => htmlspecialchars($fileName) . ' (' . $errorLine . ')',
294
+			'%%SourceFile%%' => htmlspecialchars($fileName).' ('.$errorLine.')',
295 295
 			'%%SourceCode%%' => $source,
296 296
 			'%%StackTrace%%' => htmlspecialchars($this->getExactTraceAsString($exception)),
297 297
 			'%%Version%%' => $version,
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 	protected function getExceptionTemplate($exception)
314 314
 	{
315 315
 		$lang = Prado::getPreferredLanguage();
316
-		$exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '-' . $lang . '.html';
317
-		if(!is_file($exceptionFile))
318
-			$exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '.html';
319
-		if(($content = @file_get_contents($exceptionFile)) === false)
316
+		$exceptionFile = Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'-'.$lang.'.html';
317
+		if (!is_file($exceptionFile))
318
+			$exceptionFile = Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'.html';
319
+		if (($content = @file_get_contents($exceptionFile)) === false)
320 320
 			die("Unable to open exception template file '$exceptionFile'.");
321 321
 		return $content;
322 322
 	}
@@ -339,17 +339,17 @@  discard block
 block discarded – undo
339 339
 	 */
340 340
 	protected function getErrorTemplate($statusCode, $exception)
341 341
 	{
342
-		$base = $this->getErrorTemplatePath() . DIRECTORY_SEPARATOR . self::ERROR_FILE_NAME;
342
+		$base = $this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME;
343 343
 		$lang = Prado::getPreferredLanguage();
344
-		if(is_file("$base$statusCode-$lang.html"))
344
+		if (is_file("$base$statusCode-$lang.html"))
345 345
 			$errorFile = "$base$statusCode-$lang.html";
346
-		elseif(is_file("$base$statusCode.html"))
346
+		elseif (is_file("$base$statusCode.html"))
347 347
 			$errorFile = "$base$statusCode.html";
348
-		elseif(is_file("$base-$lang.html"))
348
+		elseif (is_file("$base-$lang.html"))
349 349
 			$errorFile = "$base-$lang.html";
350 350
 		else
351 351
 			$errorFile = "$base.html";
352
-		if(($content = @file_get_contents($errorFile)) === false)
352
+		if (($content = @file_get_contents($errorFile)) === false)
353 353
 			die("Unable to open error template file '$errorFile'.");
354 354
 		return $content;
355 355
 	}
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	private function getExactTrace($exception)
358 358
 	{
359 359
 		$result = null;
360
-		if($exception instanceof TPhpFatalErrorException &&
360
+		if ($exception instanceof TPhpFatalErrorException &&
361 361
 			function_exists('xdebug_get_function_stack'))
362 362
 		{
363 363
 			$trace = array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1);
@@ -367,17 +367,17 @@  discard block
 block discarded – undo
367 367
 		
368 368
 		// if PHP exception, we want to show the 2nd stack level context
369 369
 		// because the 1st stack level is of little use (it's in error handler)
370
-		if($exception instanceof TPhpErrorException) {
371
-			if(isset($trace[0]['file']))
370
+		if ($exception instanceof TPhpErrorException) {
371
+			if (isset($trace[0]['file']))
372 372
 				$result = $trace[0];
373
-			elseif(isset($trace[1]))
373
+			elseif (isset($trace[1]))
374 374
 				$result = $trace[1];
375
-		} elseif($exception instanceof TInvalidOperationException) {
375
+		} elseif ($exception instanceof TInvalidOperationException) {
376 376
 			// in case of getter or setter error, find out the exact file and row
377
-			if(($result = $this->getPropertyAccessTrace($trace, '__get')) === null)
377
+			if (($result = $this->getPropertyAccessTrace($trace, '__get')) === null)
378 378
 				$result = $this->getPropertyAccessTrace($trace, '__set');
379 379
 		}
380
-		if($result !== null && strpos($result['file'], ': eval()\'d code') !== false)
380
+		if ($result !== null && strpos($result['file'], ': eval()\'d code') !== false)
381 381
 			return null;
382 382
 
383 383
 		return $result;
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 
386 386
 	private function getExactTraceAsString($exception)
387 387
 	{
388
-		if($exception instanceof TPhpFatalErrorException &&
388
+		if ($exception instanceof TPhpFatalErrorException &&
389 389
 			function_exists('xdebug_get_function_stack'))
390 390
 		{
391 391
 			$trace = array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1);
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 			$row = 0;
394 394
 
395 395
 			// try to mimic Exception::getTraceAsString()
396
-			foreach($trace as $line)
396
+			foreach ($trace as $line)
397 397
 			{
398
-				if(array_key_exists('function', $line))
399
-					$func = $line['function'] . '(' . implode(',', $line['params']) . ')';
398
+				if (array_key_exists('function', $line))
399
+					$func = $line['function'].'('.implode(',', $line['params']).')';
400 400
 				else
401 401
 					$func = 'unknown';
402 402
 
403
-				$txt .= '#' . $row . ' ' . $line['file'] . '(' . $line['line'] . '): ' . $func . "\n";
403
+				$txt .= '#'.$row.' '.$line['file'].'('.$line['line'].'): '.$func."\n";
404 404
 				$row++;
405 405
 			}
406 406
 
@@ -413,9 +413,9 @@  discard block
 block discarded – undo
413 413
 	private function getPropertyAccessTrace($trace, $pattern)
414 414
 	{
415 415
 		$result = null;
416
-		foreach($trace as $t)
416
+		foreach ($trace as $t)
417 417
 		{
418
-			if(isset($t['function']) && $t['function'] === $pattern)
418
+			if (isset($t['function']) && $t['function'] === $pattern)
419 419
 				$result = $t;
420 420
 			else
421 421
 				break;
@@ -425,16 +425,16 @@  discard block
 block discarded – undo
425 425
 
426 426
 	private function getSourceCode($lines, $errorLine)
427 427
 	{
428
-		$beginLine = $errorLine - self::SOURCE_LINES >= 0?$errorLine - self::SOURCE_LINES:0;
429
-		$endLine = $errorLine + self::SOURCE_LINES <= count($lines)?$errorLine + self::SOURCE_LINES:count($lines);
428
+		$beginLine = $errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0;
429
+		$endLine = $errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines);
430 430
 
431 431
 		$source = '';
432
-		for($i = $beginLine;$i < $endLine;++$i)
432
+		for ($i = $beginLine; $i < $endLine; ++$i)
433 433
 		{
434
-			if($i === $errorLine - 1)
434
+			if ($i === $errorLine - 1)
435 435
 			{
436 436
 				$line = htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", '    ', $lines[$i])));
437
-				$source .= "<div class=\"error\">" . $line . "</div>";
437
+				$source .= "<div class=\"error\">".$line."</div>";
438 438
 			}
439 439
 			else
440 440
 				$source .= htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", '    ', $lines[$i])));
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
 	private function addLink($message) {
446 446
 		if (null !== ($class = $this->getErrorClassNameSpace($message))) {
447
-			return str_replace($class['name'], '<a href="' . $class['url'] . '" target="_blank">' . $class['name'] . '</a>', $message);
447
+			return str_replace($class['name'], '<a href="'.$class['url'].'" target="_blank">'.$class['name'].'</a>', $message);
448 448
 		}
449 449
 		return $message;
450 450
 	}
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 			}
463 463
 			$classname = $function->getNamespaceName();
464 464
 			return [
465
-				'url' => 'http://pradosoft.github.io/docs/manual/class-' . str_replace('\\', '.', (string) $classname) . '.' . $class . '.html',
465
+				'url' => 'http://pradosoft.github.io/docs/manual/class-'.str_replace('\\', '.', (string) $classname).'.'.$class.'.html',
466 466
 				'name' => $class,
467 467
 			];
468 468
 		}
Please login to merge, or discard this patch.
Braces   +89 added lines, -73 removed lines patch added patch discarded remove patch
@@ -91,8 +91,9 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function getErrorTemplatePath()
93 93
 	{
94
-		if($this->_templatePath === null)
95
-			$this->_templatePath = Prado::getFrameworkPath() . '/Exceptions/templates';
94
+		if($this->_templatePath === null) {
95
+					$this->_templatePath = Prado::getFrameworkPath() . '/Exceptions/templates';
96
+		}
96 97
 		return $this->_templatePath;
97 98
 	}
98 99
 
@@ -104,10 +105,11 @@  discard block
 block discarded – undo
104 105
 	 */
105 106
 	public function setErrorTemplatePath($value)
106 107
 	{
107
-		if(($templatePath = Prado::getPathOfNamespace($value)) !== null && is_dir($templatePath))
108
-			$this->_templatePath = $templatePath;
109
-		else
110
-			throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value);
108
+		if(($templatePath = Prado::getPathOfNamespace($value)) !== null && is_dir($templatePath)) {
109
+					$this->_templatePath = $templatePath;
110
+		} else {
111
+					throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value);
112
+		}
111 113
 	}
112 114
 
113 115
 	/**
@@ -128,21 +130,24 @@  discard block
 block discarded – undo
128 130
 		restore_error_handler();
129 131
 		restore_exception_handler();
130 132
 		// ensure that we do not enter infinite loop of error handling
131
-		if($handling)
132
-			$this->handleRecursiveError($param);
133
-		else
133
+		if($handling) {
134
+					$this->handleRecursiveError($param);
135
+		} else
134 136
 		{
135 137
 			$handling = true;
136
-			if(($response = $this->getResponse()) !== null)
137
-				$response->clear();
138
-			if(!headers_sent())
139
-				header('Content-Type: text/html; charset=UTF-8');
140
-			if($param instanceof THttpException)
141
-				$this->handleExternalError($param->getStatusCode(), $param);
142
-			elseif($this->getApplication()->getMode() === TApplicationMode::Debug)
143
-				$this->displayException($param);
144
-			else
145
-				$this->handleExternalError(500, $param);
138
+			if(($response = $this->getResponse()) !== null) {
139
+							$response->clear();
140
+			}
141
+			if(!headers_sent()) {
142
+							header('Content-Type: text/html; charset=UTF-8');
143
+			}
144
+			if($param instanceof THttpException) {
145
+							$this->handleExternalError($param->getStatusCode(), $param);
146
+			} elseif($this->getApplication()->getMode() === TApplicationMode::Debug) {
147
+							$this->displayException($param);
148
+			} else {
149
+							$this->handleExternalError(500, $param);
150
+			}
146 151
 		}
147 152
 	}
148 153
 
@@ -168,14 +173,17 @@  discard block
 block discarded – undo
168 173
 
169 174
 			foreach($aTrace as $item)
170 175
 			{
171
-				if(isset($item['file']))
172
-					$aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR;
176
+				if(isset($item['file'])) {
177
+									$aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR;
178
+				}
173 179
 			}
174 180
 		}
175 181
 		$aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}';
176 182
 		$aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}';
177 183
 		$aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR;
178
-		if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]);
184
+		if(isset($aRpl[DIRECTORY_SEPARATOR])) {
185
+			unset($aRpl[DIRECTORY_SEPARATOR]);
186
+		}
179 187
 		$aRpl = array_reverse($aRpl, true);
180 188
 
181 189
 		return str_replace(array_keys($aRpl), $aRpl, $value);
@@ -190,8 +198,9 @@  discard block
 block discarded – undo
190 198
 	 */
191 199
 	protected function handleExternalError($statusCode, $exception)
192 200
 	{
193
-		if(!($exception instanceof THttpException))
194
-			error_log($exception->__toString());
201
+		if(!($exception instanceof THttpException)) {
202
+					error_log($exception->__toString());
203
+		}
195 204
 
196 205
 		$content = $this->getErrorTemplate($statusCode, $exception);
197 206
 
@@ -200,9 +209,9 @@  discard block
 block discarded – undo
200 209
 		$isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug;
201 210
 
202 211
 		$errorMessage = $exception->getMessage();
203
-		if($isDebug)
204
-			$version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion();
205
-		else
212
+		if($isDebug) {
213
+					$version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion();
214
+		} else
206 215
 		{
207 216
 			$version = '';
208 217
 			$errorMessage = self::hideSecurityRelated($errorMessage, $exception);
@@ -235,8 +244,7 @@  discard block
 block discarded – undo
235 244
 			echo "<body><h1>Recursive Error</h1>\n";
236 245
 			echo "<pre>" . $exception->__toString() . "</pre>\n";
237 246
 			echo "</body></html>";
238
-		}
239
-		else
247
+		} else
240 248
 		{
241 249
 			error_log("Error happened while processing an existing error:\n" . $exception->__toString());
242 250
 			header('HTTP/1.0 500 Internal Error');
@@ -264,18 +272,17 @@  discard block
 block discarded – undo
264 272
 			$fileName = $exception->getTemplateFile();
265 273
 			$lines = empty($fileName)?explode("\n", $exception->getTemplateSource()):@file($fileName);
266 274
 			$source = $this->getSourceCode($lines, $exception->getLineNumber());
267
-			if($fileName === '')
268
-				$fileName = '---embedded template---';
275
+			if($fileName === '') {
276
+							$fileName = '---embedded template---';
277
+			}
269 278
 			$errorLine = $exception->getLineNumber();
270
-		}
271
-		else
279
+		} else
272 280
 		{
273 281
 			if(($trace = $this->getExactTrace($exception)) !== null)
274 282
 			{
275 283
 				$fileName = $trace['file'];
276 284
 				$errorLine = $trace['line'];
277
-			}
278
-			else
285
+			} else
279 286
 			{
280 287
 				$fileName = $exception->getFile();
281 288
 				$errorLine = $exception->getLine();
@@ -283,10 +290,11 @@  discard block
 block discarded – undo
283 290
 			$source = $this->getSourceCode(@file($fileName), $errorLine);
284 291
 		}
285 292
 
286
-		if($this->getApplication()->getMode() === TApplicationMode::Debug)
287
-			$version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion();
288
-		else
289
-			$version = '';
293
+		if($this->getApplication()->getMode() === TApplicationMode::Debug) {
294
+					$version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion();
295
+		} else {
296
+					$version = '';
297
+		}
290 298
 
291 299
 		$tokens = [
292 300
 			'%%ErrorType%%' => get_class($exception),
@@ -314,10 +322,12 @@  discard block
 block discarded – undo
314 322
 	{
315 323
 		$lang = Prado::getPreferredLanguage();
316 324
 		$exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '-' . $lang . '.html';
317
-		if(!is_file($exceptionFile))
318
-			$exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '.html';
319
-		if(($content = @file_get_contents($exceptionFile)) === false)
320
-			die("Unable to open exception template file '$exceptionFile'.");
325
+		if(!is_file($exceptionFile)) {
326
+					$exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '.html';
327
+		}
328
+		if(($content = @file_get_contents($exceptionFile)) === false) {
329
+					die("Unable to open exception template file '$exceptionFile'.");
330
+		}
321 331
 		return $content;
322 332
 	}
323 333
 
@@ -341,16 +351,18 @@  discard block
 block discarded – undo
341 351
 	{
342 352
 		$base = $this->getErrorTemplatePath() . DIRECTORY_SEPARATOR . self::ERROR_FILE_NAME;
343 353
 		$lang = Prado::getPreferredLanguage();
344
-		if(is_file("$base$statusCode-$lang.html"))
345
-			$errorFile = "$base$statusCode-$lang.html";
346
-		elseif(is_file("$base$statusCode.html"))
347
-			$errorFile = "$base$statusCode.html";
348
-		elseif(is_file("$base-$lang.html"))
349
-			$errorFile = "$base-$lang.html";
350
-		else
351
-			$errorFile = "$base.html";
352
-		if(($content = @file_get_contents($errorFile)) === false)
353
-			die("Unable to open error template file '$errorFile'.");
354
+		if(is_file("$base$statusCode-$lang.html")) {
355
+					$errorFile = "$base$statusCode-$lang.html";
356
+		} elseif(is_file("$base$statusCode.html")) {
357
+					$errorFile = "$base$statusCode.html";
358
+		} elseif(is_file("$base-$lang.html")) {
359
+					$errorFile = "$base-$lang.html";
360
+		} else {
361
+					$errorFile = "$base.html";
362
+		}
363
+		if(($content = @file_get_contents($errorFile)) === false) {
364
+					die("Unable to open error template file '$errorFile'.");
365
+		}
354 366
 		return $content;
355 367
 	}
356 368
 
@@ -368,17 +380,20 @@  discard block
 block discarded – undo
368 380
 		// if PHP exception, we want to show the 2nd stack level context
369 381
 		// because the 1st stack level is of little use (it's in error handler)
370 382
 		if($exception instanceof TPhpErrorException) {
371
-			if(isset($trace[0]['file']))
372
-				$result = $trace[0];
373
-			elseif(isset($trace[1]))
374
-				$result = $trace[1];
383
+			if(isset($trace[0]['file'])) {
384
+							$result = $trace[0];
385
+			} elseif(isset($trace[1])) {
386
+							$result = $trace[1];
387
+			}
375 388
 		} elseif($exception instanceof TInvalidOperationException) {
376 389
 			// in case of getter or setter error, find out the exact file and row
377
-			if(($result = $this->getPropertyAccessTrace($trace, '__get')) === null)
378
-				$result = $this->getPropertyAccessTrace($trace, '__set');
390
+			if(($result = $this->getPropertyAccessTrace($trace, '__get')) === null) {
391
+							$result = $this->getPropertyAccessTrace($trace, '__set');
392
+			}
393
+		}
394
+		if($result !== null && strpos($result['file'], ': eval()\'d code') !== false) {
395
+					return null;
379 396
 		}
380
-		if($result !== null && strpos($result['file'], ': eval()\'d code') !== false)
381
-			return null;
382 397
 
383 398
 		return $result;
384 399
 	}
@@ -395,10 +410,11 @@  discard block
 block discarded – undo
395 410
 			// try to mimic Exception::getTraceAsString()
396 411
 			foreach($trace as $line)
397 412
 			{
398
-				if(array_key_exists('function', $line))
399
-					$func = $line['function'] . '(' . implode(',', $line['params']) . ')';
400
-				else
401
-					$func = 'unknown';
413
+				if(array_key_exists('function', $line)) {
414
+									$func = $line['function'] . '(' . implode(',', $line['params']) . ')';
415
+				} else {
416
+									$func = 'unknown';
417
+				}
402 418
 
403 419
 				$txt .= '#' . $row . ' ' . $line['file'] . '(' . $line['line'] . '): ' . $func . "\n";
404 420
 				$row++;
@@ -415,10 +431,11 @@  discard block
 block discarded – undo
415 431
 		$result = null;
416 432
 		foreach($trace as $t)
417 433
 		{
418
-			if(isset($t['function']) && $t['function'] === $pattern)
419
-				$result = $t;
420
-			else
421
-				break;
434
+			if(isset($t['function']) && $t['function'] === $pattern) {
435
+							$result = $t;
436
+			} else {
437
+							break;
438
+			}
422 439
 		}
423 440
 		return $result;
424 441
 	}
@@ -435,9 +452,9 @@  discard block
 block discarded – undo
435 452
 			{
436 453
 				$line = htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", '    ', $lines[$i])));
437 454
 				$source .= "<div class=\"error\">" . $line . "</div>";
455
+			} else {
456
+							$source .= htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", '    ', $lines[$i])));
438 457
 			}
439
-			else
440
-				$source .= htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", '    ', $lines[$i])));
441 458
 		}
442 459
 		return $source;
443 460
 	}
@@ -456,8 +473,7 @@  discard block
 block discarded – undo
456 473
 			$class = $matches[0];
457 474
 			try {
458 475
 				$function = new \ReflectionClass($class);
459
-			}
460
-			catch (\Exception $e) {
476
+			} catch (\Exception $e) {
461 477
 				return null;
462 478
 			}
463 479
 			$classname = $function->getNamespaceName();
Please login to merge, or discard this patch.