Completed
Push — prado-3.3 ( f4da81...5dd4b5 )
by Fabio
09:03
created
framework/Collections/TAttributeCollection.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	protected function __getZappableSleepProps(&$exprops)
54 54
 	{
55 55
 		parent::__getZappableSleepProps($exprops);
56
-		if ($this->_caseSensitive===false)
57
-			$exprops[] = "\0TAttributeCollection\0_caseSensitive";
56
+		if($this->_caseSensitive===false)
57
+			$exprops[]="\0TAttributeCollection\0_caseSensitive";
58 58
 	}
59 59
 
60 60
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function __get($name)
69 69
 	{
70
-		return $this->contains($name)?$this->itemAt($name):parent::__get($name);
70
+		return $this->contains($name) ? $this->itemAt($name) : parent::__get($name);
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	 * @param mixed the property value or event handler
79 79
 	 * @throws TInvalidOperationException If the property is not defined or read-only.
80 80
 	 */
81
-	public function __set($name,$value)
81
+	public function __set($name, $value)
82 82
 	{
83
-		$this->add($name,$value);
83
+		$this->add($name, $value);
84 84
 	}
85 85
 
86 86
 	/**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function itemAt($key)
109 109
 	{
110
-		return parent::itemAt($this->_caseSensitive?$key:strtolower($key));
110
+		return parent::itemAt($this->_caseSensitive ? $key : strtolower($key));
111 111
 	}
112 112
 
113 113
 
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	 * @param mixed key
118 118
 	 * @param mixed value
119 119
 	 */
120
-	public function add($key,$value)
120
+	public function add($key, $value)
121 121
 	{
122
-		parent::add($this->_caseSensitive?$key:strtolower($key),$value);
122
+		parent::add($this->_caseSensitive ? $key : strtolower($key), $value);
123 123
 	}
124 124
 
125 125
 	/**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function remove($key)
132 132
 	{
133
-		return parent::remove($this->_caseSensitive?$key:strtolower($key));
133
+		return parent::remove($this->_caseSensitive ? $key : strtolower($key));
134 134
 	}
135 135
 
136 136
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function contains($key)
143 143
 	{
144
-		return parent::contains($this->_caseSensitive?$key:strtolower($key));
144
+		return parent::contains($this->_caseSensitive ? $key : strtolower($key));
145 145
 	}
146 146
 
147 147
 	/**
Please login to merge, or discard this patch.
framework/Collections/TListItemCollection.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 	public function createListItem($index=-1)
39 39
 	{
40 40
 		$item=$this->createNewListItem();
41
-		if($index<0)
41
+		if($index < 0)
42 42
 			$this->add($item);
43 43
 		else
44
-			$this->insertAt($index,$item);
44
+			$this->insertAt($index, $item);
45 45
 		return $item;
46 46
 	}
47 47
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	protected function createNewListItem($text=null)
52 52
 	{
53
-		$item =  new TListItem;
53
+		$item=new TListItem;
54 54
 		if($text!==null)
55 55
 			$item->setText($text);
56 56
 		return $item;
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 	 * @param TListItem the item to be inserted.
64 64
 	 * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem
65 65
 	 */
66
-	public function insertAt($index,$item)
66
+	public function insertAt($index, $item)
67 67
 	{
68 68
 		if(is_string($item))
69
-			$item = $this->createNewListItem($item);
69
+			$item=$this->createNewListItem($item);
70 70
 		if(!($item instanceof TListItem))
71
-			throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this));
72
-		parent::insertAt($index,$item);
71
+			throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this));
72
+		parent::insertAt($index, $item);
73 73
 	}
74 74
 
75 75
 	/**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param boolean whether to look for disabled items also
79 79
 	 * @return integer the index of the item found, -1 if not found.
80 80
 	 */
81
-	public function findIndexByValue($value,$includeDisabled=true)
81
+	public function findIndexByValue($value, $includeDisabled=true)
82 82
 	{
83 83
 		$value=TPropertyValue::ensureString($value);
84 84
 		$index=0;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param boolean whether to look for disabled items also
98 98
 	 * @return integer the index of the item found, -1 if not found.
99 99
 	 */
100
-	public function findIndexByText($text,$includeDisabled=true)
100
+	public function findIndexByText($text, $includeDisabled=true)
101 101
 	{
102 102
 		$text=TPropertyValue::ensureString($text);
103 103
 		$index=0;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	 * @param boolean whether to look for disabled items also
117 117
 	 * @return TListItem the item found, null if not found.
118 118
 	 */
119
-	public function findItemByValue($value,$includeDisabled=true)
119
+	public function findItemByValue($value, $includeDisabled=true)
120 120
 	{
121
-		if(($index=$this->findIndexByValue($value,$includeDisabled))>=0)
121
+		if(($index=$this->findIndexByValue($value, $includeDisabled)) >= 0)
122 122
 			return $this->itemAt($index);
123 123
 		else
124 124
 			return null;
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 * @param boolean whether to look for disabled items also
131 131
 	 * @return TListItem the item found, null if not found.
132 132
 	 */
133
-	public function findItemByText($text,$includeDisabled=true)
133
+	public function findItemByText($text, $includeDisabled=true)
134 134
 	{
135
-		if(($index=$this->findIndexByText($text,$includeDisabled))>=0)
135
+		if(($index=$this->findIndexByText($text, $includeDisabled)) >= 0)
136 136
 			return $this->itemAt($index);
137 137
 		else
138 138
 			return null;
@@ -157,6 +157,6 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function saveState()
159 159
 	{
160
-		return ($this->getCount()>0) ? $this->toArray() : null;
160
+		return ($this->getCount() > 0) ? $this->toArray() : null;
161 161
 	}
162 162
 }
Please login to merge, or discard this patch.
framework/Collections/TPriorityMap.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  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 100
 		if($data!==null)
101 101
 			$this->copyFrom($data);
@@ -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
 	/**
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
 			return $this->_fd;
185 185
 
186 186
 		$this->sortPriorities();
187
-		$this->_fd = array();
187
+		$this->_fd=array();
188 188
 		foreach($this->_d as $priority => $itemsatpriority)
189
-			$this->_fd = array_merge($this->_fd, $itemsatpriority);
189
+			$this->_fd=array_merge($this->_fd, $itemsatpriority);
190 190
 		return $this->_fd;
191 191
 	}
192 192
 
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 	{
219 219
 		if($priority===null)
220 220
 			$priority=$this->getDefaultPriority();
221
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
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){
257
+		if($priority===false) {
258 258
 			$map=$this->flattenPriorities();
259
-			return isset($map[$key])?$map[$key]:null;
259
+			return isset($map[$key]) ? $map[$key] : null;
260 260
 		} else {
261 261
 			if($priority===null)
262 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;
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 277
 		if($priority===null)
278 278
 			$priority=$this->getDefaultPriority();
279
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
279
+		$priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p);
280 280
 
281 281
 		$oldpriority=$this->priorityAt($key);
282
-		if($oldpriority!==false&&$oldpriority!=$priority) {
283
-			$value=$this->remove($key,$oldpriority);
284
-			$this->add($key,$value,$priority);
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
 	}
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 	{
296 296
 		if($priority===null)
297 297
 			$priority=$this->getDefaultPriority();
298
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
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
 	/**
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	{
310 310
 		$this->sortPriorities();
311 311
 		foreach($this->_d as $priority=>$items)
312
-			if(($index=array_search($item,$items,true))!==false)
312
+			if(($index=array_search($item, $items, true))!==false)
313 313
 				return $priority;
314 314
 		return false;
315 315
 	}
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	{
324 324
 		$this->sortPriorities();
325 325
 		foreach($this->_d as $priority=>$items)
326
-			if(array_key_exists($key,$items))
326
+			if(array_key_exists($key, $items))
327 327
 				return $priority;
328 328
 		return false;
329 329
 	}
@@ -341,16 +341,16 @@  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 346
 		if($priority===null)
347 347
 			$priority=$this->getDefaultPriority();
348
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
348
+		$priority=(string) round(TPropertyValue::ensureFloat($priority), $this->_p);
349 349
 
350 350
 		if(!$this->_r)
351 351
 		{
352 352
 			foreach($this->_d as $innerpriority=>$items)
353
-				if(array_key_exists($key,$items))
353
+				if(array_key_exists($key, $items))
354 354
 				{
355 355
 					unset($this->_d[$innerpriority][$key]);
356 356
 					$this->_c--;
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 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,7 +383,7 @@  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 388
 		if(!$this->_r)
389 389
 		{
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 			{
395 395
 				$this->sortPriorities();
396 396
 				foreach($this->_d as $priority=>$items)
397
-					if(array_key_exists($key,$items))
397
+					if(array_key_exists($key, $items))
398 398
 					{
399 399
 						$value=$this->_d[$priority][$key];
400 400
 						unset($this->_d[$priority][$key]);
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
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 417
 					$value=$this->_d[$priority][$key];
418 418
 					unset($this->_d[$priority][$key]);
@@ -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
 	/**
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	public function contains($key)
450 450
 	{
451 451
 		$map=$this->flattenPriorities();
452
-		return isset($map[$key])||array_key_exists($key,$map);
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 476
 		$items=array();
477 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 496
 		$items=array();
497 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
 	}
@@ -514,20 +514,20 @@  discard block
 block discarded – undo
514 514
 	{
515 515
 		if($data instanceof TPriorityMap)
516 516
 		{
517
-			if($this->getCount()>0)
517
+			if($this->getCount() > 0)
518 518
 				$this->clear();
519 519
 			foreach($data->getPriorities() as $priority) {
520 520
 				foreach($data->itemsAtPriority($priority) as $key => $value) {
521
-					$this->add($key,$value,$priority);
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 529
 			foreach($data as $key=>$value)
530
-				$this->add($key,$value);
530
+				$this->add($key, $value);
531 531
 		}
532 532
 		else if($data!==null)
533 533
 			throw new TInvalidDataTypeException('map_data_not_iterable');
@@ -547,13 +547,13 @@  discard block
 block discarded – undo
547 547
 			foreach($data->getPriorities() as $priority)
548 548
 			{
549 549
 				foreach($data->itemsAtPriority($priority) as $key => $value)
550
-					$this->add($key,$value,$priority);
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 555
 			foreach($data as $key=>$value)
556
-				$this->add($key,$value);
556
+				$this->add($key, $value);
557 557
 		}
558 558
 		else if($data!==null)
559 559
 			throw new TInvalidDataTypeException('map_data_not_iterable');
@@ -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.
framework/TApplicationComponent.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
 	 * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this).
95 95
 	 * @return string URL to the asset path.
96 96
 	 */
97
-	public function publishAsset($assetPath,$className=null)
97
+	public function publishAsset($assetPath, $className=null)
98 98
 	{
99 99
 		if($className===null)
100 100
 			$className=get_class($this);
Please login to merge, or discard this patch.
framework/Security/TAuthManager.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
 		if(is_string($this->_userManager))
95 95
 		{
96 96
 			if(($users=$application->getModule($this->_userManager))===null)
97
-				throw new TConfigurationException('authmanager_usermanager_inexistent',$this->_userManager);
97
+				throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager);
98 98
 			if(!($users instanceof IUserManager))
99
-				throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager);
99
+				throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
100 100
 			$this->_userManager=$users;
101 101
 		}
102
-		$application->attachEventHandler('OnAuthentication',array($this,'doAuthentication'));
103
-		$application->attachEventHandler('OnEndRequest',array($this,'leave'));
104
-		$application->attachEventHandler('OnAuthorization',array($this,'doAuthorization'));
102
+		$application->attachEventHandler('OnAuthentication', array($this, 'doAuthentication'));
103
+		$application->attachEventHandler('OnEndRequest', array($this, 'leave'));
104
+		$application->attachEventHandler('OnAuthorization', array($this, 'doAuthorization'));
105 105
 		$this->_initialized=true;
106 106
 	}
107 107
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		if($this->_initialized)
123 123
 			throw new TInvalidOperationException('authmanager_usermanager_unchangeable');
124 124
 		if(!is_string($provider) && !($provider instanceof IUserManager))
125
-			throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager);
125
+			throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
126 126
 		$this->_userManager=$provider;
127 127
 	}
128 128
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @param mixed sender of the Authentication event
153 153
 	 * @param mixed event parameter
154 154
 	 */
155
-	public function doAuthentication($sender,$param)
155
+	public function doAuthentication($sender, $param)
156 156
 	{
157 157
 		$this->onAuthenticate($param);
158 158
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param mixed sender of the Authorization event
169 169
 	 * @param mixed event parameter
170 170
 	 */
171
-	public function doAuthorization($sender,$param)
171
+	public function doAuthorization($sender, $param)
172 172
 	{
173 173
 		if(!$this->_skipAuthorization)
174 174
 		{
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 * @param mixed sender of the event
184 184
 	 * @param mixed event parameter
185 185
 	 */
186
-	public function leave($sender,$param)
186
+	public function leave($sender, $param)
187 187
 	{
188 188
 		$application=$this->getApplication();
189 189
 		if($application->getResponse()->getStatusCode()===401)
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function setReturnUrl($value)
231 231
 	{
232
-		$this->getSession()->add($this->getReturnUrlVarName(),$value);
232
+		$this->getSession()->add($this->getReturnUrlVarName(), $value);
233 233
 	}
234 234
 
235 235
 	/**
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 		$user=$this->_userManager->getUser(null)->loadFromString($sessionInfo);
289 289
 
290 290
 		// check for authentication expiration
291
-		$isAuthExpired = $this->_authExpire>0 && !$user->getIsGuest() &&
292
-        ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time();
291
+		$isAuthExpired=$this->_authExpire > 0 && !$user->getIsGuest() &&
292
+        ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime < time();
293 293
 
294 294
 		// try authenticating through cookie if possible
295 295
 		if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired))
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 					$user=$user2;
303 303
 					$this->updateSessionUser($user);
304 304
 					// user is restored from cookie, auth may not expire
305
-					$isAuthExpired = false;
305
+					$isAuthExpired=false;
306 306
 				}
307 307
 			}
308 308
 		}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 		// event handler gets a chance to do further auth work
319 319
 		if($this->hasEventHandler('OnAuthenticate'))
320
-			$this->raiseEvent('OnAuthenticate',$this,$application);
320
+			$this->raiseEvent('OnAuthenticate', $this, $application);
321 321
 	}
322 322
 
323 323
 	/**
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	{
330 330
 		$this->logout();
331 331
 		if($this->hasEventHandler('OnAuthExpire'))
332
-			$this->raiseEvent('OnAuthExpire',$this,$param);
332
+			$this->raiseEvent('OnAuthExpire', $this, $param);
333 333
 	}
334 334
 
335 335
 	/**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	{
344 344
 		$application=$this->getApplication();
345 345
 		if($this->hasEventHandler('OnAuthorize'))
346
-			$this->raiseEvent('OnAuthorize',$this,$application);
347
-		if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(),$application->getRequest()->getRequestType(),$application->getRequest()->getUserHostAddress()))
346
+			$this->raiseEvent('OnAuthorize', $this, $application);
347
+		if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress()))
348 348
 		{
349 349
 			$application->getResponse()->setStatusCode(401);
350 350
 			$application->completeRequest();
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 			if(($session=$this->getSession())===null)
384 384
 				throw new TConfigurationException('authmanager_session_required');
385 385
 			else
386
-				$session->add($this->getUserKey(),$user->saveToString());
386
+				$session->add($this->getUserKey(), $user->saveToString());
387 387
 		}
388 388
 	}
389 389
 
@@ -411,19 +411,19 @@  discard block
 block discarded – undo
411 411
 	 * @param integer number of seconds that automatic login will remain effective. If 0, it means user logs out when session ends. This parameter is added since 3.1.1.
412 412
 	 * @return boolean if login is successful
413 413
 	 */
414
-	public function login($username,$password,$expire=0)
414
+	public function login($username, $password, $expire=0)
415 415
 	{
416
-		if($this->_userManager->validateUser($username,$password))
416
+		if($this->_userManager->validateUser($username, $password))
417 417
 		{
418 418
 			if(($user=$this->_userManager->getUser($username))===null)
419 419
 				return false;
420 420
 			$this->updateSessionUser($user);
421 421
 			$this->getApplication()->setUser($user);
422 422
 
423
-			if($expire>0)
423
+			if($expire > 0)
424 424
 			{
425
-				$cookie=new THttpCookie($this->getUserKey(),'');
426
-				$cookie->setExpire(time()+$expire);
425
+				$cookie=new THttpCookie($this->getUserKey(), '');
426
+				$cookie->setExpire(time() + $expire);
427 427
 				$this->_userManager->saveUserToCookie($cookie);
428 428
 				$this->getResponse()->getCookies()->add($cookie);
429 429
 			}
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 		$session->destroy();
447 447
 		if($this->getAllowAutoLogin())
448 448
 		{
449
-			$cookie=new THttpCookie($this->getUserKey(),'');
449
+			$cookie=new THttpCookie($this->getUserKey(), '');
450 450
 			$this->getResponse()->getCookies()->add($cookie);
451 451
 		}
452 452
 	}
Please login to merge, or discard this patch.
framework/Security/TDbUserManager.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	{
64 64
 		if($this->_userClass==='')
65 65
 			throw new TConfigurationException('dbusermanager_userclass_required');
66
-		$this->_userFactory=Prado::createComponent($this->_userClass,$this);
66
+		$this->_userFactory=Prado::createComponent($this->_userClass, $this);
67 67
 		if(!($this->_userFactory instanceof TDbUser))
68
-			throw new TInvalidDataTypeException('dbusermanager_userclass_invalid',$this->_userClass);
68
+			throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass);
69 69
 	}
70 70
 
71 71
 	/**
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 	 * @param string password
107 107
 	 * @return boolean true if validation is successful, false otherwise.
108 108
 	 */
109
-	public function validateUser($username,$password)
109
+	public function validateUser($username, $password)
110 110
 	{
111
-		return $this->_userFactory->validateUser($username,$password);
111
+		return $this->_userFactory->validateUser($username, $password);
112 112
 	}
113 113
 
114 114
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	{
121 121
 		if($username===null)
122 122
 		{
123
-			$user=Prado::createComponent($this->_userClass,$this);
123
+			$user=Prado::createComponent($this->_userClass, $this);
124 124
 			$user->setIsGuest(true);
125 125
 			return $user;
126 126
 		}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 			if($conn instanceof TDataSourceConfig)
175 175
 				return $conn->getDbConnection();
176 176
 			else
177
-				throw new TConfigurationException('dbusermanager_connectionid_invalid',$connectionID);
177
+				throw new TConfigurationException('dbusermanager_connectionid_invalid', $connectionID);
178 178
 		}
179 179
 		else
180 180
 			throw new TConfigurationException('dbusermanager_connectionid_required');
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 * @param string password
256 256
 	 * @return boolean whether the validation succeeds
257 257
 	 */
258
-	abstract public function validateUser($username,$password);
258
+	abstract public function validateUser($username, $password);
259 259
 
260 260
 	/**
261 261
 	 * Creates a new user instance given the username.
Please login to merge, or discard this patch.
framework/Security/TUser.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function getName()
70 70
 	{
71
-		return $this->getState('Name','');
71
+		return $this->getState('Name', '');
72 72
 	}
73 73
 
74 74
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function setName($value)
78 78
 	{
79
-		$this->setState('Name',$value,'');
79
+		$this->setState('Name', $value, '');
80 80
 	}
81 81
 
82 82
 	/**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function getIsGuest()
86 86
 	{
87
-		return $this->getState('IsGuest',true);
87
+		return $this->getState('IsGuest', true);
88 88
 	}
89 89
 
90 90
 	/**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			$this->setName($this->_manager->getGuestName());
98 98
 			$this->setRoles(array());
99 99
 		}
100
-		$this->setState('IsGuest',$isGuest);
100
+		$this->setState('IsGuest', $isGuest);
101 101
 	}
102 102
 
103 103
 	/**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function getRoles()
107 107
 	{
108
-		return $this->getState('Roles',array());
108
+		return $this->getState('Roles', array());
109 109
 	}
110 110
 
111 111
 	/**
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
 	public function setRoles($value)
115 115
 	{
116 116
 		if(is_array($value))
117
-			$this->setState('Roles',$value,array());
117
+			$this->setState('Roles', $value, array());
118 118
 		else
119 119
 		{
120 120
 			$roles=array();
121
-			foreach(explode(',',$value) as $role)
121
+			foreach(explode(',', $value) as $role)
122 122
 			{
123 123
 				if(($role=trim($role))!=='')
124 124
 					$roles[]=$role;
125 125
 			}
126
-			$this->setState('Roles',$roles,array());
126
+			$this->setState('Roles', $roles, array());
127 127
 		}
128 128
 	}
129 129
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	public function isInRole($role)
135 135
 	{
136 136
 		foreach($this->getRoles() as $r)
137
-			if(strcasecmp($role,$r)===0)
137
+			if(strcasecmp($role, $r)===0)
138 138
 				return true;
139 139
 		return false;
140 140
 	}
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
 	 * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned
174 174
 	 * @see setState
175 175
 	 */
176
-	protected function getState($key,$defaultValue=null)
176
+	protected function getState($key, $defaultValue=null)
177 177
 	{
178
-		return isset($this->_state[$key])?$this->_state[$key]:$defaultValue;
178
+		return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue;
179 179
 	}
180 180
 
181 181
 	/**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage.
193 193
 	 * @see getState
194 194
 	 */
195
-	protected function setState($key,$value,$defaultValue=null)
195
+	protected function setState($key, $value, $defaultValue=null)
196 196
 	{
197 197
 		if($value===$defaultValue)
198 198
 			unset($this->_state[$key]);
Please login to merge, or discard this patch.
framework/Security/IUserManager.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,6 +51,6 @@
 block discarded – undo
51 51
 	 * @param string password
52 52
 	 * @return boolean true if validation is successful, false otherwise.
53 53
 	 */
54
-	public function validateUser($username,$password);
54
+	public function validateUser($username, $password);
55 55
 }
56 56
 
Please login to merge, or discard this patch.
framework/Security/TSecurityManager.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
  */
41 41
 class TSecurityManager extends TModule
42 42
 {
43
-	const STATE_VALIDATION_KEY = 'prado:securitymanager:validationkey';
44
-	const STATE_ENCRYPTION_KEY = 'prado:securitymanager:encryptionkey';
43
+	const STATE_VALIDATION_KEY='prado:securitymanager:validationkey';
44
+	const STATE_ENCRYPTION_KEY='prado:securitymanager:encryptionkey';
45 45
 
46
-	private $_validationKey = null;
47
-	private $_encryptionKey = null;
48
-	private $_hashAlgorithm = 'sha1';
49
-	private $_cryptAlgorithm = 'rijndael-256';
46
+	private $_validationKey=null;
47
+	private $_encryptionKey=null;
48
+	private $_hashAlgorithm='sha1';
49
+	private $_cryptAlgorithm='rijndael-256';
50 50
 	private $_mbstring;
51 51
 
52 52
 	/**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	protected function generateRandomKey()
67 67
 	{
68
-		return sprintf('%08x%08x%08x%08x',mt_rand(),mt_rand(),mt_rand(),mt_rand());
68
+		return sprintf('%08x%08x%08x%08x', mt_rand(), mt_rand(), mt_rand(), mt_rand());
69 69
 	}
70 70
 
71 71
 	/**
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function getValidationKey()
76 76
 	{
77
-		if(null === $this->_validationKey) {
78
-			if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
79
-				$this->_validationKey = $this->generateRandomKey();
77
+		if(null===$this->_validationKey) {
78
+			if(null===($this->_validationKey=$this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
79
+				$this->_validationKey=$this->generateRandomKey();
80 80
 				$this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true);
81 81
 			}
82 82
 		}
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function setValidationKey($value)
91 91
 	{
92
-		if('' === $value)
92
+		if(''===$value)
93 93
 			throw new TInvalidDataValueException('securitymanager_validationkey_invalid');
94 94
 
95
-		$this->_validationKey = $value;
95
+		$this->_validationKey=$value;
96 96
 	}
97 97
 
98 98
 	/**
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function getEncryptionKey()
103 103
 	{
104
-		if(null === $this->_encryptionKey) {
105
-			if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
106
-				$this->_encryptionKey = $this->generateRandomKey();
104
+		if(null===$this->_encryptionKey) {
105
+			if(null===($this->_encryptionKey=$this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
106
+				$this->_encryptionKey=$this->generateRandomKey();
107 107
 				$this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true);
108 108
 			}
109 109
 		}
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function setEncryptionKey($value)
118 118
 	{
119
-		if('' === $value)
119
+		if(''===$value)
120 120
 			throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid');
121 121
 
122
-		$this->_encryptionKey = $value;
122
+		$this->_encryptionKey=$value;
123 123
 	}
124 124
 
125 125
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function setValidation($value)
149 149
 	{
150
-		$this->_hashAlgorithm = TPropertyValue::ensureEnum($value, 'TSecurityManagerValidationMode');
150
+		$this->_hashAlgorithm=TPropertyValue::ensureEnum($value, 'TSecurityManagerValidationMode');
151 151
 	}
152 152
 
153 153
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function setHashAlgorithm($value)
157 157
 	{
158
-		$this->_hashAlgorithm = TPropertyValue::ensureString($value);
158
+		$this->_hashAlgorithm=TPropertyValue::ensureString($value);
159 159
 	}
160 160
 
161 161
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	public function setEncryption($value)
180 180
 	{
181
-		$this->_cryptAlgorithm = $value;
181
+		$this->_cryptAlgorithm=$value;
182 182
 	}
183 183
 
184 184
 	/**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 */
196 196
 	public function setCryptAlgorithm($value)
197 197
 	{
198
-		$this->_cryptAlgorithm = $value;
198
+		$this->_cryptAlgorithm=$value;
199 199
 	}
200 200
 
201 201
 	/**
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
 	public function encrypt($data)
208 208
 	{
209 209
 		$module=$this->openCryptModule();
210
-		$key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module));
210
+		$key=$this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module));
211 211
 		srand();
212
-		$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
212
+		$iv=mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
213 213
 		mcrypt_generic_init($module, $key, $iv);
214
-		$encrypted = $iv.mcrypt_generic($module, $data);
214
+		$encrypted=$iv.mcrypt_generic($module, $data);
215 215
 		mcrypt_generic_deinit($module);
216 216
 		mcrypt_module_close($module);
217 217
 		return $encrypted;
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
 	public function decrypt($data)
227 227
 	{
228 228
 		$module=$this->openCryptModule();
229
-		$key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module));
230
-		$ivSize = mcrypt_enc_get_iv_size($module);
231
-		$iv = $this->substr($data, 0, $ivSize);
229
+		$key=$this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module));
230
+		$ivSize=mcrypt_enc_get_iv_size($module);
231
+		$iv=$this->substr($data, 0, $ivSize);
232 232
 		mcrypt_generic_init($module, $key, $iv);
233
-		$decrypted = mdecrypt_generic($module, $this->substr($data, $ivSize, $this->strlen($data)));
233
+		$decrypted=mdecrypt_generic($module, $this->substr($data, $ivSize, $this->strlen($data)));
234 234
 		mcrypt_generic_deinit($module);
235 235
 		mcrypt_module_close($module);
236 236
 		return $decrypted;
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 		if(extension_loaded('mcrypt'))
247 247
 		{
248 248
 			if(is_array($this->_cryptAlgorithm))
249
-				$module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm);
249
+				$module=@call_user_func_array('mcrypt_module_open', $this->_cryptAlgorithm);
250 250
 			else
251
-				$module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,'');
251
+				$module=@mcrypt_module_open($this->_cryptAlgorithm, '', MCRYPT_MODE_CBC, '');
252 252
 
253 253
 			if($module===false)
254 254
 				throw new TNotSupportedException('securitymanager_mcryptextension_initfailed');
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	public function hashData($data)
268 268
 	{
269
-		$hmac = $this->computeHMAC($data);
269
+		$hmac=$this->computeHMAC($data);
270 270
 		return $hmac.$data;
271 271
 	}
272 272
 
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 		if($this->strlen($data) < $len)
285 285
 			return false;
286 286
 
287
-		$hmac = $this->substr($data, 0, $len);
287
+		$hmac=$this->substr($data, 0, $len);
288 288
 		$data2=$this->substr($data, $len, $this->strlen($data));
289
-		return $hmac === $this->computeHMAC($data2) ? $data2 : false;
289
+		return $hmac===$this->computeHMAC($data2) ? $data2 : false;
290 290
 	}
291 291
 
292 292
 	/**
@@ -296,22 +296,22 @@  discard block
 block discarded – undo
296 296
 	 */
297 297
 	protected function computeHMAC($data)
298 298
 	{
299
-		$key = $this->getValidationKey();
299
+		$key=$this->getValidationKey();
300 300
 
301 301
 		if(function_exists('hash_hmac'))
302 302
 			return hash_hmac($this->_hashAlgorithm, $data, $key);
303 303
 
304
-		if(!strcasecmp($this->_hashAlgorithm,'sha1'))
304
+		if(!strcasecmp($this->_hashAlgorithm, 'sha1'))
305 305
 		{
306
-			$pack = 'H40';
307
-			$func = 'sha1';
306
+			$pack='H40';
307
+			$func='sha1';
308 308
 		} else {
309
-			$pack = 'H32';
310
-			$func = 'md5';
309
+			$pack='H32';
310
+			$func='md5';
311 311
 		}
312 312
 
313
-		$key = str_pad($func($key), 64, chr(0));
314
-		return $func((str_repeat(chr(0x5C), 64) ^ substr($key, 0, 64)) . pack($pack, $func((str_repeat(chr(0x36), 64) ^ substr($key, 0, 64)) . $data)));
313
+		$key=str_pad($func($key), 64, chr(0));
314
+		return $func((str_repeat(chr(0x5C), 64) ^ substr($key, 0, 64)).pack($pack, $func((str_repeat(chr(0x36), 64) ^ substr($key, 0, 64)).$data)));
315 315
 	}
316 316
 
317 317
 	/**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 */
323 323
 	private function strlen($string)
324 324
 	{
325
-		return $this->_mbstring ? mb_strlen($string,'8bit') : strlen($string);
325
+		return $this->_mbstring ? mb_strlen($string, '8bit') : strlen($string);
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
 	 * @param int $length the desired portion length
334 334
 	 * @return string the extracted part of string, or FALSE on failure or an empty string.
335 335
 	 */
336
-	private function substr($string,$start,$length)
336
+	private function substr($string, $start, $length)
337 337
 	{
338
-		return $this->_mbstring ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length);
338
+		return $this->_mbstring ? mb_substr($string, $start, $length, '8bit') : substr($string, $start, $length);
339 339
 	}
340 340
 }
341 341
 
@@ -357,6 +357,6 @@  discard block
 block discarded – undo
357 357
  */
358 358
 class TSecurityManagerValidationMode extends TEnumerable
359 359
 {
360
-	const MD5 = 'MD5';
361
-	const SHA1 = 'SHA1';
360
+	const MD5='MD5';
361
+	const SHA1='SHA1';
362 362
 }
Please login to merge, or discard this patch.