Completed
Push — php-cs-fixer ( b6f93e...b9836a )
by Fabio
07:15
created
framework/Exceptions/TPhpErrorException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function __construct($errno, $errstr, $errfile, $errline)
34 34
 	{
35
-		static $errorTypes = [
35
+		static $errorTypes=[
36 36
 			E_ERROR => "Error",
37 37
 			E_WARNING => "Warning",
38 38
 			E_PARSE => "Parsing Error",
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 			E_USER_NOTICE => "User Notice",
47 47
 			E_STRICT => "Runtime Notice"
48 48
 		];
49
-		$errorType = isset($errorTypes[$errno])?$errorTypes[$errno]:'Unknown Error';
49
+		$errorType=isset($errorTypes[$errno]) ? $errorTypes[$errno] : 'Unknown Error';
50 50
 		parent::__construct("[$errorType] $errstr (@line $errline in file $errfile).");
51 51
 	}
52 52
 
Please login to merge, or discard this patch.
framework/TApplicationConfiguration.php 2 patches
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -29,35 +29,35 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * @var array list of application initial property values, indexed by property names
31 31
 	 */
32
-	private $_properties = [];
32
+	private $_properties=[];
33 33
 	/**
34 34
 	 * @var array list of namespaces to be used
35 35
 	 */
36
-	private $_usings = [];
36
+	private $_usings=[];
37 37
 	/**
38 38
 	 * @var array list of path aliases, indexed by alias names
39 39
 	 */
40
-	private $_aliases = [];
40
+	private $_aliases=[];
41 41
 	/**
42 42
 	 * @var array list of module configurations
43 43
 	 */
44
-	private $_modules = [];
44
+	private $_modules=[];
45 45
 	/**
46 46
 	 * @var array list of service configurations
47 47
 	 */
48
-	private $_services = [];
48
+	private $_services=[];
49 49
 	/**
50 50
 	 * @var array list of parameters
51 51
 	 */
52
-	private $_parameters = [];
52
+	private $_parameters=[];
53 53
 	/**
54 54
 	 * @var array list of included configurations
55 55
 	 */
56
-	private $_includes = [];
56
+	private $_includes=[];
57 57
 	/**
58 58
 	 * @var boolean whether this configuration contains actual stuff
59 59
 	 */
60
-	private $_empty = true;
60
+	private $_empty=true;
61 61
 
62 62
 	/**
63 63
 	 * Parses the application configuration file.
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function loadFromFile($fname)
68 68
 	{
69
-		if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
69
+		if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
70 70
 		{
71
-			$fcontent = include $fname;
71
+			$fcontent=include $fname;
72 72
 			$this->loadFromPhp($fcontent, dirname($fname));
73 73
 		}
74 74
 		else
75 75
 		{
76
-			$dom = new TXmlDocument;
76
+			$dom=new TXmlDocument;
77 77
 			$dom->loadFromFile($fname);
78 78
 			$this->loadFromXml($dom, dirname($fname));
79 79
 		}
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 		{
100 100
 			foreach($config['application'] as $name => $value)
101 101
 			{
102
-				$this->_properties[$name] = $value;
102
+				$this->_properties[$name]=$value;
103 103
 			}
104
-			$this->_empty = false;
104
+			$this->_empty=false;
105 105
 		}
106 106
 
107 107
 		if(isset($config['paths']) && is_array($config['paths']))
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 		// application properties
131 131
 		foreach($dom->getAttributes() as $name => $value)
132 132
 		{
133
-			$this->_properties[$name] = $value;
134
-			$this->_empty = false;
133
+			$this->_properties[$name]=$value;
134
+			$this->_empty=false;
135 135
 		}
136 136
 
137 137
 		foreach($dom->getElements() as $element)
@@ -171,16 +171,16 @@  discard block
 block discarded – undo
171 171
 		{
172 172
 			foreach($pathsNode['aliases'] as $id => $path)
173 173
 			{
174
-				$path = str_replace('\\', '/', $path);
174
+				$path=str_replace('\\', '/', $path);
175 175
 				if(preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
176
-					$p = realpath($path);
176
+					$p=realpath($path);
177 177
 				else
178
-					$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
179
-				if($p === false || !is_dir($p))
178
+					$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
179
+				if($p===false || !is_dir($p))
180 180
 					throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
181 181
 				if(isset($this->_aliases[$id]))
182 182
 					throw new TConfigurationException('appconfig_alias_redefined', $id);
183
-				$this->_aliases[$id] = $p;
183
+				$this->_aliases[$id]=$p;
184 184
 			}
185 185
 		}
186 186
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		{
189 189
 			foreach($pathsNode['using'] as $namespace)
190 190
 			{
191
-				$this->_usings[] = $namespace;
191
+				$this->_usings[]=$namespace;
192 192
 			}
193 193
 		}
194 194
 	}
@@ -206,31 +206,31 @@  discard block
 block discarded – undo
206 206
 			{
207 207
 				case 'alias':
208 208
 				{
209
-					if(($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null)
209
+					if(($id=$element->getAttribute('id'))!==null && ($path=$element->getAttribute('path'))!==null)
210 210
 					{
211
-						$path = str_replace('\\', '/', $path);
211
+						$path=str_replace('\\', '/', $path);
212 212
 						if(preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
213
-							$p = realpath($path);
213
+							$p=realpath($path);
214 214
 						else
215
-							$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
216
-						if($p === false || !is_dir($p))
215
+							$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
216
+						if($p===false || !is_dir($p))
217 217
 							throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
218 218
 						if(isset($this->_aliases[$id]))
219 219
 							throw new TConfigurationException('appconfig_alias_redefined', $id);
220
-						$this->_aliases[$id] = $p;
220
+						$this->_aliases[$id]=$p;
221 221
 					}
222 222
 					else
223 223
 						throw new TConfigurationException('appconfig_alias_invalid');
224
-					$this->_empty = false;
224
+					$this->_empty=false;
225 225
 					break;
226 226
 				}
227 227
 				case 'using':
228 228
 				{
229
-					if(($namespace = $element->getAttribute('namespace')) !== null)
230
-						$this->_usings[] = $namespace;
229
+					if(($namespace=$element->getAttribute('namespace'))!==null)
230
+						$this->_usings[]=$namespace;
231 231
 					else
232 232
 						throw new TConfigurationException('appconfig_using_invalid');
233
-					$this->_empty = false;
233
+					$this->_empty=false;
234 234
 					break;
235 235
 				}
236 236
 				default:
@@ -250,17 +250,17 @@  discard block
 block discarded – undo
250 250
 		{
251 251
 			if(!isset($module['class']))
252 252
 				throw new TConfigurationException('appconfig_moduletype_required', $id);
253
-			$type = $module['class'];
253
+			$type=$module['class'];
254 254
 			unset($module['class']);
255
-			$properties = [];
255
+			$properties=[];
256 256
 			if(isset($module['properties']))
257 257
 			{
258
-				$properties = $module['properties'];
258
+				$properties=$module['properties'];
259 259
 				unset($module['properties']);
260 260
 			}
261
-			$properties['id'] = $id;
262
-			$this->_modules[$id] = [$type,$properties,$module];
263
-			$this->_empty = false;
261
+			$properties['id']=$id;
262
+			$this->_modules[$id]=[$type, $properties, $module];
263
+			$this->_empty=false;
264 264
 		}
265 265
 	}
266 266
 
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
 	{
274 274
 		foreach($modulesNode->getElements() as $element)
275 275
 		{
276
-			if($element->getTagName() === 'module')
276
+			if($element->getTagName()==='module')
277 277
 			{
278
-				$properties = $element->getAttributes();
279
-				$id = $properties->itemAt('id');
280
-				$type = $properties->remove('class');
281
-				if($type === null)
278
+				$properties=$element->getAttributes();
279
+				$id=$properties->itemAt('id');
280
+				$type=$properties->remove('class');
281
+				if($type===null)
282 282
 					throw new TConfigurationException('appconfig_moduletype_required', $id);
283 283
 				$element->setParent(null);
284
-				if($id === null)
285
-					$this->_modules[] = [$type,$properties->toArray(),$element];
284
+				if($id===null)
285
+					$this->_modules[]=[$type, $properties->toArray(), $element];
286 286
 				else
287
-					$this->_modules[$id] = [$type,$properties->toArray(),$element];
288
-				$this->_empty = false;
287
+					$this->_modules[$id]=[$type, $properties->toArray(), $element];
288
+				$this->_empty=false;
289 289
 			}
290 290
 			else
291 291
 				throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName());
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
 		{
304 304
 			if(!isset($service['class']))
305 305
 				throw new TConfigurationException('appconfig_servicetype_required');
306
-			$type = $service['class'];
307
-			$properties = isset($service['properties']) ? $service['properties'] : [];
306
+			$type=$service['class'];
307
+			$properties=isset($service['properties']) ? $service['properties'] : [];
308 308
 			unset($service['properties']);
309
-			$properties['id'] = $id;
310
-			$this->_services[$id] = [$type,$properties,$service];
311
-			$this->_empty = false;
309
+			$properties['id']=$id;
310
+			$this->_services[$id]=[$type, $properties, $service];
311
+			$this->_empty=false;
312 312
 		}
313 313
 	}
314 314
 
@@ -321,16 +321,16 @@  discard block
 block discarded – undo
321 321
 	{
322 322
 		foreach($servicesNode->getElements() as $element)
323 323
 		{
324
-			if($element->getTagName() === 'service')
324
+			if($element->getTagName()==='service')
325 325
 			{
326
-				$properties = $element->getAttributes();
327
-				if(($id = $properties->itemAt('id')) === null)
326
+				$properties=$element->getAttributes();
327
+				if(($id=$properties->itemAt('id'))===null)
328 328
 					throw new TConfigurationException('appconfig_serviceid_required');
329
-				if(($type = $properties->remove('class')) === null)
329
+				if(($type=$properties->remove('class'))===null)
330 330
 					throw new TConfigurationException('appconfig_servicetype_required', $id);
331 331
 				$element->setParent(null);
332
-				$this->_services[$id] = [$type,$properties->toArray(),$element];
333
-				$this->_empty = false;
332
+				$this->_services[$id]=[$type, $properties->toArray(), $element];
333
+				$this->_empty=false;
334 334
 			}
335 335
 			else
336 336
 				throw new TConfigurationException('appconfig_services_invalid', $element->getTagName());
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
 			{
351 351
 				if(isset($parameter['class']))
352 352
 				{
353
-					$type = $parameter['class'];
353
+					$type=$parameter['class'];
354 354
 					unset($parameter['class']);
355
-					$properties = isset($service['properties']) ? $service['properties'] : [];
356
-					$properties['id'] = $id;
357
-					$this->_parameters[$id] = [$type,$properties];
355
+					$properties=isset($service['properties']) ? $service['properties'] : [];
356
+					$properties['id']=$id;
357
+					$this->_parameters[$id]=[$type, $properties];
358 358
 				}
359 359
 			}
360 360
 			else
361 361
 			{
362
-				$this->_parameters[$id] = $parameter;
362
+				$this->_parameters[$id]=$parameter;
363 363
 			}
364 364
 		}
365 365
 	}
@@ -373,21 +373,21 @@  discard block
 block discarded – undo
373 373
 	{
374 374
 		foreach($parametersNode->getElements() as $element)
375 375
 		{
376
-			if($element->getTagName() === 'parameter')
376
+			if($element->getTagName()==='parameter')
377 377
 			{
378
-				$properties = $element->getAttributes();
379
-				if(($id = $properties->remove('id')) === null)
378
+				$properties=$element->getAttributes();
379
+				if(($id=$properties->remove('id'))===null)
380 380
 					throw new TConfigurationException('appconfig_parameterid_required');
381
-				if(($type = $properties->remove('class')) === null)
381
+				if(($type=$properties->remove('class'))===null)
382 382
 				{
383
-					if(($value = $properties->remove('value')) === null)
384
-						$this->_parameters[$id] = $element;
383
+					if(($value=$properties->remove('value'))===null)
384
+						$this->_parameters[$id]=$element;
385 385
 					else
386
-						$this->_parameters[$id] = $value;
386
+						$this->_parameters[$id]=$value;
387 387
 				}
388 388
 				else
389
-					$this->_parameters[$id] = [$type,$properties->toArray()];
390
-				$this->_empty = false;
389
+					$this->_parameters[$id]=[$type, $properties->toArray()];
390
+				$this->_empty=false;
391 391
 			}
392 392
 			else
393 393
 				throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName());
@@ -403,15 +403,15 @@  discard block
 block discarded – undo
403 403
 	{
404 404
 		foreach($includeNode as $include)
405 405
 		{
406
-			$when = isset($include['when'])?true:false;
406
+			$when=isset($include['when']) ?true:false;
407 407
 			if(!isset($include['file']))
408 408
 				throw new TConfigurationException('appconfig_includefile_required');
409
-			$filePath = $include['file'];
409
+			$filePath=$include['file'];
410 410
 			if(isset($this->_includes[$filePath]))
411
-				$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
411
+				$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
412 412
 			else
413
-				$$this->_includes[$filePath] = $when;
414
-			$this->_empty = false;
413
+				$$this->_includes[$filePath]=$when;
414
+			$this->_empty=false;
415 415
 		}
416 416
 	}
417 417
 
@@ -422,15 +422,15 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	protected function loadExternalXml($includeNode, $configPath)
424 424
 	{
425
-		if(($when = $includeNode->getAttribute('when')) === null)
426
-			$when = true;
427
-		if(($filePath = $includeNode->getAttribute('file')) === null)
425
+		if(($when=$includeNode->getAttribute('when'))===null)
426
+			$when=true;
427
+		if(($filePath=$includeNode->getAttribute('file'))===null)
428 428
 			throw new TConfigurationException('appconfig_includefile_required');
429 429
 		if(isset($this->_includes[$filePath]))
430
-			$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
430
+			$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
431 431
 		else
432
-			$this->_includes[$filePath] = $when;
433
-		$this->_empty = false;
432
+			$this->_includes[$filePath]=$when;
433
+		$this->_empty=false;
434 434
 	}
435 435
 
436 436
 	/**
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,8 +70,7 @@  discard block
 block discarded – undo
70 70
 		{
71 71
 			$fcontent = include $fname;
72 72
 			$this->loadFromPhp($fcontent, dirname($fname));
73
-		}
74
-		else
73
+		} else
75 74
 		{
76 75
 			$dom = new TXmlDocument;
77 76
 			$dom->loadFromFile($fname);
@@ -218,8 +217,7 @@  discard block
 block discarded – undo
218 217
 						if(isset($this->_aliases[$id]))
219 218
 							throw new TConfigurationException('appconfig_alias_redefined', $id);
220 219
 						$this->_aliases[$id] = $p;
221
-					}
222
-					else
220
+					} else
223 221
 						throw new TConfigurationException('appconfig_alias_invalid');
224 222
 					$this->_empty = false;
225 223
 					break;
@@ -286,8 +284,7 @@  discard block
 block discarded – undo
286 284
 				else
287 285
 					$this->_modules[$id] = [$type,$properties->toArray(),$element];
288 286
 				$this->_empty = false;
289
-			}
290
-			else
287
+			} else
291 288
 				throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName());
292 289
 		}
293 290
 	}
@@ -331,8 +328,7 @@  discard block
 block discarded – undo
331 328
 				$element->setParent(null);
332 329
 				$this->_services[$id] = [$type,$properties->toArray(),$element];
333 330
 				$this->_empty = false;
334
-			}
335
-			else
331
+			} else
336 332
 				throw new TConfigurationException('appconfig_services_invalid', $element->getTagName());
337 333
 		}
338 334
 	}
@@ -356,8 +352,7 @@  discard block
 block discarded – undo
356 352
 					$properties['id'] = $id;
357 353
 					$this->_parameters[$id] = [$type,$properties];
358 354
 				}
359
-			}
360
-			else
355
+			} else
361 356
 			{
362 357
 				$this->_parameters[$id] = $parameter;
363 358
 			}
@@ -384,12 +379,10 @@  discard block
 block discarded – undo
384 379
 						$this->_parameters[$id] = $element;
385 380
 					else
386 381
 						$this->_parameters[$id] = $value;
387
-				}
388
-				else
382
+				} else
389 383
 					$this->_parameters[$id] = [$type,$properties->toArray()];
390 384
 				$this->_empty = false;
391
-			}
392
-			else
385
+			} else
393 386
 				throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName());
394 387
 		}
395 388
 	}
Please login to merge, or discard this patch.
framework/Security/TAuthorizationRuleCollection.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@
 block discarded – undo
34 34
 	{
35 35
 		if($user instanceof IUser)
36 36
 		{
37
-			$verb = strtolower(trim($verb));
37
+			$verb=strtolower(trim($verb));
38 38
 			foreach($this as $rule)
39 39
 			{
40
-				if(($decision = $rule->isUserAllowed($user, $verb, $ip)) !== 0)
40
+				if(($decision=$rule->isUserAllowed($user, $verb, $ip))!==0)
41 41
 					return ($decision > 0);
42 42
 			}
43 43
 			return true;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,7 @@
 block discarded – undo
41 41
 					return ($decision > 0);
42 42
 			}
43 43
 			return true;
44
-		}
45
-		else
44
+		} else
46 45
 			return false;
47 46
 	}
48 47
 
Please login to merge, or discard this patch.
framework/Security/TUserManagerPasswordMode.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
  */
28 28
 class TUserManagerPasswordMode extends \Prado\TEnumerable
29 29
 {
30
-	const Clear = 'Clear';
31
-	const MD5 = 'MD5';
32
-	const SHA1 = 'SHA1';
30
+	const Clear='Clear';
31
+	const MD5='MD5';
32
+	const SHA1='SHA1';
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Security/TDbUser.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,19 +37,19 @@
 block discarded – undo
37 37
 	 */
38 38
 	public function getDbConnection()
39 39
 	{
40
-		if($this->_connection === null)
40
+		if($this->_connection===null)
41 41
 		{
42
-			$userManager = $this->getManager();
42
+			$userManager=$this->getManager();
43 43
 			if($userManager instanceof TDbUserManager)
44 44
 			{
45
-				$connection = $userManager->getDbConnection();
45
+				$connection=$userManager->getDbConnection();
46 46
 				if($connection instanceof TDbConnection)
47 47
 				{
48 48
 					$connection->setActive(true);
49
-					$this->_connection = $connection;
49
+					$this->_connection=$connection;
50 50
 				}
51 51
 			}
52
-			if($this->_connection === null)
52
+			if($this->_connection===null)
53 53
 				throw new TConfigurationException('dbuser_dbconnection_invalid');
54 54
 		}
55 55
 		return $this->_connection;
Please login to merge, or discard this patch.
framework/Security/TUserManager.php 2 patches
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -75,28 +75,28 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * extension name to the user file
77 77
 	 */
78
-	const USER_FILE_EXT = '.xml';
78
+	const USER_FILE_EXT='.xml';
79 79
 
80 80
 	/**
81 81
 	 * @var array list of users managed by this module
82 82
 	 */
83
-	private $_users = [];
83
+	private $_users=[];
84 84
 	/**
85 85
 	 * @var array list of roles managed by this module
86 86
 	 */
87
-	private $_roles = [];
87
+	private $_roles=[];
88 88
 	/**
89 89
 	 * @var string guest name
90 90
 	 */
91
-	private $_guestName = 'Guest';
91
+	private $_guestName='Guest';
92 92
 	/**
93 93
 	 * @var TUserManagerPasswordMode password mode
94 94
 	 */
95
-	private $_passwordMode = TUserManagerPasswordMode::MD5;
95
+	private $_passwordMode=TUserManagerPasswordMode::MD5;
96 96
 	/**
97 97
 	 * @var boolean whether the module has been initialized
98 98
 	 */
99
-	private $_initialized = false;
99
+	private $_initialized=false;
100 100
 	/**
101 101
 	 * @var string user/role information file
102 102
 	 */
@@ -111,21 +111,21 @@  discard block
 block discarded – undo
111 111
 	public function init($config)
112 112
 	{
113 113
 		$this->loadUserData($config);
114
-		if($this->_userFile !== null)
114
+		if($this->_userFile!==null)
115 115
 		{
116
-			if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
116
+			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
117 117
 			{
118
-				$userFile = include $this->_userFile;
118
+				$userFile=include $this->_userFile;
119 119
 				$this->loadUserDataFromPhp($userFile);
120 120
 			}
121 121
 			else
122 122
 			{
123
-				$dom = new TXmlDocument;
123
+				$dom=new TXmlDocument;
124 124
 				$dom->loadFromFile($this->_userFile);
125 125
 				$this->loadUserDataFromXml($dom);
126 126
 			}
127 127
 		}
128
-		$this->_initialized = true;
128
+		$this->_initialized=true;
129 129
 	}
130 130
 
131 131
 	/*
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	private function loadUserData($config)
136 136
 	{
137
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
137
+		if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
138 138
 			$this->loadUserDataFromPhp($config);
139 139
 		else
140 140
 			$this->loadUserDataFromXml($config);
@@ -150,16 +150,16 @@  discard block
 block discarded – undo
150 150
 		{
151 151
 			foreach($config['users'] as $user)
152 152
 			{
153
-				$name = trim(strtolower(isset($user['name'])?$user['name']:''));
154
-				$password = isset($user['password'])?$user['password']:'';
155
-				$this->_users[$name] = $password;
156
-				$roles = isset($user['roles'])?$user['roles']:'';
157
-				if($roles !== '')
153
+				$name=trim(strtolower(isset($user['name']) ? $user['name'] : ''));
154
+				$password=isset($user['password']) ? $user['password'] : '';
155
+				$this->_users[$name]=$password;
156
+				$roles=isset($user['roles']) ? $user['roles'] : '';
157
+				if($roles!=='')
158 158
 				{
159 159
 					foreach(explode(',', $roles) as $role)
160 160
 					{
161
-						if(($role = trim($role)) !== '')
162
-							$this->_roles[$name][] = $role;
161
+						if(($role=trim($role))!=='')
162
+							$this->_roles[$name][]=$role;
163 163
 					}
164 164
 				}
165 165
 			}
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 		{
169 169
 			foreach($config['roles'] as $role)
170 170
 			{
171
-				$name = isset($role['name'])?$role['name']:'';
172
-				$users = isset($role['users'])?$role['users']:'';
171
+				$name=isset($role['name']) ? $role['name'] : '';
172
+				$users=isset($role['users']) ? $role['users'] : '';
173 173
 				foreach(explode(',', $users) as $user)
174 174
 				{
175
-					if(($user = trim($user)) !== '')
176
-						$this->_roles[strtolower($user)][] = $name;
175
+					if(($user=trim($user))!=='')
176
+						$this->_roles[strtolower($user)][]=$name;
177 177
 				}
178 178
 			}
179 179
 		}
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
 	{
188 188
 		foreach($xmlNode->getElementsByTagName('user') as $node)
189 189
 		{
190
-			$name = trim(strtolower($node->getAttribute('name')));
191
-			$this->_users[$name] = $node->getAttribute('password');
192
-			if(($roles = trim($node->getAttribute('roles'))) !== '')
190
+			$name=trim(strtolower($node->getAttribute('name')));
191
+			$this->_users[$name]=$node->getAttribute('password');
192
+			if(($roles=trim($node->getAttribute('roles')))!=='')
193 193
 			{
194 194
 				foreach(explode(',', $roles) as $role)
195 195
 				{
196
-					if(($role = trim($role)) !== '')
197
-						$this->_roles[$name][] = $role;
196
+					if(($role=trim($role))!=='')
197
+						$this->_roles[$name][]=$role;
198 198
 				}
199 199
 			}
200 200
 		}
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 		{
203 203
 			foreach(explode(',', $node->getAttribute('users')) as $user)
204 204
 			{
205
-				if(($user = trim($user)) !== '')
206
-					$this->_roles[strtolower($user)][] = $node->getAttribute('name');
205
+				if(($user=trim($user))!=='')
206
+					$this->_roles[strtolower($user)][]=$node->getAttribute('name');
207 207
 			}
208 208
 		}
209 209
 	}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	{
251 251
 		if($this->_initialized)
252 252
 			throw new TInvalidOperationException('usermanager_userfile_unchangeable');
253
-		elseif(($this->_userFile = Prado::getPathOfNamespace($value, self::USER_FILE_EXT)) === null || !is_file($this->_userFile))
253
+		elseif(($this->_userFile=Prado::getPathOfNamespace($value, self::USER_FILE_EXT))===null || !is_file($this->_userFile))
254 254
 			throw new TConfigurationException('usermanager_userfile_invalid', $value);
255 255
 	}
256 256
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 */
268 268
 	public function setGuestName($value)
269 269
 	{
270
-		$this->_guestName = $value;
270
+		$this->_guestName=$value;
271 271
 	}
272 272
 
273 273
 	/**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	public function setPasswordMode($value)
285 285
 	{
286
-		$this->_passwordMode = TPropertyValue::ensureEnum($value, 'Prado\\Security\\TUserManagerPasswordMode');
286
+		$this->_passwordMode=TPropertyValue::ensureEnum($value, 'Prado\\Security\\TUserManagerPasswordMode');
287 287
 	}
288 288
 
289 289
 	/**
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	public function validateUser($username, $password)
296 296
 	{
297
-		if($this->_passwordMode === TUserManagerPasswordMode::MD5)
298
-			$password = md5($password);
299
-		elseif($this->_passwordMode === TUserManagerPasswordMode::SHA1)
300
-			$password = sha1($password);
301
-		$username = strtolower($username);
302
-		return (isset($this->_users[$username]) && $this->_users[$username] === $password);
297
+		if($this->_passwordMode===TUserManagerPasswordMode::MD5)
298
+			$password=md5($password);
299
+		elseif($this->_passwordMode===TUserManagerPasswordMode::SHA1)
300
+			$password=sha1($password);
301
+		$username=strtolower($username);
302
+		return (isset($this->_users[$username]) && $this->_users[$username]===$password);
303 303
 	}
304 304
 
305 305
 	/**
@@ -307,20 +307,20 @@  discard block
 block discarded – undo
307 307
 	 * @param string user name, null if it is a guest.
308 308
 	 * @return TUser the user instance, null if the specified username is not in the user database.
309 309
 	 */
310
-	public function getUser($username = null)
310
+	public function getUser($username=null)
311 311
 	{
312
-		if($username === null)
312
+		if($username===null)
313 313
 		{
314
-			$user = new TUser($this);
314
+			$user=new TUser($this);
315 315
 			$user->setIsGuest(true);
316 316
 			return $user;
317 317
 		}
318 318
 		else
319 319
 		{
320
-			$username = strtolower($username);
320
+			$username=strtolower($username);
321 321
 			if(isset($this->_users[$username]))
322 322
 			{
323
-				$user = new TUser($this);
323
+				$user=new TUser($this);
324 324
 				$user->setName($username);
325 325
 				$user->setIsGuest(false);
326 326
 				if(isset($this->_roles[$username]))
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 	 */
341 341
 	public function getUserFromCookie($cookie)
342 342
 	{
343
-		if(($data = $cookie->getValue()) !== '')
343
+		if(($data=$cookie->getValue())!=='')
344 344
 		{
345
-			$data = unserialize($data);
346
-			if(is_array($data) && count($data) === 2)
345
+			$data=unserialize($data);
346
+			if(is_array($data) && count($data)===2)
347 347
 			{
348
-				list($username, $token) = $data;
349
-				if(isset($this->_users[$username]) && $token === md5($username . $this->_users[$username]))
348
+				list($username, $token)=$data;
349
+				if(isset($this->_users[$username]) && $token===md5($username.$this->_users[$username]))
350 350
 					return $this->getUser($username);
351 351
 			}
352 352
 		}
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	public function saveUserToCookie($cookie)
362 362
 	{
363
-		$user = $this->getApplication()->getUser();
364
-		$username = strtolower($user->getName());
363
+		$user=$this->getApplication()->getUser();
364
+		$username=strtolower($user->getName());
365 365
 		if(isset($this->_users[$username]))
366 366
 		{
367
-			$data = [$username,md5($username . $this->_users[$username])];
367
+			$data=[$username, md5($username.$this->_users[$username])];
368 368
 			$cookie->setValue(serialize($data));
369 369
 		}
370 370
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -117,8 +117,7 @@  discard block
 block discarded – undo
117 117
 			{
118 118
 				$userFile = include $this->_userFile;
119 119
 				$this->loadUserDataFromPhp($userFile);
120
-			}
121
-			else
120
+			} else
122 121
 			{
123 122
 				$dom = new TXmlDocument;
124 123
 				$dom->loadFromFile($this->_userFile);
@@ -314,8 +313,7 @@  discard block
 block discarded – undo
314 313
 			$user = new TUser($this);
315 314
 			$user->setIsGuest(true);
316 315
 			return $user;
317
-		}
318
-		else
316
+		} else
319 317
 		{
320 318
 			$username = strtolower($username);
321 319
 			if(isset($this->_users[$username]))
@@ -326,8 +324,7 @@  discard block
 block discarded – undo
326 324
 				if(isset($this->_roles[$username]))
327 325
 					$user->setRoles($this->_roles[$username]);
328 326
 				return $user;
329
-			}
330
-			else
327
+			} else
331 328
 				return null;
332 329
 		}
333 330
 	}
Please login to merge, or discard this patch.
framework/Security/TAuthManager.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * GET variable name for return url
49 49
 	 */
50
-	const RETURN_URL_VAR = 'ReturnUrl';
50
+	const RETURN_URL_VAR='ReturnUrl';
51 51
 	/**
52 52
 	 * @var boolean if the module has been initialized
53 53
 	 */
54
-	private $_initialized = false;
54
+	private $_initialized=false;
55 55
 	/**
56 56
 	 * @var IUserManager user manager instance
57 57
 	 */
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	/**
64 64
 	 * @var boolean whether authorization should be skipped
65 65
 	 */
66
-	private $_skipAuthorization = false;
66
+	private $_skipAuthorization=false;
67 67
 	/**
68 68
 	 * @var string the session var name for storing return URL
69 69
 	 */
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	/**
72 72
 	 * @var boolean whether to allow auto login (using cookie)
73 73
 	 */
74
-	private $_allowAutoLogin = false;
74
+	private $_allowAutoLogin=false;
75 75
 	/**
76 76
 	 * @var string variable name used to store user session or cookie
77 77
 	 */
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	/**
80 80
 	 * @var integer authentication expiration time in seconds. Defaults to zero (no expiration)
81 81
 	 */
82
-	private $_authExpire = 0;
82
+	private $_authExpire=0;
83 83
 
84 84
 	/**
85 85
 	 * Initializes this module.
@@ -89,23 +89,23 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function init($config)
91 91
 	{
92
-		if($this->_userManager === null)
92
+		if($this->_userManager===null)
93 93
 			throw new TConfigurationException('authmanager_usermanager_required');
94
-		if($this->_returnUrlVarName === null)
95
-			$this->_returnUrlVarName = $this->getApplication()->getID() . ':' . self::RETURN_URL_VAR;
96
-		$application = $this->getApplication();
94
+		if($this->_returnUrlVarName===null)
95
+			$this->_returnUrlVarName=$this->getApplication()->getID().':'.self::RETURN_URL_VAR;
96
+		$application=$this->getApplication();
97 97
 		if(is_string($this->_userManager))
98 98
 		{
99
-			if(($users = $application->getModule($this->_userManager)) === null)
99
+			if(($users=$application->getModule($this->_userManager))===null)
100 100
 				throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager);
101 101
 			if(!($users instanceof IUserManager))
102 102
 				throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
103
-			$this->_userManager = $users;
103
+			$this->_userManager=$users;
104 104
 		}
105
-		$application->attachEventHandler('OnAuthentication', [$this,'doAuthentication']);
106
-		$application->attachEventHandler('OnEndRequest', [$this,'leave']);
107
-		$application->attachEventHandler('OnAuthorization', [$this,'doAuthorization']);
108
-		$this->_initialized = true;
105
+		$application->attachEventHandler('OnAuthentication', [$this, 'doAuthentication']);
106
+		$application->attachEventHandler('OnEndRequest', [$this, 'leave']);
107
+		$application->attachEventHandler('OnAuthorization', [$this, 'doAuthorization']);
108
+		$this->_initialized=true;
109 109
 	}
110 110
 
111 111
 	/**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			throw new TInvalidOperationException('authmanager_usermanager_unchangeable');
127 127
 		if(!is_string($provider) && !($provider instanceof IUserManager))
128 128
 			throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
129
-		$this->_userManager = $provider;
129
+		$this->_userManager=$provider;
130 130
 	}
131 131
 
132 132
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	public function setLoginPage($pagePath)
147 147
 	{
148
-		$this->_loginPage = $pagePath;
148
+		$this->_loginPage=$pagePath;
149 149
 	}
150 150
 
151 151
 	/**
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	{
160 160
 		$this->onAuthenticate($param);
161 161
 
162
-		$service = $this->getService();
163
-		if(($service instanceof TPageService) && $service->getRequestedPagePath() === $this->getLoginPage())
164
-			$this->_skipAuthorization = true;
162
+		$service=$this->getService();
163
+		if(($service instanceof TPageService) && $service->getRequestedPagePath()===$this->getLoginPage())
164
+			$this->_skipAuthorization=true;
165 165
 	}
166 166
 
167 167
 	/**
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public function leave($sender, $param)
190 190
 	{
191
-		$application = $this->getApplication();
192
-		if($application->getResponse()->getStatusCode() === 401)
191
+		$application=$this->getApplication();
192
+		if($application->getResponse()->getStatusCode()===401)
193 193
 		{
194
-			$service = $application->getService();
194
+			$service=$application->getService();
195 195
 			if($service instanceof TPageService)
196 196
 			{
197
-				$returnUrl = $application->getRequest()->getRequestUri();
197
+				$returnUrl=$application->getRequest()->getRequestUri();
198 198
 				$this->setReturnUrl($returnUrl);
199
-				$url = $service->constructUrl($this->getLoginPage());
199
+				$url=$service->constructUrl($this->getLoginPage());
200 200
 				$application->getResponse()->redirect($url);
201 201
 			}
202 202
 		}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function setReturnUrlVarName($value)
217 217
 	{
218
-		$this->_returnUrlVarName = $value;
218
+		$this->_returnUrlVarName=$value;
219 219
 	}
220 220
 
221 221
 	/**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function setAllowAutoLogin($value)
252 252
 	{
253
-		$this->_allowAutoLogin = TPropertyValue::ensureBoolean($value);
253
+		$this->_allowAutoLogin=TPropertyValue::ensureBoolean($value);
254 254
 	}
255 255
 
256 256
 	/**
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 */
269 269
 	public function setAuthExpire($value)
270 270
 	{
271
-		$this->_authExpire = TPropertyValue::ensureInteger($value);
271
+		$this->_authExpire=TPropertyValue::ensureInteger($value);
272 272
 	}
273 273
 
274 274
 	/**
@@ -281,31 +281,31 @@  discard block
 block discarded – undo
281 281
 	 */
282 282
 	public function onAuthenticate($param)
283 283
 	{
284
-		$application = $this->getApplication();
284
+		$application=$this->getApplication();
285 285
 
286 286
 		// restoring user info from session
287
-		if(($session = $application->getSession()) === null)
287
+		if(($session=$application->getSession())===null)
288 288
 			throw new TConfigurationException('authmanager_session_required');
289 289
 		$session->open();
290
-		$sessionInfo = $session->itemAt($this->getUserKey());
291
-		$user = $this->_userManager->getUser(null)->loadFromString($sessionInfo);
290
+		$sessionInfo=$session->itemAt($this->getUserKey());
291
+		$user=$this->_userManager->getUser(null)->loadFromString($sessionInfo);
292 292
 
293 293
 		// check for authentication expiration
294
-		$isAuthExpired = $this->_authExpire > 0 && !$user->getIsGuest() &&
295
-		($expiretime = $session->itemAt('AuthExpireTime')) && $expiretime < time();
294
+		$isAuthExpired=$this->_authExpire > 0 && !$user->getIsGuest() &&
295
+		($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime < time();
296 296
 
297 297
 		// try authenticating through cookie if possible
298 298
 		if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired))
299 299
 		{
300
-			$cookie = $this->getRequest()->getCookies()->itemAt($this->getUserKey());
300
+			$cookie=$this->getRequest()->getCookies()->itemAt($this->getUserKey());
301 301
 			if($cookie instanceof THttpCookie)
302 302
 			{
303
-				if(($user2 = $this->_userManager->getUserFromCookie($cookie)) !== null)
303
+				if(($user2=$this->_userManager->getUserFromCookie($cookie))!==null)
304 304
 				{
305
-					$user = $user2;
305
+					$user=$user2;
306 306
 					$this->updateSessionUser($user);
307 307
 					// user is restored from cookie, auth may not expire
308
-					$isAuthExpired = false;
308
+					$isAuthExpired=false;
309 309
 				}
310 310
 			}
311 311
 		}
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	 */
345 345
 	public function onAuthorize($param)
346 346
 	{
347
-		$application = $this->getApplication();
347
+		$application=$this->getApplication();
348 348
 		if($this->hasEventHandler('OnAuthorize'))
349 349
 			$this->raiseEvent('OnAuthorize', $this, $application);
350 350
 		if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress()))
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	public function getUserKey()
362 362
 	{
363
-		if($this->_userKey === null)
364
-			$this->_userKey = $this->generateUserKey();
363
+		if($this->_userKey===null)
364
+			$this->_userKey=$this->generateUserKey();
365 365
 		return $this->_userKey;
366 366
 	}
367 367
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	protected function generateUserKey()
373 373
 	{
374
-		return md5($this->getApplication()->getUniqueID() . 'prado:user');
374
+		return md5($this->getApplication()->getUniqueID().'prado:user');
375 375
 	}
376 376
 
377 377
 	/**
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	{
384 384
 		if(!$user->getIsGuest())
385 385
 		{
386
-			if(($session = $this->getSession()) === null)
386
+			if(($session=$this->getSession())===null)
387 387
 				throw new TConfigurationException('authmanager_session_required');
388 388
 			else
389 389
 				$session->add($this->getUserKey(), $user->saveToString());
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	public function switchUser($username)
400 400
 	{
401
-		if(($user = $this->_userManager->getUser($username)) === null)
401
+		if(($user=$this->_userManager->getUser($username))===null)
402 402
 			return false;
403 403
 		$this->updateSessionUser($user);
404 404
 		$this->getApplication()->setUser($user);
@@ -414,18 +414,18 @@  discard block
 block discarded – undo
414 414
 	 * @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.
415 415
 	 * @return boolean if login is successful
416 416
 	 */
417
-	public function login($username, $password, $expire = 0)
417
+	public function login($username, $password, $expire=0)
418 418
 	{
419 419
 		if($this->_userManager->validateUser($username, $password))
420 420
 		{
421
-			if(($user = $this->_userManager->getUser($username)) === null)
421
+			if(($user=$this->_userManager->getUser($username))===null)
422 422
 				return false;
423 423
 			$this->updateSessionUser($user);
424 424
 			$this->getApplication()->setUser($user);
425 425
 
426 426
 			if($expire > 0)
427 427
 			{
428
-				$cookie = new THttpCookie($this->getUserKey(), '');
428
+				$cookie=new THttpCookie($this->getUserKey(), '');
429 429
 				$cookie->setExpire(time() + $expire);
430 430
 				$this->_userManager->saveUserToCookie($cookie);
431 431
 				$this->getResponse()->getCookies()->add($cookie);
@@ -443,13 +443,13 @@  discard block
 block discarded – undo
443 443
 	 */
444 444
 	public function logout()
445 445
 	{
446
-		if(($session = $this->getSession()) === null)
446
+		if(($session=$this->getSession())===null)
447 447
 			throw new TConfigurationException('authmanager_session_required');
448 448
 		$this->getApplication()->getUser()->setIsGuest(true);
449 449
 		$session->destroy();
450 450
 		if($this->getAllowAutoLogin())
451 451
 		{
452
-			$cookie = new THttpCookie($this->getUserKey(), '');
452
+			$cookie=new THttpCookie($this->getUserKey(), '');
453 453
 			$this->getResponse()->getCookies()->add($cookie);
454 454
 		}
455 455
 	}
Please login to merge, or discard this patch.
framework/Security/TDbUserManager.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
  */
49 49
 class TDbUserManager extends \Prado\TModule implements IUserManager
50 50
 {
51
-	private $_connID = '';
51
+	private $_connID='';
52 52
 	private $_conn;
53
-	private $_guestName = 'Guest';
54
-	private $_userClass = '';
53
+	private $_guestName='Guest';
54
+	private $_userClass='';
55 55
 	private $_userFactory;
56 56
 
57 57
 	/**
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function init($config)
63 63
 	{
64
-		if($this->_userClass === '')
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 68
 			throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass);
69 69
 	}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function setUserClass($value)
83 83
 	{
84
-		$this->_userClass = $value;
84
+		$this->_userClass=$value;
85 85
 	}
86 86
 
87 87
 	/**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function setGuestName($value)
99 99
 	{
100
-		$this->_guestName = $value;
100
+		$this->_guestName=$value;
101 101
 	}
102 102
 
103 103
 	/**
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 * @param string user name, null if it is a guest.
117 117
 	 * @return TUser the user instance, null if the specified username is not in the user database.
118 118
 	 */
119
-	public function getUser($username = null)
119
+	public function getUser($username=null)
120 120
 	{
121
-		if($username === null)
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
 		}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	public function setConnectionID($value)
146 146
 	{
147
-		$this->_connID = $value;
147
+		$this->_connID=$value;
148 148
 	}
149 149
 
150 150
 	/**
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function getDbConnection()
154 154
 	{
155
-		if($this->_conn === null)
155
+		if($this->_conn===null)
156 156
 		{
157
-			$this->_conn = $this->createDbConnection($this->_connID);
157
+			$this->_conn=$this->createDbConnection($this->_connID);
158 158
 			$this->_conn->setActive(true);
159 159
 		}
160 160
 		return $this->_conn;
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	protected function createDbConnection($connectionID)
170 170
 	{
171
-		if($connectionID !== '')
171
+		if($connectionID!=='')
172 172
 		{
173
-			$conn = $this->getApplication()->getModule($connectionID);
173
+			$conn=$this->getApplication()->getModule($connectionID);
174 174
 			if($conn instanceof TDataSourceConfig)
175 175
 				return $conn->getDbConnection();
176 176
 			else
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function saveUserToCookie($cookie)
200 200
 	{
201
-		$user = $this->getApplication()->getUser();
201
+		$user=$this->getApplication()->getUser();
202 202
 		if($user instanceof TDbUser)
203 203
 			$user->saveUserToCookie($cookie);
204 204
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -123,8 +123,7 @@  discard block
 block discarded – undo
123 123
 			$user = Prado::createComponent($this->_userClass, $this);
124 124
 			$user->setIsGuest(true);
125 125
 			return $user;
126
-		}
127
-		else
126
+		} else
128 127
 			return $this->_userFactory->createUser($username);
129 128
 	}
130 129
 
@@ -175,8 +174,7 @@  discard block
 block discarded – undo
175 174
 				return $conn->getDbConnection();
176 175
 			else
177 176
 				throw new TConfigurationException('dbusermanager_connectionid_invalid', $connectionID);
178
-		}
179
-		else
177
+		} else
180 178
 			throw new TConfigurationException('dbusermanager_connectionid_required');
181 179
 	}
182 180
 
Please login to merge, or discard this patch.
framework/Security/TSecurityManager.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
  */
51 51
 class TSecurityManager extends \Prado\TModule
52 52
 {
53
-	const STATE_VALIDATION_KEY = 'prado:securitymanager:validationkey';
54
-	const STATE_ENCRYPTION_KEY = 'prado:securitymanager:encryptionkey';
53
+	const STATE_VALIDATION_KEY='prado:securitymanager:validationkey';
54
+	const STATE_ENCRYPTION_KEY='prado:securitymanager:encryptionkey';
55 55
 
56 56
 	private $_validationKey;
57 57
 	private $_encryptionKey;
58
-	private $_hashAlgorithm = 'sha256';
59
-	private $_cryptAlgorithm = 'aes-256-cbc';
58
+	private $_hashAlgorithm='sha256';
59
+	private $_cryptAlgorithm='aes-256-cbc';
60 60
 	private $_mbstring;
61 61
 
62 62
 	/**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function init($config)
68 68
 	{
69
-		$this->_mbstring = extension_loaded('mbstring');
69
+		$this->_mbstring=extension_loaded('mbstring');
70 70
 		$this->getApplication()->setSecurityManager($this);
71 71
 	}
72 72
 
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function getValidationKey()
86 86
 	{
87
-		if(null === $this->_validationKey) {
88
-			if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
89
-				$this->_validationKey = $this->generateRandomKey();
87
+		if(null===$this->_validationKey) {
88
+			if(null===($this->_validationKey=$this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
89
+				$this->_validationKey=$this->generateRandomKey();
90 90
 				$this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true);
91 91
 			}
92 92
 		}
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function setValidationKey($value)
101 101
 	{
102
-		if('' === $value)
102
+		if(''===$value)
103 103
 			throw new TInvalidDataValueException('securitymanager_validationkey_invalid');
104 104
 
105
-		$this->_validationKey = $value;
105
+		$this->_validationKey=$value;
106 106
 	}
107 107
 
108 108
 	/**
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function getEncryptionKey()
113 113
 	{
114
-		if(null === $this->_encryptionKey) {
115
-			if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
116
-				$this->_encryptionKey = $this->generateRandomKey();
114
+		if(null===$this->_encryptionKey) {
115
+			if(null===($this->_encryptionKey=$this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
116
+				$this->_encryptionKey=$this->generateRandomKey();
117 117
 				$this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true);
118 118
 			}
119 119
 		}
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function setEncryptionKey($value)
128 128
 	{
129
-		if('' === $value)
129
+		if(''===$value)
130 130
 			throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid');
131 131
 
132
-		$this->_encryptionKey = $value;
132
+		$this->_encryptionKey=$value;
133 133
 	}
134 134
 
135 135
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function setHashAlgorithm($value)
149 149
 	{
150
-		$this->_hashAlgorithm = TPropertyValue::ensureString($value);
150
+		$this->_hashAlgorithm=TPropertyValue::ensureString($value);
151 151
 		if(!in_array($this->_hashAlgorithm, hash_algos()))
152 152
 			throw new TInvalidDataValueException('securitymanager_hash_algorithm_invalid');
153 153
 	}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function setCryptAlgorithm($value)
168 168
 	{
169
-		$this->_cryptAlgorithm = TPropertyValue::ensureString($value);
169
+		$this->_cryptAlgorithm=TPropertyValue::ensureString($value);
170 170
 		if(!in_array($this->_hashAlgorithm, openssl_get_cipher_methods()))
171 171
 			throw new TInvalidDataValueException('securitymanager_crypt_algorithm_invalid');
172 172
 	}
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	{
182 182
 		if(extension_loaded('openssl'))
183 183
 		{
184
-			$key = md5($this->getEncryptionKey());
185
-			$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->_cryptAlgorithm));
186
-			return $iv . openssl_encrypt($data, $this->_cryptAlgorithm, $key, null, $iv);
184
+			$key=md5($this->getEncryptionKey());
185
+			$iv=openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->_cryptAlgorithm));
186
+			return $iv.openssl_encrypt($data, $this->_cryptAlgorithm, $key, null, $iv);
187 187
 		}
188 188
 		else
189 189
 			throw new TNotSupportedException('securitymanager_openssl_required');
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	{
200 200
 		if(extension_loaded('openssl'))
201 201
 		{
202
-			$key = md5($this->getEncryptionKey());
203
-			$iv = $this->substr($data, 0, openssl_cipher_iv_length($this->_cryptAlgorithm));
202
+			$key=md5($this->getEncryptionKey());
203
+			$iv=$this->substr($data, 0, openssl_cipher_iv_length($this->_cryptAlgorithm));
204 204
 			return openssl_decrypt($this->substr($data, $this->strlen($iv), $this->strlen($data)), $this->_cryptAlgorithm, $key, null, $iv);
205 205
 		}
206 206
 		else
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function hashData($data)
216 216
 	{
217
-		$hmac = $this->computeHMAC($data);
218
-		return $hmac . $data;
217
+		$hmac=$this->computeHMAC($data);
218
+		return $hmac.$data;
219 219
 	}
220 220
 
221 221
 	/**
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function validateData($data)
229 229
 	{
230
-		$len = $this->strlen($this->computeHMAC('test'));
230
+		$len=$this->strlen($this->computeHMAC('test'));
231 231
 
232 232
 		if($this->strlen($data) < $len)
233 233
 			return false;
234 234
 
235
-		$hmac = $this->substr($data, 0, $len);
236
-		$data2 = $this->substr($data, $len, $this->strlen($data));
237
-		return $hmac === $this->computeHMAC($data2) ? $data2 : false;
235
+		$hmac=$this->substr($data, 0, $len);
236
+		$data2=$this->substr($data, $len, $this->strlen($data));
237
+		return $hmac===$this->computeHMAC($data2) ? $data2 : false;
238 238
 	}
239 239
 
240 240
 	/**
Please login to merge, or discard this patch.