Completed
Push — scrutinizer ( c2ef4a...84e9d0 )
by Fabio
22:07
created
framework/Collections/TPriorityMap.php 3 patches
Doc Comments   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,6 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
 	/**
116 116
 	 * @param boolean whether this list is read-only or not
117
+	 * @param boolean $value
117 118
 	 */
118 119
 	protected function setReadOnly($value)
119 120
 	{
@@ -131,6 +132,7 @@  discard block
 block discarded – undo
131 132
 	/**
132 133
 	 * This must be called internally or when instantiated.
133 134
 	 * @param numeric sets the default priority of inserted items without a specified priority
135
+	 * @param integer $value
134 136
 	 */
135 137
 	protected function setDefaultPriority($value)
136 138
 	{
@@ -148,6 +150,7 @@  discard block
 block discarded – undo
148 150
 	/**
149 151
 	 * This must be called internally or when instantiated.
150 152
 	 * @param integer The precision of numeric priorities.
153
+	 * @param integer $value
151 154
 	 */
152 155
 	protected function setPrecision($value)
153 156
 	{
@@ -270,6 +273,8 @@  discard block
 block discarded – undo
270 273
 	 * This method is exactly the same as {@link offsetGet}.
271 274
 	 * @param mixed the key
272 275
 	 * @param numeric|null the priority.  default: null, filled in with the default priority numeric.
276
+	 * @param string $key
277
+	 * @param integer $priority
273 278
 	 * @return numeric old priority of the item
274 279
 	 */
275 280
 	public function setPriorityAt($key,$priority=null)
@@ -338,7 +343,7 @@  discard block
 block discarded – undo
338 343
 	 * @param mixed key
339 344
 	 * @param mixed value
340 345
 	 * @param numeric|null priority, default: null, filled in with default priority
341
-	 * @return numeric priority at which the pair was added
346
+	 * @return string priority at which the pair was added
342 347
 	 * @throws TInvalidOperationException if the map is read-only
343 348
 	 */
344 349
 	public function add($key,$value,$priority=null)
@@ -467,6 +472,7 @@  discard block
 block discarded – undo
467 472
 	 * Combines the map elements which have a priority below the parameter value
468 473
 	 * @param numeric the cut-off priority.  All items of priority less than this are returned.
469 474
 	 * @param boolean whether or not the input cut-off priority is inclusive.  Default: false, not inclusive.
475
+	 * @param integer $priority
470 476
 	 * @return array the array of priorities keys with values of arrays of items that are below a specified priority.
471 477
 	 *  The priorities are sorted so important priorities, lower numerics, are first.
472 478
 	 */
@@ -487,6 +493,7 @@  discard block
 block discarded – undo
487 493
 	 * Combines the map elements which have a priority above the parameter value
488 494
 	 * @param numeric the cut-off priority.  All items of priority greater than this are returned.
489 495
 	 * @param boolean whether or not the input cut-off priority is inclusive.  Default: true, inclusive.
496
+	 * @param integer $priority
490 497
 	 * @return array the array of priorities keys with values of arrays of items that are above a specified priority.
491 498
 	 *  The priorities are sorted so important priorities, lower numerics, are first.
492 499
 	 */
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -60,31 +60,31 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * @var array internal data storage
62 62
 	 */
63
-	private $_d=array();
63
+	private $_d = array();
64 64
 	/**
65 65
 	 * @var boolean whether this list is read-only
66 66
 	 */
67
-	private $_r=false;
67
+	private $_r = false;
68 68
 	/**
69 69
 	 * @var boolean indicates if the _d is currently ordered.
70 70
 	 */
71
-	private $_o=false;
71
+	private $_o = false;
72 72
 	/**
73 73
 	 * @var array cached flattened internal data storage
74 74
 	 */
75
-	private $_fd=null;
75
+	private $_fd = null;
76 76
 	/**
77 77
 	 * @var integer number of items contain within the map
78 78
 	 */
79
-	private $_c=0;
79
+	private $_c = 0;
80 80
 	/**
81 81
 	 * @var numeric the default priority of items without specified priorities
82 82
 	 */
83
-	private $_dp=10;
83
+	private $_dp = 10;
84 84
 	/**
85 85
 	 * @var integer the precision of the numeric priorities within this priority list.
86 86
 	 */
87
-	private $_p=8;
87
+	private $_p = 8;
88 88
 
89 89
 	/**
90 90
 	 * Constructor.
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	 * @param integer the precision of the numeric priorities
96 96
 	 * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator.
97 97
 	 */
98
-	public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8)
98
+	public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8)
99 99
 	{
100
-		if($data!==null)
100
+		if ($data !== null)
101 101
 			$this->copyFrom($data);
102 102
 		$this->setReadOnly($readOnly);
103 103
 		$this->setPrecision($precision);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function setReadOnly($value)
119 119
 	{
120
-		$this->_r=TPropertyValue::ensureBoolean($value);
120
+		$this->_r = TPropertyValue::ensureBoolean($value);
121 121
 	}
122 122
 
123 123
 	/**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	protected function setDefaultPriority($value)
136 136
 	{
137
-		$this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p);
137
+		$this->_dp = (string) round(TPropertyValue::ensureFloat($value), $this->_p);
138 138
 	}
139 139
 
140 140
 	/**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	protected function setPrecision($value)
153 153
 	{
154
-		$this->_p=TPropertyValue::ensureInteger($value);
154
+		$this->_p = TPropertyValue::ensureInteger($value);
155 155
 	}
156 156
 
157 157
 	/**
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 	 * Orders the priority list internally.
170 170
 	 */
171 171
 	protected function sortPriorities() {
172
-		if(!$this->_o) {
172
+		if (!$this->_o) {
173 173
 			ksort($this->_d, SORT_NUMERIC);
174
-			$this->_o=true;
174
+			$this->_o = true;
175 175
 		}
176 176
 	}
177 177
 
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 	 * @return array array of items in the list in priority and index order
181 181
 	 */
182 182
 	protected function flattenPriorities() {
183
-		if(is_array($this->_fd))
183
+		if (is_array($this->_fd))
184 184
 			return $this->_fd;
185 185
 
186 186
 		$this->sortPriorities();
187 187
 		$this->_fd = array();
188
-		foreach($this->_d as $priority => $itemsatpriority)
188
+		foreach ($this->_d as $priority => $itemsatpriority)
189 189
 			$this->_fd = array_merge($this->_fd, $itemsatpriority);
190 190
 		return $this->_fd;
191 191
 	}
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
 	 * it will be set to the default {@link getDefaultPriority}
215 215
 	 * @return integer the number of items in the map at the specified priority
216 216
 	 */
217
-	public function getPriorityCount($priority=null)
217
+	public function getPriorityCount($priority = null)
218 218
 	{
219
-		if($priority===null)
220
-			$priority=$this->getDefaultPriority();
221
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
219
+		if ($priority === null)
220
+			$priority = $this->getDefaultPriority();
221
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
222 222
 
223
-		if(!isset($this->_d[$priority])||!is_array($this->_d[$priority]))
223
+		if (!isset($this->_d[$priority]) || !is_array($this->_d[$priority]))
224 224
 			return false;
225 225
 		return count($this->_d[$priority]);
226 226
 	}
@@ -252,16 +252,16 @@  discard block
 block discarded – undo
252 252
 	 * and numeric is a specific priority.  default: false, any priority.
253 253
 	 * @return mixed the element at the offset, null if no element is found at the offset
254 254
 	 */
255
-	public function itemAt($key,$priority=false)
255
+	public function itemAt($key, $priority = false)
256 256
 	{
257
-		if($priority===false){
258
-			$map=$this->flattenPriorities();
259
-			return isset($map[$key])?$map[$key]:null;
257
+		if ($priority === false) {
258
+			$map = $this->flattenPriorities();
259
+			return isset($map[$key]) ? $map[$key] : null;
260 260
 		} else {
261
-			if($priority===null)
262
-				$priority=$this->getDefaultPriority();
263
-			$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
264
-			return (isset($this->_d[$priority])&&isset($this->_d[$priority][$key]))?$this->_d[$priority][$key]:null;
261
+			if ($priority === null)
262
+				$priority = $this->getDefaultPriority();
263
+			$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
264
+			return (isset($this->_d[$priority]) && isset($this->_d[$priority][$key])) ? $this->_d[$priority][$key] : null;
265 265
 		}
266 266
 	}
267 267
 
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 	 * @param numeric|null the priority.  default: null, filled in with the default priority numeric.
273 273
 	 * @return numeric old priority of the item
274 274
 	 */
275
-	public function setPriorityAt($key,$priority=null)
275
+	public function setPriorityAt($key, $priority = null)
276 276
 	{
277
-		if($priority===null)
278
-			$priority=$this->getDefaultPriority();
279
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
280
-
281
-		$oldpriority=$this->priorityAt($key);
282
-		if($oldpriority!==false&&$oldpriority!=$priority) {
283
-			$value=$this->remove($key,$oldpriority);
284
-			$this->add($key,$value,$priority);
277
+		if ($priority === null)
278
+			$priority = $this->getDefaultPriority();
279
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
280
+
281
+		$oldpriority = $this->priorityAt($key);
282
+		if ($oldpriority !== false && $oldpriority != $priority) {
283
+			$value = $this->remove($key, $oldpriority);
284
+			$this->add($key, $value, $priority);
285 285
 		}
286 286
 		return $oldpriority;
287 287
 	}
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
 	 * @param numeric priority of the items to get.  Defaults to null, filled in with the default priority, if left blank.
292 292
 	 * @return array all items at priority in index order, null if there are no items at that priority
293 293
 	 */
294
-	public function itemsAtPriority($priority=null)
294
+	public function itemsAtPriority($priority = null)
295 295
 	{
296
-		if($priority===null)
297
-			$priority=$this->getDefaultPriority();
298
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
296
+		if ($priority === null)
297
+			$priority = $this->getDefaultPriority();
298
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
299 299
 
300
-		return isset($this->_d[$priority])?$this->_d[$priority]:null;
300
+		return isset($this->_d[$priority]) ? $this->_d[$priority] : null;
301 301
 	}
302 302
 
303 303
 	/**
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 	public function priorityOf($item)
309 309
 	{
310 310
 		$this->sortPriorities();
311
-		foreach($this->_d as $priority=>$items)
312
-			if(($index=array_search($item,$items,true))!==false)
311
+		foreach ($this->_d as $priority=>$items)
312
+			if (($index = array_search($item, $items, true)) !== false)
313 313
 				return $priority;
314 314
 		return false;
315 315
 	}
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 	public function priorityAt($key)
323 323
 	{
324 324
 		$this->sortPriorities();
325
-		foreach($this->_d as $priority=>$items)
326
-			if(array_key_exists($key,$items))
325
+		foreach ($this->_d as $priority=>$items)
326
+			if (array_key_exists($key, $items))
327 327
 				return $priority;
328 328
 		return false;
329 329
 	}
@@ -341,33 +341,33 @@  discard block
 block discarded – undo
341 341
 	 * @return numeric priority at which the pair was added
342 342
 	 * @throws TInvalidOperationException if the map is read-only
343 343
 	 */
344
-	public function add($key,$value,$priority=null)
344
+	public function add($key, $value, $priority = null)
345 345
 	{
346
-		if($priority===null)
347
-			$priority=$this->getDefaultPriority();
348
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
346
+		if ($priority === null)
347
+			$priority = $this->getDefaultPriority();
348
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
349 349
 
350
-		if(!$this->_r)
350
+		if (!$this->_r)
351 351
 		{
352
-			foreach($this->_d as $innerpriority=>$items)
353
-				if(array_key_exists($key,$items))
352
+			foreach ($this->_d as $innerpriority=>$items)
353
+				if (array_key_exists($key, $items))
354 354
 				{
355 355
 					unset($this->_d[$innerpriority][$key]);
356 356
 					$this->_c--;
357
-					if(count($this->_d[$innerpriority])===0)
357
+					if (count($this->_d[$innerpriority]) === 0)
358 358
 						unset($this->_d[$innerpriority]);
359 359
 				}
360
-			if(!isset($this->_d[$priority])) {
361
-				$this->_d[$priority]=array($key=>$value);
362
-				$this->_o=false;
360
+			if (!isset($this->_d[$priority])) {
361
+				$this->_d[$priority] = array($key=>$value);
362
+				$this->_o = false;
363 363
 			}
364 364
 			else
365
-				$this->_d[$priority][$key]=$value;
365
+				$this->_d[$priority][$key] = $value;
366 366
 			$this->_c++;
367
-			$this->_fd=null;
367
+			$this->_fd = null;
368 368
 		}
369 369
 		else
370
-			throw new TInvalidOperationException('map_readonly',get_class($this));
370
+			throw new TInvalidOperationException('map_readonly', get_class($this));
371 371
 		return $priority;
372 372
 	}
373 373
 
@@ -383,45 +383,45 @@  discard block
 block discarded – undo
383 383
 	 * @return mixed the removed value, null if no such key exists.
384 384
 	 * @throws TInvalidOperationException if the map is read-only
385 385
 	 */
386
-	public function remove($key,$priority=false)
386
+	public function remove($key, $priority = false)
387 387
 	{
388
-		if(!$this->_r)
388
+		if (!$this->_r)
389 389
 		{
390
-			if($priority===null)
391
-				$priority=$this->getDefaultPriority();
390
+			if ($priority === null)
391
+				$priority = $this->getDefaultPriority();
392 392
 
393
-			if($priority===false)
393
+			if ($priority === false)
394 394
 			{
395 395
 				$this->sortPriorities();
396
-				foreach($this->_d as $priority=>$items)
397
-					if(array_key_exists($key,$items))
396
+				foreach ($this->_d as $priority=>$items)
397
+					if (array_key_exists($key, $items))
398 398
 					{
399
-						$value=$this->_d[$priority][$key];
399
+						$value = $this->_d[$priority][$key];
400 400
 						unset($this->_d[$priority][$key]);
401 401
 						$this->_c--;
402
-						if(count($this->_d[$priority])===0)
402
+						if (count($this->_d[$priority]) === 0)
403 403
 						{
404 404
 							unset($this->_d[$priority]);
405
-							$this->_o=false;
405
+							$this->_o = false;
406 406
 						}
407
-						$this->_fd=null;
407
+						$this->_fd = null;
408 408
 						return $value;
409 409
 					}
410 410
 				return null;
411 411
 			}
412 412
 			else
413 413
 			{
414
-				$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
415
-				if(isset($this->_d[$priority])&&(isset($this->_d[$priority][$key])||array_key_exists($key,$this->_d[$priority])))
414
+				$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
415
+				if (isset($this->_d[$priority]) && (isset($this->_d[$priority][$key]) || array_key_exists($key, $this->_d[$priority])))
416 416
 				{
417
-					$value=$this->_d[$priority][$key];
417
+					$value = $this->_d[$priority][$key];
418 418
 					unset($this->_d[$priority][$key]);
419 419
 					$this->_c--;
420
-					if(count($this->_d[$priority])===0) {
420
+					if (count($this->_d[$priority]) === 0) {
421 421
 						unset($this->_d[$priority]);
422
-						$this->_o=false;
422
+						$this->_o = false;
423 423
 					}
424
-					$this->_fd=null;
424
+					$this->_fd = null;
425 425
 					return $value;
426 426
 				}
427 427
 				else
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 			}
430 430
 		}
431 431
 		else
432
-			throw new TInvalidOperationException('map_readonly',get_class($this));
432
+			throw new TInvalidOperationException('map_readonly', get_class($this));
433 433
 	}
434 434
 
435 435
 	/**
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	 */
438 438
 	public function clear()
439 439
 	{
440
-		foreach($this->_d as $priority=>$items)
441
-			foreach(array_keys($items) as $key)
440
+		foreach ($this->_d as $priority=>$items)
441
+			foreach (array_keys($items) as $key)
442 442
 				$this->remove($key);
443 443
 	}
444 444
 
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
 	 */
449 449
 	public function contains($key)
450 450
 	{
451
-		$map=$this->flattenPriorities();
452
-		return isset($map[$key])||array_key_exists($key,$map);
451
+		$map = $this->flattenPriorities();
452
+		return isset($map[$key]) || array_key_exists($key, $map);
453 453
 	}
454 454
 
455 455
 	/**
@@ -470,15 +470,15 @@  discard block
 block discarded – undo
470 470
 	 * @return array the array of priorities keys with values of arrays of items that are below a specified priority.
471 471
 	 *  The priorities are sorted so important priorities, lower numerics, are first.
472 472
 	 */
473
-	public function toArrayBelowPriority($priority,$inclusive=false)
473
+	public function toArrayBelowPriority($priority, $inclusive = false)
474 474
 	{
475 475
 		$this->sortPriorities();
476
-		$items=array();
477
-		foreach($this->_d as $itemspriority=>$itemsatpriority)
476
+		$items = array();
477
+		foreach ($this->_d as $itemspriority=>$itemsatpriority)
478 478
 		{
479
-			if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority)
479
+			if ((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority)
480 480
 				break;
481
-			$items=array_merge($items,$itemsatpriority);
481
+			$items = array_merge($items, $itemsatpriority);
482 482
 		}
483 483
 		return $items;
484 484
 	}
@@ -490,15 +490,15 @@  discard block
 block discarded – undo
490 490
 	 * @return array the array of priorities keys with values of arrays of items that are above a specified priority.
491 491
 	 *  The priorities are sorted so important priorities, lower numerics, are first.
492 492
 	 */
493
-	public function toArrayAbovePriority($priority,$inclusive=true)
493
+	public function toArrayAbovePriority($priority, $inclusive = true)
494 494
 	{
495 495
 		$this->sortPriorities();
496
-		$items=array();
497
-		foreach($this->_d as $itemspriority=>$itemsatpriority)
496
+		$items = array();
497
+		foreach ($this->_d as $itemspriority=>$itemsatpriority)
498 498
 		{
499
-			if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority)
499
+			if ((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority)
500 500
 				continue;
501
-			$items=array_merge($items,$itemsatpriority);
501
+			$items = array_merge($items, $itemsatpriority);
502 502
 		}
503 503
 		return $items;
504 504
 	}
@@ -512,24 +512,24 @@  discard block
 block discarded – undo
512 512
 	 */
513 513
 	public function copyFrom($data)
514 514
 	{
515
-		if($data instanceof TPriorityMap)
515
+		if ($data instanceof TPriorityMap)
516 516
 		{
517
-			if($this->getCount()>0)
517
+			if ($this->getCount() > 0)
518 518
 				$this->clear();
519
-			foreach($data->getPriorities() as $priority) {
520
-				foreach($data->itemsAtPriority($priority) as $key => $value) {
521
-					$this->add($key,$value,$priority);
519
+			foreach ($data->getPriorities() as $priority) {
520
+				foreach ($data->itemsAtPriority($priority) as $key => $value) {
521
+					$this->add($key, $value, $priority);
522 522
 				}
523 523
 			}
524 524
 		}
525
-		else if(is_array($data)||$data instanceof Traversable)
525
+		else if (is_array($data) || $data instanceof Traversable)
526 526
 		{
527
-			if($this->getCount()>0)
527
+			if ($this->getCount() > 0)
528 528
 				$this->clear();
529
-			foreach($data as $key=>$value)
530
-				$this->add($key,$value);
529
+			foreach ($data as $key=>$value)
530
+				$this->add($key, $value);
531 531
 		}
532
-		else if($data!==null)
532
+		else if ($data !== null)
533 533
 			throw new TInvalidDataTypeException('map_data_not_iterable');
534 534
 	}
535 535
 
@@ -542,20 +542,20 @@  discard block
 block discarded – undo
542 542
 	 */
543 543
 	public function mergeWith($data)
544 544
 	{
545
-		if($data instanceof TPriorityMap)
545
+		if ($data instanceof TPriorityMap)
546 546
 		{
547
-			foreach($data->getPriorities() as $priority)
547
+			foreach ($data->getPriorities() as $priority)
548 548
 			{
549
-				foreach($data->itemsAtPriority($priority) as $key => $value)
550
-					$this->add($key,$value,$priority);
549
+				foreach ($data->itemsAtPriority($priority) as $key => $value)
550
+					$this->add($key, $value, $priority);
551 551
 			}
552 552
 		}
553
-		else if(is_array($data)||$data instanceof Traversable)
553
+		else if (is_array($data) || $data instanceof Traversable)
554 554
 		{
555
-			foreach($data as $key=>$value)
556
-				$this->add($key,$value);
555
+			foreach ($data as $key=>$value)
556
+				$this->add($key, $value);
557 557
 		}
558
-		else if($data!==null)
558
+		else if ($data !== null)
559 559
 			throw new TInvalidDataTypeException('map_data_not_iterable');
560 560
 	}
561 561
 
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
 	 * @param integer the offset to set element
588 588
 	 * @param mixed the element value
589 589
 	 */
590
-	public function offsetSet($offset,$item)
590
+	public function offsetSet($offset, $item)
591 591
 	{
592
-		$this->add($offset,$item);
592
+		$this->add($offset, $item);
593 593
 	}
594 594
 
595 595
 	/**
Please login to merge, or discard this patch.
Braces   +84 added lines, -64 removed lines patch added patch discarded remove patch
@@ -97,8 +97,9 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8)
99 99
 	{
100
-		if($data!==null)
101
-			$this->copyFrom($data);
100
+		if($data!==null) {
101
+					$this->copyFrom($data);
102
+		}
102 103
 		$this->setReadOnly($readOnly);
103 104
 		$this->setPrecision($precision);
104 105
 		$this->setDefaultPriority($defaultPriority);
@@ -180,13 +181,15 @@  discard block
 block discarded – undo
180 181
 	 * @return array array of items in the list in priority and index order
181 182
 	 */
182 183
 	protected function flattenPriorities() {
183
-		if(is_array($this->_fd))
184
-			return $this->_fd;
184
+		if(is_array($this->_fd)) {
185
+					return $this->_fd;
186
+		}
185 187
 
186 188
 		$this->sortPriorities();
187 189
 		$this->_fd = array();
188
-		foreach($this->_d as $priority => $itemsatpriority)
189
-			$this->_fd = array_merge($this->_fd, $itemsatpriority);
190
+		foreach($this->_d as $priority => $itemsatpriority) {
191
+					$this->_fd = array_merge($this->_fd, $itemsatpriority);
192
+		}
190 193
 		return $this->_fd;
191 194
 	}
192 195
 
@@ -216,12 +219,14 @@  discard block
 block discarded – undo
216 219
 	 */
217 220
 	public function getPriorityCount($priority=null)
218 221
 	{
219
-		if($priority===null)
220
-			$priority=$this->getDefaultPriority();
222
+		if($priority===null) {
223
+					$priority=$this->getDefaultPriority();
224
+		}
221 225
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
222 226
 
223
-		if(!isset($this->_d[$priority])||!is_array($this->_d[$priority]))
224
-			return false;
227
+		if(!isset($this->_d[$priority])||!is_array($this->_d[$priority])) {
228
+					return false;
229
+		}
225 230
 		return count($this->_d[$priority]);
226 231
 	}
227 232
 
@@ -258,8 +263,9 @@  discard block
 block discarded – undo
258 263
 			$map=$this->flattenPriorities();
259 264
 			return isset($map[$key])?$map[$key]:null;
260 265
 		} else {
261
-			if($priority===null)
262
-				$priority=$this->getDefaultPriority();
266
+			if($priority===null) {
267
+							$priority=$this->getDefaultPriority();
268
+			}
263 269
 			$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
264 270
 			return (isset($this->_d[$priority])&&isset($this->_d[$priority][$key]))?$this->_d[$priority][$key]:null;
265 271
 		}
@@ -274,8 +280,9 @@  discard block
 block discarded – undo
274 280
 	 */
275 281
 	public function setPriorityAt($key,$priority=null)
276 282
 	{
277
-		if($priority===null)
278
-			$priority=$this->getDefaultPriority();
283
+		if($priority===null) {
284
+					$priority=$this->getDefaultPriority();
285
+		}
279 286
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
280 287
 
281 288
 		$oldpriority=$this->priorityAt($key);
@@ -293,8 +300,9 @@  discard block
 block discarded – undo
293 300
 	 */
294 301
 	public function itemsAtPriority($priority=null)
295 302
 	{
296
-		if($priority===null)
297
-			$priority=$this->getDefaultPriority();
303
+		if($priority===null) {
304
+					$priority=$this->getDefaultPriority();
305
+		}
298 306
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
299 307
 
300 308
 		return isset($this->_d[$priority])?$this->_d[$priority]:null;
@@ -308,9 +316,10 @@  discard block
 block discarded – undo
308 316
 	public function priorityOf($item)
309 317
 	{
310 318
 		$this->sortPriorities();
311
-		foreach($this->_d as $priority=>$items)
312
-			if(($index=array_search($item,$items,true))!==false)
319
+		foreach($this->_d as $priority=>$items) {
320
+					if(($index=array_search($item,$items,true))!==false)
313 321
 				return $priority;
322
+		}
314 323
 		return false;
315 324
 	}
316 325
 
@@ -322,9 +331,10 @@  discard block
 block discarded – undo
322 331
 	public function priorityAt($key)
323 332
 	{
324 333
 		$this->sortPriorities();
325
-		foreach($this->_d as $priority=>$items)
326
-			if(array_key_exists($key,$items))
334
+		foreach($this->_d as $priority=>$items) {
335
+					if(array_key_exists($key,$items))
327 336
 				return $priority;
337
+		}
328 338
 		return false;
329 339
 	}
330 340
 
@@ -343,31 +353,34 @@  discard block
 block discarded – undo
343 353
 	 */
344 354
 	public function add($key,$value,$priority=null)
345 355
 	{
346
-		if($priority===null)
347
-			$priority=$this->getDefaultPriority();
356
+		if($priority===null) {
357
+					$priority=$this->getDefaultPriority();
358
+		}
348 359
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
349 360
 
350 361
 		if(!$this->_r)
351 362
 		{
352
-			foreach($this->_d as $innerpriority=>$items)
353
-				if(array_key_exists($key,$items))
363
+			foreach($this->_d as $innerpriority=>$items) {
364
+							if(array_key_exists($key,$items))
354 365
 				{
355 366
 					unset($this->_d[$innerpriority][$key]);
367
+			}
356 368
 					$this->_c--;
357
-					if(count($this->_d[$innerpriority])===0)
358
-						unset($this->_d[$innerpriority]);
369
+					if(count($this->_d[$innerpriority])===0) {
370
+											unset($this->_d[$innerpriority]);
371
+					}
359 372
 				}
360 373
 			if(!isset($this->_d[$priority])) {
361 374
 				$this->_d[$priority]=array($key=>$value);
362 375
 				$this->_o=false;
376
+			} else {
377
+							$this->_d[$priority][$key]=$value;
363 378
 			}
364
-			else
365
-				$this->_d[$priority][$key]=$value;
366 379
 			$this->_c++;
367 380
 			$this->_fd=null;
381
+		} else {
382
+					throw new TInvalidOperationException('map_readonly',get_class($this));
368 383
 		}
369
-		else
370
-			throw new TInvalidOperationException('map_readonly',get_class($this));
371 384
 		return $priority;
372 385
 	}
373 386
 
@@ -387,16 +400,18 @@  discard block
 block discarded – undo
387 400
 	{
388 401
 		if(!$this->_r)
389 402
 		{
390
-			if($priority===null)
391
-				$priority=$this->getDefaultPriority();
403
+			if($priority===null) {
404
+							$priority=$this->getDefaultPriority();
405
+			}
392 406
 
393 407
 			if($priority===false)
394 408
 			{
395 409
 				$this->sortPriorities();
396
-				foreach($this->_d as $priority=>$items)
397
-					if(array_key_exists($key,$items))
410
+				foreach($this->_d as $priority=>$items) {
411
+									if(array_key_exists($key,$items))
398 412
 					{
399 413
 						$value=$this->_d[$priority][$key];
414
+				}
400 415
 						unset($this->_d[$priority][$key]);
401 416
 						$this->_c--;
402 417
 						if(count($this->_d[$priority])===0)
@@ -408,8 +423,7 @@  discard block
 block discarded – undo
408 423
 						return $value;
409 424
 					}
410 425
 				return null;
411
-			}
412
-			else
426
+			} else
413 427
 			{
414 428
 				$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
415 429
 				if(isset($this->_d[$priority])&&(isset($this->_d[$priority][$key])||array_key_exists($key,$this->_d[$priority])))
@@ -423,13 +437,13 @@  discard block
 block discarded – undo
423 437
 					}
424 438
 					$this->_fd=null;
425 439
 					return $value;
440
+				} else {
441
+									return null;
426 442
 				}
427
-				else
428
-					return null;
429 443
 			}
444
+		} else {
445
+					throw new TInvalidOperationException('map_readonly',get_class($this));
430 446
 		}
431
-		else
432
-			throw new TInvalidOperationException('map_readonly',get_class($this));
433 447
 	}
434 448
 
435 449
 	/**
@@ -437,9 +451,10 @@  discard block
 block discarded – undo
437 451
 	 */
438 452
 	public function clear()
439 453
 	{
440
-		foreach($this->_d as $priority=>$items)
441
-			foreach(array_keys($items) as $key)
454
+		foreach($this->_d as $priority=>$items) {
455
+					foreach(array_keys($items) as $key)
442 456
 				$this->remove($key);
457
+		}
443 458
 	}
444 459
 
445 460
 	/**
@@ -476,8 +491,9 @@  discard block
 block discarded – undo
476 491
 		$items=array();
477 492
 		foreach($this->_d as $itemspriority=>$itemsatpriority)
478 493
 		{
479
-			if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority)
480
-				break;
494
+			if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) {
495
+							break;
496
+			}
481 497
 			$items=array_merge($items,$itemsatpriority);
482 498
 		}
483 499
 		return $items;
@@ -496,8 +512,9 @@  discard block
 block discarded – undo
496 512
 		$items=array();
497 513
 		foreach($this->_d as $itemspriority=>$itemsatpriority)
498 514
 		{
499
-			if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority)
500
-				continue;
515
+			if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) {
516
+							continue;
517
+			}
501 518
 			$items=array_merge($items,$itemsatpriority);
502 519
 		}
503 520
 		return $items;
@@ -514,23 +531,25 @@  discard block
 block discarded – undo
514 531
 	{
515 532
 		if($data instanceof TPriorityMap)
516 533
 		{
517
-			if($this->getCount()>0)
518
-				$this->clear();
534
+			if($this->getCount()>0) {
535
+							$this->clear();
536
+			}
519 537
 			foreach($data->getPriorities() as $priority) {
520 538
 				foreach($data->itemsAtPriority($priority) as $key => $value) {
521 539
 					$this->add($key,$value,$priority);
522 540
 				}
523 541
 			}
524
-		}
525
-		else if(is_array($data)||$data instanceof Traversable)
542
+		} else if(is_array($data)||$data instanceof Traversable)
526 543
 		{
527
-			if($this->getCount()>0)
528
-				$this->clear();
529
-			foreach($data as $key=>$value)
530
-				$this->add($key,$value);
544
+			if($this->getCount()>0) {
545
+							$this->clear();
546
+			}
547
+			foreach($data as $key=>$value) {
548
+							$this->add($key,$value);
549
+			}
550
+		} else if($data!==null) {
551
+					throw new TInvalidDataTypeException('map_data_not_iterable');
531 552
 		}
532
-		else if($data!==null)
533
-			throw new TInvalidDataTypeException('map_data_not_iterable');
534 553
 	}
535 554
 
536 555
 	/**
@@ -546,17 +565,18 @@  discard block
 block discarded – undo
546 565
 		{
547 566
 			foreach($data->getPriorities() as $priority)
548 567
 			{
549
-				foreach($data->itemsAtPriority($priority) as $key => $value)
550
-					$this->add($key,$value,$priority);
568
+				foreach($data->itemsAtPriority($priority) as $key => $value) {
569
+									$this->add($key,$value,$priority);
570
+				}
551 571
 			}
552
-		}
553
-		else if(is_array($data)||$data instanceof Traversable)
572
+		} else if(is_array($data)||$data instanceof Traversable)
554 573
 		{
555
-			foreach($data as $key=>$value)
556
-				$this->add($key,$value);
574
+			foreach($data as $key=>$value) {
575
+							$this->add($key,$value);
576
+			}
577
+		} else if($data!==null) {
578
+					throw new TInvalidDataTypeException('map_data_not_iterable');
557 579
 		}
558
-		else if($data!==null)
559
-			throw new TInvalidDataTypeException('map_data_not_iterable');
560 580
 	}
561 581
 
562 582
 	/**
Please login to merge, or discard this patch.
framework/Collections/TQueue.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -49,6 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * Constructor.
50 50
 	 * Initializes the queue with an array or an iterable object.
51 51
 	 * @param array|Iterator the intial data. Default is null, meaning no initialization.
52
+	 * @param integer[] $data
52 53
 	 * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator.
53 54
 	 */
54 55
 	public function __construct($data=null)
@@ -97,6 +98,7 @@  discard block
 block discarded – undo
97 98
 
98 99
 	/**
99 100
 	 * @param mixed the item
101
+	 * @param integer $item
100 102
 	 * @return boolean whether the queue contains the item
101 103
 	 */
102 104
 	public function contains($item)
@@ -137,6 +139,7 @@  discard block
 block discarded – undo
137 139
 	/**
138 140
 	 * Adds an object to the end of the queue.
139 141
 	 * @param mixed the item to be appended into the queue
142
+	 * @param integer $item
140 143
 	 */
141 144
 	public function enqueue($item)
142 145
 	{
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
  * @package System.Collections
33 33
  * @since 3.1
34 34
  */
35
-class TQueue extends TComponent implements IteratorAggregate,Countable
35
+class TQueue extends TComponent implements IteratorAggregate, Countable
36 36
 {
37 37
 	/**
38 38
 	 * internal data storage
39 39
 	 * @var array
40 40
 	 */
41
-	private $_d=array();
41
+	private $_d = array();
42 42
 	/**
43 43
 	 * number of items
44 44
 	 * @var integer
45 45
 	 */
46
-	private $_c=0;
46
+	private $_c = 0;
47 47
 
48 48
 	/**
49 49
 	 * Constructor.
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 	 * @param array|Iterator the intial data. Default is null, meaning no initialization.
52 52
 	 * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator.
53 53
 	 */
54
-	public function __construct($data=null)
54
+	public function __construct($data = null)
55 55
 	{
56
-		if($data!==null)
56
+		if ($data !== null)
57 57
 			$this->copyFrom($data);
58 58
 	}
59 59
 
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function copyFrom($data)
75 75
 	{
76
-		if(is_array($data) || ($data instanceof Traversable))
76
+		if (is_array($data) || ($data instanceof Traversable))
77 77
 		{
78 78
 			$this->clear();
79
-			foreach($data as $item)
79
+			foreach ($data as $item)
80 80
 			{
81
-				$this->_d[]=$item;
81
+				$this->_d[] = $item;
82 82
 				++$this->_c;
83 83
 			}
84 84
 		}
85
-		else if($data!==null)
85
+		else if ($data !== null)
86 86
 			throw new TInvalidDataTypeException('queue_data_not_iterable');
87 87
 	}
88 88
 
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function clear()
93 93
 	{
94
-		$this->_c=0;
95
-		$this->_d=array();
94
+		$this->_c = 0;
95
+		$this->_d = array();
96 96
 	}
97 97
 
98 98
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function contains($item)
103 103
 	{
104
-		return array_search($item,$this->_d,true)!==false;
104
+		return array_search($item, $this->_d, true) !== false;
105 105
 	}
106 106
 
107 107
 	/**
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function peek()
114 114
 	{
115
-		if($this->_c===0)
115
+		if ($this->_c === 0)
116 116
 			throw new TInvalidOperationException('queue_empty');
117 117
 		else
118 118
 			return $this->_d[0];
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function dequeue()
127 127
 	{
128
-		if($this->_c===0)
128
+		if ($this->_c === 0)
129 129
 			throw new TInvalidOperationException('queue_empty');
130 130
 		else
131 131
 		{
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public function getIterator()
153 153
 	{
154
-		return new ArrayIterator( $this->_d );
154
+		return new ArrayIterator($this->_d);
155 155
 	}
156 156
 
157 157
 	/**
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	public function __construct(&$data)
209 209
 	{
210
-		$this->_d=&$data;
211
-		$this->_i=0;
212
-		$this->_c=count($this->_d);
210
+		$this->_d = &$data;
211
+		$this->_i = 0;
212
+		$this->_c = count($this->_d);
213 213
 	}
214 214
 
215 215
 	/**
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 */
219 219
 	public function rewind()
220 220
 	{
221
-		$this->_i=0;
221
+		$this->_i = 0;
222 222
 	}
223 223
 
224 224
 	/**
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 */
258 258
 	public function valid()
259 259
 	{
260
-		return $this->_i<$this->_c;
260
+		return $this->_i < $this->_c;
261 261
 	}
262 262
 }
263 263
 
Please login to merge, or discard this patch.
Braces   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function __construct($data=null)
55 55
 	{
56
-		if($data!==null)
57
-			$this->copyFrom($data);
56
+		if($data!==null) {
57
+					$this->copyFrom($data);
58
+		}
58 59
 	}
59 60
 
60 61
 	/**
@@ -81,9 +82,9 @@  discard block
 block discarded – undo
81 82
 				$this->_d[]=$item;
82 83
 				++$this->_c;
83 84
 			}
85
+		} else if($data!==null) {
86
+					throw new TInvalidDataTypeException('queue_data_not_iterable');
84 87
 		}
85
-		else if($data!==null)
86
-			throw new TInvalidDataTypeException('queue_data_not_iterable');
87 88
 	}
88 89
 
89 90
 	/**
@@ -112,10 +113,11 @@  discard block
 block discarded – undo
112 113
 	 */
113 114
 	public function peek()
114 115
 	{
115
-		if($this->_c===0)
116
-			throw new TInvalidOperationException('queue_empty');
117
-		else
118
-			return $this->_d[0];
116
+		if($this->_c===0) {
117
+					throw new TInvalidOperationException('queue_empty');
118
+		} else {
119
+					return $this->_d[0];
120
+		}
119 121
 	}
120 122
 
121 123
 	/**
@@ -125,9 +127,9 @@  discard block
 block discarded – undo
125 127
 	 */
126 128
 	public function dequeue()
127 129
 	{
128
-		if($this->_c===0)
129
-			throw new TInvalidOperationException('queue_empty');
130
-		else
130
+		if($this->_c===0) {
131
+					throw new TInvalidOperationException('queue_empty');
132
+		} else
131 133
 		{
132 134
 			--$this->_c;
133 135
 			return array_shift($this->_d);
Please login to merge, or discard this patch.
framework/Collections/TStack.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -46,6 +46,7 @@
 block discarded – undo
46 46
 	 * Constructor.
47 47
 	 * Initializes the stack with an array or an iterable object.
48 48
 	 * @param array|Iterator the initial data. Default is null, meaning no initialization.
49
+	 * @param integer[] $data
49 50
 	 * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator.
50 51
 	 */
51 52
 	public function __construct($data=null)
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TStack, TStackIterator classes
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Collections
10
- */
3
+	 * TStack, TStackIterator classes
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Collections
10
+	 */
11 11
 
12 12
 /**
13 13
  * TStack class
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
  * @package System.Collections
30 30
  * @since 3.0
31 31
  */
32
-class TStack extends TComponent implements IteratorAggregate,Countable
32
+class TStack extends TComponent implements IteratorAggregate, Countable
33 33
 {
34 34
 	/**
35 35
 	 * internal data storage
36 36
 	 * @var array
37 37
 	 */
38
-	private $_d=array();
38
+	private $_d = array();
39 39
 	/**
40 40
 	 * number of items
41 41
 	 * @var integer
42 42
 	 */
43
-	private $_c=0;
43
+	private $_c = 0;
44 44
 
45 45
 	/**
46 46
 	 * Constructor.
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 * @param array|Iterator the initial data. Default is null, meaning no initialization.
49 49
 	 * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator.
50 50
 	 */
51
-	public function __construct($data=null)
51
+	public function __construct($data = null)
52 52
 	{
53
-		if($data!==null)
53
+		if ($data !== null)
54 54
 			$this->copyFrom($data);
55 55
 	}
56 56
 
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function copyFrom($data)
72 72
 	{
73
-		if(is_array($data) || ($data instanceof Traversable))
73
+		if (is_array($data) || ($data instanceof Traversable))
74 74
 		{
75 75
 			$this->clear();
76
-			foreach($data as $item)
76
+			foreach ($data as $item)
77 77
 			{
78
-				$this->_d[]=$item;
78
+				$this->_d[] = $item;
79 79
 				++$this->_c;
80 80
 			}
81 81
 		}
82
-		else if($data!==null)
82
+		else if ($data !== null)
83 83
 			throw new TInvalidDataTypeException('stack_data_not_iterable');
84 84
 	}
85 85
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function clear()
90 90
 	{
91
-		$this->_c=0;
92
-		$this->_d=array();
91
+		$this->_c = 0;
92
+		$this->_d = array();
93 93
 	}
94 94
 
95 95
 	/**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public function contains($item)
100 100
 	{
101
-		return array_search($item,$this->_d,true)!==false;
101
+		return array_search($item, $this->_d, true) !== false;
102 102
 	}
103 103
 
104 104
 	/**
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function peek()
111 111
 	{
112
-		if($this->_c===0)
112
+		if ($this->_c === 0)
113 113
 			throw new TInvalidOperationException('stack_empty');
114 114
 		else
115
-			return $this->_d[$this->_c-1];
115
+			return $this->_d[$this->_c - 1];
116 116
 	}
117 117
 
118 118
 	/**
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function pop()
124 124
 	{
125
-		if($this->_c===0)
125
+		if ($this->_c === 0)
126 126
 			throw new TInvalidOperationException('stack_empty');
127 127
 		else
128 128
 		{
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function getIterator()
150 150
 	{
151
-		return new ArrayIterator( $this->_d );
151
+		return new ArrayIterator($this->_d);
152 152
 	}
153 153
 
154 154
 	/**
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	public function __construct(&$data)
206 206
 	{
207
-		$this->_d=&$data;
208
-		$this->_i=0;
209
-		$this->_c=count($this->_d);
207
+		$this->_d = &$data;
208
+		$this->_i = 0;
209
+		$this->_c = count($this->_d);
210 210
 	}
211 211
 
212 212
 	/**
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function rewind()
217 217
 	{
218
-		$this->_i=0;
218
+		$this->_i = 0;
219 219
 	}
220 220
 
221 221
 	/**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public function valid()
256 256
 	{
257
-		return $this->_i<$this->_c;
257
+		return $this->_i < $this->_c;
258 258
 	}
259 259
 }
260 260
 
Please login to merge, or discard this patch.
Braces   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,8 +50,9 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function __construct($data=null)
52 52
 	{
53
-		if($data!==null)
54
-			$this->copyFrom($data);
53
+		if($data!==null) {
54
+					$this->copyFrom($data);
55
+		}
55 56
 	}
56 57
 
57 58
 	/**
@@ -78,9 +79,9 @@  discard block
 block discarded – undo
78 79
 				$this->_d[]=$item;
79 80
 				++$this->_c;
80 81
 			}
82
+		} else if($data!==null) {
83
+					throw new TInvalidDataTypeException('stack_data_not_iterable');
81 84
 		}
82
-		else if($data!==null)
83
-			throw new TInvalidDataTypeException('stack_data_not_iterable');
84 85
 	}
85 86
 
86 87
 	/**
@@ -109,10 +110,11 @@  discard block
 block discarded – undo
109 110
 	 */
110 111
 	public function peek()
111 112
 	{
112
-		if($this->_c===0)
113
-			throw new TInvalidOperationException('stack_empty');
114
-		else
115
-			return $this->_d[$this->_c-1];
113
+		if($this->_c===0) {
114
+					throw new TInvalidOperationException('stack_empty');
115
+		} else {
116
+					return $this->_d[$this->_c-1];
117
+		}
116 118
 	}
117 119
 
118 120
 	/**
@@ -122,9 +124,9 @@  discard block
 block discarded – undo
122 124
 	 */
123 125
 	public function pop()
124 126
 	{
125
-		if($this->_c===0)
126
-			throw new TInvalidOperationException('stack_empty');
127
-		else
127
+		if($this->_c===0) {
128
+					throw new TInvalidOperationException('stack_empty');
129
+		} else
128 130
 		{
129 131
 			--$this->_c;
130 132
 			return array_pop($this->_d);
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordHasManyAssociation.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -208,6 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @param string active record class name.
209 209
 	 * @param array row data
210 210
 	 * @param array foreign key column names
211
+	 * @param string $type
211 212
 	 * @return TActiveRecord
212 213
 	 */
213 214
 	protected function createFkObject($type,$row,$foreignKeys)
@@ -227,6 +228,7 @@  discard block
 block discarded – undo
227 228
 	 * @param TTableInfo association table info
228 229
 	 * @param array field names
229 230
 	 * @param array field values
231
+	 * @param TActiveRecordCriteria $criteria
230 232
 	 */
231 233
 	public function createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys)
232 234
 	{
@@ -341,6 +343,10 @@  discard block
 block discarded – undo
341 343
 		return $this->getCommandBuilder()->onExecuteCommand($command, $command->execute()) > 0;
342 344
 	}
343 345
 
346
+	/**
347
+	 * @param TActiveRecord $obj
348
+	 * @param TDbCommandBuilder $builder
349
+	 */
344 350
 	private function updateAssociationTable($obj,$fkObjects, $builder)
345 351
 	{
346 352
 		$source = $this->getSourceRecordValues($obj);
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -90,10 +90,10 @@
 block discarded – undo
90 90
 	private $_association_columns=array();
91 91
 
92 92
 	/**
93
-	* Get the foreign key index values from the results and make calls to the
94
-	* database to find the corresponding foreign objects using association table.
95
-	* @param array original results.
96
-	*/
93
+	 * Get the foreign key index values from the results and make calls to the
94
+	 * database to find the corresponding foreign objects using association table.
95
+	 * @param array original results.
96
+	 */
97 97
 	protected function collectForeignObjects(&$results)
98 98
 	{
99 99
 		list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys();
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	private $_association;
88 88
 	private $_sourceTable;
89 89
 	private $_foreignTable;
90
-	private $_association_columns=array();
90
+	private $_association_columns = array();
91 91
 
92 92
 	/**
93 93
 	* Get the foreign key index values from the results and make calls to the
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys();
100 100
 		$properties = array_values($sourceKeys);
101 101
 		$indexValues = $this->getIndexValues($properties, $results);
102
-		$this->fetchForeignObjects($results, $foreignKeys,$indexValues,$sourceKeys);
102
+		$this->fetchForeignObjects($results, $foreignKeys, $indexValues, $sourceKeys);
103 103
 	}
104 104
 
105 105
 	/**
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	protected function getAssociationTable()
121 121
 	{
122
-		if($this->_association===null)
122
+		if ($this->_association === null)
123 123
 		{
124 124
 			$gateway = $this->getSourceRecord()->getRecordGateway();
125 125
 			$conn = $this->getSourceRecord()->getDbConnection();
126 126
 			//table name may include the fk column name separated with a dot.
127 127
 			$table = explode('.', $this->getContext()->getAssociationTable());
128
-			if(count($table)>1)
128
+			if (count($table) > 1)
129 129
 			{
130 130
 				$columns = preg_replace('/^\((.*)\)/', '\1', $table[1]);
131
-				$this->_association_columns = preg_split('/\s*[, ]\*/',$columns);
131
+				$this->_association_columns = preg_split('/\s*[, ]\*/', $columns);
132 132
 			}
133 133
 			$this->_association = $gateway->getTableInfo($conn, $table[0]);
134 134
 		}
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	protected function getSourceTable()
142 142
 	{
143
-		if($this->_sourceTable===null)
143
+		if ($this->_sourceTable === null)
144 144
 		{
145 145
 			$gateway = $this->getSourceRecord()->getRecordGateway();
146 146
 			$this->_sourceTable = $gateway->getRecordTableInfo($this->getSourceRecord());
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	protected function getForeignTable()
155 155
 	{
156
-		if($this->_foreignTable===null)
156
+		if ($this->_foreignTable === null)
157 157
 		{
158 158
 			$gateway = $this->getSourceRecord()->getRecordGateway();
159 159
 			$fkObject = $this->getContext()->getForeignRecordFinder();
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
 	 * @param array field names
186 186
 	 * @param array foreign key index values.
187 187
 	 */
188
-	protected function fetchForeignObjects(&$results,$foreignKeys,$indexValues,$sourceKeys)
188
+	protected function fetchForeignObjects(&$results, $foreignKeys, $indexValues, $sourceKeys)
189 189
 	{
190 190
 		$criteria = $this->getCriteria();
191 191
 		$finder = $this->getContext()->getForeignRecordFinder();
192 192
 		$type = get_class($finder);
193
-		$command = $this->createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys);
193
+		$command = $this->createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys);
194 194
 		$srcProps = array_keys($sourceKeys);
195
-		$collections=array();
196
-		foreach($this->getCommandBuilder()->onExecuteCommand($command, $command->query()) as $row)
195
+		$collections = array();
196
+		foreach ($this->getCommandBuilder()->onExecuteCommand($command, $command->query()) as $row)
197 197
 		{
198 198
 			$hash = $this->getObjectHash($row, $srcProps);
199
-			foreach($srcProps as $column)
199
+			foreach ($srcProps as $column)
200 200
 				unset($row[$column]);
201
-			$obj = $this->createFkObject($type,$row,$foreignKeys);
201
+			$obj = $this->createFkObject($type, $row, $foreignKeys);
202 202
 			$collections[$hash][] = $obj;
203 203
 		}
204 204
 		$this->setResultCollection($results, $collections, array_values($sourceKeys));
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
 	 * @param array foreign key column names
211 211
 	 * @return TActiveRecord
212 212
 	 */
213
-	protected function createFkObject($type,$row,$foreignKeys)
213
+	protected function createFkObject($type, $row, $foreignKeys)
214 214
 	{
215 215
 		$obj = TActiveRecord::createRecord($type, $row);
216
-		if(count($this->_association_columns) > 0)
216
+		if (count($this->_association_columns) > 0)
217 217
 		{
218
-			$i=0;
219
-			foreach($foreignKeys as $ref=>$fk)
218
+			$i = 0;
219
+			foreach ($foreignKeys as $ref=>$fk)
220 220
 				$obj->setColumnValue($ref, $row[$this->_association_columns[$i++]]);
221 221
 		}
222 222
 		return $obj;
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
 	 * @param array field names
229 229
 	 * @param array field values
230 230
 	 */
231
-	public function createCommand($criteria, $foreignKeys,$indexValues,$sourceKeys)
231
+	public function createCommand($criteria, $foreignKeys, $indexValues, $sourceKeys)
232 232
 	{
233
-		$innerJoin = $this->getAssociationJoin($foreignKeys,$indexValues,$sourceKeys);
233
+		$innerJoin = $this->getAssociationJoin($foreignKeys, $indexValues, $sourceKeys);
234 234
 		$fkTable = $this->getForeignTable()->getTableFullName();
235 235
 		$srcColumns = $this->getSourceColumns($sourceKeys);
236
-		if(($where=$criteria->getCondition())===null)
237
-			$where='1=1';
236
+		if (($where = $criteria->getCondition()) === null)
237
+			$where = '1=1';
238 238
 		$sql = "SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}";
239 239
 
240 240
 		$parameters = $criteria->getParameters()->toArray();
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 		$offset = $criteria->getOffset();
244 244
 
245 245
 		$builder = $this->getForeignCommandBuilder()->getBuilder();
246
-		$command = $builder->applyCriterias($sql,$parameters,$ordering,$limit,$offset);
246
+		$command = $builder->applyCriterias($sql, $parameters, $ordering, $limit, $offset);
247 247
 		$this->getCommandBuilder()->onCreateCommand($command, $criteria);
248 248
 		return $command;
249 249
 	}
@@ -254,12 +254,12 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	protected function getSourceColumns($sourceKeys)
256 256
 	{
257
-		$columns=array();
257
+		$columns = array();
258 258
 		$table = $this->getAssociationTable();
259 259
 		$tableName = $table->getTableFullName();
260
-		$columnNames = array_merge(array_keys($sourceKeys),$this->_association_columns);
261
-		foreach($columnNames as $name)
262
-			$columns[] = $tableName.'.'.$table->getColumn($name)->getColumnName();
260
+		$columnNames = array_merge(array_keys($sourceKeys), $this->_association_columns);
261
+		foreach ($columnNames as $name)
262
+			$columns[] = $tableName . '.' . $table->getColumn($name)->getColumnName();
263 263
 		return implode(', ', $columns);
264 264
 	}
265 265
 
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 	 * @param array source table column names.
271 271
 	 * @return string inner join condition for M-N relationship via association table.
272 272
 	 */
273
-	protected function getAssociationJoin($foreignKeys,$indexValues,$sourceKeys)
273
+	protected function getAssociationJoin($foreignKeys, $indexValues, $sourceKeys)
274 274
 	{
275
-		$refInfo= $this->getAssociationTable();
275
+		$refInfo = $this->getAssociationTable();
276 276
 		$fkInfo = $this->getForeignTable();
277 277
 
278 278
 		$refTable = $refInfo->getTableFullName();
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 
281 281
 		$joins = array();
282 282
 		$hasAssociationColumns = count($this->_association_columns) > 0;
283
-		$i=0;
284
-		foreach($foreignKeys as $ref=>$fk)
283
+		$i = 0;
284
+		foreach ($foreignKeys as $ref=>$fk)
285 285
 		{
286
-			if($hasAssociationColumns)
286
+			if ($hasAssociationColumns)
287 287
 				$refField = $refInfo->getColumn($this->_association_columns[$i++])->getColumnName();
288 288
 			else
289 289
 				$refField = $refInfo->getColumn($ref)->getColumnName();
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			$joins[] = "{$fkTable}.{$fkField} = {$refTable}.{$refField}";
292 292
 		}
293 293
 		$joinCondition = implode(' AND ', $joins);
294
-		$index = $this->getCommandBuilder()->getIndexKeyCondition($refInfo,array_keys($sourceKeys), $indexValues);
294
+		$index = $this->getCommandBuilder()->getIndexKeyCondition($refInfo, array_keys($sourceKeys), $indexValues);
295 295
 		return "INNER JOIN {$refTable} ON ({$joinCondition}) AND {$index}";
296 296
 	}
297 297
 
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
 	{
304 304
 		$obj = $this->getContext()->getSourceRecord();
305 305
 		$fkObjects = &$obj->{$this->getContext()->getProperty()};
306
-		$success=true;
307
-		if(($total = count($fkObjects))> 0)
306
+		$success = true;
307
+		if (($total = count($fkObjects)) > 0)
308 308
 		{
309 309
 			$source = $this->getSourceRecord();
310 310
 			$builder = $this->getAssociationTableCommandBuilder();
311
-			for($i=0;$i<$total;$i++)
311
+			for ($i = 0; $i < $total; $i++)
312 312
 				$success = $fkObjects[$i]->save() && $success;
313 313
 			return $this->updateAssociationTable($obj, $fkObjects, $builder) && $success;
314 314
 		}
@@ -324,33 +324,33 @@  discard block
 block discarded – undo
324 324
 		return $this->getAssociationTable()->createCommandBuilder($conn);
325 325
 	}
326 326
 
327
-	private function hasAssociationData($builder,$data)
327
+	private function hasAssociationData($builder, $data)
328 328
 	{
329
-		$condition=array();
329
+		$condition = array();
330 330
 		$table = $this->getAssociationTable();
331
-		foreach($data as $name=>$value)
332
-			$condition[] = $table->getColumn($name)->getColumnName().' = ?';
333
-		$command = $builder->createCountCommand(implode(' AND ', $condition),array_values($data));
331
+		foreach ($data as $name=>$value)
332
+			$condition[] = $table->getColumn($name)->getColumnName() . ' = ?';
333
+		$command = $builder->createCountCommand(implode(' AND ', $condition), array_values($data));
334 334
 		$result = $this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar()));
335 335
 		return intval($result) > 0;
336 336
 	}
337 337
 
338
-	private function addAssociationData($builder,$data)
338
+	private function addAssociationData($builder, $data)
339 339
 	{
340 340
 		$command = $builder->createInsertCommand($data);
341 341
 		return $this->getCommandBuilder()->onExecuteCommand($command, $command->execute()) > 0;
342 342
 	}
343 343
 
344
-	private function updateAssociationTable($obj,$fkObjects, $builder)
344
+	private function updateAssociationTable($obj, $fkObjects, $builder)
345 345
 	{
346 346
 		$source = $this->getSourceRecordValues($obj);
347 347
 		$foreignKeys = $this->findForeignKeys($this->getAssociationTable(), $fkObjects[0]);
348
-		$success=true;
349
-		foreach($fkObjects as $fkObject)
348
+		$success = true;
349
+		foreach ($fkObjects as $fkObject)
350 350
 		{
351
-			$data = array_merge($source, $this->getForeignObjectValues($foreignKeys,$fkObject));
352
-			if(!$this->hasAssociationData($builder,$data))
353
-				$success = $this->addAssociationData($builder,$data) && $success;
351
+			$data = array_merge($source, $this->getForeignObjectValues($foreignKeys, $fkObject));
352
+			if (!$this->hasAssociationData($builder, $data))
353
+				$success = $this->addAssociationData($builder, $data) && $success;
354 354
 		}
355 355
 		return $success;
356 356
 	}
@@ -360,16 +360,16 @@  discard block
 block discarded – undo
360 360
 		$sourceKeys = $this->findForeignKeys($this->getAssociationTable(), $obj);
361 361
 		$indexValues = $this->getIndexValues(array_values($sourceKeys), $obj);
362 362
 		$data = array();
363
-		$i=0;
364
-		foreach($sourceKeys as $name=>$srcKey)
363
+		$i = 0;
364
+		foreach ($sourceKeys as $name=>$srcKey)
365 365
 			$data[$name] = $indexValues[0][$i++];
366 366
 		return $data;
367 367
 	}
368 368
 
369
-	private function getForeignObjectValues($foreignKeys,$fkObject)
369
+	private function getForeignObjectValues($foreignKeys, $fkObject)
370 370
 	{
371
-		$data=array();
372
-		foreach($foreignKeys as $name=>$fKey)
371
+		$data = array();
372
+		foreach ($foreignKeys as $name=>$fKey)
373 373
 			$data[$name] = $fkObject->getColumnValue($fKey);
374 374
 		return $data;
375 375
 	}
Please login to merge, or discard this patch.
Braces   +32 added lines, -22 removed lines patch added patch discarded remove patch
@@ -196,8 +196,9 @@  discard block
 block discarded – undo
196 196
 		foreach($this->getCommandBuilder()->onExecuteCommand($command, $command->query()) as $row)
197 197
 		{
198 198
 			$hash = $this->getObjectHash($row, $srcProps);
199
-			foreach($srcProps as $column)
200
-				unset($row[$column]);
199
+			foreach($srcProps as $column) {
200
+							unset($row[$column]);
201
+			}
201 202
 			$obj = $this->createFkObject($type,$row,$foreignKeys);
202 203
 			$collections[$hash][] = $obj;
203 204
 		}
@@ -216,8 +217,9 @@  discard block
 block discarded – undo
216 217
 		if(count($this->_association_columns) > 0)
217 218
 		{
218 219
 			$i=0;
219
-			foreach($foreignKeys as $ref=>$fk)
220
-				$obj->setColumnValue($ref, $row[$this->_association_columns[$i++]]);
220
+			foreach($foreignKeys as $ref=>$fk) {
221
+							$obj->setColumnValue($ref, $row[$this->_association_columns[$i++]]);
222
+			}
221 223
 		}
222 224
 		return $obj;
223 225
 	}
@@ -233,8 +235,9 @@  discard block
 block discarded – undo
233 235
 		$innerJoin = $this->getAssociationJoin($foreignKeys,$indexValues,$sourceKeys);
234 236
 		$fkTable = $this->getForeignTable()->getTableFullName();
235 237
 		$srcColumns = $this->getSourceColumns($sourceKeys);
236
-		if(($where=$criteria->getCondition())===null)
237
-			$where='1=1';
238
+		if(($where=$criteria->getCondition())===null) {
239
+					$where='1=1';
240
+		}
238 241
 		$sql = "SELECT {$fkTable}.*, {$srcColumns} FROM {$fkTable} {$innerJoin} WHERE {$where}";
239 242
 
240 243
 		$parameters = $criteria->getParameters()->toArray();
@@ -258,8 +261,9 @@  discard block
 block discarded – undo
258 261
 		$table = $this->getAssociationTable();
259 262
 		$tableName = $table->getTableFullName();
260 263
 		$columnNames = array_merge(array_keys($sourceKeys),$this->_association_columns);
261
-		foreach($columnNames as $name)
262
-			$columns[] = $tableName.'.'.$table->getColumn($name)->getColumnName();
264
+		foreach($columnNames as $name) {
265
+					$columns[] = $tableName.'.'.$table->getColumn($name)->getColumnName();
266
+		}
263 267
 		return implode(', ', $columns);
264 268
 	}
265 269
 
@@ -283,10 +287,11 @@  discard block
 block discarded – undo
283 287
 		$i=0;
284 288
 		foreach($foreignKeys as $ref=>$fk)
285 289
 		{
286
-			if($hasAssociationColumns)
287
-				$refField = $refInfo->getColumn($this->_association_columns[$i++])->getColumnName();
288
-			else
289
-				$refField = $refInfo->getColumn($ref)->getColumnName();
290
+			if($hasAssociationColumns) {
291
+							$refField = $refInfo->getColumn($this->_association_columns[$i++])->getColumnName();
292
+			} else {
293
+							$refField = $refInfo->getColumn($ref)->getColumnName();
294
+			}
290 295
 			$fkField = $fkInfo->getColumn($fk)->getColumnName();
291 296
 			$joins[] = "{$fkTable}.{$fkField} = {$refTable}.{$refField}";
292 297
 		}
@@ -308,8 +313,9 @@  discard block
 block discarded – undo
308 313
 		{
309 314
 			$source = $this->getSourceRecord();
310 315
 			$builder = $this->getAssociationTableCommandBuilder();
311
-			for($i=0;$i<$total;$i++)
312
-				$success = $fkObjects[$i]->save() && $success;
316
+			for($i=0;$i<$total;$i++) {
317
+							$success = $fkObjects[$i]->save() && $success;
318
+			}
313 319
 			return $this->updateAssociationTable($obj, $fkObjects, $builder) && $success;
314 320
 		}
315 321
 		return $success;
@@ -328,8 +334,9 @@  discard block
 block discarded – undo
328 334
 	{
329 335
 		$condition=array();
330 336
 		$table = $this->getAssociationTable();
331
-		foreach($data as $name=>$value)
332
-			$condition[] = $table->getColumn($name)->getColumnName().' = ?';
337
+		foreach($data as $name=>$value) {
338
+					$condition[] = $table->getColumn($name)->getColumnName().' = ?';
339
+		}
333 340
 		$command = $builder->createCountCommand(implode(' AND ', $condition),array_values($data));
334 341
 		$result = $this->getCommandBuilder()->onExecuteCommand($command, intval($command->queryScalar()));
335 342
 		return intval($result) > 0;
@@ -349,8 +356,9 @@  discard block
 block discarded – undo
349 356
 		foreach($fkObjects as $fkObject)
350 357
 		{
351 358
 			$data = array_merge($source, $this->getForeignObjectValues($foreignKeys,$fkObject));
352
-			if(!$this->hasAssociationData($builder,$data))
353
-				$success = $this->addAssociationData($builder,$data) && $success;
359
+			if(!$this->hasAssociationData($builder,$data)) {
360
+							$success = $this->addAssociationData($builder,$data) && $success;
361
+			}
354 362
 		}
355 363
 		return $success;
356 364
 	}
@@ -361,16 +369,18 @@  discard block
 block discarded – undo
361 369
 		$indexValues = $this->getIndexValues(array_values($sourceKeys), $obj);
362 370
 		$data = array();
363 371
 		$i=0;
364
-		foreach($sourceKeys as $name=>$srcKey)
365
-			$data[$name] = $indexValues[0][$i++];
372
+		foreach($sourceKeys as $name=>$srcKey) {
373
+					$data[$name] = $indexValues[0][$i++];
374
+		}
366 375
 		return $data;
367 376
 	}
368 377
 
369 378
 	private function getForeignObjectValues($foreignKeys,$fkObject)
370 379
 	{
371 380
 		$data=array();
372
-		foreach($foreignKeys as $name=>$fKey)
373
-			$data[$name] = $fkObject->getColumnValue($fKey);
381
+		foreach($foreignKeys as $name=>$fKey) {
382
+					$data[$name] = $fkObject->getColumnValue($fKey);
383
+		}
374 384
 		return $data;
375 385
 	}
376 386
 }
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,6 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 	/**
94 94
 	 * Fetch results for current relationship.
95
+	 * @param TActiveRecord $obj
95 96
 	 * @return boolean always true.
96 97
 	 */
97 98
 	public function fetchResultsInto($obj)
@@ -104,7 +105,6 @@  discard block
 block discarded – undo
104 105
 	 * Returns foreign keys in $fromRecord with source column names as key
105 106
 	 * and foreign column names in the corresponding $matchesRecord as value.
106 107
 	 * The method returns the first matching foreign key between these 2 records.
107
-	 * @param TActiveRecord $fromRecord
108 108
 	 * @param TActiveRecord $matchesRecord
109 109
 	 * @return array foreign keys with source column names as key and foreign column names as value.
110 110
 	 */
@@ -212,6 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @param array source property names
213 213
 	 * @param array foreign objects
214 214
 	 * @param array foreign object field names.
215
+	 * @param TActiveRecord[] $fkObjects
215 216
 	 */
216 217
 	protected function populateResult(&$results,$properties,&$fkObjects,$fields)
217 218
 	{
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
 	 * @param array method arguments
72 72
 	 * @return mixed TActiveRecord or array of TActiveRecord results depending on the method called.
73 73
 	 */
74
-	public function __call($method,$args)
74
+	public function __call($method, $args)
75 75
 	{
76
-		static $stack=array();
76
+		static $stack = array();
77 77
 
78
-		$results = call_user_func_array(array($this->getSourceRecord(),$method),$args);
78
+		$results = call_user_func_array(array($this->getSourceRecord(), $method), $args);
79 79
 		$validArray = is_array($results) && count($results) > 0;
80
-		if($validArray || $results instanceof ArrayAccess || $results instanceof TActiveRecord)
80
+		if ($validArray || $results instanceof ArrayAccess || $results instanceof TActiveRecord)
81 81
 		{
82 82
 			$this->collectForeignObjects($results);
83
-			while($obj = array_pop($stack))
83
+			while ($obj = array_pop($stack))
84 84
 				$obj->collectForeignObjects($results);
85 85
 		}
86
-		else if($results instanceof TActiveRecordRelation)
86
+		else if ($results instanceof TActiveRecordRelation)
87 87
 			$stack[] = $this; //call it later
88
-		else if($results === null || !$validArray)
88
+		else if ($results === null || !$validArray)
89 89
 			$stack = array();
90 90
 		return $results;
91 91
 	}
@@ -108,24 +108,24 @@  discard block
 block discarded – undo
108 108
 	 * @param TActiveRecord $matchesRecord
109 109
 	 * @return array foreign keys with source column names as key and foreign column names as value.
110 110
 	 */
111
-	protected function findForeignKeys($from, $matchesRecord, $loose=false)
111
+	protected function findForeignKeys($from, $matchesRecord, $loose = false)
112 112
 	{
113 113
 		$gateway = $matchesRecord->getRecordGateway();
114 114
 		$recordTableInfo = $gateway->getRecordTableInfo($matchesRecord);
115 115
 		$matchingTableName = strtolower($recordTableInfo->getTableName());
116 116
 		$matchingFullTableName = strtolower($recordTableInfo->getTableFullName());
117
-		$tableInfo=$from;
118
-		if($from instanceof TActiveRecord)
117
+		$tableInfo = $from;
118
+		if ($from instanceof TActiveRecord)
119 119
 			$tableInfo = $gateway->getRecordTableInfo($from);
120 120
 		//find first non-empty FK
121
-		foreach($tableInfo->getForeignKeys() as $fkeys)
121
+		foreach ($tableInfo->getForeignKeys() as $fkeys)
122 122
 		{
123 123
 			$fkTable = strtolower($fkeys['table']);
124
-			if($fkTable===$matchingTableName || $fkTable===$matchingFullTableName)
124
+			if ($fkTable === $matchingTableName || $fkTable === $matchingFullTableName)
125 125
 			{
126 126
 				$hasFkField = !$loose && $this->getContext()->hasFkField();
127 127
 				$key = $hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys'];
128
-				if(!empty($key))
128
+				if (!empty($key))
129 129
 					return $key;
130 130
 			}
131 131
 		}
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 		$matching = array();
153 153
 		preg_match_all('/\s*(\S+\.)?([\w-]+)\s*/', $this->getContext()->getFkField(), $matching);
154 154
 		$fields = array();
155
-		foreach($fkeys as $fkName => $field)
155
+		foreach ($fkeys as $fkName => $field)
156 156
 		{
157
-			if(in_array($fkName, $matching[2]))
157
+			if (in_array($fkName, $matching[2]))
158 158
 				$fields[$fkName] = $field;
159 159
 		}
160 160
 		return $fields;
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	protected function getObjectHash($obj, $properties)
169 169
 	{
170
-		$ids=array();
171
-		foreach($properties as $property)
172
-			$ids[] = is_object($obj) ? (string)$obj->getColumnValue($property) : (string)$obj[$property];
170
+		$ids = array();
171
+		foreach ($properties as $property)
172
+			$ids[] = is_object($obj) ? (string) $obj->getColumnValue($property) : (string) $obj[$property];
173 173
 		return serialize($ids);
174 174
 	}
175 175
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	protected function getIndexValues($keys, $results)
195 195
 	{
196
-		if(!is_array($results) && !$results instanceof ArrayAccess)
196
+		if (!is_array($results) && !$results instanceof ArrayAccess)
197 197
 			$results = array($results);
198
-		$values=array();
199
-		foreach($results as $result)
198
+		$values = array();
199
+		foreach ($results as $result)
200 200
 		{
201 201
 			$value = array();
202
-			foreach($keys as $name)
202
+			foreach ($keys as $name)
203 203
 				$value[] = $result->getColumnValue($name);
204 204
 			$values[] = $value;
205 205
 		}
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	 * @param array foreign objects
214 214
 	 * @param array foreign object field names.
215 215
 	 */
216
-	protected function populateResult(&$results,$properties,&$fkObjects,$fields)
216
+	protected function populateResult(&$results, $properties, &$fkObjects, $fields)
217 217
 	{
218
-		$collections=array();
219
-		foreach($fkObjects as $fkObject)
220
-			$collections[$this->getObjectHash($fkObject, $fields)][]=$fkObject;
218
+		$collections = array();
219
+		foreach ($fkObjects as $fkObject)
220
+			$collections[$this->getObjectHash($fkObject, $fields)][] = $fkObject;
221 221
 		$this->setResultCollection($results, $collections, $properties);
222 222
 	}
223 223
 
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	protected function setResultCollection(&$results, &$collections, $properties)
231 231
 	{
232
-		if(is_array($results) || $results instanceof ArrayAccess)
232
+		if (is_array($results) || $results instanceof ArrayAccess)
233 233
 		{
234
-			for($i=0,$k=count($results);$i<$k;$i++)
234
+			for ($i = 0, $k = count($results); $i < $k; $i++)
235 235
 				$this->setObjectProperty($results[$i], $properties, $collections);
236 236
 		}
237 237
 		else
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	{
249 249
 		$hash = $this->getObjectHash($source, $properties);
250 250
 		$prop = $this->getContext()->getProperty();
251
-		$source->$prop=isset($collections[$hash]) ? $collections[$hash] : array();
251
+		$source->$prop = isset($collections[$hash]) ? $collections[$hash] : array();
252 252
 	}
253 253
 }
254 254
 
Please login to merge, or discard this patch.
Braces   +35 added lines, -24 removed lines patch added patch discarded remove patch
@@ -80,13 +80,16 @@  discard block
 block discarded – undo
80 80
 		if($validArray || $results instanceof ArrayAccess || $results instanceof TActiveRecord)
81 81
 		{
82 82
 			$this->collectForeignObjects($results);
83
-			while($obj = array_pop($stack))
84
-				$obj->collectForeignObjects($results);
83
+			while($obj = array_pop($stack)) {
84
+							$obj->collectForeignObjects($results);
85
+			}
86
+		} else if($results instanceof TActiveRecordRelation) {
87
+					$stack[] = $this;
88
+		}
89
+		//call it later
90
+		else if($results === null || !$validArray) {
91
+					$stack = array();
85 92
 		}
86
-		else if($results instanceof TActiveRecordRelation)
87
-			$stack[] = $this; //call it later
88
-		else if($results === null || !$validArray)
89
-			$stack = array();
90 93
 		return $results;
91 94
 	}
92 95
 
@@ -115,8 +118,9 @@  discard block
 block discarded – undo
115 118
 		$matchingTableName = strtolower($recordTableInfo->getTableName());
116 119
 		$matchingFullTableName = strtolower($recordTableInfo->getTableFullName());
117 120
 		$tableInfo=$from;
118
-		if($from instanceof TActiveRecord)
119
-			$tableInfo = $gateway->getRecordTableInfo($from);
121
+		if($from instanceof TActiveRecord) {
122
+					$tableInfo = $gateway->getRecordTableInfo($from);
123
+		}
120 124
 		//find first non-empty FK
121 125
 		foreach($tableInfo->getForeignKeys() as $fkeys)
122 126
 		{
@@ -125,8 +129,9 @@  discard block
 block discarded – undo
125 129
 			{
126 130
 				$hasFkField = !$loose && $this->getContext()->hasFkField();
127 131
 				$key = $hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys'];
128
-				if(!empty($key))
129
-					return $key;
132
+				if(!empty($key)) {
133
+									return $key;
134
+				}
130 135
 			}
131 136
 		}
132 137
 
@@ -154,8 +159,9 @@  discard block
 block discarded – undo
154 159
 		$fields = array();
155 160
 		foreach($fkeys as $fkName => $field)
156 161
 		{
157
-			if(in_array($fkName, $matching[2]))
158
-				$fields[$fkName] = $field;
162
+			if(in_array($fkName, $matching[2])) {
163
+							$fields[$fkName] = $field;
164
+			}
159 165
 		}
160 166
 		return $fields;
161 167
 	}
@@ -168,8 +174,9 @@  discard block
 block discarded – undo
168 174
 	protected function getObjectHash($obj, $properties)
169 175
 	{
170 176
 		$ids=array();
171
-		foreach($properties as $property)
172
-			$ids[] = is_object($obj) ? (string)$obj->getColumnValue($property) : (string)$obj[$property];
177
+		foreach($properties as $property) {
178
+					$ids[] = is_object($obj) ? (string)$obj->getColumnValue($property) : (string)$obj[$property];
179
+		}
173 180
 		return serialize($ids);
174 181
 	}
175 182
 
@@ -193,14 +200,16 @@  discard block
 block discarded – undo
193 200
 	 */
194 201
 	protected function getIndexValues($keys, $results)
195 202
 	{
196
-		if(!is_array($results) && !$results instanceof ArrayAccess)
197
-			$results = array($results);
203
+		if(!is_array($results) && !$results instanceof ArrayAccess) {
204
+					$results = array($results);
205
+		}
198 206
 		$values=array();
199 207
 		foreach($results as $result)
200 208
 		{
201 209
 			$value = array();
202
-			foreach($keys as $name)
203
-				$value[] = $result->getColumnValue($name);
210
+			foreach($keys as $name) {
211
+							$value[] = $result->getColumnValue($name);
212
+			}
204 213
 			$values[] = $value;
205 214
 		}
206 215
 		return $values;
@@ -216,8 +225,9 @@  discard block
 block discarded – undo
216 225
 	protected function populateResult(&$results,$properties,&$fkObjects,$fields)
217 226
 	{
218 227
 		$collections=array();
219
-		foreach($fkObjects as $fkObject)
220
-			$collections[$this->getObjectHash($fkObject, $fields)][]=$fkObject;
228
+		foreach($fkObjects as $fkObject) {
229
+					$collections[$this->getObjectHash($fkObject, $fields)][]=$fkObject;
230
+		}
221 231
 		$this->setResultCollection($results, $collections, $properties);
222 232
 	}
223 233
 
@@ -231,11 +241,12 @@  discard block
 block discarded – undo
231 241
 	{
232 242
 		if(is_array($results) || $results instanceof ArrayAccess)
233 243
 		{
234
-			for($i=0,$k=count($results);$i<$k;$i++)
235
-				$this->setObjectProperty($results[$i], $properties, $collections);
244
+			for($i=0,$k=count($results);$i<$k;$i++) {
245
+							$this->setObjectProperty($results[$i], $properties, $collections);
246
+			}
247
+		} else {
248
+					$this->setObjectProperty($results, $properties, $collections);
236 249
 		}
237
-		else
238
-			$this->setObjectProperty($results, $properties, $collections);
239 250
 	}
240 251
 
241 252
 	/**
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Relations/TActiveRecordRelationContext.php 4 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@  discard block
 block discarded – undo
30 30
 	private $_relation; //data from an entry of TActiveRecord::$RELATION
31 31
 	private $_fkeys;
32 32
 
33
+	/**
34
+	 * @param TActiveRecord $record
35
+	 */
33 36
 	public function __construct($record, $property=null, $relation=null)
34 37
 	{
35 38
 		$this->_record=$record;
@@ -163,6 +166,7 @@  discard block
 block discarded – undo
163 166
 	 * An instance of TActiveRecordHasOne, TActiveRecordBelongsTo, TActiveRecordHasMany,
164 167
 	 * or TActiveRecordHasManyAssocation will be returned.
165 168
 	 * @param TActiveRecordCriteria search criteria
169
+	 * @param TSqlCriteria $criteria
166 170
 	 * @return TActiveRecordRelation record relationship handler instnace.
167 171
 	 * @throws TActiveRecordException if property is not defined or missing.
168 172
 	 */
@@ -195,7 +199,7 @@  discard block
 block discarded – undo
195 199
 	}
196 200
 
197 201
 	/**
198
-	 * @return TActiveRecordRelationCommand
202
+	 * @return boolean
199 203
 	 */
200 204
 	public function updateAssociatedRecords($updateBelongsTo=false)
201 205
 	{
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TActiveRecordRelationContext class.
4
- *
5
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @version $Id$
10
- * @package System.Data.ActiveRecord.Relations
11
- */
3
+	 * TActiveRecordRelationContext class.
4
+	 *
5
+	 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @version $Id$
10
+	 * @package System.Data.ActiveRecord.Relations
11
+	 */
12 12
 
13 13
 /**
14 14
  * TActiveRecordRelationContext holds information regarding record relationships
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 	private $_relation; //data from an entry of TActiveRecord::$RELATION
31 31
 	private $_fkeys;
32 32
 
33
-	public function __construct($record, $property=null, $relation=null)
33
+	public function __construct($record, $property = null, $relation = null)
34 34
 	{
35
-		$this->_record=$record;
36
-		$this->_property=$property;
37
-		$this->_relation=$relation;
35
+		$this->_record = $record;
36
+		$this->_property = $property;
37
+		$this->_relation = $relation;
38 38
 	}
39 39
 
40 40
 	/**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function hasRecordRelation()
45 45
 	{
46
-		return $this->_relation!==null;
46
+		return $this->_relation !== null;
47 47
 	}
48 48
 
49 49
 	public function getPropertyValue()
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function getRelationForeignKeys()
77 77
 	{
78
-		if($this->_fkeys===null)
79
-			$this->_fkeys=$this->getRelationHandler()->getRelationForeignKeys();
78
+		if ($this->_fkeys === null)
79
+			$this->_fkeys = $this->getRelationHandler()->getRelationForeignKeys();
80 80
 		return $this->_fkeys;
81 81
 	}
82 82
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function getCondition()
113 113
 	{
114
-		return isset($this->_relation[3])?$this->_relation[3]:null;
114
+		return isset($this->_relation[3]) ? $this->_relation[3] : null;
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function getParameters()
122 122
 	{
123
-		return isset($this->_relation[4])?$this->_relation[4]:array();
123
+		return isset($this->_relation[4]) ? $this->_relation[4] : array();
124 124
 	}
125 125
 
126 126
 	/**
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 	 * @return TActiveRecordRelation record relationship handler instnace.
167 167
 	 * @throws TActiveRecordException if property is not defined or missing.
168 168
 	 */
169
-	public function getRelationHandler($criteria=null)
169
+	public function getRelationHandler($criteria = null)
170 170
 	{
171
-		if(!$this->hasRecordRelation())
171
+		if (!$this->hasRecordRelation())
172 172
 		{
173 173
 			throw new TActiveRecordException('ar_undefined_relation_prop',
174 174
 				$this->_property, get_class($this->_record), 'RELATIONS');
175 175
 		}
176
-		if($criteria===null)
176
+		if ($criteria === null)
177 177
 			$criteria = new TActiveRecordCriteria($this->getCondition(), $this->getParameters());
178
-		switch($this->getRelationType())
178
+		switch ($this->getRelationType())
179 179
 		{
180 180
 			case TActiveRecord::HAS_MANY:
181 181
 				Prado::using('System.Data.ActiveRecord.Relations.TActiveRecordHasMany');
@@ -197,19 +197,19 @@  discard block
 block discarded – undo
197 197
 	/**
198 198
 	 * @return TActiveRecordRelationCommand
199 199
 	 */
200
-	public function updateAssociatedRecords($updateBelongsTo=false)
200
+	public function updateAssociatedRecords($updateBelongsTo = false)
201 201
 	{
202
-		$success=true;
203
-		foreach($this->_record->getRecordRelations() as $data)
202
+		$success = true;
203
+		foreach ($this->_record->getRecordRelations() as $data)
204 204
 		{
205 205
 			list($property, $relation) = $data;
206
-			$belongsTo = $relation[0]==TActiveRecord::BELONGS_TO;
207
-			if(($updateBelongsTo && $belongsTo) || (!$updateBelongsTo && !$belongsTo))
206
+			$belongsTo = $relation[0] == TActiveRecord::BELONGS_TO;
207
+			if (($updateBelongsTo && $belongsTo) || (!$updateBelongsTo && !$belongsTo))
208 208
 			{
209 209
 				$obj = $this->getSourceRecord();
210
-				if(!$this->isEmptyFkObject($obj->getColumnValue($property)))
210
+				if (!$this->isEmptyFkObject($obj->getColumnValue($property)))
211 211
 				{
212
-					$context = new TActiveRecordRelationContext($this->getSourceRecord(),$property,$relation);
212
+					$context = new TActiveRecordRelationContext($this->getSourceRecord(), $property, $relation);
213 213
 					$success = $context->getRelationHandler()->updateAssociatedRecords() && $success;
214 214
 				}
215 215
 			}
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 
220 220
 	protected function isEmptyFkObject($obj)
221 221
 	{
222
-		if(is_object($obj))
222
+		if (is_object($obj))
223 223
 			return $obj instanceof TList ? $obj->count() === 0 : false;
224
-		else if(is_array($obj))
225
-			return count($obj)===0;
224
+		else if (is_array($obj))
225
+			return count($obj) === 0;
226 226
 		else
227 227
 			return empty($obj);
228 228
 	}
Please login to merge, or discard this patch.
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -75,8 +75,9 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function getRelationForeignKeys()
77 77
 	{
78
-		if($this->_fkeys===null)
79
-			$this->_fkeys=$this->getRelationHandler()->getRelationForeignKeys();
78
+		if($this->_fkeys===null) {
79
+					$this->_fkeys=$this->getRelationHandler()->getRelationForeignKeys();
80
+		}
80 81
 		return $this->_fkeys;
81 82
 	}
82 83
 
@@ -173,8 +174,9 @@  discard block
 block discarded – undo
173 174
 			throw new TActiveRecordException('ar_undefined_relation_prop',
174 175
 				$this->_property, get_class($this->_record), 'RELATIONS');
175 176
 		}
176
-		if($criteria===null)
177
-			$criteria = new TActiveRecordCriteria($this->getCondition(), $this->getParameters());
177
+		if($criteria===null) {
178
+					$criteria = new TActiveRecordCriteria($this->getCondition(), $this->getParameters());
179
+		}
178 180
 		switch($this->getRelationType())
179 181
 		{
180 182
 			case TActiveRecord::HAS_MANY:
@@ -219,12 +221,13 @@  discard block
 block discarded – undo
219 221
 
220 222
 	protected function isEmptyFkObject($obj)
221 223
 	{
222
-		if(is_object($obj))
223
-			return $obj instanceof TList ? $obj->count() === 0 : false;
224
-		else if(is_array($obj))
225
-			return count($obj)===0;
226
-		else
227
-			return empty($obj);
224
+		if(is_object($obj)) {
225
+					return $obj instanceof TList ? $obj->count() === 0 : false;
226
+		} else if(is_array($obj)) {
227
+					return count($obj)===0;
228
+		} else {
229
+					return empty($obj);
230
+		}
228 231
 	}
229 232
 }
230 233
 
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputBase.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -46,6 +46,10 @@  discard block
 block discarded – undo
46 46
 		}
47 47
 	}
48 48
 
49
+	/**
50
+	 * @param TScaffoldEditView $parent
51
+	 * @param TActiveRecord $record
52
+	 */
49 53
 	public function createScaffoldInput($parent, $item, $column, $record)
50 54
 	{
51 55
 		$this->_parent=$parent;
@@ -62,6 +66,11 @@  discard block
 block discarded – undo
62 66
 		$label->setForControl(self::DEFAULT_ID);
63 67
 	}
64 68
 
69
+	/**
70
+	 * @param TScaffoldEditView $parent
71
+	 * @param TDbTableColumn $column
72
+	 * @param TActiveRecord $record
73
+	 */
65 74
 	public function loadScaffoldInput($parent, $item, $column, $record)
66 75
 	{
67 76
 		$this->_parent=$parent;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,51 +21,51 @@  discard block
 block discarded – undo
21 21
 	{
22 22
 		$record->getDbConnection()->setActive(true); //must be connected before retrieving driver name!
23 23
 		$driver = $record->getDbConnection()->getDriverName();
24
-		switch(strtolower($driver))
24
+		switch (strtolower($driver))
25 25
 		{
26 26
 			case 'sqlite': //sqlite 3
27 27
 			case 'sqlite2': //sqlite 2
28
-				require_once(dirname(__FILE__).'/TSqliteScaffoldInput.php');
28
+				require_once(dirname(__FILE__) . '/TSqliteScaffoldInput.php');
29 29
 				return new TSqliteScaffoldInput($conn);
30 30
 			case 'mysqli':
31 31
 			case 'mysql':
32
-				require_once(dirname(__FILE__).'/TMysqlScaffoldInput.php');
32
+				require_once(dirname(__FILE__) . '/TMysqlScaffoldInput.php');
33 33
 				return new TMysqlScaffoldInput($conn);
34 34
 			case 'pgsql':
35
-				require_once(dirname(__FILE__).'/TPgsqlScaffoldInput.php');
35
+				require_once(dirname(__FILE__) . '/TPgsqlScaffoldInput.php');
36 36
 				return new TPgsqlScaffoldInput($conn);
37 37
 			case 'mssql':
38
-				require_once(dirname(__FILE__).'/TMssqlScaffoldInput.php');
38
+				require_once(dirname(__FILE__) . '/TMssqlScaffoldInput.php');
39 39
 				return new TMssqlScaffoldInput($conn);
40 40
 			case 'ibm':
41
-				require_once(dirname(__FILE__).'/TIbmScaffoldInput.php');
41
+				require_once(dirname(__FILE__) . '/TIbmScaffoldInput.php');
42 42
 				return new TIbmScaffoldInput($conn);
43 43
 			default:
44 44
 				throw new TConfigurationException(
45
-					'scaffold_invalid_database_driver',$driver);
45
+					'scaffold_invalid_database_driver', $driver);
46 46
 		}
47 47
 	}
48 48
 
49 49
 	public function createScaffoldInput($parent, $item, $column, $record)
50 50
 	{
51
-		$this->_parent=$parent;
51
+		$this->_parent = $parent;
52 52
 		$item->setCustomData($column->getColumnId());
53 53
 		$this->createControl($item->_input, $column, $record);
54
-		if($item->_input->findControl(self::DEFAULT_ID))
54
+		if ($item->_input->findControl(self::DEFAULT_ID))
55 55
 			$this->createControlLabel($item->_label, $column, $record);
56 56
 	}
57 57
 
58 58
 	protected function createControlLabel($label, $column, $record)
59 59
 	{
60
-		$fieldname = ucwords(str_replace('_', ' ', $column->getColumnId())).':';
60
+		$fieldname = ucwords(str_replace('_', ' ', $column->getColumnId())) . ':';
61 61
 		$label->setText($fieldname);
62 62
 		$label->setForControl(self::DEFAULT_ID);
63 63
 	}
64 64
 
65 65
 	public function loadScaffoldInput($parent, $item, $column, $record)
66 66
 	{
67
-		$this->_parent=$parent;
68
-		if($this->getIsEnabled($column, $record))
67
+		$this->_parent = $parent;
68
+		if ($this->getIsEnabled($column, $record))
69 69
 		{
70 70
 			$prop = $column->getColumnId();
71 71
 			$record->setColumnValue($prop, $this->getControlValue($item->_input, $column, $record));
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	protected function getRecordPropertyValue($column, $record)
82 82
 	{
83 83
 		$value = $record->getColumnValue($column->getColumnId());
84
-		if($column->getDefaultValue()!==TDbTableColumn::UNDEFINED_VALUE && $value===null)
84
+		if ($column->getDefaultValue() !== TDbTableColumn::UNDEFINED_VALUE && $value === null)
85 85
 			return $column->getDefaultValue();
86 86
 		else
87 87
 			return $value;
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
 		$this->_parent=$parent;
52 52
 		$item->setCustomData($column->getColumnId());
53 53
 		$this->createControl($item->_input, $column, $record);
54
-		if($item->_input->findControl(self::DEFAULT_ID))
55
-			$this->createControlLabel($item->_label, $column, $record);
54
+		if($item->_input->findControl(self::DEFAULT_ID)) {
55
+					$this->createControlLabel($item->_label, $column, $record);
56
+		}
56 57
 	}
57 58
 
58 59
 	protected function createControlLabel($label, $column, $record)
@@ -81,10 +82,11 @@  discard block
 block discarded – undo
81 82
 	protected function getRecordPropertyValue($column, $record)
82 83
 	{
83 84
 		$value = $record->getColumnValue($column->getColumnId());
84
-		if($column->getDefaultValue()!==TDbTableColumn::UNDEFINED_VALUE && $value===null)
85
-			return $column->getDefaultValue();
86
-		else
87
-			return $value;
85
+		if($column->getDefaultValue()!==TDbTableColumn::UNDEFINED_VALUE && $value===null) {
86
+					return $column->getDefaultValue();
87
+		} else {
88
+					return $value;
89
+		}
88 90
 	}
89 91
 
90 92
 	protected function setRecordPropertyValue($item, $record, $input)
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Scaffold/InputBuilder/TScaffoldInputCommon.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -47,6 +47,9 @@
 block discarded – undo
47 47
 		return $control;
48 48
 	}
49 49
 
50
+	/**
51
+	 * @return string
52
+	 */
50 53
 	protected function getDefaultControlValue($container,$column, $record)
51 54
 	{
52 55
 		$control = $container->findControl(self::DEFAULT_ID);
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	protected function setNotNullProperty($container, $control, $column, $record)
22 22
 	{
23 23
 		$this->setDefaultProperty($container, $control, $column, $record);
24
-		if(!$column->getAllowNull() && !$column->hasSequence())
24
+		if (!$column->getAllowNull() && !$column->hasSequence())
25 25
 			$this->createRequiredValidator($container, $column, $record);
26 26
 	}
27 27
 
@@ -41,18 +41,18 @@  discard block
 block discarded – undo
41 41
 		$control = new TTextBox();
42 42
 		$control->setText($value);
43 43
 		$control->setCssClass('default-textbox scaffold_input');
44
-		if(($len=$column->getColumnSize())!==null)
44
+		if (($len = $column->getColumnSize()) !== null)
45 45
 			$control->setMaxLength($len);
46 46
 		$this->setNotNullProperty($container, $control, $column, $record);
47 47
 		return $control;
48 48
 	}
49 49
 
50
-	protected function getDefaultControlValue($container,$column, $record)
50
+	protected function getDefaultControlValue($container, $column, $record)
51 51
 	{
52 52
 		$control = $container->findControl(self::DEFAULT_ID);
53
-		if($control instanceof TCheckBox)
53
+		if ($control instanceof TCheckBox)
54 54
 			return $control->getChecked();
55
-		else if($control instanceof TControl)
55
+		else if ($control instanceof TControl)
56 56
 			return $control->getText();
57 57
 	}
58 58
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 		$control = new TDropDownList();
74 74
 		$years = array();
75 75
 		$current = intval(@date('Y'));
76
-		$from = $current-10; $to=$current+10;
77
-		for($i = $from; $i <= $to; $i++)
76
+		$from = $current - 10; $to = $current + 10;
77
+		for ($i = $from; $i <= $to; $i++)
78 78
 			$years[$i] = $i;
79 79
 		$control->setDataSource($years);
80 80
 		$control->setSelectedValue(empty($value) ? $current : $value);
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 		$val = $this->createTypeValidator($container, $column, $record);
99 99
 		$val->setDataType(TValidationDataType::Float);
100 100
 		$val->setErrorMessage('Please entery a decimal number.');
101
-		if(($max= $column->getMaxiumNumericConstraint())!==null)
101
+		if (($max = $column->getMaxiumNumericConstraint()) !== null)
102 102
 		{
103
-			$val = $this->createRangeValidator($container,$column,$record);
103
+			$val = $this->createRangeValidator($container, $column, $record);
104 104
 			$val->setDataType(TValidationDataType::Float);
105 105
 			$val->setMaxValue($max);
106 106
 			$val->setStrictComparison(true);
107
-			$val->setErrorMessage('Please entery a decimal number strictly less than '.$max.'.');
107
+			$val->setErrorMessage('Please entery a decimal number strictly less than ' . $max . '.');
108 108
 		}
109 109
 		return $control;
110 110
 	}
@@ -149,22 +149,22 @@  discard block
 block discarded – undo
149 149
 	protected function createTimeControl($container, $column, $record)
150 150
 	{
151 151
 		$value = $this->getRecordPropertyValue($column, $record);
152
-		$hours=array();
153
-		for($i=0;$i<24;$i++) $hours[] = str_pad($i,2,'0',STR_PAD_LEFT);
154
-		$mins=array();
155
-		for($i=0;$i<60;$i++) $mins[] = str_pad($i,2,'0',STR_PAD_LEFT);
152
+		$hours = array();
153
+		for ($i = 0; $i < 24; $i++) $hours[] = str_pad($i, 2, '0', STR_PAD_LEFT);
154
+		$mins = array();
155
+		for ($i = 0; $i < 60; $i++) $mins[] = str_pad($i, 2, '0', STR_PAD_LEFT);
156 156
 		$hour = intval(@date('H'));
157 157
 		$min = intval(@date('i'));
158 158
 		$sec = intval(@date('s'));
159
-		if(!empty($value))
159
+		if (!empty($value))
160 160
 		{
161
-			$match=array();
162
-			if(preg_match('/(\d+):(\d+):?(\d+)?/', $value, $match))
161
+			$match = array();
162
+			if (preg_match('/(\d+):(\d+):?(\d+)?/', $value, $match))
163 163
 			{
164 164
 				$hour = $match[1];
165 165
 				$min = $match[2];
166
-				if(isset($match[3]))
167
-					$sec=$match[3];
166
+				if (isset($match[3]))
167
+					$sec = $match[3];
168 168
 			}
169 169
 		}
170 170
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		$scontrol->setSelectedValue(intval($sec));
192 192
 		$container->Controls[] = $scontrol;
193 193
 
194
-		return array($hcontrol,$mcontrol,$scontrol);
194
+		return array($hcontrol, $mcontrol, $scontrol);
195 195
 	}
196 196
 
197 197
 
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 		$control->setFromYear(1900);
203 203
 		$control->setInputMode(TDatePickerInputMode::DropDownList);
204 204
 		$control->setDateFormat('yyyy-MM-dd');
205
-		if(!empty($value))
206
-			$control->setDate(substr($value,0,10));
205
+		if (!empty($value))
206
+			$control->setDate(substr($value, 0, 10));
207 207
 		$control->setCssClass('date-dropdown');
208 208
 		$this->setNotNullProperty($container, $control, $column, $record);
209 209
 		return $control;
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
 		$control = $this->createDateControl($container, $column, $record);
216 216
 		$container->Controls[] = ' @ ';
217 217
 		$time = $this->createTimeControl($container, $column, $record);
218
-		if(!empty($value))
218
+		if (!empty($value))
219 219
 		{
220
-			$match=array();
221
-			if(preg_match('/(\d+):(\d+):?(\d+)?/', substr($value, 11), $match))
220
+			$match = array();
221
+			if (preg_match('/(\d+):(\d+):?(\d+)?/', substr($value, 11), $match))
222 222
 			{
223 223
 				$time[0]->setSelectedValue(intval($match[1]));
224 224
 				$time[1]->setSelectedValue(intval($match[2]));
225
-				if(isset($match[3]))
225
+				if (isset($match[3]))
226 226
 					$time[2]->setSelectedValue(intval($match[3]));
227 227
 			}
228 228
 		}
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 		$values = $column->getDbTypeValues();
256 256
 		$control->setDataSource($values);
257 257
 		$control->dataBind();
258
-		$control->setSelectedIndices($this->getMatchingIndices($values,$selectedValues));
258
+		$control->setSelectedIndices($this->getMatchingIndices($values, $selectedValues));
259 259
 		$control->setID(self::DEFAULT_ID);
260 260
 		$control->setCssClass('set-checkboxes');
261 261
 		$this->setNotNullProperty($container, $control, $column, $record);
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 
265 265
 	protected function getMatchingIndices($checks, $values)
266 266
 	{
267
-		$index=array();
268
-		for($i=0, $k=count($checks); $i<$k; $i++)
267
+		$index = array();
268
+		for ($i = 0, $k = count($checks); $i < $k; $i++)
269 269
 		{
270
-			if(in_array($checks[$i], $values))
270
+			if (in_array($checks[$i], $values))
271 271
 				$index[] = $i;
272 272
 		}
273 273
 		return $index;
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 		$values = $column->getDbTypeValues();
282 282
 		$control->setDataSource($values);
283 283
 		$control->dataBind();
284
-		$index = $this->getMatchingIndices($values,$selectedValues);
285
-		if(count($index) > 0)
284
+		$index = $this->getMatchingIndices($values, $selectedValues);
285
+		if (count($index) > 0)
286 286
 			$control->setSelectedIndex($index[0]);
287 287
 		$control->setID(self::DEFAULT_ID);
288 288
 		$control->setCssClass('enum-radio-buttons');
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
 
293 293
 	protected function getSetValue($container, $column, $record)
294 294
 	{
295
-		$value=array();
296
-		foreach($container->findControl(self::DEFAULT_ID)->getItems() as $item)
295
+		$value = array();
296
+		foreach ($container->findControl(self::DEFAULT_ID)->getItems() as $item)
297 297
 		{
298
-			if($item->getSelected())
298
+			if ($item->getSelected())
299 299
 				$value[] = $item->getText();
300 300
 		}
301 301
 		return implode(',', $value);
Please login to merge, or discard this patch.
Braces   +38 added lines, -24 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@  discard block
 block discarded – undo
21 21
 	protected function setNotNullProperty($container, $control, $column, $record)
22 22
 	{
23 23
 		$this->setDefaultProperty($container, $control, $column, $record);
24
-		if(!$column->getAllowNull() && !$column->hasSequence())
25
-			$this->createRequiredValidator($container, $column, $record);
24
+		if(!$column->getAllowNull() && !$column->hasSequence()) {
25
+					$this->createRequiredValidator($container, $column, $record);
26
+		}
26 27
 	}
27 28
 
28 29
 	protected function createBooleanControl($container, $column, $record)
@@ -41,8 +42,9 @@  discard block
 block discarded – undo
41 42
 		$control = new TTextBox();
42 43
 		$control->setText($value);
43 44
 		$control->setCssClass('default-textbox scaffold_input');
44
-		if(($len=$column->getColumnSize())!==null)
45
-			$control->setMaxLength($len);
45
+		if(($len=$column->getColumnSize())!==null) {
46
+					$control->setMaxLength($len);
47
+		}
46 48
 		$this->setNotNullProperty($container, $control, $column, $record);
47 49
 		return $control;
48 50
 	}
@@ -50,10 +52,11 @@  discard block
 block discarded – undo
50 52
 	protected function getDefaultControlValue($container,$column, $record)
51 53
 	{
52 54
 		$control = $container->findControl(self::DEFAULT_ID);
53
-		if($control instanceof TCheckBox)
54
-			return $control->getChecked();
55
-		else if($control instanceof TControl)
56
-			return $control->getText();
55
+		if($control instanceof TCheckBox) {
56
+					return $control->getChecked();
57
+		} else if($control instanceof TControl) {
58
+					return $control->getText();
59
+		}
57 60
 	}
58 61
 
59 62
 	protected function createMultiLineControl($container, $column, $record)
@@ -74,8 +77,9 @@  discard block
 block discarded – undo
74 77
 		$years = array();
75 78
 		$current = intval(@date('Y'));
76 79
 		$from = $current-10; $to=$current+10;
77
-		for($i = $from; $i <= $to; $i++)
78
-			$years[$i] = $i;
80
+		for($i = $from; $i <= $to; $i++) {
81
+					$years[$i] = $i;
82
+		}
79 83
 		$control->setDataSource($years);
80 84
 		$control->setSelectedValue(empty($value) ? $current : $value);
81 85
 		$control->setCssClass('year-dropdown');
@@ -150,9 +154,13 @@  discard block
 block discarded – undo
150 154
 	{
151 155
 		$value = $this->getRecordPropertyValue($column, $record);
152 156
 		$hours=array();
153
-		for($i=0;$i<24;$i++) $hours[] = str_pad($i,2,'0',STR_PAD_LEFT);
157
+		for($i=0;$i<24;$i++) {
158
+			$hours[] = str_pad($i,2,'0',STR_PAD_LEFT);
159
+		}
154 160
 		$mins=array();
155
-		for($i=0;$i<60;$i++) $mins[] = str_pad($i,2,'0',STR_PAD_LEFT);
161
+		for($i=0;$i<60;$i++) {
162
+			$mins[] = str_pad($i,2,'0',STR_PAD_LEFT);
163
+		}
156 164
 		$hour = intval(@date('H'));
157 165
 		$min = intval(@date('i'));
158 166
 		$sec = intval(@date('s'));
@@ -163,8 +171,9 @@  discard block
 block discarded – undo
163 171
 			{
164 172
 				$hour = $match[1];
165 173
 				$min = $match[2];
166
-				if(isset($match[3]))
167
-					$sec=$match[3];
174
+				if(isset($match[3])) {
175
+									$sec=$match[3];
176
+				}
168 177
 			}
169 178
 		}
170 179
 
@@ -202,8 +211,9 @@  discard block
 block discarded – undo
202 211
 		$control->setFromYear(1900);
203 212
 		$control->setInputMode(TDatePickerInputMode::DropDownList);
204 213
 		$control->setDateFormat('yyyy-MM-dd');
205
-		if(!empty($value))
206
-			$control->setDate(substr($value,0,10));
214
+		if(!empty($value)) {
215
+					$control->setDate(substr($value,0,10));
216
+		}
207 217
 		$control->setCssClass('date-dropdown');
208 218
 		$this->setNotNullProperty($container, $control, $column, $record);
209 219
 		return $control;
@@ -222,8 +232,9 @@  discard block
 block discarded – undo
222 232
 			{
223 233
 				$time[0]->setSelectedValue(intval($match[1]));
224 234
 				$time[1]->setSelectedValue(intval($match[2]));
225
-				if(isset($match[3]))
226
-					$time[2]->setSelectedValue(intval($match[3]));
235
+				if(isset($match[3])) {
236
+									$time[2]->setSelectedValue(intval($match[3]));
237
+				}
227 238
 			}
228 239
 		}
229 240
 		$time[0]->setID('scaffold_time_hour');
@@ -267,8 +278,9 @@  discard block
 block discarded – undo
267 278
 		$index=array();
268 279
 		for($i=0, $k=count($checks); $i<$k; $i++)
269 280
 		{
270
-			if(in_array($checks[$i], $values))
271
-				$index[] = $i;
281
+			if(in_array($checks[$i], $values)) {
282
+							$index[] = $i;
283
+			}
272 284
 		}
273 285
 		return $index;
274 286
 	}
@@ -282,8 +294,9 @@  discard block
 block discarded – undo
282 294
 		$control->setDataSource($values);
283 295
 		$control->dataBind();
284 296
 		$index = $this->getMatchingIndices($values,$selectedValues);
285
-		if(count($index) > 0)
286
-			$control->setSelectedIndex($index[0]);
297
+		if(count($index) > 0) {
298
+					$control->setSelectedIndex($index[0]);
299
+		}
287 300
 		$control->setID(self::DEFAULT_ID);
288 301
 		$control->setCssClass('enum-radio-buttons');
289 302
 		$this->setNotNullProperty($container, $control, $column, $record);
@@ -295,8 +308,9 @@  discard block
 block discarded – undo
295 308
 		$value=array();
296 309
 		foreach($container->findControl(self::DEFAULT_ID)->getItems() as $item)
297 310
 		{
298
-			if($item->getSelected())
299
-				$value[] = $item->getText();
311
+			if($item->getSelected()) {
312
+							$value[] = $item->getText();
313
+			}
300 314
 		}
301 315
 		return implode(',', $value);
302 316
 	}
Please login to merge, or discard this patch.
framework/Data/ActiveRecord/Scaffold/TScaffoldBase.php 3 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	private $_record;
37 37
 
38 38
 	/**
39
-	 * @return TDbMetaData table/view information
39
+	 * @return TDbTableInfo table/view information
40 40
 	 */
41 41
 	protected function getTableInfo()
42 42
 	{
@@ -84,6 +84,7 @@  discard block
 block discarded – undo
84 84
 	/**
85 85
 	 * Name of the Active Record class to be viewed or scaffolded.
86 86
 	 * @param string Active Record class name.
87
+	 * @param string $value
87 88
 	 */
88 89
 	public function setRecordClass($value)
89 90
 	{
@@ -183,6 +184,7 @@  discard block
 block discarded – undo
183 184
 
184 185
 	/**
185 186
 	 * @param boolean enable default stylesheet, default is true.
187
+	 * @param boolean $value
186 188
 	 */
187 189
 	public function setEnableDefaultStyle($value)
188 190
 	{
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	protected function getRecordPropertyValues($record)
53 53
 	{
54 54
 		$data = array();
55
-		foreach($this->getTableInfo()->getColumns() as $name=>$column)
55
+		foreach ($this->getTableInfo()->getColumns() as $name=>$column)
56 56
 			$data[] = $record->getColumnValue($name);
57 57
 		return $data;
58 58
 	}
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	protected function getRecordPkValues($record)
65 65
 	{
66
-		$data=array();
67
-		foreach($this->getTableInfo()->getColumns() as $name=>$column)
66
+		$data = array();
67
+		foreach ($this->getTableInfo()->getColumns() as $name=>$column)
68 68
 		{
69
-			if($column->getIsPrimaryKey())
69
+			if ($column->getIsPrimaryKey())
70 70
 				$data[] = $record->getColumnValue($name);
71 71
 		}
72 72
 		return $data;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	protected function clearRecordObject()
108 108
 	{
109
-		$this->_record=null;
109
+		$this->_record = null;
110 110
 	}
111 111
 
112 112
 	/**
@@ -115,26 +115,26 @@  discard block
 block discarded – undo
115 115
 	 * @param array primary key value
116 116
 	 * @return TActiveRecord record instance
117 117
 	 */
118
-	protected function getRecordObject($pk=null)
118
+	protected function getRecordObject($pk = null)
119 119
 	{
120
-		if($this->_record===null)
120
+		if ($this->_record === null)
121 121
 		{
122
-			if($pk!==null)
122
+			if ($pk !== null)
123 123
 			{
124
-				$this->_record=$this->getRecordFinder()->findByPk($pk);
125
-				if($this->_record===null)
124
+				$this->_record = $this->getRecordFinder()->findByPk($pk);
125
+				if ($this->_record === null)
126 126
 					throw new TConfigurationException('scaffold_invalid_record_pk',
127 127
 						$this->getRecordClass(), $pk);
128 128
 			}
129 129
 			else
130 130
 			{
131 131
 				$class = $this->getRecordClass();
132
-				if($class!==null)
133
-					$this->_record=Prado::createComponent($class);
132
+				if ($class !== null)
133
+					$this->_record = Prado::createComponent($class);
134 134
 				else
135 135
 				{
136 136
 					throw new TConfigurationException('scaffold_invalid_record_class',
137
-						$this->getRecordClass(),$this->getID());
137
+						$this->getRecordClass(), $this->getID());
138 138
 				}
139 139
 			}
140 140
 		}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	protected function setRecordObject(TActiveRecord $value)
148 148
 	{
149
-		$this->_record=$value;
149
+		$this->_record = $value;
150 150
 	}
151 151
 
152 152
 	/**
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 	public function onPreRender($param)
196 196
 	{
197 197
 		parent::onPreRender($param);
198
-		if($this->getEnableDefaultStyle())
198
+		if ($this->getEnableDefaultStyle())
199 199
 		{
200
-			$url = $this->publishAsset($this->getDefaultStyle().'.css');
201
-			$this->getPage()->getClientScript()->registerStyleSheetFile($url,$url);
200
+			$url = $this->publishAsset($this->getDefaultStyle() . '.css');
201
+			$this->getPage()->getClientScript()->registerStyleSheetFile($url, $url);
202 202
 		}
203 203
 	}
204 204
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -52,8 +52,9 @@  discard block
 block discarded – undo
52 52
 	protected function getRecordPropertyValues($record)
53 53
 	{
54 54
 		$data = array();
55
-		foreach($this->getTableInfo()->getColumns() as $name=>$column)
56
-			$data[] = $record->getColumnValue($name);
55
+		foreach($this->getTableInfo()->getColumns() as $name=>$column) {
56
+					$data[] = $record->getColumnValue($name);
57
+		}
57 58
 		return $data;
58 59
 	}
59 60
 
@@ -66,8 +67,9 @@  discard block
 block discarded – undo
66 67
 		$data=array();
67 68
 		foreach($this->getTableInfo()->getColumns() as $name=>$column)
68 69
 		{
69
-			if($column->getIsPrimaryKey())
70
-				$data[] = $record->getColumnValue($name);
70
+			if($column->getIsPrimaryKey()) {
71
+							$data[] = $record->getColumnValue($name);
72
+			}
71 73
 		}
72 74
 		return $data;
73 75
 	}
@@ -122,16 +124,16 @@  discard block
 block discarded – undo
122 124
 			if($pk!==null)
123 125
 			{
124 126
 				$this->_record=$this->getRecordFinder()->findByPk($pk);
125
-				if($this->_record===null)
126
-					throw new TConfigurationException('scaffold_invalid_record_pk',
127
+				if($this->_record===null) {
128
+									throw new TConfigurationException('scaffold_invalid_record_pk',
127 129
 						$this->getRecordClass(), $pk);
128
-			}
129
-			else
130
+				}
131
+			} else
130 132
 			{
131 133
 				$class = $this->getRecordClass();
132
-				if($class!==null)
133
-					$this->_record=Prado::createComponent($class);
134
-				else
134
+				if($class!==null) {
135
+									$this->_record=Prado::createComponent($class);
136
+				} else
135 137
 				{
136 138
 					throw new TConfigurationException('scaffold_invalid_record_class',
137 139
 						$this->getRecordClass(),$this->getID());
Please login to merge, or discard this patch.