Passed
Branch php-cs-fixer (b9836a)
by Fabio
15:58
created
framework/TApplication.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 		$this->setConfigurationType($configType);
301 301
 		$this->resolvePaths($basePath);
302 302
 
303
-		if($cacheConfig)
304
-			$this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE;
303
+		if ($cacheConfig)
304
+			$this->_cacheFile = $this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
305 305
 
306 306
 		// generates unique ID by hashing the runtime path
307 307
 		$this->_uniqueID = md5($this->_runtimePath);
308 308
 		$this->_parameters = new \Prado\Collections\TMap;
309
-		$this->_services = [$this->getPageServiceID() => ['TPageService',[],null]];
309
+		$this->_services = [$this->getPageServiceID() => ['TPageService', [], null]];
310 310
 
311 311
 		Prado::setPathOfAlias('Application', $this->_basePath);
312 312
 	}
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 	protected function resolvePaths($basePath)
325 325
 	{
326 326
 		// determine configuration path and file
327
-		if(empty($basePath) || ($basePath = realpath($basePath)) === false)
327
+		if (empty($basePath) || ($basePath = realpath($basePath)) === false)
328 328
 			throw new TConfigurationException('application_basepath_invalid', $basePath);
329
-		if(is_dir($basePath) && is_file($basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName()))
330
-			$configFile = $basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName();
331
-		elseif(is_file($basePath))
329
+		if (is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName()))
330
+			$configFile = $basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName();
331
+		elseif (is_file($basePath))
332 332
 		{
333 333
 			$configFile = $basePath;
334 334
 			$basePath = dirname($configFile);
@@ -337,15 +337,15 @@  discard block
 block discarded – undo
337 337
 			$configFile = null;
338 338
 
339 339
 		// determine runtime path
340
-		$runtimePath = $basePath . DIRECTORY_SEPARATOR . self::RUNTIME_PATH;
341
-		if(is_writable($runtimePath))
340
+		$runtimePath = $basePath.DIRECTORY_SEPARATOR.self::RUNTIME_PATH;
341
+		if (is_writable($runtimePath))
342 342
 		{
343
-			if($configFile !== null)
343
+			if ($configFile !== null)
344 344
 			{
345
-				$runtimePath .= DIRECTORY_SEPARATOR . basename($configFile) . '-' . Prado::getVersion();
346
-				if(!is_dir($runtimePath))
345
+				$runtimePath .= DIRECTORY_SEPARATOR.basename($configFile).'-'.Prado::getVersion();
346
+				if (!is_dir($runtimePath))
347 347
 				{
348
-					if(@mkdir($runtimePath) === false)
348
+					if (@mkdir($runtimePath) === false)
349 349
 						throw new TConfigurationException('application_runtimepath_failed', $runtimePath);
350 350
 					@chmod($runtimePath, PRADO_CHMOD); //make it deletable
351 351
 				}
@@ -372,11 +372,11 @@  discard block
 block discarded – undo
372 372
 			$n = count(self::$_steps);
373 373
 			$this->_step = 0;
374 374
 			$this->_requestCompleted = false;
375
-			while($this->_step < $n)
375
+			while ($this->_step < $n)
376 376
 			{
377
-				if($this->_mode === TApplicationMode::Off)
377
+				if ($this->_mode === TApplicationMode::Off)
378 378
 					throw new THttpException(503, 'application_unavailable');
379
-				if($this->_requestCompleted)
379
+				if ($this->_requestCompleted)
380 380
 					break;
381 381
 				$method = self::$_steps[$this->_step];
382 382
 				Prado::trace("Executing $method()", 'Prado\TApplication');
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 				$this->_step++;
385 385
 			}
386 386
 		}
387
-		catch(\Exception $e)
387
+		catch (\Exception $e)
388 388
 		{
389 389
 			$this->onError($e);
390 390
 		}
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 */
420 420
 	public function getGlobalState($key, $defaultValue = null)
421 421
 	{
422
-		return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue;
422
+		return isset($this->_globals[$key]) ? $this->_globals[$key] : $defaultValue;
423 423
 	}
424 424
 
425 425
 	/**
@@ -435,11 +435,11 @@  discard block
 block discarded – undo
435 435
 	public function setGlobalState($key, $value, $defaultValue = null, $forceSave = false)
436 436
 	{
437 437
 		$this->_stateChanged = true;
438
-		if($value === $defaultValue)
438
+		if ($value === $defaultValue)
439 439
 			unset($this->_globals[$key]);
440 440
 		else
441 441
 			$this->_globals[$key] = $value;
442
-		if($forceSave)
442
+		if ($forceSave)
443 443
 			$this->saveGlobals();
444 444
 	}
445 445
 
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 */
473 473
 	protected function saveGlobals()
474 474
 	{
475
-		if($this->_stateChanged)
475
+		if ($this->_stateChanged)
476 476
 		{
477 477
 			$this->_stateChanged = false;
478 478
 			$this->getApplicationStatePersister()->save($this->_globals);
@@ -588,9 +588,9 @@  discard block
 block discarded – undo
588 588
 	 */
589 589
 	public function getConfigurationFileExt()
590 590
 	{
591
-		if($this->_configFileExt === null)
591
+		if ($this->_configFileExt === null)
592 592
 		{
593
-			switch($this->_configType)
593
+			switch ($this->_configType)
594 594
 			{
595 595
 				case TApplication::CONFIG_TYPE_PHP:
596 596
 					$this->_configFileExt = TApplication::CONFIG_FILE_EXT_PHP;
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
 	public function getConfigurationFileName()
609 609
 	{
610 610
 		static $fileName;
611
-		if($fileName == null)
611
+		if ($fileName == null)
612 612
 		{
613
-			switch($this->_configType)
613
+			switch ($this->_configType)
614 614
 			{
615 615
 				case TApplication::CONFIG_TYPE_PHP:
616 616
 					$fileName = TApplication::CONFIG_FILE_PHP;
@@ -636,8 +636,8 @@  discard block
 block discarded – undo
636 636
 	public function setRuntimePath($value)
637 637
 	{
638 638
 		$this->_runtimePath = $value;
639
-		if($this->_cacheFile)
640
-			$this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE;
639
+		if ($this->_cacheFile)
640
+			$this->_cacheFile = $this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
641 641
 		// generates unique ID by hashing the runtime path
642 642
 		$this->_uniqueID = md5($this->_runtimePath);
643 643
 	}
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 */
667 667
 	public function setModule($id, IModule $module = null)
668 668
 	{
669
-		if(isset($this->_modules[$id]))
669
+		if (isset($this->_modules[$id]))
670 670
 			throw new TConfigurationException('application_moduleid_duplicated', $id);
671 671
 		else
672 672
 			$this->_modules[$id] = $module;
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
 	 */
678 678
 	public function getModule($id)
679 679
 	{
680
-		if(!array_key_exists($id, $this->_modules))
680
+		if (!array_key_exists($id, $this->_modules))
681 681
 			return null;
682 682
 
683 683
 		// force loading of a lazy module
684
-		if($this->_modules[$id] === null)
684
+		if ($this->_modules[$id] === null)
685 685
 		{
686 686
 			$module = $this->internalLoadModule($id, true);
687 687
 			$module[0]->init($module[1]);
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 	 */
717 717
 	public function getRequest()
718 718
 	{
719
-		if(!$this->_request)
719
+		if (!$this->_request)
720 720
 		{
721 721
 			$this->_request = new \Prado\Web\THttpRequest;
722 722
 			$this->_request->init(null);
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	 */
738 738
 	public function getResponse()
739 739
 	{
740
-		if(!$this->_response)
740
+		if (!$this->_response)
741 741
 		{
742 742
 			$this->_response = new THttpResponse;
743 743
 			$this->_response->init(null);
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 	 */
759 759
 	public function getSession()
760 760
 	{
761
-		if(!$this->_session)
761
+		if (!$this->_session)
762 762
 		{
763 763
 			$this->_session = new THttpSession;
764 764
 			$this->_session->init(null);
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	 */
780 780
 	public function getErrorHandler()
781 781
 	{
782
-		if(!$this->_errorHandler)
782
+		if (!$this->_errorHandler)
783 783
 		{
784 784
 			$this->_errorHandler = new TErrorHandler;
785 785
 			$this->_errorHandler->init(null);
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 	 */
801 801
 	public function getSecurityManager()
802 802
 	{
803
-		if(!$this->_security)
803
+		if (!$this->_security)
804 804
 		{
805 805
 			$this->_security = new TSecurityManager;
806 806
 			$this->_security->init(null);
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	 */
822 822
 	public function getAssetManager()
823 823
 	{
824
-		if(!$this->_assetManager)
824
+		if (!$this->_assetManager)
825 825
 		{
826 826
 			$this->_assetManager = new TAssetManager;
827 827
 			$this->_assetManager->init(null);
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 	 */
843 843
 	public function getApplicationStatePersister()
844 844
 	{
845
-		if(!$this->_statePersister)
845
+		if (!$this->_statePersister)
846 846
 		{
847 847
 			$this->_statePersister = new TApplicationStatePersister;
848 848
 			$this->_statePersister->init(null);
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 */
897 897
 	public function getGlobalization($createIfNotExists = true)
898 898
 	{
899
-		if($this->_globalization === null && $createIfNotExists)
899
+		if ($this->_globalization === null && $createIfNotExists)
900 900
 		{
901 901
 			$this->_globalization = new TGlobalization;
902 902
 			$this->_globalization->init(null);
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 	 */
918 918
 	public function getAuthorizationRules()
919 919
 	{
920
-		if($this->_authRules === null)
920
+		if ($this->_authRules === null)
921 921
 			$this->_authRules = new \Prado\Security\TAuthorizationRuleCollection;
922 922
 		return $this->_authRules;
923 923
 	}
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 	protected function internalLoadModule($id, $force = false)
931 931
 	{
932 932
 		list($moduleClass, $initProperties, $configElement) = $this->_lazyModules[$id];
933
-		if(isset($initProperties['lazy']) && $initProperties['lazy'] && !$force)
933
+		if (isset($initProperties['lazy']) && $initProperties['lazy'] && !$force)
934 934
 		{
935 935
 			Prado::trace("Postponed loading of lazy module $id ({$moduleClass})", '\Prado\TApplication');
936 936
 			$this->setModule($id, null);
@@ -939,16 +939,16 @@  discard block
 block discarded – undo
939 939
 
940 940
 		Prado::trace("Loading module $id ({$moduleClass})", '\Prado\TApplication');
941 941
 		$module = Prado::createComponent($moduleClass);
942
-		foreach($initProperties as $name => $value)
942
+		foreach ($initProperties as $name => $value)
943 943
 		{
944
-			if($name === 'lazy') continue;
944
+			if ($name === 'lazy') continue;
945 945
 			$module->setSubProperty($name, $value);
946 946
 		}
947 947
 		$this->setModule($id, $module);
948 948
 		// keep the key to avoid reuse of the old module id
949 949
 		$this->_lazyModules[$id] = null;
950 950
 
951
-		return [$module,$configElement];
951
+		return [$module, $configElement];
952 952
 	}
953 953
 	/**
954 954
 	 * Applies an application configuration.
@@ -957,32 +957,32 @@  discard block
 block discarded – undo
957 957
 	 */
958 958
 	public function applyConfiguration($config, $withinService = false)
959 959
 	{
960
-		if($config->getIsEmpty())
960
+		if ($config->getIsEmpty())
961 961
 			return;
962 962
 
963 963
 		// set path aliases and using namespaces
964
-		foreach($config->getAliases() as $alias => $path)
964
+		foreach ($config->getAliases() as $alias => $path)
965 965
 			Prado::setPathOfAlias($alias, $path);
966
-		foreach($config->getUsings() as $using)
966
+		foreach ($config->getUsings() as $using)
967 967
 			Prado::using($using);
968 968
 
969 969
 		// set application properties
970
-		if(!$withinService)
970
+		if (!$withinService)
971 971
 		{
972
-			foreach($config->getProperties() as $name => $value)
972
+			foreach ($config->getProperties() as $name => $value)
973 973
 				$this->setSubProperty($name, $value);
974 974
 		}
975 975
 
976
-		if(empty($this->_services))
977
-			$this->_services = [$this->getPageServiceID() => ['Prado\Web\Services\TPageService',[],null]];
976
+		if (empty($this->_services))
977
+			$this->_services = [$this->getPageServiceID() => ['Prado\Web\Services\TPageService', [], null]];
978 978
 
979 979
 		// load parameters
980
-		foreach($config->getParameters() as $id => $parameter)
980
+		foreach ($config->getParameters() as $id => $parameter)
981 981
 		{
982
-			if(is_array($parameter))
982
+			if (is_array($parameter))
983 983
 			{
984 984
 				$component = Prado::createComponent($parameter[0]);
985
-				foreach($parameter[1] as $name => $value)
985
+				foreach ($parameter[1] as $name => $value)
986 986
 					$component->setSubProperty($name, $value);
987 987
 				$this->_parameters->add($id, $component);
988 988
 			}
@@ -992,29 +992,29 @@  discard block
 block discarded – undo
992 992
 
993 993
 		// load and init modules specified in app config
994 994
 		$modules = [];
995
-		foreach($config->getModules() as $id => $moduleConfig)
995
+		foreach ($config->getModules() as $id => $moduleConfig)
996 996
 		{
997
-			if(!is_string($id))
998
-				$id = '_module' . count($this->_lazyModules);
997
+			if (!is_string($id))
998
+				$id = '_module'.count($this->_lazyModules);
999 999
 			$this->_lazyModules[$id] = $moduleConfig;
1000
-			if($module = $this->internalLoadModule($id))
1000
+			if ($module = $this->internalLoadModule($id))
1001 1001
 				$modules[] = $module;
1002 1002
 		}
1003
-		foreach($modules as $module)
1003
+		foreach ($modules as $module)
1004 1004
 			$module[0]->init($module[1]);
1005 1005
 
1006 1006
 		// load service
1007
-		foreach($config->getServices() as $serviceID => $serviceConfig)
1007
+		foreach ($config->getServices() as $serviceID => $serviceConfig)
1008 1008
 			$this->_services[$serviceID] = $serviceConfig;
1009 1009
 
1010 1010
 		// external configurations
1011
-		foreach($config->getExternalConfigurations() as $filePath => $condition)
1011
+		foreach ($config->getExternalConfigurations() as $filePath => $condition)
1012 1012
 		{
1013
-			if($condition !== true)
1013
+			if ($condition !== true)
1014 1014
 				$condition = $this->evaluateExpression($condition);
1015
-			if($condition)
1015
+			if ($condition)
1016 1016
 			{
1017
-				if(($path = Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt())) === null || !is_file($path))
1017
+				if (($path = Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt())) === null || !is_file($path))
1018 1018
 					throw new TConfigurationException('application_includefile_invalid', $filePath);
1019 1019
 				$cn = $this->getApplicationConfigurationClass();
1020 1020
 				$c = new $cn;
@@ -1037,13 +1037,13 @@  discard block
 block discarded – undo
1037 1037
 	{
1038 1038
 		Prado::trace('Initializing application', 'Prado\TApplication');
1039 1039
 
1040
-		if($this->_configFile !== null)
1040
+		if ($this->_configFile !== null)
1041 1041
 		{
1042
-			if($this->_cacheFile === null || @filemtime($this->_cacheFile) < filemtime($this->_configFile))
1042
+			if ($this->_cacheFile === null || @filemtime($this->_cacheFile) < filemtime($this->_configFile))
1043 1043
 			{
1044 1044
 				$config = new TApplicationConfiguration;
1045 1045
 				$config->loadFromFile($this->_configFile);
1046
-				if($this->_cacheFile !== null)
1046
+				if ($this->_cacheFile !== null)
1047 1047
 					file_put_contents($this->_cacheFile, serialize($config), LOCK_EX);
1048 1048
 			}
1049 1049
 			else
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 			$this->applyConfiguration($config, false);
1053 1053
 		}
1054 1054
 
1055
-		if(($serviceID = $this->getRequest()->resolveRequest(array_keys($this->_services))) === null)
1055
+		if (($serviceID = $this->getRequest()->resolveRequest(array_keys($this->_services))) === null)
1056 1056
 			$serviceID = $this->getPageServiceID();
1057 1057
 
1058 1058
 		$this->startService($serviceID);
@@ -1066,24 +1066,24 @@  discard block
 block discarded – undo
1066 1066
 	 */
1067 1067
 	public function startService($serviceID)
1068 1068
 	{
1069
-		if(isset($this->_services[$serviceID]))
1069
+		if (isset($this->_services[$serviceID]))
1070 1070
 		{
1071 1071
 			list($serviceClass, $initProperties, $configElement) = $this->_services[$serviceID];
1072 1072
 			$service = Prado::createComponent($serviceClass);
1073
-			if(!($service instanceof IService))
1073
+			if (!($service instanceof IService))
1074 1074
 				throw new THttpException(500, 'application_service_invalid', $serviceClass);
1075
-			if(!$service->getEnabled())
1075
+			if (!$service->getEnabled())
1076 1076
 				throw new THttpException(500, 'application_service_unavailable', $serviceClass);
1077 1077
 			$service->setID($serviceID);
1078 1078
 			$this->setService($service);
1079 1079
 
1080
-			foreach($initProperties as $name => $value)
1080
+			foreach ($initProperties as $name => $value)
1081 1081
 				$service->setSubProperty($name, $value);
1082 1082
 
1083
-			if($configElement !== null)
1083
+			if ($configElement !== null)
1084 1084
 			{
1085 1085
 				$config = new TApplicationConfiguration;
1086
-				if($this->getConfigurationType() == self::CONFIG_TYPE_PHP)
1086
+				if ($this->getConfigurationType() == self::CONFIG_TYPE_PHP)
1087 1087
 					$config->loadFromPhp($configElement, $this->getBasePath());
1088 1088
 				else
1089 1089
 					$config->loadFromXml($configElement, $this->getBasePath());
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 	 */
1191 1191
 	public function runService()
1192 1192
 	{
1193
-		if($this->_service)
1193
+		if ($this->_service)
1194 1194
 			$this->_service->run();
1195 1195
 	}
1196 1196
 
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 	public function onEndRequest()
1239 1239
 	{
1240 1240
 		$this->flushOutput(false); // flush all remaining content in the buffer
1241
-		$this->saveGlobals();  // save global state
1241
+		$this->saveGlobals(); // save global state
1242 1242
 		$this->raiseEvent('OnEndRequest', $this, null);
1243 1243
 	}
1244 1244
 }
Please login to merge, or discard this patch.
framework/Security/TUserManager.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -111,9 +111,9 @@  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 118
 				$userFile = include $this->_userFile;
119 119
 				$this->loadUserDataFromPhp($userFile);
@@ -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);
@@ -146,33 +146,33 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	private function loadUserDataFromPhp($config)
148 148
 	{
149
-		if(isset($config['users']) && is_array($config['users']))
149
+		if (isset($config['users']) && is_array($config['users']))
150 150
 		{
151
-			foreach($config['users'] as $user)
151
+			foreach ($config['users'] as $user)
152 152
 			{
153
-				$name = trim(strtolower(isset($user['name'])?$user['name']:''));
154
-				$password = isset($user['password'])?$user['password']:'';
153
+				$name = trim(strtolower(isset($user['name']) ? $user['name'] : ''));
154
+				$password = isset($user['password']) ? $user['password'] : '';
155 155
 				$this->_users[$name] = $password;
156
-				$roles = isset($user['roles'])?$user['roles']:'';
157
-				if($roles !== '')
156
+				$roles = isset($user['roles']) ? $user['roles'] : '';
157
+				if ($roles !== '')
158 158
 				{
159
-					foreach(explode(',', $roles) as $role)
159
+					foreach (explode(',', $roles) as $role)
160 160
 					{
161
-						if(($role = trim($role)) !== '')
161
+						if (($role = trim($role)) !== '')
162 162
 							$this->_roles[$name][] = $role;
163 163
 					}
164 164
 				}
165 165
 			}
166 166
 		}
167
-		if(isset($config['roles']) && is_array($config['roles']))
167
+		if (isset($config['roles']) && is_array($config['roles']))
168 168
 		{
169
-			foreach($config['roles'] as $role)
169
+			foreach ($config['roles'] as $role)
170 170
 			{
171
-				$name = isset($role['name'])?$role['name']:'';
172
-				$users = isset($role['users'])?$role['users']:'';
173
-				foreach(explode(',', $users) as $user)
171
+				$name = isset($role['name']) ? $role['name'] : '';
172
+				$users = isset($role['users']) ? $role['users'] : '';
173
+				foreach (explode(',', $users) as $user)
174 174
 				{
175
-					if(($user = trim($user)) !== '')
175
+					if (($user = trim($user)) !== '')
176 176
 						$this->_roles[strtolower($user)][] = $name;
177 177
 				}
178 178
 			}
@@ -185,24 +185,24 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	private function loadUserDataFromXml($xmlNode)
187 187
 	{
188
-		foreach($xmlNode->getElementsByTagName('user') as $node)
188
+		foreach ($xmlNode->getElementsByTagName('user') as $node)
189 189
 		{
190 190
 			$name = trim(strtolower($node->getAttribute('name')));
191 191
 			$this->_users[$name] = $node->getAttribute('password');
192
-			if(($roles = trim($node->getAttribute('roles'))) !== '')
192
+			if (($roles = trim($node->getAttribute('roles'))) !== '')
193 193
 			{
194
-				foreach(explode(',', $roles) as $role)
194
+				foreach (explode(',', $roles) as $role)
195 195
 				{
196
-					if(($role = trim($role)) !== '')
196
+					if (($role = trim($role)) !== '')
197 197
 						$this->_roles[$name][] = $role;
198 198
 				}
199 199
 			}
200 200
 		}
201
-		foreach($xmlNode->getElementsByTagName('role') as $node)
201
+		foreach ($xmlNode->getElementsByTagName('role') as $node)
202 202
 		{
203
-			foreach(explode(',', $node->getAttribute('users')) as $user)
203
+			foreach (explode(',', $node->getAttribute('users')) as $user)
204 204
 			{
205
-				if(($user = trim($user)) !== '')
205
+				if (($user = trim($user)) !== '')
206 206
 					$this->_roles[strtolower($user)][] = $node->getAttribute('name');
207 207
 			}
208 208
 		}
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 */
249 249
 	public function setUserFile($value)
250 250
 	{
251
-		if($this->_initialized)
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
 
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	public function validateUser($username, $password)
296 296
 	{
297
-		if($this->_passwordMode === TUserManagerPasswordMode::MD5)
297
+		if ($this->_passwordMode === TUserManagerPasswordMode::MD5)
298 298
 			$password = md5($password);
299
-		elseif($this->_passwordMode === TUserManagerPasswordMode::SHA1)
299
+		elseif ($this->_passwordMode === TUserManagerPasswordMode::SHA1)
300 300
 			$password = sha1($password);
301 301
 		$username = strtolower($username);
302 302
 		return (isset($this->_users[$username]) && $this->_users[$username] === $password);
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 */
310 310
 	public function getUser($username = null)
311 311
 	{
312
-		if($username === null)
312
+		if ($username === null)
313 313
 		{
314 314
 			$user = new TUser($this);
315 315
 			$user->setIsGuest(true);
@@ -318,12 +318,12 @@  discard block
 block discarded – undo
318 318
 		else
319 319
 		{
320 320
 			$username = strtolower($username);
321
-			if(isset($this->_users[$username]))
321
+			if (isset($this->_users[$username]))
322 322
 			{
323 323
 				$user = new TUser($this);
324 324
 				$user->setName($username);
325 325
 				$user->setIsGuest(false);
326
-				if(isset($this->_roles[$username]))
326
+				if (isset($this->_roles[$username]))
327 327
 					$user->setRoles($this->_roles[$username]);
328 328
 				return $user;
329 329
 			}
@@ -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 345
 			$data = unserialize($data);
346
-			if(is_array($data) && count($data) === 2)
346
+			if (is_array($data) && count($data) === 2)
347 347
 			{
348 348
 				list($username, $token) = $data;
349
-				if(isset($this->_users[$username]) && $token === md5($username . $this->_users[$username]))
349
+				if (isset($this->_users[$username]) && $token === md5($username.$this->_users[$username]))
350 350
 					return $this->getUser($username);
351 351
 			}
352 352
 		}
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	{
363 363
 		$user = $this->getApplication()->getUser();
364 364
 		$username = strtolower($user->getName());
365
-		if(isset($this->_users[$username]))
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.
framework/Security/TAuthManager.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -89,22 +89,22 @@  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;
94
+		if ($this->_returnUrlVarName === null)
95
+			$this->_returnUrlVarName = $this->getApplication()->getID().':'.self::RETURN_URL_VAR;
96 96
 		$application = $this->getApplication();
97
-		if(is_string($this->_userManager))
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
-			if(!($users instanceof IUserManager))
101
+			if (!($users instanceof IUserManager))
102 102
 				throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
103 103
 			$this->_userManager = $users;
104 104
 		}
105
-		$application->attachEventHandler('OnAuthentication', [$this,'doAuthentication']);
106
-		$application->attachEventHandler('OnEndRequest', [$this,'leave']);
107
-		$application->attachEventHandler('OnAuthorization', [$this,'doAuthorization']);
105
+		$application->attachEventHandler('OnAuthentication', [$this, 'doAuthentication']);
106
+		$application->attachEventHandler('OnEndRequest', [$this, 'leave']);
107
+		$application->attachEventHandler('OnAuthorization', [$this, 'doAuthorization']);
108 108
 		$this->_initialized = true;
109 109
 	}
110 110
 
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function setUserManager($provider)
124 124
 	{
125
-		if($this->_initialized)
125
+		if ($this->_initialized)
126 126
 			throw new TInvalidOperationException('authmanager_usermanager_unchangeable');
127
-		if(!is_string($provider) && !($provider instanceof IUserManager))
127
+		if (!is_string($provider) && !($provider instanceof IUserManager))
128 128
 			throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
129 129
 		$this->_userManager = $provider;
130 130
 	}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		$this->onAuthenticate($param);
161 161
 
162 162
 		$service = $this->getService();
163
-		if(($service instanceof TPageService) && $service->getRequestedPagePath() === $this->getLoginPage())
163
+		if (($service instanceof TPageService) && $service->getRequestedPagePath() === $this->getLoginPage())
164 164
 			$this->_skipAuthorization = true;
165 165
 	}
166 166
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	public function doAuthorization($sender, $param)
175 175
 	{
176
-		if(!$this->_skipAuthorization)
176
+		if (!$this->_skipAuthorization)
177 177
 		{
178 178
 			$this->onAuthorize($param);
179 179
 		}
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 	public function leave($sender, $param)
190 190
 	{
191 191
 		$application = $this->getApplication();
192
-		if($application->getResponse()->getStatusCode() === 401)
192
+		if ($application->getResponse()->getStatusCode() === 401)
193 193
 		{
194 194
 			$service = $application->getService();
195
-			if($service instanceof TPageService)
195
+			if ($service instanceof TPageService)
196 196
 			{
197 197
 				$returnUrl = $application->getRequest()->getRequestUri();
198 198
 				$this->setReturnUrl($returnUrl);
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 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 290
 		$sessionInfo = $session->itemAt($this->getUserKey());
@@ -295,12 +295,12 @@  discard block
 block discarded – undo
295 295
 		($expiretime = $session->itemAt('AuthExpireTime')) && $expiretime < time();
296 296
 
297 297
 		// try authenticating through cookie if possible
298
-		if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired))
298
+		if ($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired))
299 299
 		{
300 300
 			$cookie = $this->getRequest()->getCookies()->itemAt($this->getUserKey());
301
-			if($cookie instanceof THttpCookie)
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 305
 					$user = $user2;
306 306
 					$this->updateSessionUser($user);
@@ -313,13 +313,13 @@  discard block
 block discarded – undo
313 313
 		$application->setUser($user);
314 314
 
315 315
 		// handle authentication expiration or update expiration time
316
-		if($isAuthExpired)
316
+		if ($isAuthExpired)
317 317
 			$this->onAuthExpire($param);
318 318
 		else
319 319
 			$session->add('AuthExpireTime', time() + $this->_authExpire);
320 320
 
321 321
 		// event handler gets a chance to do further auth work
322
-		if($this->hasEventHandler('OnAuthenticate'))
322
+		if ($this->hasEventHandler('OnAuthenticate'))
323 323
 			$this->raiseEvent('OnAuthenticate', $this, $application);
324 324
 	}
325 325
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	public function onAuthExpire($param)
332 332
 	{
333 333
 		$this->logout();
334
-		if($this->hasEventHandler('OnAuthExpire'))
334
+		if ($this->hasEventHandler('OnAuthExpire'))
335 335
 			$this->raiseEvent('OnAuthExpire', $this, $param);
336 336
 	}
337 337
 
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 	public function onAuthorize($param)
346 346
 	{
347 347
 		$application = $this->getApplication();
348
-		if($this->hasEventHandler('OnAuthorize'))
348
+		if ($this->hasEventHandler('OnAuthorize'))
349 349
 			$this->raiseEvent('OnAuthorize', $this, $application);
350
-		if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress()))
350
+		if (!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress()))
351 351
 		{
352 352
 			$application->getResponse()->setStatusCode(401);
353 353
 			$application->completeRequest();
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	public function getUserKey()
362 362
 	{
363
-		if($this->_userKey === null)
363
+		if ($this->_userKey === null)
364 364
 			$this->_userKey = $this->generateUserKey();
365 365
 		return $this->_userKey;
366 366
 	}
@@ -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
 	/**
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 	 */
382 382
 	public function updateSessionUser($user)
383 383
 	{
384
-		if(!$user->getIsGuest())
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);
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
 	 */
417 417
 	public function login($username, $password, $expire = 0)
418 418
 	{
419
-		if($this->_userManager->validateUser($username, $password))
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
-			if($expire > 0)
426
+			if ($expire > 0)
427 427
 			{
428 428
 				$cookie = new THttpCookie($this->getUserKey(), '');
429 429
 				$cookie->setExpire(time() + $expire);
@@ -443,11 +443,11 @@  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
-		if($this->getAllowAutoLogin())
450
+		if ($this->getAllowAutoLogin())
451 451
 		{
452 452
 			$cookie = new THttpCookie($this->getUserKey(), '');
453 453
 			$this->getResponse()->getCookies()->add($cookie);
Please login to merge, or discard this patch.
framework/Security/TDbUser.php 1 patch
Spacing   +4 added lines, -4 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 42
 			$userManager = $this->getManager();
43
-			if($userManager instanceof TDbUserManager)
43
+			if ($userManager instanceof TDbUserManager)
44 44
 			{
45 45
 				$connection = $userManager->getDbConnection();
46
-				if($connection instanceof TDbConnection)
46
+				if ($connection instanceof TDbConnection)
47 47
 				{
48 48
 					$connection->setActive(true);
49 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/TAuthorizationRule.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	public function __construct($action, $users, $roles, $verb = '', $ipRules = '')
79 79
 	{
80 80
 		$action = strtolower(trim($action));
81
-		if($action === 'allow' || $action === 'deny')
81
+		if ($action === 'allow' || $action === 'deny')
82 82
 			$this->_action = $action;
83 83
 		else
84 84
 			throw new TInvalidDataValueException('authorizationrule_action_invalid', $action);
@@ -89,46 +89,46 @@  discard block
 block discarded – undo
89 89
 		$this->_guest = false;
90 90
 		$this->_authenticated = false;
91 91
 
92
-		if(trim($users) === '')
92
+		if (trim($users) === '')
93 93
 			$users = '*';
94
-		foreach(explode(',', $users) as $user)
94
+		foreach (explode(',', $users) as $user)
95 95
 		{
96
-			if(($user = trim(strtolower($user))) !== '')
96
+			if (($user = trim(strtolower($user))) !== '')
97 97
 			{
98
-				if($user === '*')
98
+				if ($user === '*')
99 99
 				{
100 100
 					$this->_everyone = true;
101 101
 					break;
102 102
 				}
103
-				elseif($user === '?')
103
+				elseif ($user === '?')
104 104
 					$this->_guest = true;
105
-				elseif($user === '@')
105
+				elseif ($user === '@')
106 106
 					$this->_authenticated = true;
107 107
 				else
108 108
 					$this->_users[] = $user;
109 109
 			}
110 110
 		}
111 111
 
112
-		if(trim($roles) === '')
112
+		if (trim($roles) === '')
113 113
 			$roles = '*';
114
-		foreach(explode(',', $roles) as $role)
114
+		foreach (explode(',', $roles) as $role)
115 115
 		{
116
-			if(($role = trim(strtolower($role))) !== '')
116
+			if (($role = trim(strtolower($role))) !== '')
117 117
 				$this->_roles[] = $role;
118 118
 		}
119 119
 
120
-		if(($verb = trim(strtolower($verb))) === '')
120
+		if (($verb = trim(strtolower($verb))) === '')
121 121
 			$verb = '*';
122
-		if($verb === '*' || $verb === 'get' || $verb === 'post')
122
+		if ($verb === '*' || $verb === 'get' || $verb === 'post')
123 123
 			$this->_verb = $verb;
124 124
 		else
125 125
 			throw new TInvalidDataValueException('authorizationrule_verb_invalid', $verb);
126 126
 
127
-		if(trim($ipRules) === '')
127
+		if (trim($ipRules) === '')
128 128
 			$ipRules = '*';
129
-		foreach(explode(',', $ipRules) as $ipRule)
129
+		foreach (explode(',', $ipRules) as $ipRule)
130 130
 		{
131
-			if(($ipRule = trim($ipRule)) !== '')
131
+			if (($ipRule = trim($ipRule)) !== '')
132 132
 				$this->_ipRules[] = $ipRule;
133 133
 		}
134 134
 	}
@@ -206,19 +206,19 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function isUserAllowed(IUser $user, $verb, $ip)
208 208
 	{
209
-		if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user))
210
-			return ($this->_action === 'allow')?1:-1;
209
+		if ($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user))
210
+			return ($this->_action === 'allow') ? 1 : -1;
211 211
 		else
212 212
 			return 0;
213 213
 	}
214 214
 
215 215
 	private function isIpMatched($ip)
216 216
 	{
217
-		if(empty($this->_ipRules))
217
+		if (empty($this->_ipRules))
218 218
 			return 1;
219
-		foreach($this->_ipRules as $rule)
219
+		foreach ($this->_ipRules as $rule)
220 220
 		{
221
-			if($rule === '*' || $rule === $ip || (($pos = strpos($rule, '*')) !== false && strncmp($ip, $rule, $pos) === 0))
221
+			if ($rule === '*' || $rule === $ip || (($pos = strpos($rule, '*')) !== false && strncmp($ip, $rule, $pos) === 0))
222 222
 				return 1;
223 223
 		}
224 224
 		return 0;
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 
232 232
 	private function isRoleMatched($user)
233 233
 	{
234
-		foreach($this->_roles as $role)
234
+		foreach ($this->_roles as $role)
235 235
 		{
236
-			if($role === '*' || $user->isInRole($role))
236
+			if ($role === '*' || $user->isInRole($role))
237 237
 				return true;
238 238
 		}
239 239
 		return false;
Please login to merge, or discard this patch.
framework/Security/TAuthorizationRuleCollection.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function isUserAllowed($user, $verb, $ip)
34 34
 	{
35
-		if($user instanceof IUser)
35
+		if ($user instanceof IUser)
36 36
 		{
37 37
 			$verb = strtolower(trim($verb));
38
-			foreach($this as $rule)
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;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function insertAt($index, $item)
58 58
 	{
59
-		if($item instanceof TAuthorizationRule)
59
+		if ($item instanceof TAuthorizationRule)
60 60
 			parent::insertAt($index, $item);
61 61
 		else
62 62
 			throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required');
Please login to merge, or discard this patch.
framework/Security/TUser.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function setIsGuest($value)
93 93
 	{
94
-		if($isGuest = TPropertyValue::ensureBoolean($value))
94
+		if ($isGuest = TPropertyValue::ensureBoolean($value))
95 95
 		{
96 96
 			$this->setName($this->_manager->getGuestName());
97 97
 			$this->setRoles([]);
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function setRoles($value)
114 114
 	{
115
-		if(is_array($value))
115
+		if (is_array($value))
116 116
 			$this->setState('Roles', $value, []);
117 117
 		else
118 118
 		{
119 119
 			$roles = [];
120
-			foreach(explode(',', $value) as $role)
120
+			foreach (explode(',', $value) as $role)
121 121
 			{
122
-				if(($role = trim($role)) !== '')
122
+				if (($role = trim($role)) !== '')
123 123
 					$roles[] = $role;
124 124
 			}
125 125
 			$this->setState('Roles', $roles, []);
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public function isInRole($role)
134 134
 	{
135
-		foreach($this->getRoles() as $r)
136
-			if(strcasecmp($role, $r) === 0)
135
+		foreach ($this->getRoles() as $r)
136
+			if (strcasecmp($role, $r) === 0)
137 137
 				return true;
138 138
 		return false;
139 139
 	}
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function loadFromString($data)
154 154
 	{
155
-		if(!empty($data))
155
+		if (!empty($data))
156 156
 			$this->_state = unserialize($data);
157
-		if(!is_array($this->_state))
157
+		if (!is_array($this->_state))
158 158
 			$this->_state = [];
159 159
 		return $this;
160 160
 	}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	protected function getState($key, $defaultValue = null)
176 176
 	{
177
-		return isset($this->_state[$key])?$this->_state[$key]:$defaultValue;
177
+		return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue;
178 178
 	}
179 179
 
180 180
 	/**
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	protected function setState($key, $value, $defaultValue = null)
195 195
 	{
196
-		if($value === $defaultValue)
196
+		if ($value === $defaultValue)
197 197
 			unset($this->_state[$key]);
198 198
 		else
199 199
 			$this->_state[$key] = $value;
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
@@ -61,10 +61,10 @@  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 66
 		$this->_userFactory = Prado::createComponent($this->_userClass, $this);
67
-		if(!($this->_userFactory instanceof TDbUser))
67
+		if (!($this->_userFactory instanceof TDbUser))
68 68
 			throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass);
69 69
 	}
70 70
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function getUser($username = null)
120 120
 	{
121
-		if($username === null)
121
+		if ($username === null)
122 122
 		{
123 123
 			$user = Prado::createComponent($this->_userClass, $this);
124 124
 			$user->setIsGuest(true);
@@ -152,7 +152,7 @@  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 157
 			$this->_conn = $this->createDbConnection($this->_connID);
158 158
 			$this->_conn->setActive(true);
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	protected function createDbConnection($connectionID)
170 170
 	{
171
-		if($connectionID !== '')
171
+		if ($connectionID !== '')
172 172
 		{
173 173
 			$conn = $this->getApplication()->getModule($connectionID);
174
-			if($conn instanceof TDataSourceConfig)
174
+			if ($conn instanceof TDataSourceConfig)
175 175
 				return $conn->getDbConnection();
176 176
 			else
177 177
 				throw new TConfigurationException('dbusermanager_connectionid_invalid', $connectionID);
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	public function saveUserToCookie($cookie)
200 200
 	{
201 201
 		$user = $this->getApplication()->getUser();
202
-		if($user instanceof TDbUser)
202
+		if ($user instanceof TDbUser)
203 203
 			$user->saveUserToCookie($cookie);
204 204
 	}
205 205
 }
206 206
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Security/TSecurityManager.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  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))) {
87
+		if (null === $this->_validationKey) {
88
+			if (null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
89 89
 				$this->_validationKey = $this->generateRandomKey();
90 90
 				$this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true);
91 91
 			}
@@ -99,7 +99,7 @@  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 105
 		$this->_validationKey = $value;
@@ -111,8 +111,8 @@  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))) {
114
+		if (null === $this->_encryptionKey) {
115
+			if (null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
116 116
 				$this->_encryptionKey = $this->generateRandomKey();
117 117
 				$this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true);
118 118
 			}
@@ -126,7 +126,7 @@  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 132
 		$this->_encryptionKey = $value;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	public function setHashAlgorithm($value)
149 149
 	{
150 150
 		$this->_hashAlgorithm = TPropertyValue::ensureString($value);
151
-		if(!in_array($this->_hashAlgorithm, hash_algos()))
151
+		if (!in_array($this->_hashAlgorithm, hash_algos()))
152 152
 			throw new TInvalidDataValueException('securitymanager_hash_algorithm_invalid');
153 153
 	}
154 154
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	public function setCryptAlgorithm($value)
168 168
 	{
169 169
 		$this->_cryptAlgorithm = TPropertyValue::ensureString($value);
170
-		if(!in_array($this->_hashAlgorithm, openssl_get_cipher_methods()))
170
+		if (!in_array($this->_hashAlgorithm, openssl_get_cipher_methods()))
171 171
 			throw new TInvalidDataValueException('securitymanager_crypt_algorithm_invalid');
172 172
 	}
173 173
 
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	public function encrypt($data)
181 181
 	{
182
-		if(extension_loaded('openssl'))
182
+		if (extension_loaded('openssl'))
183 183
 		{
184 184
 			$key = md5($this->getEncryptionKey());
185 185
 			$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->_cryptAlgorithm));
186
-			return $iv . openssl_encrypt($data, $this->_cryptAlgorithm, $key, null, $iv);
186
+			return $iv.openssl_encrypt($data, $this->_cryptAlgorithm, $key, null, $iv);
187 187
 		}
188 188
 		else
189 189
 			throw new TNotSupportedException('securitymanager_openssl_required');
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	public function decrypt($data)
199 199
 	{
200
-		if(extension_loaded('openssl'))
200
+		if (extension_loaded('openssl'))
201 201
 		{
202 202
 			$key = md5($this->getEncryptionKey());
203 203
 			$iv = $this->substr($data, 0, openssl_cipher_iv_length($this->_cryptAlgorithm));
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	public function hashData($data)
216 216
 	{
217 217
 		$hmac = $this->computeHMAC($data);
218
-		return $hmac . $data;
218
+		return $hmac.$data;
219 219
 	}
220 220
 
221 221
 	/**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	{
230 230
 		$len = $this->strlen($this->computeHMAC('test'));
231 231
 
232
-		if($this->strlen($data) < $len)
232
+		if ($this->strlen($data) < $len)
233 233
 			return false;
234 234
 
235 235
 		$hmac = $this->substr($data, 0, $len);
Please login to merge, or discard this patch.