Completed
Push — scrutinizer ( c2ef4a...84e9d0 )
by Fabio
22:07
created
framework/Security/TSecurityManager.php 3 patches
Doc Comments   +7 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,6 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 	/**
87 87
 	 * @param string the key used to generate HMAC
88
+	 * @param string $value
88 89
 	 * @throws TInvalidDataValueException if the key is empty
89 90
 	 */
90 91
 	public function setValidationKey($value)
@@ -112,6 +113,7 @@  discard block
 block discarded – undo
112 113
 
113 114
 	/**
114 115
 	 * @param string the key used to encrypt/decrypt data.
116
+	 * @param string $value
115 117
 	 * @throws TInvalidDataValueException if the key is empty
116 118
 	 */
117 119
 	public function setEncryptionKey($value)
@@ -144,6 +146,7 @@  discard block
 block discarded – undo
144 146
 	 * This method has been deprecated since version 3.2.1.
145 147
 	 * Please use {@link setHashAlgorithm()} instead.
146 148
 	 * @param TSecurityManagerValidationMode hashing algorithm used to generate HMAC.
149
+	 * @param string $value
147 150
 	 */
148 151
 	public function setValidation($value)
149 152
 	{
@@ -182,7 +185,7 @@  discard block
 block discarded – undo
182 185
 	}
183 186
 
184 187
 	/**
185
-	 * @return mixed the algorithm used to encrypt/decrypt data. Defaults to the string 'rijndael-256'.
188
+	 * @return string the algorithm used to encrypt/decrypt data. Defaults to the string 'rijndael-256'.
186 189
 	 */
187 190
 	public function getCryptAlgorithm()
188 191
 	{
@@ -192,6 +195,7 @@  discard block
 block discarded – undo
192 195
 	/**
193 196
 	 * Sets the crypt algorithm (also known as cipher or cypher) that will be used for {@link encrypt} and {@link decrypt}.
194 197
 	 * @param mixed either a string containing the cipther name or an array containing the full parameters to call mcrypt_module_open().
198
+	 * @param string $value
195 199
 	 */
196 200
 	public function setCryptAlgorithm($value)
197 201
 	{
@@ -201,6 +205,7 @@  discard block
 block discarded – undo
201 205
 	/**
202 206
 	 * Encrypts data with {@link getEncryptionKey EncryptionKey}.
203 207
 	 * @param string data to be encrypted.
208
+	 * @param string $data
204 209
 	 * @return string the encrypted data
205 210
 	 * @throws TNotSupportedException if PHP Mcrypt extension is not loaded
206 211
 	 */
@@ -220,6 +225,7 @@  discard block
 block discarded – undo
220 225
 	/**
221 226
 	 * Decrypts data with {@link getEncryptionKey EncryptionKey}.
222 227
 	 * @param string data to be decrypted.
228
+	 * @param string $data
223 229
 	 * @return string the decrypted data
224 230
 	 * @throws TNotSupportedException if PHP Mcrypt extension is not loaded
225 231
 	 */
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function init($config)
58 58
 	{
59
-		$this->_mbstring=extension_loaded('mbstring');
59
+		$this->_mbstring = extension_loaded('mbstring');
60 60
 		$this->getApplication()->setSecurityManager($this);
61 61
 	}
62 62
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	protected function generateRandomKey()
67 67
 	{
68
-		return sprintf('%08x%08x%08x%08x',mt_rand(),mt_rand(),mt_rand(),mt_rand());
68
+		return sprintf('%08x%08x%08x%08x', mt_rand(), mt_rand(), mt_rand(), mt_rand());
69 69
 	}
70 70
 
71 71
 	/**
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function getValidationKey()
76 76
 	{
77
-		if(null === $this->_validationKey) {
78
-			if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
77
+		if (null === $this->_validationKey) {
78
+			if (null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
79 79
 				$this->_validationKey = $this->generateRandomKey();
80 80
 				$this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true);
81 81
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function setValidationKey($value)
91 91
 	{
92
-		if('' === $value)
92
+		if ('' === $value)
93 93
 			throw new TInvalidDataValueException('securitymanager_validationkey_invalid');
94 94
 
95 95
 		$this->_validationKey = $value;
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function getEncryptionKey()
103 103
 	{
104
-		if(null === $this->_encryptionKey) {
105
-			if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
104
+		if (null === $this->_encryptionKey) {
105
+			if (null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
106 106
 				$this->_encryptionKey = $this->generateRandomKey();
107 107
 				$this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true);
108 108
 			}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function setEncryptionKey($value)
118 118
 	{
119
-		if('' === $value)
119
+		if ('' === $value)
120 120
 			throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid');
121 121
 
122 122
 		$this->_encryptionKey = $value;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function getEncryption()
167 167
 	{
168
-		if(is_string($this->_cryptAlgorithm))
168
+		if (is_string($this->_cryptAlgorithm))
169 169
 			return $this->_cryptAlgorithm;
170 170
 		// fake the pre-3.2.1 answer
171 171
 		return "3DES";
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function encrypt($data)
208 208
 	{
209
-		$module=$this->openCryptModule();
209
+		$module = $this->openCryptModule();
210 210
 		$key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module));
211 211
 		srand();
212 212
 		$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
213 213
 		mcrypt_generic_init($module, $key, $iv);
214
-		$encrypted = $iv.mcrypt_generic($module, $data);
214
+		$encrypted = $iv . mcrypt_generic($module, $data);
215 215
 		mcrypt_generic_deinit($module);
216 216
 		mcrypt_module_close($module);
217 217
 		return $encrypted;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	public function decrypt($data)
227 227
 	{
228
-		$module=$this->openCryptModule();
228
+		$module = $this->openCryptModule();
229 229
 		$key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module));
230 230
 		$ivSize = mcrypt_enc_get_iv_size($module);
231 231
 		$iv = $this->substr($data, 0, $ivSize);
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	protected function openCryptModule()
245 245
 	{
246
-		if(extension_loaded('mcrypt'))
246
+		if (extension_loaded('mcrypt'))
247 247
 		{
248
-			if(is_array($this->_cryptAlgorithm))
249
-				$module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm);
248
+			if (is_array($this->_cryptAlgorithm))
249
+				$module = @call_user_func_array('mcrypt_module_open', $this->_cryptAlgorithm);
250 250
 			else
251
-				$module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,'');
251
+				$module = @mcrypt_module_open($this->_cryptAlgorithm, '', MCRYPT_MODE_CBC, '');
252 252
 
253
-			if($module===false)
253
+			if ($module === false)
254 254
 				throw new TNotSupportedException('securitymanager_mcryptextension_initfailed');
255 255
 
256 256
 			return $module;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	public function hashData($data)
268 268
 	{
269 269
 		$hmac = $this->computeHMAC($data);
270
-		return $hmac.$data;
270
+		return $hmac . $data;
271 271
 	}
272 272
 
273 273
 	/**
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function validateData($data)
281 281
 	{
282
-		$len=$this->strlen($this->computeHMAC('test'));
282
+		$len = $this->strlen($this->computeHMAC('test'));
283 283
 
284
-		if($this->strlen($data) < $len)
284
+		if ($this->strlen($data) < $len)
285 285
 			return false;
286 286
 
287 287
 		$hmac = $this->substr($data, 0, $len);
288
-		$data2=$this->substr($data, $len, $this->strlen($data));
288
+		$data2 = $this->substr($data, $len, $this->strlen($data));
289 289
 		return $hmac === $this->computeHMAC($data2) ? $data2 : false;
290 290
 	}
291 291
 
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 	{
299 299
 		$key = $this->getValidationKey();
300 300
 
301
-		if(function_exists('hash_hmac'))
301
+		if (function_exists('hash_hmac'))
302 302
 			return hash_hmac($this->_hashAlgorithm, $data, $key);
303 303
 
304
-		if(!strcasecmp($this->_hashAlgorithm,'sha1'))
304
+		if (!strcasecmp($this->_hashAlgorithm, 'sha1'))
305 305
 		{
306 306
 			$pack = 'H40';
307 307
 			$func = 'sha1';
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 */
323 323
 	private function strlen($string)
324 324
 	{
325
-		return $this->_mbstring ? mb_strlen($string,'8bit') : strlen($string);
325
+		return $this->_mbstring ? mb_strlen($string, '8bit') : strlen($string);
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
 	 * @param int $length the desired portion length
334 334
 	 * @return string the extracted part of string, or FALSE on failure or an empty string.
335 335
 	 */
336
-	private function substr($string,$start,$length)
336
+	private function substr($string, $start, $length)
337 337
 	{
338
-		return $this->_mbstring ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length);
338
+		return $this->_mbstring ? mb_substr($string, $start, $length, '8bit') : substr($string, $start, $length);
339 339
 	}
340 340
 }
341 341
 
Please login to merge, or discard this patch.
Braces   +25 added lines, -18 removed lines patch added patch discarded remove patch
@@ -89,8 +89,9 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function setValidationKey($value)
91 91
 	{
92
-		if('' === $value)
93
-			throw new TInvalidDataValueException('securitymanager_validationkey_invalid');
92
+		if('' === $value) {
93
+					throw new TInvalidDataValueException('securitymanager_validationkey_invalid');
94
+		}
94 95
 
95 96
 		$this->_validationKey = $value;
96 97
 	}
@@ -116,8 +117,9 @@  discard block
 block discarded – undo
116 117
 	 */
117 118
 	public function setEncryptionKey($value)
118 119
 	{
119
-		if('' === $value)
120
-			throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid');
120
+		if('' === $value) {
121
+					throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid');
122
+		}
121 123
 
122 124
 		$this->_encryptionKey = $value;
123 125
 	}
@@ -165,8 +167,9 @@  discard block
 block discarded – undo
165 167
 	 */
166 168
 	public function getEncryption()
167 169
 	{
168
-		if(is_string($this->_cryptAlgorithm))
169
-			return $this->_cryptAlgorithm;
170
+		if(is_string($this->_cryptAlgorithm)) {
171
+					return $this->_cryptAlgorithm;
172
+		}
170 173
 		// fake the pre-3.2.1 answer
171 174
 		return "3DES";
172 175
 	}
@@ -245,18 +248,20 @@  discard block
 block discarded – undo
245 248
 	{
246 249
 		if(extension_loaded('mcrypt'))
247 250
 		{
248
-			if(is_array($this->_cryptAlgorithm))
249
-				$module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm);
250
-			else
251
-				$module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,'');
251
+			if(is_array($this->_cryptAlgorithm)) {
252
+							$module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm);
253
+			} else {
254
+							$module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,'');
255
+			}
252 256
 
253
-			if($module===false)
254
-				throw new TNotSupportedException('securitymanager_mcryptextension_initfailed');
257
+			if($module===false) {
258
+							throw new TNotSupportedException('securitymanager_mcryptextension_initfailed');
259
+			}
255 260
 
256 261
 			return $module;
262
+		} else {
263
+					throw new TNotSupportedException('securitymanager_mcryptextension_required');
257 264
 		}
258
-		else
259
-			throw new TNotSupportedException('securitymanager_mcryptextension_required');
260 265
 	}
261 266
 
262 267
 	/**
@@ -281,8 +286,9 @@  discard block
 block discarded – undo
281 286
 	{
282 287
 		$len=$this->strlen($this->computeHMAC('test'));
283 288
 
284
-		if($this->strlen($data) < $len)
285
-			return false;
289
+		if($this->strlen($data) < $len) {
290
+					return false;
291
+		}
286 292
 
287 293
 		$hmac = $this->substr($data, 0, $len);
288 294
 		$data2=$this->substr($data, $len, $this->strlen($data));
@@ -298,8 +304,9 @@  discard block
 block discarded – undo
298 304
 	{
299 305
 		$key = $this->getValidationKey();
300 306
 
301
-		if(function_exists('hash_hmac'))
302
-			return hash_hmac($this->_hashAlgorithm, $data, $key);
307
+		if(function_exists('hash_hmac')) {
308
+					return hash_hmac($this->_hashAlgorithm, $data, $key);
309
+		}
303 310
 
304 311
 		if(!strcasecmp($this->_hashAlgorithm,'sha1'))
305 312
 		{
Please login to merge, or discard this patch.
framework/Security/TUser.php 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -89,6 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 	/**
91 91
 	 * @param boolean if the user is a guest
92
+	 * @param boolean $value
92 93
 	 */
93 94
 	public function setIsGuest($value)
94 95
 	{
@@ -129,6 +130,7 @@  discard block
 block discarded – undo
129 130
 
130 131
 	/**
131 132
 	 * @param string role to be tested. Note, role is case-insensitive.
133
+	 * @param string $role
132 134
 	 * @return boolean whether the user is of this role
133 135
 	 */
134 136
 	public function isInRole($role)
@@ -170,6 +172,7 @@  discard block
 block discarded – undo
170 172
 	 *
171 173
 	 * @param string variable name
172 174
 	 * @param mixed default value
175
+	 * @param string $key
173 176
 	 * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned
174 177
 	 * @see setState
175 178
 	 */
@@ -190,6 +193,7 @@  discard block
 block discarded – undo
190 193
 	 * @param string variable name
191 194
 	 * @param mixed variable value
192 195
 	 * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage.
196
+	 * @param string $key
193 197
 	 * @see getState
194 198
 	 */
195 199
 	protected function setState($key,$value,$defaultValue=null)
@@ -211,6 +215,7 @@  discard block
 block discarded – undo
211 215
 
212 216
 	/**
213 217
 	 * @param boolean whether user session state is changed
218
+	 * @param boolean $value
214 219
 	 */
215 220
 	public function setStateChanged($value)
216 221
 	{
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	/**
39 39
 	 * @var boolean whether user state is changed
40 40
 	 */
41
-	private $_stateChanged=false;
41
+	private $_stateChanged = false;
42 42
 	/**
43 43
 	 * @var IUserManager user manager
44 44
 	 */
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function __construct(IUserManager $manager)
52 52
 	{
53
-		$this->_state=array();
54
-		$this->_manager=$manager;
53
+		$this->_state = array();
54
+		$this->_manager = $manager;
55 55
 		$this->setName($manager->getGuestName());
56 56
 	}
57 57
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function getName()
70 70
 	{
71
-		return $this->getState('Name','');
71
+		return $this->getState('Name', '');
72 72
 	}
73 73
 
74 74
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function setName($value)
78 78
 	{
79
-		$this->setState('Name',$value,'');
79
+		$this->setState('Name', $value, '');
80 80
 	}
81 81
 
82 82
 	/**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function getIsGuest()
86 86
 	{
87
-		return $this->getState('IsGuest',true);
87
+		return $this->getState('IsGuest', true);
88 88
 	}
89 89
 
90 90
 	/**
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function setIsGuest($value)
94 94
 	{
95
-		if($isGuest=TPropertyValue::ensureBoolean($value))
95
+		if ($isGuest = TPropertyValue::ensureBoolean($value))
96 96
 		{
97 97
 			$this->setName($this->_manager->getGuestName());
98 98
 			$this->setRoles(array());
99 99
 		}
100
-		$this->setState('IsGuest',$isGuest);
100
+		$this->setState('IsGuest', $isGuest);
101 101
 	}
102 102
 
103 103
 	/**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function getRoles()
107 107
 	{
108
-		return $this->getState('Roles',array());
108
+		return $this->getState('Roles', array());
109 109
 	}
110 110
 
111 111
 	/**
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function setRoles($value)
115 115
 	{
116
-		if(is_array($value))
117
-			$this->setState('Roles',$value,array());
116
+		if (is_array($value))
117
+			$this->setState('Roles', $value, array());
118 118
 		else
119 119
 		{
120
-			$roles=array();
121
-			foreach(explode(',',$value) as $role)
120
+			$roles = array();
121
+			foreach (explode(',', $value) as $role)
122 122
 			{
123
-				if(($role=trim($role))!=='')
124
-					$roles[]=$role;
123
+				if (($role = trim($role)) !== '')
124
+					$roles[] = $role;
125 125
 			}
126
-			$this->setState('Roles',$roles,array());
126
+			$this->setState('Roles', $roles, array());
127 127
 		}
128 128
 	}
129 129
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function isInRole($role)
135 135
 	{
136
-		foreach($this->getRoles() as $r)
137
-			if(strcasecmp($role,$r)===0)
136
+		foreach ($this->getRoles() as $r)
137
+			if (strcasecmp($role, $r) === 0)
138 138
 				return true;
139 139
 		return false;
140 140
 	}
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	public function loadFromString($data)
155 155
 	{
156
-		if(!empty($data))
157
-			$this->_state=unserialize($data);
158
-		if(!is_array($this->_state))
159
-			$this->_state=array();
156
+		if (!empty($data))
157
+			$this->_state = unserialize($data);
158
+		if (!is_array($this->_state))
159
+			$this->_state = array();
160 160
 		return $this;
161 161
 	}
162 162
 
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
 	 * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned
174 174
 	 * @see setState
175 175
 	 */
176
-	protected function getState($key,$defaultValue=null)
176
+	protected function getState($key, $defaultValue = null)
177 177
 	{
178
-		return isset($this->_state[$key])?$this->_state[$key]:$defaultValue;
178
+		return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue;
179 179
 	}
180 180
 
181 181
 	/**
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 	 * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage.
193 193
 	 * @see getState
194 194
 	 */
195
-	protected function setState($key,$value,$defaultValue=null)
195
+	protected function setState($key, $value, $defaultValue = null)
196 196
 	{
197
-		if($value===$defaultValue)
197
+		if ($value === $defaultValue)
198 198
 			unset($this->_state[$key]);
199 199
 		else
200
-			$this->_state[$key]=$value;
201
-		$this->_stateChanged=true;
200
+			$this->_state[$key] = $value;
201
+		$this->_stateChanged = true;
202 202
 	}
203 203
 
204 204
 	/**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function setStateChanged($value)
216 216
 	{
217
-		$this->_stateChanged=TPropertyValue::ensureBoolean($value);
217
+		$this->_stateChanged = TPropertyValue::ensureBoolean($value);
218 218
 	}
219 219
 }
220 220
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -113,15 +113,16 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function setRoles($value)
115 115
 	{
116
-		if(is_array($value))
117
-			$this->setState('Roles',$value,array());
118
-		else
116
+		if(is_array($value)) {
117
+					$this->setState('Roles',$value,array());
118
+		} else
119 119
 		{
120 120
 			$roles=array();
121 121
 			foreach(explode(',',$value) as $role)
122 122
 			{
123
-				if(($role=trim($role))!=='')
124
-					$roles[]=$role;
123
+				if(($role=trim($role))!=='') {
124
+									$roles[]=$role;
125
+				}
125 126
 			}
126 127
 			$this->setState('Roles',$roles,array());
127 128
 		}
@@ -133,9 +134,10 @@  discard block
 block discarded – undo
133 134
 	 */
134 135
 	public function isInRole($role)
135 136
 	{
136
-		foreach($this->getRoles() as $r)
137
-			if(strcasecmp($role,$r)===0)
137
+		foreach($this->getRoles() as $r) {
138
+					if(strcasecmp($role,$r)===0)
138 139
 				return true;
140
+		}
139 141
 		return false;
140 142
 	}
141 143
 
@@ -153,10 +155,12 @@  discard block
 block discarded – undo
153 155
 	 */
154 156
 	public function loadFromString($data)
155 157
 	{
156
-		if(!empty($data))
157
-			$this->_state=unserialize($data);
158
-		if(!is_array($this->_state))
159
-			$this->_state=array();
158
+		if(!empty($data)) {
159
+					$this->_state=unserialize($data);
160
+		}
161
+		if(!is_array($this->_state)) {
162
+					$this->_state=array();
163
+		}
160 164
 		return $this;
161 165
 	}
162 166
 
@@ -194,10 +198,11 @@  discard block
 block discarded – undo
194 198
 	 */
195 199
 	protected function setState($key,$value,$defaultValue=null)
196 200
 	{
197
-		if($value===$defaultValue)
198
-			unset($this->_state[$key]);
199
-		else
200
-			$this->_state[$key]=$value;
201
+		if($value===$defaultValue) {
202
+					unset($this->_state[$key]);
203
+		} else {
204
+					$this->_state[$key]=$value;
205
+		}
201 206
 		$this->_stateChanged=true;
202 207
 	}
203 208
 
Please login to merge, or discard this patch.
framework/Security/TUserManager.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -103,6 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * This method is required by IModule and is invoked by application.
104 104
 	 * It loads user/role information from the module configuration.
105 105
 	 * @param mixed module configuration
106
+	 * @param TXmlDocument $config
106 107
 	 */
107 108
 	public function init($config)
108 109
 	{
@@ -239,6 +240,7 @@  discard block
 block discarded – undo
239 240
 	/**
240 241
 	 * @param string user/role data file path (in namespace form). The file format is XML
241 242
 	 * whose content is similar to that user/role block in application configuration.
243
+	 * @param string $value
242 244
 	 * @throws TInvalidOperationException if the module is already initialized
243 245
 	 * @throws TConfigurationException if the file is not in proper namespace format
244 246
 	 */
@@ -260,6 +262,7 @@  discard block
 block discarded – undo
260 262
 
261 263
 	/**
262 264
 	 * @param string name to be used for guest users.
265
+	 * @param string $value
263 266
 	 */
264 267
 	public function setGuestName($value)
265 268
 	{
@@ -276,6 +279,7 @@  discard block
 block discarded – undo
276 279
 
277 280
 	/**
278 281
 	 * @param TUserManagerPasswordMode how password is stored, clear text, or MD5 or SHA1 hashed.
282
+	 * @param string $value
279 283
 	 */
280 284
 	public function setPasswordMode($value)
281 285
 	{
@@ -286,6 +290,8 @@  discard block
 block discarded – undo
286 290
 	 * Validates if the username and password are correct.
287 291
 	 * @param string user name
288 292
 	 * @param string password
293
+	 * @param string $username
294
+	 * @param string $password
289 295
 	 * @return boolean true if validation is successful, false otherwise.
290 296
 	 */
291 297
 	public function validateUser($username,$password)
@@ -369,6 +375,7 @@  discard block
 block discarded – undo
369 375
 	 * Sets a user as a guest.
370 376
 	 * User name is changed as guest name, and roles are emptied.
371 377
 	 * @param TUser the user to be changed to a guest.
378
+	 * @param TUser|null $user
372 379
 	 */
373 380
 	public function switchToGuest($user)
374 381
 	{
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -71,32 +71,32 @@  discard block
 block discarded – undo
71 71
 	/**
72 72
 	 * extension name to the user file
73 73
 	 */
74
-	const USER_FILE_EXT='.xml';
74
+	const USER_FILE_EXT = '.xml';
75 75
 
76 76
 	/**
77 77
 	 * @var array list of users managed by this module
78 78
 	 */
79
-	private $_users=array();
79
+	private $_users = array();
80 80
 	/**
81 81
 	 * @var array list of roles managed by this module
82 82
 	 */
83
-	private $_roles=array();
83
+	private $_roles = array();
84 84
 	/**
85 85
 	 * @var string guest name
86 86
 	 */
87
-	private $_guestName='Guest';
87
+	private $_guestName = 'Guest';
88 88
 	/**
89 89
 	 * @var TUserManagerPasswordMode password mode
90 90
 	 */
91
-	private $_passwordMode=TUserManagerPasswordMode::MD5;
91
+	private $_passwordMode = TUserManagerPasswordMode::MD5;
92 92
 	/**
93 93
 	 * @var boolean whether the module has been initialized
94 94
 	 */
95
-	private $_initialized=false;
95
+	private $_initialized = false;
96 96
 	/**
97 97
 	 * @var string user/role information file
98 98
 	 */
99
-	private $_userFile=null;
99
+	private $_userFile = null;
100 100
 
101 101
 	/**
102 102
 	 * Initializes the module.
@@ -107,21 +107,21 @@  discard block
 block discarded – undo
107 107
 	public function init($config)
108 108
 	{
109 109
 		$this->loadUserData($config);
110
-		if($this->_userFile!==null)
110
+		if ($this->_userFile !== null)
111 111
 		{
112
-			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
112
+			if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
113 113
 			{
114 114
 				$userFile = include $this->_userFile;
115 115
 				$this->loadUserDataFromPhp($userFile);
116 116
 			}
117 117
 			else
118 118
 			{
119
-				$dom=new TXmlDocument;
119
+				$dom = new TXmlDocument;
120 120
 				$dom->loadFromFile($this->_userFile);
121 121
 				$this->loadUserDataFromXml($dom);
122 122
 			}
123 123
 		}
124
-		$this->_initialized=true;
124
+		$this->_initialized = true;
125 125
 	}
126 126
 
127 127
 	/*
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	private function loadUserData($config)
132 132
 	{
133
-		if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
133
+		if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
134 134
 			$this->loadUserDataFromPhp($config);
135 135
 		else
136 136
 			$this->loadUserDataFromXml($config);
@@ -142,34 +142,34 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	private function loadUserDataFromPhp($config)
144 144
 	{
145
-		if(isset($config['users']) && is_array($config['users']))
145
+		if (isset($config['users']) && is_array($config['users']))
146 146
 		{
147
-			foreach($config['users'] as $user)
147
+			foreach ($config['users'] as $user)
148 148
 			{
149
-				$name = trim(strtolower(isset($user['name'])?$user['name']:''));
150
-				$password = isset($user['password'])?$user['password']:'';
149
+				$name = trim(strtolower(isset($user['name']) ? $user['name'] : ''));
150
+				$password = isset($user['password']) ? $user['password'] : '';
151 151
 				$this->_users[$name] = $password;
152
-				$roles = isset($user['roles'])?$user['roles']:'';
153
-				if($roles!=='')
152
+				$roles = isset($user['roles']) ? $user['roles'] : '';
153
+				if ($roles !== '')
154 154
 				{
155
-					foreach(explode(',',$roles) as $role)
155
+					foreach (explode(',', $roles) as $role)
156 156
 					{
157
-						if(($role=trim($role))!=='')
158
-							$this->_roles[$name][]=$role;
157
+						if (($role = trim($role)) !== '')
158
+							$this->_roles[$name][] = $role;
159 159
 					}
160 160
 				}
161 161
 			}
162 162
 		}
163
-		if(isset($config['roles']) && is_array($config['roles']))
163
+		if (isset($config['roles']) && is_array($config['roles']))
164 164
 		{
165
-			foreach($config['roles'] as $role)
165
+			foreach ($config['roles'] as $role)
166 166
 			{
167
-				$name = isset($role['name'])?$role['name']:'';
168
-				$users = isset($role['users'])?$role['users']:'';
169
-				foreach(explode(',',$users) as $user)
167
+				$name = isset($role['name']) ? $role['name'] : '';
168
+				$users = isset($role['users']) ? $role['users'] : '';
169
+				foreach (explode(',', $users) as $user)
170 170
 				{
171
-					if(($user=trim($user))!=='')
172
-						$this->_roles[strtolower($user)][]=$name;
171
+					if (($user = trim($user)) !== '')
172
+						$this->_roles[strtolower($user)][] = $name;
173 173
 				}
174 174
 			}
175 175
 		}
@@ -181,25 +181,25 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	private function loadUserDataFromXml($xmlNode)
183 183
 	{
184
-		foreach($xmlNode->getElementsByTagName('user') as $node)
184
+		foreach ($xmlNode->getElementsByTagName('user') as $node)
185 185
 		{
186
-			$name=trim(strtolower($node->getAttribute('name')));
187
-			$this->_users[$name]=$node->getAttribute('password');
188
-			if(($roles=trim($node->getAttribute('roles')))!=='')
186
+			$name = trim(strtolower($node->getAttribute('name')));
187
+			$this->_users[$name] = $node->getAttribute('password');
188
+			if (($roles = trim($node->getAttribute('roles'))) !== '')
189 189
 			{
190
-				foreach(explode(',',$roles) as $role)
190
+				foreach (explode(',', $roles) as $role)
191 191
 				{
192
-					if(($role=trim($role))!=='')
193
-						$this->_roles[$name][]=$role;
192
+					if (($role = trim($role)) !== '')
193
+						$this->_roles[$name][] = $role;
194 194
 				}
195 195
 			}
196 196
 		}
197
-		foreach($xmlNode->getElementsByTagName('role') as $node)
197
+		foreach ($xmlNode->getElementsByTagName('role') as $node)
198 198
 		{
199
-			foreach(explode(',',$node->getAttribute('users')) as $user)
199
+			foreach (explode(',', $node->getAttribute('users')) as $user)
200 200
 			{
201
-				if(($user=trim($user))!=='')
202
-					$this->_roles[strtolower($user)][]=$node->getAttribute('name');
201
+				if (($user = trim($user)) !== '')
202
+					$this->_roles[strtolower($user)][] = $node->getAttribute('name');
203 203
 			}
204 204
 		}
205 205
 	}
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function setUserFile($value)
246 246
 	{
247
-		if($this->_initialized)
247
+		if ($this->_initialized)
248 248
 			throw new TInvalidOperationException('usermanager_userfile_unchangeable');
249
-		else if(($this->_userFile=Prado::getPathOfNamespace($value,self::USER_FILE_EXT))===null || !is_file($this->_userFile))
250
-			throw new TConfigurationException('usermanager_userfile_invalid',$value);
249
+		else if (($this->_userFile = Prado::getPathOfNamespace($value, self::USER_FILE_EXT)) === null || !is_file($this->_userFile))
250
+			throw new TConfigurationException('usermanager_userfile_invalid', $value);
251 251
 	}
252 252
 
253 253
 	/**
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 */
264 264
 	public function setGuestName($value)
265 265
 	{
266
-		$this->_guestName=$value;
266
+		$this->_guestName = $value;
267 267
 	}
268 268
 
269 269
 	/**
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function setPasswordMode($value)
281 281
 	{
282
-		$this->_passwordMode=TPropertyValue::ensureEnum($value,'TUserManagerPasswordMode');
282
+		$this->_passwordMode = TPropertyValue::ensureEnum($value, 'TUserManagerPasswordMode');
283 283
 	}
284 284
 
285 285
 	/**
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
 	 * @param string password
289 289
 	 * @return boolean true if validation is successful, false otherwise.
290 290
 	 */
291
-	public function validateUser($username,$password)
291
+	public function validateUser($username, $password)
292 292
 	{
293
-		if($this->_passwordMode===TUserManagerPasswordMode::MD5)
294
-			$password=md5($password);
295
-		else if($this->_passwordMode===TUserManagerPasswordMode::SHA1)
296
-			$password=sha1($password);
297
-		$username=strtolower($username);
298
-		return (isset($this->_users[$username]) && $this->_users[$username]===$password);
293
+		if ($this->_passwordMode === TUserManagerPasswordMode::MD5)
294
+			$password = md5($password);
295
+		else if ($this->_passwordMode === TUserManagerPasswordMode::SHA1)
296
+			$password = sha1($password);
297
+		$username = strtolower($username);
298
+		return (isset($this->_users[$username]) && $this->_users[$username] === $password);
299 299
 	}
300 300
 
301 301
 	/**
@@ -303,23 +303,23 @@  discard block
 block discarded – undo
303 303
 	 * @param string user name, null if it is a guest.
304 304
 	 * @return TUser the user instance, null if the specified username is not in the user database.
305 305
 	 */
306
-	public function getUser($username=null)
306
+	public function getUser($username = null)
307 307
 	{
308
-		if($username===null)
308
+		if ($username === null)
309 309
 		{
310
-			$user=new TUser($this);
310
+			$user = new TUser($this);
311 311
 			$user->setIsGuest(true);
312 312
 			return $user;
313 313
 		}
314 314
 		else
315 315
 		{
316
-			$username=strtolower($username);
317
-			if(isset($this->_users[$username]))
316
+			$username = strtolower($username);
317
+			if (isset($this->_users[$username]))
318 318
 			{
319
-				$user=new TUser($this);
319
+				$user = new TUser($this);
320 320
 				$user->setName($username);
321 321
 				$user->setIsGuest(false);
322
-				if(isset($this->_roles[$username]))
322
+				if (isset($this->_roles[$username]))
323 323
 					$user->setRoles($this->_roles[$username]);
324 324
 				return $user;
325 325
 			}
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 	 */
337 337
 	public function getUserFromCookie($cookie)
338 338
 	{
339
-		if(($data=$cookie->getValue())!=='')
339
+		if (($data = $cookie->getValue()) !== '')
340 340
 		{
341
-			$data=unserialize($data);
342
-			if(is_array($data) && count($data)===2)
341
+			$data = unserialize($data);
342
+			if (is_array($data) && count($data) === 2)
343 343
 			{
344
-				list($username,$token)=$data;
345
-				if(isset($this->_users[$username]) && $token===md5($username.$this->_users[$username]))
344
+				list($username, $token) = $data;
345
+				if (isset($this->_users[$username]) && $token === md5($username . $this->_users[$username]))
346 346
 					return $this->getUser($username);
347 347
 			}
348 348
 		}
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 	 */
357 357
 	public function saveUserToCookie($cookie)
358 358
 	{
359
-		$user=$this->getApplication()->getUser();
360
-		$username=strtolower($user->getName());
361
-		if(isset($this->_users[$username]))
359
+		$user = $this->getApplication()->getUser();
360
+		$username = strtolower($user->getName());
361
+		if (isset($this->_users[$username]))
362 362
 		{
363
-			$data=array($username,md5($username.$this->_users[$username]));
363
+			$data = array($username, md5($username . $this->_users[$username]));
364 364
 			$cookie->setValue(serialize($data));
365 365
 		}
366 366
 	}
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
  */
393 393
 class TUserManagerPasswordMode extends TEnumerable
394 394
 {
395
-	const Clear='Clear';
396
-	const MD5='MD5';
397
-	const SHA1='SHA1';
395
+	const Clear = 'Clear';
396
+	const MD5 = 'MD5';
397
+	const SHA1 = 'SHA1';
398 398
 }
399 399
 
Please login to merge, or discard this patch.
Braces   +37 added lines, -30 removed lines patch added patch discarded remove patch
@@ -113,8 +113,7 @@  discard block
 block discarded – undo
113 113
 			{
114 114
 				$userFile = include $this->_userFile;
115 115
 				$this->loadUserDataFromPhp($userFile);
116
-			}
117
-			else
116
+			} else
118 117
 			{
119 118
 				$dom=new TXmlDocument;
120 119
 				$dom->loadFromFile($this->_userFile);
@@ -130,10 +129,11 @@  discard block
 block discarded – undo
130 129
 	 */
131 130
 	private function loadUserData($config)
132 131
 	{
133
-		if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
134
-			$this->loadUserDataFromPhp($config);
135
-		else
136
-			$this->loadUserDataFromXml($config);
132
+		if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) {
133
+					$this->loadUserDataFromPhp($config);
134
+		} else {
135
+					$this->loadUserDataFromXml($config);
136
+		}
137 137
 	}
138 138
 
139 139
 	/**
@@ -154,8 +154,9 @@  discard block
 block discarded – undo
154 154
 				{
155 155
 					foreach(explode(',',$roles) as $role)
156 156
 					{
157
-						if(($role=trim($role))!=='')
158
-							$this->_roles[$name][]=$role;
157
+						if(($role=trim($role))!=='') {
158
+													$this->_roles[$name][]=$role;
159
+						}
159 160
 					}
160 161
 				}
161 162
 			}
@@ -168,8 +169,9 @@  discard block
 block discarded – undo
168 169
 				$users = isset($role['users'])?$role['users']:'';
169 170
 				foreach(explode(',',$users) as $user)
170 171
 				{
171
-					if(($user=trim($user))!=='')
172
-						$this->_roles[strtolower($user)][]=$name;
172
+					if(($user=trim($user))!=='') {
173
+											$this->_roles[strtolower($user)][]=$name;
174
+					}
173 175
 				}
174 176
 			}
175 177
 		}
@@ -189,8 +191,9 @@  discard block
 block discarded – undo
189 191
 			{
190 192
 				foreach(explode(',',$roles) as $role)
191 193
 				{
192
-					if(($role=trim($role))!=='')
193
-						$this->_roles[$name][]=$role;
194
+					if(($role=trim($role))!=='') {
195
+											$this->_roles[$name][]=$role;
196
+					}
194 197
 				}
195 198
 			}
196 199
 		}
@@ -198,8 +201,9 @@  discard block
 block discarded – undo
198 201
 		{
199 202
 			foreach(explode(',',$node->getAttribute('users')) as $user)
200 203
 			{
201
-				if(($user=trim($user))!=='')
202
-					$this->_roles[strtolower($user)][]=$node->getAttribute('name');
204
+				if(($user=trim($user))!=='') {
205
+									$this->_roles[strtolower($user)][]=$node->getAttribute('name');
206
+				}
203 207
 			}
204 208
 		}
205 209
 	}
@@ -244,10 +248,11 @@  discard block
 block discarded – undo
244 248
 	 */
245 249
 	public function setUserFile($value)
246 250
 	{
247
-		if($this->_initialized)
248
-			throw new TInvalidOperationException('usermanager_userfile_unchangeable');
249
-		else if(($this->_userFile=Prado::getPathOfNamespace($value,self::USER_FILE_EXT))===null || !is_file($this->_userFile))
250
-			throw new TConfigurationException('usermanager_userfile_invalid',$value);
251
+		if($this->_initialized) {
252
+					throw new TInvalidOperationException('usermanager_userfile_unchangeable');
253
+		} else if(($this->_userFile=Prado::getPathOfNamespace($value,self::USER_FILE_EXT))===null || !is_file($this->_userFile)) {
254
+					throw new TConfigurationException('usermanager_userfile_invalid',$value);
255
+		}
251 256
 	}
252 257
 
253 258
 	/**
@@ -290,10 +295,11 @@  discard block
 block discarded – undo
290 295
 	 */
291 296
 	public function validateUser($username,$password)
292 297
 	{
293
-		if($this->_passwordMode===TUserManagerPasswordMode::MD5)
294
-			$password=md5($password);
295
-		else if($this->_passwordMode===TUserManagerPasswordMode::SHA1)
296
-			$password=sha1($password);
298
+		if($this->_passwordMode===TUserManagerPasswordMode::MD5) {
299
+					$password=md5($password);
300
+		} else if($this->_passwordMode===TUserManagerPasswordMode::SHA1) {
301
+					$password=sha1($password);
302
+		}
297 303
 		$username=strtolower($username);
298 304
 		return (isset($this->_users[$username]) && $this->_users[$username]===$password);
299 305
 	}
@@ -310,8 +316,7 @@  discard block
 block discarded – undo
310 316
 			$user=new TUser($this);
311 317
 			$user->setIsGuest(true);
312 318
 			return $user;
313
-		}
314
-		else
319
+		} else
315 320
 		{
316 321
 			$username=strtolower($username);
317 322
 			if(isset($this->_users[$username]))
@@ -319,12 +324,13 @@  discard block
 block discarded – undo
319 324
 				$user=new TUser($this);
320 325
 				$user->setName($username);
321 326
 				$user->setIsGuest(false);
322
-				if(isset($this->_roles[$username]))
323
-					$user->setRoles($this->_roles[$username]);
327
+				if(isset($this->_roles[$username])) {
328
+									$user->setRoles($this->_roles[$username]);
329
+				}
324 330
 				return $user;
331
+			} else {
332
+							return null;
325 333
 			}
326
-			else
327
-				return null;
328 334
 		}
329 335
 	}
330 336
 
@@ -342,8 +348,9 @@  discard block
 block discarded – undo
342 348
 			if(is_array($data) && count($data)===2)
343 349
 			{
344 350
 				list($username,$token)=$data;
345
-				if(isset($this->_users[$username]) && $token===md5($username.$this->_users[$username]))
346
-					return $this->getUser($username);
351
+				if(isset($this->_users[$username]) && $token===md5($username.$this->_users[$username])) {
352
+									return $this->getUser($username);
353
+				}
347 354
 			}
348 355
 		}
349 356
 		return null;
Please login to merge, or discard this patch.
framework/TApplication.php 4 patches
Doc Comments   +10 added lines, -1 removed lines patch added patch discarded remove patch
@@ -342,6 +342,7 @@  discard block
 block discarded – undo
342 342
 	 * to determine the application configuration file,
343 343
 	 * application root path and the runtime path.
344 344
 	 * @param string the application root path or the application configuration file
345
+	 * @param string $basePath
345 346
 	 * @see setBasePath
346 347
 	 * @see setRuntimePath
347 348
 	 * @see setConfigurationFile
@@ -440,6 +441,7 @@  discard block
 block discarded – undo
440 441
 	 * A global value is one that is persistent across users sessions and requests.
441 442
 	 * @param string the name of the value to be returned
442 443
 	 * @param mixed the default value. If $key is not found, $defaultValue will be returned
444
+	 * @param integer $defaultValue
443 445
 	 * @return mixed the global value corresponding to $key
444 446
 	 */
445 447
 	public function getGlobalState($key,$defaultValue=null)
@@ -456,6 +458,7 @@  discard block
 block discarded – undo
456 458
 	 * @param mixed the global value to be set
457 459
 	 * @param mixed the default value. If $key is not found, $defaultValue will be returned
458 460
 	 * @param boolean wheter to force an immediate GlobalState save. defaults to false
461
+	 * @param string $key
459 462
 	 */
460 463
 	public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false)
461 464
 	{
@@ -545,7 +548,7 @@  discard block
 block discarded – undo
545 548
 	}
546 549
 
547 550
 	/**
548
-	 * @return TApplicationMode application mode. Defaults to TApplicationMode::Debug.
551
+	 * @return string application mode. Defaults to TApplicationMode::Debug.
549 552
 	 */
550 553
 	public function getMode()
551 554
 	{
@@ -570,6 +573,7 @@  discard block
 block discarded – undo
570 573
 
571 574
 	/**
572 575
 	 * @param string the directory containing the application configuration file
576
+	 * @param string $value
573 577
 	 */
574 578
 	public function setBasePath($value)
575 579
 	{
@@ -586,6 +590,7 @@  discard block
 block discarded – undo
586 590
 
587 591
 	/**
588 592
 	 * @param string the application configuration file (absolute path)
593
+	 * @param string $value
589 594
 	 */
590 595
 	public function setConfigurationFile($value)
591 596
 	{
@@ -602,6 +607,7 @@  discard block
 block discarded – undo
602 607
 
603 608
  	/**
604 609
  	 * @param string the application configuration type. 'xml' and 'php' are valid values
610
+ 	 * @param string $value
605 611
 	 */
606 612
 	public function setConfigurationType($value)
607 613
 	{
@@ -657,6 +663,7 @@  discard block
 block discarded – undo
657 663
 
658 664
 	/**
659 665
 	 * @param string the directory storing cache data and application-level persistent data. (absolute path)
666
+	 * @param string $value
660 667
 	 */
661 668
 	public function setRuntimePath($value)
662 669
 	{
@@ -677,6 +684,7 @@  discard block
 block discarded – undo
677 684
 
678 685
 	/**
679 686
 	 * @param IService the currently requested service
687
+	 * @param IService $value
680 688
 	 */
681 689
 	public function setService($value)
682 690
 	{
@@ -1126,6 +1134,7 @@  discard block
 block discarded – undo
1126 1134
 	 * This method is invoked when an exception is raised during the lifecycles
1127 1135
 	 * of the application.
1128 1136
 	 * @param mixed event parameter
1137
+	 * @param Exception $param
1129 1138
 	 */
1130 1139
 	public function onError($param)
1131 1140
 	{
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -602,7 +602,7 @@
 block discarded – undo
602 602
 
603 603
  	/**
604 604
  	 * @param string the application configuration type. 'xml' and 'php' are valid values
605
-	 */
605
+ 	 */
606 606
 	public function setConfigurationType($value)
607 607
 	{
608 608
 		$this->_configType = $value;
Please login to merge, or discard this patch.
Spacing   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Includes core interfaces essential for TApplication class
14 14
  */
15
-require_once(PRADO_DIR.'/interfaces.php');
15
+require_once(PRADO_DIR . '/interfaces.php');
16 16
 
17 17
 /**
18 18
  * Includes core classes essential for TApplication class
@@ -113,23 +113,23 @@  discard block
 block discarded – undo
113 113
 	 * possible application mode.
114 114
 	 * @deprecated deprecated since version 3.0.4 (use TApplicationMode constants instead)
115 115
 	 */
116
-	const STATE_OFF='Off';
117
-	const STATE_DEBUG='Debug';
118
-	const STATE_NORMAL='Normal';
119
-	const STATE_PERFORMANCE='Performance';
116
+	const STATE_OFF = 'Off';
117
+	const STATE_DEBUG = 'Debug';
118
+	const STATE_NORMAL = 'Normal';
119
+	const STATE_PERFORMANCE = 'Performance';
120 120
 
121 121
 	/**
122 122
 	 * Page service ID
123 123
 	 */
124
-	const PAGE_SERVICE_ID='page';
124
+	const PAGE_SERVICE_ID = 'page';
125 125
 	/**
126 126
 	 * Application configuration file name
127 127
 	 */
128
-	const CONFIG_FILE_XML='application.xml';
128
+	const CONFIG_FILE_XML = 'application.xml';
129 129
 	/**
130 130
 	 * File extension for external config files
131 131
 	 */
132
-	const CONFIG_FILE_EXT_XML='.xml';
132
+	const CONFIG_FILE_EXT_XML = '.xml';
133 133
 	/**
134 134
 	 * Configuration file type, application.xml and config.xml
135 135
 	 */
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 	/**
138 138
 	 * Application configuration file name
139 139
 	 */
140
-	const CONFIG_FILE_PHP='application.php';
140
+	const CONFIG_FILE_PHP = 'application.php';
141 141
 	/**
142 142
 	 * File extension for external config files
143 143
 	 */
144
-	const CONFIG_FILE_EXT_PHP='.php';
144
+	const CONFIG_FILE_EXT_PHP = '.php';
145 145
 	/**
146 146
 	 * Configuration file type, application.php and config.php
147 147
 	 */
@@ -149,20 +149,20 @@  discard block
 block discarded – undo
149 149
 	/**
150 150
 	 * Runtime directory name
151 151
 	 */
152
-	const RUNTIME_PATH='runtime';
152
+	const RUNTIME_PATH = 'runtime';
153 153
 	/**
154 154
 	 * Config cache file
155 155
 	 */
156
-	const CONFIGCACHE_FILE='config.cache';
156
+	const CONFIGCACHE_FILE = 'config.cache';
157 157
 	/**
158 158
 	 * Global data file
159 159
 	 */
160
-	const GLOBAL_FILE='global.cache';
160
+	const GLOBAL_FILE = 'global.cache';
161 161
 
162 162
 	/**
163 163
 	 * @var array list of events that define application lifecycles
164 164
 	 */
165
-	private static $_steps=array(
165
+	private static $_steps = array(
166 166
 		'onBeginRequest',
167 167
 		'onLoadState',
168 168
 		'onLoadStateComplete',
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	/**
190 190
 	 * @var boolean whether the request is completed
191 191
 	 */
192
-	private $_requestCompleted=false;
192
+	private $_requestCompleted = false;
193 193
 	/**
194 194
 	 * @var integer application state
195 195
 	 */
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 	/**
206 206
 	 * @var array list of loaded application modules
207 207
 	 */
208
-	private $_modules=array();
208
+	private $_modules = array();
209 209
 	/**
210 210
 	 * @var array list of application modules yet to be loaded
211 211
 	 */
212
-	private $_lazyModules=array();
212
+	private $_lazyModules = array();
213 213
 	/**
214 214
 	 * @var TMap list of application parameters
215 215
 	 */
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
 	/**
238 238
 	 * @var boolean if any global state is changed during the current request
239 239
 	 */
240
-	private $_stateChanged=false;
240
+	private $_stateChanged = false;
241 241
 	/**
242 242
 	 * @var array global variables (persistent across sessions, requests)
243 243
 	 */
244
-	private $_globals=array();
244
+	private $_globals = array();
245 245
 	/**
246 246
 	 * @var string cache file
247 247
 	 */
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	/**
294 294
 	 * @var TApplicationMode application mode
295 295
 	 */
296
-	private $_mode=TApplicationMode::Debug;
296
+	private $_mode = TApplicationMode::Debug;
297 297
 
298 298
 	/**
299 299
 	 * @var string Customizable page service ID
@@ -318,22 +318,22 @@  discard block
 block discarded – undo
318 318
 	 * @param boolean whether to cache application configuration. Defaults to true.
319 319
 	 * @throws TConfigurationException if configuration file cannot be read or the runtime path is invalid.
320 320
 	 */
321
-	public function __construct($basePath='protected',$cacheConfig=true, $configType=self::CONFIG_TYPE_XML)
321
+	public function __construct($basePath = 'protected', $cacheConfig = true, $configType = self::CONFIG_TYPE_XML)
322 322
 	{
323 323
 		// register application as a singleton
324 324
 		Prado::setApplication($this);
325 325
 		$this->setConfigurationType($configType);
326 326
 		$this->resolvePaths($basePath);
327 327
 
328
-		if($cacheConfig)
329
-			$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
328
+		if ($cacheConfig)
329
+			$this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE;
330 330
 
331 331
 		// generates unique ID by hashing the runtime path
332
-		$this->_uniqueID=md5($this->_runtimePath);
333
-		$this->_parameters=new TMap;
334
-		$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
332
+		$this->_uniqueID = md5($this->_runtimePath);
333
+		$this->_parameters = new TMap;
334
+		$this->_services = array($this->getPageServiceID()=>array('TPageService', array(), null));
335 335
 
336
-		Prado::setPathOfAlias('Application',$this->_basePath);
336
+		Prado::setPathOfAlias('Application', $this->_basePath);
337 337
 	}
338 338
 
339 339
 	/**
@@ -349,29 +349,29 @@  discard block
 block discarded – undo
349 349
 	protected function resolvePaths($basePath)
350 350
 	{
351 351
 		// determine configuration path and file
352
-		if(empty($basePath) || ($basePath=realpath($basePath))===false)
353
-			throw new TConfigurationException('application_basepath_invalid',$basePath);
354
-		if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName()))
355
-			$configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName();
356
-		else if(is_file($basePath))
352
+		if (empty($basePath) || ($basePath = realpath($basePath)) === false)
353
+			throw new TConfigurationException('application_basepath_invalid', $basePath);
354
+		if (is_dir($basePath) && is_file($basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName()))
355
+			$configFile = $basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName();
356
+		else if (is_file($basePath))
357 357
 		{
358
-			$configFile=$basePath;
359
-			$basePath=dirname($configFile);
358
+			$configFile = $basePath;
359
+			$basePath = dirname($configFile);
360 360
 		}
361 361
 		else
362
-			$configFile=null;
362
+			$configFile = null;
363 363
 
364 364
 		// determine runtime path
365
-		$runtimePath=$basePath.DIRECTORY_SEPARATOR.self::RUNTIME_PATH;
366
-		if(is_writable($runtimePath))
365
+		$runtimePath = $basePath . DIRECTORY_SEPARATOR . self::RUNTIME_PATH;
366
+		if (is_writable($runtimePath))
367 367
 		{
368
-			if($configFile!==null)
368
+			if ($configFile !== null)
369 369
 			{
370
-				$runtimePath.=DIRECTORY_SEPARATOR.basename($configFile).'-'.Prado::getVersion();
371
-				if(!is_dir($runtimePath))
370
+				$runtimePath .= DIRECTORY_SEPARATOR . basename($configFile) . '-' . Prado::getVersion();
371
+				if (!is_dir($runtimePath))
372 372
 				{
373
-					if(@mkdir($runtimePath)===false)
374
-						throw new TConfigurationException('application_runtimepath_failed',$runtimePath);
373
+					if (@mkdir($runtimePath) === false)
374
+						throw new TConfigurationException('application_runtimepath_failed', $runtimePath);
375 375
 					@chmod($runtimePath, PRADO_CHMOD); //make it deletable
376 376
 				}
377 377
 				$this->setConfigurationFile($configFile);
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 			$this->setRuntimePath($runtimePath);
381 381
 		}
382 382
 		else
383
-			throw new TConfigurationException('application_runtimepath_invalid',$runtimePath);
383
+			throw new TConfigurationException('application_runtimepath_invalid', $runtimePath);
384 384
 
385 385
 	}
386 386
 
@@ -394,22 +394,22 @@  discard block
 block discarded – undo
394 394
 		try
395 395
 		{
396 396
 			$this->initApplication();
397
-			$n=count(self::$_steps);
398
-			$this->_step=0;
399
-			$this->_requestCompleted=false;
400
-			while($this->_step<$n)
397
+			$n = count(self::$_steps);
398
+			$this->_step = 0;
399
+			$this->_requestCompleted = false;
400
+			while ($this->_step < $n)
401 401
 			{
402
-				if($this->_mode===self::STATE_OFF)
403
-					throw new THttpException(503,'application_unavailable');
404
-				if($this->_requestCompleted)
402
+				if ($this->_mode === self::STATE_OFF)
403
+					throw new THttpException(503, 'application_unavailable');
404
+				if ($this->_requestCompleted)
405 405
 					break;
406
-				$method=self::$_steps[$this->_step];
407
-				Prado::trace("Executing $method()",'System.TApplication');
406
+				$method = self::$_steps[$this->_step];
407
+				Prado::trace("Executing $method()", 'System.TApplication');
408 408
 				$this->$method();
409 409
 				$this->_step++;
410 410
 			}
411 411
 		}
412
-		catch(Exception $e)
412
+		catch (Exception $e)
413 413
 		{
414 414
 			$this->onError($e);
415 415
 		}
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	public function completeRequest()
425 425
 	{
426
-		$this->_requestCompleted=true;
426
+		$this->_requestCompleted = true;
427 427
 	}
428 428
 
429 429
 	/**
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 	 * @param mixed the default value. If $key is not found, $defaultValue will be returned
443 443
 	 * @return mixed the global value corresponding to $key
444 444
 	 */
445
-	public function getGlobalState($key,$defaultValue=null)
445
+	public function getGlobalState($key, $defaultValue = null)
446 446
 	{
447
-		return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue;
447
+		return isset($this->_globals[$key]) ? $this->_globals[$key] : $defaultValue;
448 448
 	}
449 449
 
450 450
 	/**
@@ -457,14 +457,14 @@  discard block
 block discarded – undo
457 457
 	 * @param mixed the default value. If $key is not found, $defaultValue will be returned
458 458
 	 * @param boolean wheter to force an immediate GlobalState save. defaults to false
459 459
 	 */
460
-	public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false)
460
+	public function setGlobalState($key, $value, $defaultValue = null, $forceSave = false)
461 461
 	{
462
-		$this->_stateChanged=true;
463
-		if($value===$defaultValue)
462
+		$this->_stateChanged = true;
463
+		if ($value === $defaultValue)
464 464
 			unset($this->_globals[$key]);
465 465
 		else
466
-			$this->_globals[$key]=$value;
467
-		if($forceSave)
466
+			$this->_globals[$key] = $value;
467
+		if ($forceSave)
468 468
 			$this->saveGlobals();
469 469
 	}
470 470
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 */
477 477
 	public function clearGlobalState($key)
478 478
 	{
479
-		$this->_stateChanged=true;
479
+		$this->_stateChanged = true;
480 480
 		unset($this->_globals[$key]);
481 481
 	}
482 482
 
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	 */
489 489
 	protected function loadGlobals()
490 490
 	{
491
-		$this->_globals=$this->getApplicationStatePersister()->load();
491
+		$this->_globals = $this->getApplicationStatePersister()->load();
492 492
 	}
493 493
 
494 494
 	/**
@@ -497,9 +497,9 @@  discard block
 block discarded – undo
497 497
 	 */
498 498
 	protected function saveGlobals()
499 499
 	{
500
-		if($this->_stateChanged)
500
+		if ($this->_stateChanged)
501 501
 		{
502
-			$this->_stateChanged=false;
502
+			$this->_stateChanged = false;
503 503
 			$this->getApplicationStatePersister()->save($this->_globals);
504 504
 		}
505 505
 	}
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 	 */
518 518
 	public function setID($value)
519 519
 	{
520
-		$this->_id=$value;
520
+		$this->_id = $value;
521 521
 	}
522 522
 
523 523
 	/**
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 	 */
534 534
 	public function setPageServiceID($value)
535 535
 	{
536
-		$this->_pageServiceID=$value;
536
+		$this->_pageServiceID = $value;
537 537
 	}
538 538
 
539 539
 	/**
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 	 */
558 558
 	public function setMode($value)
559 559
 	{
560
-		$this->_mode=TPropertyValue::ensureEnum($value,'TApplicationMode');
560
+		$this->_mode = TPropertyValue::ensureEnum($value, 'TApplicationMode');
561 561
 	}
562 562
 
563 563
 	/**
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 	 */
574 574
 	public function setBasePath($value)
575 575
 	{
576
-		$this->_basePath=$value;
576
+		$this->_basePath = $value;
577 577
 	}
578 578
 
579 579
 	/**
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 	 */
590 590
 	public function setConfigurationFile($value)
591 591
 	{
592
-		$this->_configFile=$value;
592
+		$this->_configFile = $value;
593 593
 	}
594 594
 
595 595
 	/**
@@ -613,9 +613,9 @@  discard block
 block discarded – undo
613 613
 	 */
614 614
 	public function getConfigurationFileExt()
615 615
 	{
616
-		if($this->_configFileExt===null)
616
+		if ($this->_configFileExt === null)
617 617
 		{
618
-			switch($this->_configType)
618
+			switch ($this->_configType)
619 619
 			{
620 620
 				case TApplication::CONFIG_TYPE_PHP:
621 621
 					$this->_configFileExt = TApplication::CONFIG_FILE_EXT_PHP;
@@ -633,9 +633,9 @@  discard block
 block discarded – undo
633 633
 	public function getConfigurationFileName()
634 634
 	{
635 635
 		static $fileName;
636
-		if($fileName == null)
636
+		if ($fileName == null)
637 637
 		{
638
-			switch($this->_configType)
638
+			switch ($this->_configType)
639 639
 			{
640 640
 				case TApplication::CONFIG_TYPE_PHP:
641 641
 					$fileName = TApplication::CONFIG_FILE_PHP;
@@ -660,11 +660,11 @@  discard block
 block discarded – undo
660 660
 	 */
661 661
 	public function setRuntimePath($value)
662 662
 	{
663
-		$this->_runtimePath=$value;
664
-		if($this->_cacheFile)
665
-			$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
663
+		$this->_runtimePath = $value;
664
+		if ($this->_cacheFile)
665
+			$this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE;
666 666
 		// generates unique ID by hashing the runtime path
667
-		$this->_uniqueID=md5($this->_runtimePath);
667
+		$this->_uniqueID = md5($this->_runtimePath);
668 668
 	}
669 669
 
670 670
 	/**
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 	 */
681 681
 	public function setService($value)
682 682
 	{
683
-		$this->_service=$value;
683
+		$this->_service = $value;
684 684
 	}
685 685
 
686 686
 	/**
@@ -689,12 +689,12 @@  discard block
 block discarded – undo
689 689
 	 * @param string ID of the module
690 690
 	 * @param IModule module object or null if the module has not been loaded yet
691 691
 	 */
692
-	public function setModule($id,IModule $module=null)
692
+	public function setModule($id, IModule $module = null)
693 693
 	{
694
-		if(isset($this->_modules[$id]))
695
-			throw new TConfigurationException('application_moduleid_duplicated',$id);
694
+		if (isset($this->_modules[$id]))
695
+			throw new TConfigurationException('application_moduleid_duplicated', $id);
696 696
 		else
697
-			$this->_modules[$id]=$module;
697
+			$this->_modules[$id] = $module;
698 698
 	}
699 699
 
700 700
 	/**
@@ -702,11 +702,11 @@  discard block
 block discarded – undo
702 702
 	 */
703 703
 	public function getModule($id)
704 704
 	{
705
-		if(!array_key_exists($id, $this->_modules))
705
+		if (!array_key_exists($id, $this->_modules))
706 706
 			return null;
707 707
 
708 708
 		// force loading of a lazy module
709
-		if($this->_modules[$id]===null)
709
+		if ($this->_modules[$id] === null)
710 710
 		{
711 711
 			$module = $this->internalLoadModule($id, true);
712 712
 			$module[0]->init($module[1]);
@@ -741,9 +741,9 @@  discard block
 block discarded – undo
741 741
 	 */
742 742
 	public function getRequest()
743 743
 	{
744
-		if(!$this->_request)
744
+		if (!$this->_request)
745 745
 		{
746
-			$this->_request=new THttpRequest;
746
+			$this->_request = new THttpRequest;
747 747
 			$this->_request->init(null);
748 748
 		}
749 749
 		return $this->_request;
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 	 */
755 755
 	public function setRequest(THttpRequest $request)
756 756
 	{
757
-		$this->_request=$request;
757
+		$this->_request = $request;
758 758
 	}
759 759
 
760 760
 	/**
@@ -762,9 +762,9 @@  discard block
 block discarded – undo
762 762
 	 */
763 763
 	public function getResponse()
764 764
 	{
765
-		if(!$this->_response)
765
+		if (!$this->_response)
766 766
 		{
767
-			$this->_response=new THttpResponse;
767
+			$this->_response = new THttpResponse;
768 768
 			$this->_response->init(null);
769 769
 		}
770 770
 		return $this->_response;
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 	 */
776 776
 	public function setResponse(THttpResponse $response)
777 777
 	{
778
-		$this->_response=$response;
778
+		$this->_response = $response;
779 779
 	}
780 780
 
781 781
 	/**
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
 	 */
784 784
 	public function getSession()
785 785
 	{
786
-		if(!$this->_session)
786
+		if (!$this->_session)
787 787
 		{
788
-			$this->_session=new THttpSession;
788
+			$this->_session = new THttpSession;
789 789
 			$this->_session->init(null);
790 790
 		}
791 791
 		return $this->_session;
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 	 */
797 797
 	public function setSession(THttpSession $session)
798 798
 	{
799
-		$this->_session=$session;
799
+		$this->_session = $session;
800 800
 	}
801 801
 
802 802
 	/**
@@ -804,9 +804,9 @@  discard block
 block discarded – undo
804 804
 	 */
805 805
 	public function getErrorHandler()
806 806
 	{
807
-		if(!$this->_errorHandler)
807
+		if (!$this->_errorHandler)
808 808
 		{
809
-			$this->_errorHandler=new TErrorHandler;
809
+			$this->_errorHandler = new TErrorHandler;
810 810
 			$this->_errorHandler->init(null);
811 811
 		}
812 812
 		return $this->_errorHandler;
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 	 */
818 818
 	public function setErrorHandler(TErrorHandler $handler)
819 819
 	{
820
-		$this->_errorHandler=$handler;
820
+		$this->_errorHandler = $handler;
821 821
 	}
822 822
 
823 823
 	/**
@@ -825,9 +825,9 @@  discard block
 block discarded – undo
825 825
 	 */
826 826
 	public function getSecurityManager()
827 827
 	{
828
-		if(!$this->_security)
828
+		if (!$this->_security)
829 829
 		{
830
-			$this->_security=new TSecurityManager;
830
+			$this->_security = new TSecurityManager;
831 831
 			$this->_security->init(null);
832 832
 		}
833 833
 		return $this->_security;
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	 */
839 839
 	public function setSecurityManager(TSecurityManager $sm)
840 840
 	{
841
-		$this->_security=$sm;
841
+		$this->_security = $sm;
842 842
 	}
843 843
 
844 844
 	/**
@@ -846,9 +846,9 @@  discard block
 block discarded – undo
846 846
 	 */
847 847
 	public function getAssetManager()
848 848
 	{
849
-		if(!$this->_assetManager)
849
+		if (!$this->_assetManager)
850 850
 		{
851
-			$this->_assetManager=new TAssetManager;
851
+			$this->_assetManager = new TAssetManager;
852 852
 			$this->_assetManager->init(null);
853 853
 		}
854 854
 		return $this->_assetManager;
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 	 */
860 860
 	public function setAssetManager(TAssetManager $value)
861 861
 	{
862
-		$this->_assetManager=$value;
862
+		$this->_assetManager = $value;
863 863
 	}
864 864
 
865 865
 	/**
@@ -867,9 +867,9 @@  discard block
 block discarded – undo
867 867
 	 */
868 868
 	public function getApplicationStatePersister()
869 869
 	{
870
-		if(!$this->_statePersister)
870
+		if (!$this->_statePersister)
871 871
 		{
872
-			$this->_statePersister=new TApplicationStatePersister;
872
+			$this->_statePersister = new TApplicationStatePersister;
873 873
 			$this->_statePersister->init(null);
874 874
 		}
875 875
 		return $this->_statePersister;
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 	 */
881 881
 	public function setApplicationStatePersister(IStatePersister $persister)
882 882
 	{
883
-		$this->_statePersister=$persister;
883
+		$this->_statePersister = $persister;
884 884
 	}
885 885
 
886 886
 	/**
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 */
897 897
 	public function setCache(ICache $cache)
898 898
 	{
899
-		$this->_cache=$cache;
899
+		$this->_cache = $cache;
900 900
 	}
901 901
 
902 902
 	/**
@@ -912,18 +912,18 @@  discard block
 block discarded – undo
912 912
 	 */
913 913
 	public function setUser(IUser $user)
914 914
 	{
915
-		$this->_user=$user;
915
+		$this->_user = $user;
916 916
 	}
917 917
 
918 918
 	/**
919 919
 	 * @param boolean whether to create globalization if it does not exist
920 920
 	 * @return TGlobalization globalization module
921 921
 	 */
922
-	public function getGlobalization($createIfNotExists=true)
922
+	public function getGlobalization($createIfNotExists = true)
923 923
 	{
924
-		if($this->_globalization===null && $createIfNotExists)
924
+		if ($this->_globalization === null && $createIfNotExists)
925 925
 		{
926
-			$this->_globalization=new TGlobalization;
926
+			$this->_globalization = new TGlobalization;
927 927
 			$this->_globalization->init(null);
928 928
 		}
929 929
 		return $this->_globalization;
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 	 */
935 935
 	public function setGlobalization(TGlobalization $glob)
936 936
 	{
937
-		$this->_globalization=$glob;
937
+		$this->_globalization = $glob;
938 938
 	}
939 939
 
940 940
 	/**
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
 	 */
943 943
 	public function getAuthorizationRules()
944 944
 	{
945
-		if($this->_authRules===null)
946
-			$this->_authRules=new TAuthorizationRuleCollection;
945
+		if ($this->_authRules === null)
946
+			$this->_authRules = new TAuthorizationRuleCollection;
947 947
 		return $this->_authRules;
948 948
 	}
949 949
 
@@ -952,99 +952,99 @@  discard block
 block discarded – undo
952 952
 		return 'TApplicationConfiguration';
953 953
 	}
954 954
 
955
-	protected function internalLoadModule($id, $force=false)
955
+	protected function internalLoadModule($id, $force = false)
956 956
 	{
957
-		list($moduleClass, $initProperties, $configElement)=$this->_lazyModules[$id];
958
-		if(isset($initProperties['lazy']) && $initProperties['lazy'] && !$force)
957
+		list($moduleClass, $initProperties, $configElement) = $this->_lazyModules[$id];
958
+		if (isset($initProperties['lazy']) && $initProperties['lazy'] && !$force)
959 959
 		{
960
-			Prado::trace("Postponed loading of lazy module $id ({$moduleClass})",'System.TApplication');
960
+			Prado::trace("Postponed loading of lazy module $id ({$moduleClass})", 'System.TApplication');
961 961
 			$this->setModule($id, null);
962 962
 			return null;
963 963
 		}
964 964
 
965
-		Prado::trace("Loading module $id ({$moduleClass})",'System.TApplication');
966
-		$module=Prado::createComponent($moduleClass);
967
-		foreach($initProperties as $name=>$value)
965
+		Prado::trace("Loading module $id ({$moduleClass})", 'System.TApplication');
966
+		$module = Prado::createComponent($moduleClass);
967
+		foreach ($initProperties as $name=>$value)
968 968
 		{
969
-			if($name==='lazy') continue;
970
-			$module->setSubProperty($name,$value);
969
+			if ($name === 'lazy') continue;
970
+			$module->setSubProperty($name, $value);
971 971
 		}
972
-		$this->setModule($id,$module);
972
+		$this->setModule($id, $module);
973 973
 		// keep the key to avoid reuse of the old module id
974
-		$this->_lazyModules[$id]=null;
974
+		$this->_lazyModules[$id] = null;
975 975
 
976
-		return array($module,$configElement);
976
+		return array($module, $configElement);
977 977
 	}
978 978
 	/**
979 979
 	 * Applies an application configuration.
980 980
 	 * @param TApplicationConfiguration the configuration
981 981
 	 * @param boolean whether the configuration is specified within a service.
982 982
 	 */
983
-	public function applyConfiguration($config,$withinService=false)
983
+	public function applyConfiguration($config, $withinService = false)
984 984
 	{
985
-		if($config->getIsEmpty())
985
+		if ($config->getIsEmpty())
986 986
 			return;
987 987
 
988 988
 		// set path aliases and using namespaces
989
-		foreach($config->getAliases() as $alias=>$path)
990
-			Prado::setPathOfAlias($alias,$path);
991
-		foreach($config->getUsings() as $using)
989
+		foreach ($config->getAliases() as $alias=>$path)
990
+			Prado::setPathOfAlias($alias, $path);
991
+		foreach ($config->getUsings() as $using)
992 992
 			Prado::using($using);
993 993
 
994 994
 		// set application properties
995
-		if(!$withinService)
995
+		if (!$withinService)
996 996
 		{
997
-			foreach($config->getProperties() as $name=>$value)
998
-				$this->setSubProperty($name,$value);
997
+			foreach ($config->getProperties() as $name=>$value)
998
+				$this->setSubProperty($name, $value);
999 999
 		}
1000 1000
 
1001
-		if(empty($this->_services))
1002
-			$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
1001
+		if (empty($this->_services))
1002
+			$this->_services = array($this->getPageServiceID()=>array('TPageService', array(), null));
1003 1003
 
1004 1004
 		// load parameters
1005
-		foreach($config->getParameters() as $id=>$parameter)
1005
+		foreach ($config->getParameters() as $id=>$parameter)
1006 1006
 		{
1007
-			if(is_array($parameter))
1007
+			if (is_array($parameter))
1008 1008
 			{
1009
-				$component=Prado::createComponent($parameter[0]);
1010
-				foreach($parameter[1] as $name=>$value)
1011
-					$component->setSubProperty($name,$value);
1012
-				$this->_parameters->add($id,$component);
1009
+				$component = Prado::createComponent($parameter[0]);
1010
+				foreach ($parameter[1] as $name=>$value)
1011
+					$component->setSubProperty($name, $value);
1012
+				$this->_parameters->add($id, $component);
1013 1013
 			}
1014 1014
 			else
1015
-				$this->_parameters->add($id,$parameter);
1015
+				$this->_parameters->add($id, $parameter);
1016 1016
 		}
1017 1017
 
1018 1018
 		// load and init modules specified in app config
1019
-		$modules=array();
1020
-		foreach($config->getModules() as $id=>$moduleConfig)
1019
+		$modules = array();
1020
+		foreach ($config->getModules() as $id=>$moduleConfig)
1021 1021
 		{
1022
-			if(!is_string($id))
1023
-				$id='_module'.count($this->_lazyModules);
1024
-			$this->_lazyModules[$id]=$moduleConfig;
1025
-			if($module = $this->internalLoadModule($id))
1026
-				$modules[]=$module;
1022
+			if (!is_string($id))
1023
+				$id = '_module' . count($this->_lazyModules);
1024
+			$this->_lazyModules[$id] = $moduleConfig;
1025
+			if ($module = $this->internalLoadModule($id))
1026
+				$modules[] = $module;
1027 1027
 		}
1028
-		foreach($modules as $module)
1028
+		foreach ($modules as $module)
1029 1029
 			$module[0]->init($module[1]);
1030 1030
 
1031 1031
 		// load service
1032
-		foreach($config->getServices() as $serviceID=>$serviceConfig)
1033
-			$this->_services[$serviceID]=$serviceConfig;
1032
+		foreach ($config->getServices() as $serviceID=>$serviceConfig)
1033
+			$this->_services[$serviceID] = $serviceConfig;
1034 1034
 
1035 1035
 		// external configurations
1036
-		foreach($config->getExternalConfigurations() as $filePath=>$condition)
1036
+		foreach ($config->getExternalConfigurations() as $filePath=>$condition)
1037 1037
 		{
1038
-			if($condition!==true)
1039
-				$condition=$this->evaluateExpression($condition);
1040
-			if($condition)
1038
+			if ($condition !== true)
1039
+				$condition = $this->evaluateExpression($condition);
1040
+			if ($condition)
1041 1041
 			{
1042
-				if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path))
1043
-					throw new TConfigurationException('application_includefile_invalid',$filePath);
1044
-				$cn=$this->getApplicationConfigurationClass();
1045
-				$c=new $cn;
1042
+				if (($path = Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt())) === null || !is_file($path))
1043
+					throw new TConfigurationException('application_includefile_invalid', $filePath);
1044
+				$cn = $this->getApplicationConfigurationClass();
1045
+				$c = new $cn;
1046 1046
 				$c->loadFromFile($path);
1047
-				$this->applyConfiguration($c,$withinService);
1047
+				$this->applyConfiguration($c, $withinService);
1048 1048
 			}
1049 1049
 		}
1050 1050
 	}
@@ -1060,25 +1060,25 @@  discard block
 block discarded – undo
1060 1060
 	 */
1061 1061
 	protected function initApplication()
1062 1062
 	{
1063
-		Prado::trace('Initializing application','System.TApplication');
1063
+		Prado::trace('Initializing application', 'System.TApplication');
1064 1064
 
1065
-		if($this->_configFile!==null)
1065
+		if ($this->_configFile !== null)
1066 1066
 		{
1067
-			if($this->_cacheFile===null || @filemtime($this->_cacheFile)<filemtime($this->_configFile))
1067
+			if ($this->_cacheFile === null || @filemtime($this->_cacheFile) < filemtime($this->_configFile))
1068 1068
 			{
1069
-				$config=new TApplicationConfiguration;
1069
+				$config = new TApplicationConfiguration;
1070 1070
 				$config->loadFromFile($this->_configFile);
1071
-				if($this->_cacheFile!==null)
1072
-					file_put_contents($this->_cacheFile,serialize($config),LOCK_EX);
1071
+				if ($this->_cacheFile !== null)
1072
+					file_put_contents($this->_cacheFile, serialize($config), LOCK_EX);
1073 1073
 			}
1074 1074
 			else
1075
-				$config=unserialize(file_get_contents($this->_cacheFile));
1075
+				$config = unserialize(file_get_contents($this->_cacheFile));
1076 1076
 
1077
-			$this->applyConfiguration($config,false);
1077
+			$this->applyConfiguration($config, false);
1078 1078
 		}
1079 1079
 
1080
-		if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null)
1081
-			$serviceID=$this->getPageServiceID();
1080
+		if (($serviceID = $this->getRequest()->resolveRequest(array_keys($this->_services))) === null)
1081
+			$serviceID = $this->getPageServiceID();
1082 1082
 
1083 1083
 		$this->startService($serviceID);
1084 1084
 	}
@@ -1091,34 +1091,34 @@  discard block
 block discarded – undo
1091 1091
 	 */
1092 1092
 	public function startService($serviceID)
1093 1093
 	{
1094
-		if(isset($this->_services[$serviceID]))
1094
+		if (isset($this->_services[$serviceID]))
1095 1095
 		{
1096
-			list($serviceClass,$initProperties,$configElement)=$this->_services[$serviceID];
1097
-			$service=Prado::createComponent($serviceClass);
1098
-			if(!($service instanceof IService))
1099
-				throw new THttpException(500,'application_service_invalid',$serviceClass);
1100
-			if(!$service->getEnabled())
1101
-				throw new THttpException(500,'application_service_unavailable',$serviceClass);
1096
+			list($serviceClass, $initProperties, $configElement) = $this->_services[$serviceID];
1097
+			$service = Prado::createComponent($serviceClass);
1098
+			if (!($service instanceof IService))
1099
+				throw new THttpException(500, 'application_service_invalid', $serviceClass);
1100
+			if (!$service->getEnabled())
1101
+				throw new THttpException(500, 'application_service_unavailable', $serviceClass);
1102 1102
 			$service->setID($serviceID);
1103 1103
 			$this->setService($service);
1104 1104
 
1105
-			foreach($initProperties as $name=>$value)
1106
-				$service->setSubProperty($name,$value);
1105
+			foreach ($initProperties as $name=>$value)
1106
+				$service->setSubProperty($name, $value);
1107 1107
 
1108
-			if($configElement!==null)
1108
+			if ($configElement !== null)
1109 1109
 			{
1110
-				$config=new TApplicationConfiguration;
1111
-				if($this->getConfigurationType()==self::CONFIG_TYPE_PHP)
1112
-					$config->loadFromPhp($configElement,$this->getBasePath());
1110
+				$config = new TApplicationConfiguration;
1111
+				if ($this->getConfigurationType() == self::CONFIG_TYPE_PHP)
1112
+					$config->loadFromPhp($configElement, $this->getBasePath());
1113 1113
 				else
1114
-					$config->loadFromXml($configElement,$this->getBasePath());
1115
-				$this->applyConfiguration($config,true);
1114
+					$config->loadFromXml($configElement, $this->getBasePath());
1115
+				$this->applyConfiguration($config, true);
1116 1116
 			}
1117 1117
 
1118 1118
 			$service->init($configElement);
1119 1119
 		}
1120 1120
 		else
1121
-			throw new THttpException(500,'application_service_unknown',$serviceID);
1121
+			throw new THttpException(500, 'application_service_unknown', $serviceID);
1122 1122
 	}
1123 1123
 
1124 1124
 	/**
@@ -1129,9 +1129,9 @@  discard block
 block discarded – undo
1129 1129
 	 */
1130 1130
 	public function onError($param)
1131 1131
 	{
1132
-		Prado::log($param->getMessage(),TLogger::ERROR,'System.TApplication');
1133
-		$this->raiseEvent('OnError',$this,$param);
1134
-		$this->getErrorHandler()->handleError($this,$param);
1132
+		Prado::log($param->getMessage(), TLogger::ERROR, 'System.TApplication');
1133
+		$this->raiseEvent('OnError', $this, $param);
1134
+		$this->getErrorHandler()->handleError($this, $param);
1135 1135
 	}
1136 1136
 
1137 1137
 	/**
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 	 */
1144 1144
 	public function onBeginRequest()
1145 1145
 	{
1146
-		$this->raiseEvent('OnBeginRequest',$this,null);
1146
+		$this->raiseEvent('OnBeginRequest', $this, null);
1147 1147
 	}
1148 1148
 
1149 1149
 	/**
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	 */
1153 1153
 	public function onAuthentication()
1154 1154
 	{
1155
-		$this->raiseEvent('OnAuthentication',$this,null);
1155
+		$this->raiseEvent('OnAuthentication', $this, null);
1156 1156
 	}
1157 1157
 
1158 1158
 	/**
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 	 */
1162 1162
 	public function onAuthenticationComplete()
1163 1163
 	{
1164
-		$this->raiseEvent('OnAuthenticationComplete',$this,null);
1164
+		$this->raiseEvent('OnAuthenticationComplete', $this, null);
1165 1165
 	}
1166 1166
 
1167 1167
 	/**
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 	 */
1171 1171
 	public function onAuthorization()
1172 1172
 	{
1173
-		$this->raiseEvent('OnAuthorization',$this,null);
1173
+		$this->raiseEvent('OnAuthorization', $this, null);
1174 1174
 	}
1175 1175
 
1176 1176
 	/**
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 	 */
1180 1180
 	public function onAuthorizationComplete()
1181 1181
 	{
1182
-		$this->raiseEvent('OnAuthorizationComplete',$this,null);
1182
+		$this->raiseEvent('OnAuthorizationComplete', $this, null);
1183 1183
 	}
1184 1184
 
1185 1185
 	/**
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
 	public function onLoadState()
1190 1190
 	{
1191 1191
 		$this->loadGlobals();
1192
-		$this->raiseEvent('OnLoadState',$this,null);
1192
+		$this->raiseEvent('OnLoadState', $this, null);
1193 1193
 	}
1194 1194
 
1195 1195
 	/**
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
 	 */
1199 1199
 	public function onLoadStateComplete()
1200 1200
 	{
1201
-		$this->raiseEvent('OnLoadStateComplete',$this,null);
1201
+		$this->raiseEvent('OnLoadStateComplete', $this, null);
1202 1202
 	}
1203 1203
 
1204 1204
 	/**
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
 	 */
1208 1208
 	public function onPreRunService()
1209 1209
 	{
1210
-		$this->raiseEvent('OnPreRunService',$this,null);
1210
+		$this->raiseEvent('OnPreRunService', $this, null);
1211 1211
 	}
1212 1212
 
1213 1213
 	/**
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 	 */
1216 1216
 	public function runService()
1217 1217
 	{
1218
-		if($this->_service)
1218
+		if ($this->_service)
1219 1219
 			$this->_service->run();
1220 1220
 	}
1221 1221
 
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 	 */
1226 1226
 	public function onSaveState()
1227 1227
 	{
1228
-		$this->raiseEvent('OnSaveState',$this,null);
1228
+		$this->raiseEvent('OnSaveState', $this, null);
1229 1229
 		$this->saveGlobals();
1230 1230
 	}
1231 1231
 
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 	 */
1236 1236
 	public function onSaveStateComplete()
1237 1237
 	{
1238
-		$this->raiseEvent('OnSaveStateComplete',$this,null);
1238
+		$this->raiseEvent('OnSaveStateComplete', $this, null);
1239 1239
 	}
1240 1240
 
1241 1241
 	/**
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 	 */
1245 1245
 	public function onPreFlushOutput()
1246 1246
 	{
1247
-		$this->raiseEvent('OnPreFlushOutput',$this,null);
1247
+		$this->raiseEvent('OnPreFlushOutput', $this, null);
1248 1248
 	}
1249 1249
 
1250 1250
 	/**
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 	public function onEndRequest()
1264 1264
 	{
1265 1265
 		$this->flushOutput(false); // flush all remaining content in the buffer
1266
-		$this->saveGlobals();  // save global state
1267
-		$this->raiseEvent('OnEndRequest',$this,null);
1266
+		$this->saveGlobals(); // save global state
1267
+		$this->raiseEvent('OnEndRequest', $this, null);
1268 1268
 	}
1269 1269
 }
1270 1270
 
@@ -1283,10 +1283,10 @@  discard block
 block discarded – undo
1283 1283
  */
1284 1284
 class TApplicationMode extends TEnumerable
1285 1285
 {
1286
-	const Off='Off';
1287
-	const Debug='Debug';
1288
-	const Normal='Normal';
1289
-	const Performance='Performance';
1286
+	const Off = 'Off';
1287
+	const Debug = 'Debug';
1288
+	const Normal = 'Normal';
1289
+	const Performance = 'Performance';
1290 1290
 }
1291 1291
 
1292 1292
 
@@ -1305,35 +1305,35 @@  discard block
 block discarded – undo
1305 1305
 	/**
1306 1306
 	 * @var array list of application initial property values, indexed by property names
1307 1307
 	 */
1308
-	private $_properties=array();
1308
+	private $_properties = array();
1309 1309
 	/**
1310 1310
 	 * @var array list of namespaces to be used
1311 1311
 	 */
1312
-	private $_usings=array();
1312
+	private $_usings = array();
1313 1313
 	/**
1314 1314
 	 * @var array list of path aliases, indexed by alias names
1315 1315
 	 */
1316
-	private $_aliases=array();
1316
+	private $_aliases = array();
1317 1317
 	/**
1318 1318
 	 * @var array list of module configurations
1319 1319
 	 */
1320
-	private $_modules=array();
1320
+	private $_modules = array();
1321 1321
 	/**
1322 1322
 	 * @var array list of service configurations
1323 1323
 	 */
1324
-	private $_services=array();
1324
+	private $_services = array();
1325 1325
 	/**
1326 1326
 	 * @var array list of parameters
1327 1327
 	 */
1328
-	private $_parameters=array();
1328
+	private $_parameters = array();
1329 1329
 	/**
1330 1330
 	 * @var array list of included configurations
1331 1331
 	 */
1332
-	private $_includes=array();
1332
+	private $_includes = array();
1333 1333
 	/**
1334 1334
 	 * @var boolean whether this configuration contains actual stuff
1335 1335
 	 */
1336
-	private $_empty=true;
1336
+	private $_empty = true;
1337 1337
 
1338 1338
 	/**
1339 1339
 	 * Parses the application configuration file.
@@ -1342,16 +1342,16 @@  discard block
 block discarded – undo
1342 1342
 	 */
1343 1343
 	public function loadFromFile($fname)
1344 1344
 	{
1345
-		if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
1345
+		if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
1346 1346
 		{
1347 1347
 			$fcontent = include $fname;
1348
-			$this->loadFromPhp($fcontent,dirname($fname));
1348
+			$this->loadFromPhp($fcontent, dirname($fname));
1349 1349
 		}
1350 1350
 		else
1351 1351
 		{
1352
-			$dom=new TXmlDocument;
1352
+			$dom = new TXmlDocument;
1353 1353
 			$dom->loadFromFile($fname);
1354
-			$this->loadFromXml($dom,dirname($fname));
1354
+			$this->loadFromXml($dom, dirname($fname));
1355 1355
 		}
1356 1356
 	}
1357 1357
 
@@ -1371,29 +1371,29 @@  discard block
 block discarded – undo
1371 1371
 	public function loadFromPhp($config, $configPath)
1372 1372
 	{
1373 1373
 		// application properties
1374
-		if(isset($config['application']))
1374
+		if (isset($config['application']))
1375 1375
 		{
1376
-			foreach($config['application'] as $name=>$value)
1376
+			foreach ($config['application'] as $name=>$value)
1377 1377
 			{
1378
-				$this->_properties[$name]=$value;
1378
+				$this->_properties[$name] = $value;
1379 1379
 			}
1380 1380
 			$this->_empty = false;
1381 1381
 		}
1382 1382
 
1383
-		if(isset($config['paths']) && is_array($config['paths']))
1384
-			$this->loadPathsPhp($config['paths'],$configPath);
1383
+		if (isset($config['paths']) && is_array($config['paths']))
1384
+			$this->loadPathsPhp($config['paths'], $configPath);
1385 1385
 
1386
-		if(isset($config['modules']) && is_array($config['modules']))
1387
-			$this->loadModulesPhp($config['modules'],$configPath);
1386
+		if (isset($config['modules']) && is_array($config['modules']))
1387
+			$this->loadModulesPhp($config['modules'], $configPath);
1388 1388
 
1389
-		if(isset($config['services']) && is_array($config['services']))
1390
-			$this->loadServicesPhp($config['services'],$configPath);
1389
+		if (isset($config['services']) && is_array($config['services']))
1390
+			$this->loadServicesPhp($config['services'], $configPath);
1391 1391
 
1392
-		if(isset($config['parameters']) && is_array($config['parameters']))
1392
+		if (isset($config['parameters']) && is_array($config['parameters']))
1393 1393
 			$this->loadParametersPhp($config['parameters'], $configPath);
1394 1394
 
1395
-		if(isset($config['includes']) && is_array($config['includes']))
1396
-			$this->loadExternalXml($config['includes'],$configPath);
1395
+		if (isset($config['includes']) && is_array($config['includes']))
1396
+			$this->loadExternalXml($config['includes'], $configPath);
1397 1397
 	}
1398 1398
 
1399 1399
 	/**
@@ -1401,33 +1401,33 @@  discard block
 block discarded – undo
1401 1401
 	 * @param TXmlElement the XML element
1402 1402
 	 * @param string the context path (for specifying relative paths)
1403 1403
 	 */
1404
-	public function loadFromXml($dom,$configPath)
1404
+	public function loadFromXml($dom, $configPath)
1405 1405
 	{
1406 1406
 		// application properties
1407
-		foreach($dom->getAttributes() as $name=>$value)
1407
+		foreach ($dom->getAttributes() as $name=>$value)
1408 1408
 		{
1409
-			$this->_properties[$name]=$value;
1410
-			$this->_empty=false;
1409
+			$this->_properties[$name] = $value;
1410
+			$this->_empty = false;
1411 1411
 		}
1412 1412
 
1413
-		foreach($dom->getElements() as $element)
1413
+		foreach ($dom->getElements() as $element)
1414 1414
 		{
1415
-			switch($element->getTagName())
1415
+			switch ($element->getTagName())
1416 1416
 			{
1417 1417
 				case 'paths':
1418
-					$this->loadPathsXml($element,$configPath);
1418
+					$this->loadPathsXml($element, $configPath);
1419 1419
 					break;
1420 1420
 				case 'modules':
1421
-					$this->loadModulesXml($element,$configPath);
1421
+					$this->loadModulesXml($element, $configPath);
1422 1422
 					break;
1423 1423
 				case 'services':
1424
-					$this->loadServicesXml($element,$configPath);
1424
+					$this->loadServicesXml($element, $configPath);
1425 1425
 					break;
1426 1426
 				case 'parameters':
1427
-					$this->loadParametersXml($element,$configPath);
1427
+					$this->loadParametersXml($element, $configPath);
1428 1428
 					break;
1429 1429
 				case 'include':
1430
-					$this->loadExternalXml($element,$configPath);
1430
+					$this->loadExternalXml($element, $configPath);
1431 1431
 					break;
1432 1432
 				default:
1433 1433
 					//throw new TConfigurationException('appconfig_tag_invalid',$element->getTagName());
@@ -1443,26 +1443,26 @@  discard block
 block discarded – undo
1443 1443
 	 */
1444 1444
 	protected function loadPathsPhp($pathsNode, $configPath)
1445 1445
 	{
1446
-		if(isset($pathsNode['aliases']) && is_array($pathsNode['aliases']))
1446
+		if (isset($pathsNode['aliases']) && is_array($pathsNode['aliases']))
1447 1447
 		{
1448
-			foreach($pathsNode['aliases'] as $id=>$path)
1448
+			foreach ($pathsNode['aliases'] as $id=>$path)
1449 1449
 			{
1450
-				$path=str_replace('\\','/',$path);
1451
-				if(preg_match('/^\\/|.:\\/|.:\\\\/',$path))	// if absolute path
1452
-					$p=realpath($path);
1450
+				$path = str_replace('\\', '/', $path);
1451
+				if (preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
1452
+					$p = realpath($path);
1453 1453
 				else
1454
-					$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
1455
-				if($p===false || !is_dir($p))
1456
-					throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
1457
-				if(isset($this->_aliases[$id]))
1458
-					throw new TConfigurationException('appconfig_alias_redefined',$id);
1459
-				$this->_aliases[$id]=$p;
1454
+					$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
1455
+				if ($p === false || !is_dir($p))
1456
+					throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
1457
+				if (isset($this->_aliases[$id]))
1458
+					throw new TConfigurationException('appconfig_alias_redefined', $id);
1459
+				$this->_aliases[$id] = $p;
1460 1460
 			}
1461 1461
 		}
1462 1462
 
1463
-		if(isset($pathsNode['using']) && is_array($pathsNode['using']))
1463
+		if (isset($pathsNode['using']) && is_array($pathsNode['using']))
1464 1464
 		{
1465
-			foreach($pathsNode['using'] as $namespace)
1465
+			foreach ($pathsNode['using'] as $namespace)
1466 1466
 			{
1467 1467
 				$this->_usings[] = $namespace;
1468 1468
 			}
@@ -1474,43 +1474,43 @@  discard block
 block discarded – undo
1474 1474
 	 * @param TXmlElement the paths XML node
1475 1475
 	 * @param string the context path (for specifying relative paths)
1476 1476
 	 */
1477
-	protected function loadPathsXml($pathsNode,$configPath)
1477
+	protected function loadPathsXml($pathsNode, $configPath)
1478 1478
 	{
1479
-		foreach($pathsNode->getElements() as $element)
1479
+		foreach ($pathsNode->getElements() as $element)
1480 1480
 		{
1481
-			switch($element->getTagName())
1481
+			switch ($element->getTagName())
1482 1482
 			{
1483 1483
 				case 'alias':
1484 1484
 				{
1485
-					if(($id=$element->getAttribute('id'))!==null && ($path=$element->getAttribute('path'))!==null)
1485
+					if (($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null)
1486 1486
 					{
1487
-						$path=str_replace('\\','/',$path);
1488
-						if(preg_match('/^\\/|.:\\/|.:\\\\/',$path))	// if absolute path
1489
-							$p=realpath($path);
1487
+						$path = str_replace('\\', '/', $path);
1488
+						if (preg_match('/^\\/|.:\\/|.:\\\\/', $path))	// if absolute path
1489
+							$p = realpath($path);
1490 1490
 						else
1491
-							$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
1492
-						if($p===false || !is_dir($p))
1493
-							throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
1494
-						if(isset($this->_aliases[$id]))
1495
-							throw new TConfigurationException('appconfig_alias_redefined',$id);
1496
-						$this->_aliases[$id]=$p;
1491
+							$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
1492
+						if ($p === false || !is_dir($p))
1493
+							throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
1494
+						if (isset($this->_aliases[$id]))
1495
+							throw new TConfigurationException('appconfig_alias_redefined', $id);
1496
+						$this->_aliases[$id] = $p;
1497 1497
 					}
1498 1498
 					else
1499 1499
 						throw new TConfigurationException('appconfig_alias_invalid');
1500
-					$this->_empty=false;
1500
+					$this->_empty = false;
1501 1501
 					break;
1502 1502
 				}
1503 1503
 				case 'using':
1504 1504
 				{
1505
-					if(($namespace=$element->getAttribute('namespace'))!==null)
1506
-						$this->_usings[]=$namespace;
1505
+					if (($namespace = $element->getAttribute('namespace')) !== null)
1506
+						$this->_usings[] = $namespace;
1507 1507
 					else
1508 1508
 						throw new TConfigurationException('appconfig_using_invalid');
1509
-					$this->_empty=false;
1509
+					$this->_empty = false;
1510 1510
 					break;
1511 1511
 				}
1512 1512
 				default:
1513
-					throw new TConfigurationException('appconfig_paths_invalid',$element->getTagName());
1513
+					throw new TConfigurationException('appconfig_paths_invalid', $element->getTagName());
1514 1514
 			}
1515 1515
 		}
1516 1516
 	}
@@ -1522,21 +1522,21 @@  discard block
 block discarded – undo
1522 1522
 	 */
1523 1523
 	protected function loadModulesPhp($modulesNode, $configPath)
1524 1524
 	{
1525
-		foreach($modulesNode as $id=>$module)
1525
+		foreach ($modulesNode as $id=>$module)
1526 1526
 		{
1527
-			if(!isset($module['class']))
1528
-				throw new TConfigurationException('appconfig_moduletype_required',$id);
1527
+			if (!isset($module['class']))
1528
+				throw new TConfigurationException('appconfig_moduletype_required', $id);
1529 1529
 			$type = $module['class'];
1530 1530
 			unset($module['class']);
1531 1531
 			$properties = array();
1532
-			if(isset($module['properties']))
1532
+			if (isset($module['properties']))
1533 1533
 			{
1534 1534
 				$properties = $module['properties'];
1535 1535
 				unset($module['properties']);
1536 1536
 			}
1537 1537
 			$properties['id'] = $id;
1538
-			$this->_modules[$id]=array($type,$properties,$module);
1539
-			$this->_empty=false;
1538
+			$this->_modules[$id] = array($type, $properties, $module);
1539
+			$this->_empty = false;
1540 1540
 		}
1541 1541
 	}
1542 1542
 
@@ -1545,26 +1545,26 @@  discard block
 block discarded – undo
1545 1545
 	 * @param TXmlElement the modules XML node
1546 1546
 	 * @param string the context path (for specifying relative paths)
1547 1547
 	 */
1548
-	protected function loadModulesXml($modulesNode,$configPath)
1548
+	protected function loadModulesXml($modulesNode, $configPath)
1549 1549
 	{
1550
-		foreach($modulesNode->getElements() as $element)
1550
+		foreach ($modulesNode->getElements() as $element)
1551 1551
 		{
1552
-			if($element->getTagName()==='module')
1552
+			if ($element->getTagName() === 'module')
1553 1553
 			{
1554
-				$properties=$element->getAttributes();
1555
-				$id=$properties->itemAt('id');
1556
-				$type=$properties->remove('class');
1557
-				if($type===null)
1558
-					throw new TConfigurationException('appconfig_moduletype_required',$id);
1554
+				$properties = $element->getAttributes();
1555
+				$id = $properties->itemAt('id');
1556
+				$type = $properties->remove('class');
1557
+				if ($type === null)
1558
+					throw new TConfigurationException('appconfig_moduletype_required', $id);
1559 1559
 				$element->setParent(null);
1560
-				if($id===null)
1561
-					$this->_modules[]=array($type,$properties->toArray(),$element);
1560
+				if ($id === null)
1561
+					$this->_modules[] = array($type, $properties->toArray(), $element);
1562 1562
 				else
1563
-					$this->_modules[$id]=array($type,$properties->toArray(),$element);
1564
-				$this->_empty=false;
1563
+					$this->_modules[$id] = array($type, $properties->toArray(), $element);
1564
+				$this->_empty = false;
1565 1565
 			}
1566 1566
 			else
1567
-				throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName());
1567
+				throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName());
1568 1568
 		}
1569 1569
 	}
1570 1570
 
@@ -1573,17 +1573,17 @@  discard block
 block discarded – undo
1573 1573
 	 * @param array the services PHP array
1574 1574
 	 * @param string the context path (for specifying relative paths)
1575 1575
 	 */
1576
-	protected function loadServicesPhp($servicesNode,$configPath)
1576
+	protected function loadServicesPhp($servicesNode, $configPath)
1577 1577
 	{
1578
-		foreach($servicesNode as $id => $service)
1578
+		foreach ($servicesNode as $id => $service)
1579 1579
 		{
1580
-			if(!isset($service['class']))
1580
+			if (!isset($service['class']))
1581 1581
 				throw new TConfigurationException('appconfig_servicetype_required');
1582 1582
 			$type = $service['class'];
1583 1583
 			$properties = isset($service['properties']) ? $service['properties'] : array();
1584 1584
 			unset($service['properties']);
1585 1585
 			$properties['id'] = $id;
1586
-			$this->_services[$id] = array($type,$properties,$service);
1586
+			$this->_services[$id] = array($type, $properties, $service);
1587 1587
 			$this->_empty = false;
1588 1588
 		}
1589 1589
 	}
@@ -1593,23 +1593,23 @@  discard block
 block discarded – undo
1593 1593
 	 * @param TXmlElement the services XML node
1594 1594
 	 * @param string the context path (for specifying relative paths)
1595 1595
 	 */
1596
-	protected function loadServicesXml($servicesNode,$configPath)
1596
+	protected function loadServicesXml($servicesNode, $configPath)
1597 1597
 	{
1598
-		foreach($servicesNode->getElements() as $element)
1598
+		foreach ($servicesNode->getElements() as $element)
1599 1599
 		{
1600
-			if($element->getTagName()==='service')
1600
+			if ($element->getTagName() === 'service')
1601 1601
 			{
1602
-				$properties=$element->getAttributes();
1603
-				if(($id=$properties->itemAt('id'))===null)
1602
+				$properties = $element->getAttributes();
1603
+				if (($id = $properties->itemAt('id')) === null)
1604 1604
 					throw new TConfigurationException('appconfig_serviceid_required');
1605
-				if(($type=$properties->remove('class'))===null)
1606
-					throw new TConfigurationException('appconfig_servicetype_required',$id);
1605
+				if (($type = $properties->remove('class')) === null)
1606
+					throw new TConfigurationException('appconfig_servicetype_required', $id);
1607 1607
 				$element->setParent(null);
1608
-				$this->_services[$id]=array($type,$properties->toArray(),$element);
1609
-				$this->_empty=false;
1608
+				$this->_services[$id] = array($type, $properties->toArray(), $element);
1609
+				$this->_empty = false;
1610 1610
 			}
1611 1611
 			else
1612
-				throw new TConfigurationException('appconfig_services_invalid',$element->getTagName());
1612
+				throw new TConfigurationException('appconfig_services_invalid', $element->getTagName());
1613 1613
 		}
1614 1614
 	}
1615 1615
 
@@ -1618,19 +1618,19 @@  discard block
 block discarded – undo
1618 1618
 	 * @param array the parameters PHP array
1619 1619
 	 * @param string the context path (for specifying relative paths)
1620 1620
 	 */
1621
-	protected function loadParametersPhp($parametersNode,$configPath)
1621
+	protected function loadParametersPhp($parametersNode, $configPath)
1622 1622
 	{
1623
-		foreach($parametersNode as $id => $parameter)
1623
+		foreach ($parametersNode as $id => $parameter)
1624 1624
 		{
1625
-			if(is_array($parameter))
1625
+			if (is_array($parameter))
1626 1626
 			{
1627
-				if(isset($parameter['class']))
1627
+				if (isset($parameter['class']))
1628 1628
 				{
1629 1629
 					$type = $parameter['class'];
1630 1630
 					unset($parameter['class']);
1631 1631
 					$properties = isset($service['properties']) ? $service['properties'] : array();
1632 1632
 					$properties['id'] = $id;
1633
-					$this->_parameters[$id] = array($type,$properties);
1633
+					$this->_parameters[$id] = array($type, $properties);
1634 1634
 				}
1635 1635
 			}
1636 1636
 			else
@@ -1645,28 +1645,28 @@  discard block
 block discarded – undo
1645 1645
 	 * @param TXmlElement the parameters XML node
1646 1646
 	 * @param string the context path (for specifying relative paths)
1647 1647
 	 */
1648
-	protected function loadParametersXml($parametersNode,$configPath)
1648
+	protected function loadParametersXml($parametersNode, $configPath)
1649 1649
 	{
1650
-		foreach($parametersNode->getElements() as $element)
1650
+		foreach ($parametersNode->getElements() as $element)
1651 1651
 		{
1652
-			if($element->getTagName()==='parameter')
1652
+			if ($element->getTagName() === 'parameter')
1653 1653
 			{
1654
-				$properties=$element->getAttributes();
1655
-				if(($id=$properties->remove('id'))===null)
1654
+				$properties = $element->getAttributes();
1655
+				if (($id = $properties->remove('id')) === null)
1656 1656
 					throw new TConfigurationException('appconfig_parameterid_required');
1657
-				if(($type=$properties->remove('class'))===null)
1657
+				if (($type = $properties->remove('class')) === null)
1658 1658
 				{
1659
-					if(($value=$properties->remove('value'))===null)
1660
-						$this->_parameters[$id]=$element;
1659
+					if (($value = $properties->remove('value')) === null)
1660
+						$this->_parameters[$id] = $element;
1661 1661
 					else
1662
-						$this->_parameters[$id]=$value;
1662
+						$this->_parameters[$id] = $value;
1663 1663
 				}
1664 1664
 				else
1665
-					$this->_parameters[$id]=array($type,$properties->toArray());
1666
-				$this->_empty=false;
1665
+					$this->_parameters[$id] = array($type, $properties->toArray());
1666
+				$this->_empty = false;
1667 1667
 			}
1668 1668
 			else
1669
-				throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName());
1669
+				throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName());
1670 1670
 		}
1671 1671
 	}
1672 1672
 
@@ -1675,19 +1675,19 @@  discard block
 block discarded – undo
1675 1675
 	 * @param array the application PHP array
1676 1676
 	 * @param string the context path (for specifying relative paths)
1677 1677
 	 */
1678
-	protected function loadExternalPhp($includeNode,$configPath)
1678
+	protected function loadExternalPhp($includeNode, $configPath)
1679 1679
 	{
1680
-		foreach($includeNode as $include)
1680
+		foreach ($includeNode as $include)
1681 1681
 		{
1682
-			$when = isset($include['when'])?true:false;
1683
-			if(!isset($include['file']))
1682
+			$when = isset($include['when']) ? true : false;
1683
+			if (!isset($include['file']))
1684 1684
 				throw new TConfigurationException('appconfig_includefile_required');
1685 1685
 			$filePath = $include['file'];
1686
-			if(isset($this->_includes[$filePath]))
1687
-				$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
1686
+			if (isset($this->_includes[$filePath]))
1687
+				$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
1688 1688
 			else
1689
-				$$this->_includes[$filePath]=$when;
1690
-			$this->_empty=false;
1689
+				$$this->_includes[$filePath] = $when;
1690
+			$this->_empty = false;
1691 1691
 		}
1692 1692
 	}
1693 1693
 
@@ -1696,17 +1696,17 @@  discard block
 block discarded – undo
1696 1696
 	 * @param TXmlElement the application DOM element
1697 1697
 	 * @param string the context path (for specifying relative paths)
1698 1698
 	 */
1699
-	protected function loadExternalXml($includeNode,$configPath)
1699
+	protected function loadExternalXml($includeNode, $configPath)
1700 1700
 	{
1701
-		if(($when=$includeNode->getAttribute('when'))===null)
1702
-			$when=true;
1703
-		if(($filePath=$includeNode->getAttribute('file'))===null)
1701
+		if (($when = $includeNode->getAttribute('when')) === null)
1702
+			$when = true;
1703
+		if (($filePath = $includeNode->getAttribute('file')) === null)
1704 1704
 			throw new TConfigurationException('appconfig_includefile_required');
1705
-		if(isset($this->_includes[$filePath]))
1706
-			$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
1705
+		if (isset($this->_includes[$filePath]))
1706
+			$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
1707 1707
 		else
1708
-			$this->_includes[$filePath]=$when;
1709
-		$this->_empty=false;
1708
+			$this->_includes[$filePath] = $when;
1709
+		$this->_empty = false;
1710 1710
 	}
1711 1711
 
1712 1712
 	/**
@@ -1813,7 +1813,7 @@  discard block
 block discarded – undo
1813 1813
 	/**
1814 1814
 	 * Name of the value stored in cache
1815 1815
 	 */
1816
-	const CACHE_NAME='prado:appstate';
1816
+	const CACHE_NAME = 'prado:appstate';
1817 1817
 
1818 1818
 	/**
1819 1819
 	 * Initializes module.
@@ -1829,7 +1829,7 @@  discard block
 block discarded – undo
1829 1829
 	 */
1830 1830
 	protected function getStateFilePath()
1831 1831
 	{
1832
-		return $this->getApplication()->getRuntimePath().'/global.cache';
1832
+		return $this->getApplication()->getRuntimePath() . '/global.cache';
1833 1833
 	}
1834 1834
 
1835 1835
 	/**
@@ -1838,11 +1838,11 @@  discard block
 block discarded – undo
1838 1838
 	 */
1839 1839
 	public function load()
1840 1840
 	{
1841
-		if(($cache=$this->getApplication()->getCache())!==null && ($value=$cache->get(self::CACHE_NAME))!==false)
1841
+		if (($cache = $this->getApplication()->getCache()) !== null && ($value = $cache->get(self::CACHE_NAME)) !== false)
1842 1842
 			return unserialize($value);
1843 1843
 		else
1844 1844
 		{
1845
-			if(($content=@file_get_contents($this->getStateFilePath()))!==false)
1845
+			if (($content = @file_get_contents($this->getStateFilePath())) !== false)
1846 1846
 				return unserialize($content);
1847 1847
 			else
1848 1848
 				return null;
@@ -1855,19 +1855,19 @@  discard block
 block discarded – undo
1855 1855
 	 */
1856 1856
 	public function save($state)
1857 1857
 	{
1858
-		$content=serialize($state);
1859
-		$saveFile=true;
1860
-		if(($cache=$this->getApplication()->getCache())!==null)
1858
+		$content = serialize($state);
1859
+		$saveFile = true;
1860
+		if (($cache = $this->getApplication()->getCache()) !== null)
1861 1861
 		{
1862
-			if($cache->get(self::CACHE_NAME)===$content)
1863
-				$saveFile=false;
1862
+			if ($cache->get(self::CACHE_NAME) === $content)
1863
+				$saveFile = false;
1864 1864
 			else
1865
-				$cache->set(self::CACHE_NAME,$content);
1865
+				$cache->set(self::CACHE_NAME, $content);
1866 1866
 		}
1867
-		if($saveFile)
1867
+		if ($saveFile)
1868 1868
 		{
1869
-			$fileName=$this->getStateFilePath();
1870
-			file_put_contents($fileName,$content,LOCK_EX);
1869
+			$fileName = $this->getStateFilePath();
1870
+			file_put_contents($fileName, $content, LOCK_EX);
1871 1871
 		}
1872 1872
 	}
1873 1873
 
Please login to merge, or discard this patch.
Braces   +227 added lines, -169 removed lines patch added patch discarded remove patch
@@ -325,8 +325,9 @@  discard block
 block discarded – undo
325 325
 		$this->setConfigurationType($configType);
326 326
 		$this->resolvePaths($basePath);
327 327
 
328
-		if($cacheConfig)
329
-			$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
328
+		if($cacheConfig) {
329
+					$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
330
+		}
330 331
 
331 332
 		// generates unique ID by hashing the runtime path
332 333
 		$this->_uniqueID=md5($this->_runtimePath);
@@ -349,17 +350,18 @@  discard block
 block discarded – undo
349 350
 	protected function resolvePaths($basePath)
350 351
 	{
351 352
 		// determine configuration path and file
352
-		if(empty($basePath) || ($basePath=realpath($basePath))===false)
353
-			throw new TConfigurationException('application_basepath_invalid',$basePath);
354
-		if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName()))
355
-			$configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName();
356
-		else if(is_file($basePath))
353
+		if(empty($basePath) || ($basePath=realpath($basePath))===false) {
354
+					throw new TConfigurationException('application_basepath_invalid',$basePath);
355
+		}
356
+		if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName())) {
357
+					$configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName();
358
+		} else if(is_file($basePath))
357 359
 		{
358 360
 			$configFile=$basePath;
359 361
 			$basePath=dirname($configFile);
362
+		} else {
363
+					$configFile=null;
360 364
 		}
361
-		else
362
-			$configFile=null;
363 365
 
364 366
 		// determine runtime path
365 367
 		$runtimePath=$basePath.DIRECTORY_SEPARATOR.self::RUNTIME_PATH;
@@ -370,17 +372,18 @@  discard block
 block discarded – undo
370 372
 				$runtimePath.=DIRECTORY_SEPARATOR.basename($configFile).'-'.Prado::getVersion();
371 373
 				if(!is_dir($runtimePath))
372 374
 				{
373
-					if(@mkdir($runtimePath)===false)
374
-						throw new TConfigurationException('application_runtimepath_failed',$runtimePath);
375
+					if(@mkdir($runtimePath)===false) {
376
+											throw new TConfigurationException('application_runtimepath_failed',$runtimePath);
377
+					}
375 378
 					@chmod($runtimePath, PRADO_CHMOD); //make it deletable
376 379
 				}
377 380
 				$this->setConfigurationFile($configFile);
378 381
 			}
379 382
 			$this->setBasePath($basePath);
380 383
 			$this->setRuntimePath($runtimePath);
384
+		} else {
385
+					throw new TConfigurationException('application_runtimepath_invalid',$runtimePath);
381 386
 		}
382
-		else
383
-			throw new TConfigurationException('application_runtimepath_invalid',$runtimePath);
384 387
 
385 388
 	}
386 389
 
@@ -399,17 +402,18 @@  discard block
 block discarded – undo
399 402
 			$this->_requestCompleted=false;
400 403
 			while($this->_step<$n)
401 404
 			{
402
-				if($this->_mode===self::STATE_OFF)
403
-					throw new THttpException(503,'application_unavailable');
404
-				if($this->_requestCompleted)
405
-					break;
405
+				if($this->_mode===self::STATE_OFF) {
406
+									throw new THttpException(503,'application_unavailable');
407
+				}
408
+				if($this->_requestCompleted) {
409
+									break;
410
+				}
406 411
 				$method=self::$_steps[$this->_step];
407 412
 				Prado::trace("Executing $method()",'System.TApplication');
408 413
 				$this->$method();
409 414
 				$this->_step++;
410 415
 			}
411
-		}
412
-		catch(Exception $e)
416
+		} catch(Exception $e)
413 417
 		{
414 418
 			$this->onError($e);
415 419
 		}
@@ -460,12 +464,14 @@  discard block
 block discarded – undo
460 464
 	public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false)
461 465
 	{
462 466
 		$this->_stateChanged=true;
463
-		if($value===$defaultValue)
464
-			unset($this->_globals[$key]);
465
-		else
466
-			$this->_globals[$key]=$value;
467
-		if($forceSave)
468
-			$this->saveGlobals();
467
+		if($value===$defaultValue) {
468
+					unset($this->_globals[$key]);
469
+		} else {
470
+					$this->_globals[$key]=$value;
471
+		}
472
+		if($forceSave) {
473
+					$this->saveGlobals();
474
+		}
469 475
 	}
470 476
 
471 477
 	/**
@@ -661,8 +667,9 @@  discard block
 block discarded – undo
661 667
 	public function setRuntimePath($value)
662 668
 	{
663 669
 		$this->_runtimePath=$value;
664
-		if($this->_cacheFile)
665
-			$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
670
+		if($this->_cacheFile) {
671
+					$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
672
+		}
666 673
 		// generates unique ID by hashing the runtime path
667 674
 		$this->_uniqueID=md5($this->_runtimePath);
668 675
 	}
@@ -691,10 +698,11 @@  discard block
 block discarded – undo
691 698
 	 */
692 699
 	public function setModule($id,IModule $module=null)
693 700
 	{
694
-		if(isset($this->_modules[$id]))
695
-			throw new TConfigurationException('application_moduleid_duplicated',$id);
696
-		else
697
-			$this->_modules[$id]=$module;
701
+		if(isset($this->_modules[$id])) {
702
+					throw new TConfigurationException('application_moduleid_duplicated',$id);
703
+		} else {
704
+					$this->_modules[$id]=$module;
705
+		}
698 706
 	}
699 707
 
700 708
 	/**
@@ -702,8 +710,9 @@  discard block
 block discarded – undo
702 710
 	 */
703 711
 	public function getModule($id)
704 712
 	{
705
-		if(!array_key_exists($id, $this->_modules))
706
-			return null;
713
+		if(!array_key_exists($id, $this->_modules)) {
714
+					return null;
715
+		}
707 716
 
708 717
 		// force loading of a lazy module
709 718
 		if($this->_modules[$id]===null)
@@ -942,8 +951,9 @@  discard block
 block discarded – undo
942 951
 	 */
943 952
 	public function getAuthorizationRules()
944 953
 	{
945
-		if($this->_authRules===null)
946
-			$this->_authRules=new TAuthorizationRuleCollection;
954
+		if($this->_authRules===null) {
955
+					$this->_authRules=new TAuthorizationRuleCollection;
956
+		}
947 957
 		return $this->_authRules;
948 958
 	}
949 959
 
@@ -966,7 +976,9 @@  discard block
 block discarded – undo
966 976
 		$module=Prado::createComponent($moduleClass);
967 977
 		foreach($initProperties as $name=>$value)
968 978
 		{
969
-			if($name==='lazy') continue;
979
+			if($name==='lazy') {
980
+				continue;
981
+			}
970 982
 			$module->setSubProperty($name,$value);
971 983
 		}
972 984
 		$this->setModule($id,$module);
@@ -982,24 +994,29 @@  discard block
 block discarded – undo
982 994
 	 */
983 995
 	public function applyConfiguration($config,$withinService=false)
984 996
 	{
985
-		if($config->getIsEmpty())
986
-			return;
997
+		if($config->getIsEmpty()) {
998
+					return;
999
+		}
987 1000
 
988 1001
 		// set path aliases and using namespaces
989
-		foreach($config->getAliases() as $alias=>$path)
990
-			Prado::setPathOfAlias($alias,$path);
991
-		foreach($config->getUsings() as $using)
992
-			Prado::using($using);
1002
+		foreach($config->getAliases() as $alias=>$path) {
1003
+					Prado::setPathOfAlias($alias,$path);
1004
+		}
1005
+		foreach($config->getUsings() as $using) {
1006
+					Prado::using($using);
1007
+		}
993 1008
 
994 1009
 		// set application properties
995 1010
 		if(!$withinService)
996 1011
 		{
997
-			foreach($config->getProperties() as $name=>$value)
998
-				$this->setSubProperty($name,$value);
1012
+			foreach($config->getProperties() as $name=>$value) {
1013
+							$this->setSubProperty($name,$value);
1014
+			}
999 1015
 		}
1000 1016
 
1001
-		if(empty($this->_services))
1002
-			$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
1017
+		if(empty($this->_services)) {
1018
+					$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
1019
+		}
1003 1020
 
1004 1021
 		// load parameters
1005 1022
 		foreach($config->getParameters() as $id=>$parameter)
@@ -1007,40 +1024,47 @@  discard block
 block discarded – undo
1007 1024
 			if(is_array($parameter))
1008 1025
 			{
1009 1026
 				$component=Prado::createComponent($parameter[0]);
1010
-				foreach($parameter[1] as $name=>$value)
1011
-					$component->setSubProperty($name,$value);
1027
+				foreach($parameter[1] as $name=>$value) {
1028
+									$component->setSubProperty($name,$value);
1029
+				}
1012 1030
 				$this->_parameters->add($id,$component);
1031
+			} else {
1032
+							$this->_parameters->add($id,$parameter);
1013 1033
 			}
1014
-			else
1015
-				$this->_parameters->add($id,$parameter);
1016 1034
 		}
1017 1035
 
1018 1036
 		// load and init modules specified in app config
1019 1037
 		$modules=array();
1020 1038
 		foreach($config->getModules() as $id=>$moduleConfig)
1021 1039
 		{
1022
-			if(!is_string($id))
1023
-				$id='_module'.count($this->_lazyModules);
1040
+			if(!is_string($id)) {
1041
+							$id='_module'.count($this->_lazyModules);
1042
+			}
1024 1043
 			$this->_lazyModules[$id]=$moduleConfig;
1025
-			if($module = $this->internalLoadModule($id))
1026
-				$modules[]=$module;
1044
+			if($module = $this->internalLoadModule($id)) {
1045
+							$modules[]=$module;
1046
+			}
1047
+		}
1048
+		foreach($modules as $module) {
1049
+					$module[0]->init($module[1]);
1027 1050
 		}
1028
-		foreach($modules as $module)
1029
-			$module[0]->init($module[1]);
1030 1051
 
1031 1052
 		// load service
1032
-		foreach($config->getServices() as $serviceID=>$serviceConfig)
1033
-			$this->_services[$serviceID]=$serviceConfig;
1053
+		foreach($config->getServices() as $serviceID=>$serviceConfig) {
1054
+					$this->_services[$serviceID]=$serviceConfig;
1055
+		}
1034 1056
 
1035 1057
 		// external configurations
1036 1058
 		foreach($config->getExternalConfigurations() as $filePath=>$condition)
1037 1059
 		{
1038
-			if($condition!==true)
1039
-				$condition=$this->evaluateExpression($condition);
1060
+			if($condition!==true) {
1061
+							$condition=$this->evaluateExpression($condition);
1062
+			}
1040 1063
 			if($condition)
1041 1064
 			{
1042
-				if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path))
1043
-					throw new TConfigurationException('application_includefile_invalid',$filePath);
1065
+				if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path)) {
1066
+									throw new TConfigurationException('application_includefile_invalid',$filePath);
1067
+				}
1044 1068
 				$cn=$this->getApplicationConfigurationClass();
1045 1069
 				$c=new $cn;
1046 1070
 				$c->loadFromFile($path);
@@ -1068,17 +1092,19 @@  discard block
 block discarded – undo
1068 1092
 			{
1069 1093
 				$config=new TApplicationConfiguration;
1070 1094
 				$config->loadFromFile($this->_configFile);
1071
-				if($this->_cacheFile!==null)
1072
-					file_put_contents($this->_cacheFile,serialize($config),LOCK_EX);
1095
+				if($this->_cacheFile!==null) {
1096
+									file_put_contents($this->_cacheFile,serialize($config),LOCK_EX);
1097
+				}
1098
+			} else {
1099
+							$config=unserialize(file_get_contents($this->_cacheFile));
1073 1100
 			}
1074
-			else
1075
-				$config=unserialize(file_get_contents($this->_cacheFile));
1076 1101
 
1077 1102
 			$this->applyConfiguration($config,false);
1078 1103
 		}
1079 1104
 
1080
-		if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null)
1081
-			$serviceID=$this->getPageServiceID();
1105
+		if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null) {
1106
+					$serviceID=$this->getPageServiceID();
1107
+		}
1082 1108
 
1083 1109
 		$this->startService($serviceID);
1084 1110
 	}
@@ -1095,30 +1121,34 @@  discard block
 block discarded – undo
1095 1121
 		{
1096 1122
 			list($serviceClass,$initProperties,$configElement)=$this->_services[$serviceID];
1097 1123
 			$service=Prado::createComponent($serviceClass);
1098
-			if(!($service instanceof IService))
1099
-				throw new THttpException(500,'application_service_invalid',$serviceClass);
1100
-			if(!$service->getEnabled())
1101
-				throw new THttpException(500,'application_service_unavailable',$serviceClass);
1124
+			if(!($service instanceof IService)) {
1125
+							throw new THttpException(500,'application_service_invalid',$serviceClass);
1126
+			}
1127
+			if(!$service->getEnabled()) {
1128
+							throw new THttpException(500,'application_service_unavailable',$serviceClass);
1129
+			}
1102 1130
 			$service->setID($serviceID);
1103 1131
 			$this->setService($service);
1104 1132
 
1105
-			foreach($initProperties as $name=>$value)
1106
-				$service->setSubProperty($name,$value);
1133
+			foreach($initProperties as $name=>$value) {
1134
+							$service->setSubProperty($name,$value);
1135
+			}
1107 1136
 
1108 1137
 			if($configElement!==null)
1109 1138
 			{
1110 1139
 				$config=new TApplicationConfiguration;
1111
-				if($this->getConfigurationType()==self::CONFIG_TYPE_PHP)
1112
-					$config->loadFromPhp($configElement,$this->getBasePath());
1113
-				else
1114
-					$config->loadFromXml($configElement,$this->getBasePath());
1140
+				if($this->getConfigurationType()==self::CONFIG_TYPE_PHP) {
1141
+									$config->loadFromPhp($configElement,$this->getBasePath());
1142
+				} else {
1143
+									$config->loadFromXml($configElement,$this->getBasePath());
1144
+				}
1115 1145
 				$this->applyConfiguration($config,true);
1116 1146
 			}
1117 1147
 
1118 1148
 			$service->init($configElement);
1149
+		} else {
1150
+					throw new THttpException(500,'application_service_unknown',$serviceID);
1119 1151
 		}
1120
-		else
1121
-			throw new THttpException(500,'application_service_unknown',$serviceID);
1122 1152
 	}
1123 1153
 
1124 1154
 	/**
@@ -1215,8 +1245,9 @@  discard block
 block discarded – undo
1215 1245
 	 */
1216 1246
 	public function runService()
1217 1247
 	{
1218
-		if($this->_service)
1219
-			$this->_service->run();
1248
+		if($this->_service) {
1249
+					$this->_service->run();
1250
+		}
1220 1251
 	}
1221 1252
 
1222 1253
 	/**
@@ -1346,8 +1377,7 @@  discard block
 block discarded – undo
1346 1377
 		{
1347 1378
 			$fcontent = include $fname;
1348 1379
 			$this->loadFromPhp($fcontent,dirname($fname));
1349
-		}
1350
-		else
1380
+		} else
1351 1381
 		{
1352 1382
 			$dom=new TXmlDocument;
1353 1383
 			$dom->loadFromFile($fname);
@@ -1380,20 +1410,25 @@  discard block
 block discarded – undo
1380 1410
 			$this->_empty = false;
1381 1411
 		}
1382 1412
 
1383
-		if(isset($config['paths']) && is_array($config['paths']))
1384
-			$this->loadPathsPhp($config['paths'],$configPath);
1413
+		if(isset($config['paths']) && is_array($config['paths'])) {
1414
+					$this->loadPathsPhp($config['paths'],$configPath);
1415
+		}
1385 1416
 
1386
-		if(isset($config['modules']) && is_array($config['modules']))
1387
-			$this->loadModulesPhp($config['modules'],$configPath);
1417
+		if(isset($config['modules']) && is_array($config['modules'])) {
1418
+					$this->loadModulesPhp($config['modules'],$configPath);
1419
+		}
1388 1420
 
1389
-		if(isset($config['services']) && is_array($config['services']))
1390
-			$this->loadServicesPhp($config['services'],$configPath);
1421
+		if(isset($config['services']) && is_array($config['services'])) {
1422
+					$this->loadServicesPhp($config['services'],$configPath);
1423
+		}
1391 1424
 
1392
-		if(isset($config['parameters']) && is_array($config['parameters']))
1393
-			$this->loadParametersPhp($config['parameters'], $configPath);
1425
+		if(isset($config['parameters']) && is_array($config['parameters'])) {
1426
+					$this->loadParametersPhp($config['parameters'], $configPath);
1427
+		}
1394 1428
 
1395
-		if(isset($config['includes']) && is_array($config['includes']))
1396
-			$this->loadExternalXml($config['includes'],$configPath);
1429
+		if(isset($config['includes']) && is_array($config['includes'])) {
1430
+					$this->loadExternalXml($config['includes'],$configPath);
1431
+		}
1397 1432
 	}
1398 1433
 
1399 1434
 	/**
@@ -1448,14 +1483,18 @@  discard block
 block discarded – undo
1448 1483
 			foreach($pathsNode['aliases'] as $id=>$path)
1449 1484
 			{
1450 1485
 				$path=str_replace('\\','/',$path);
1451
-				if(preg_match('/^\\/|.:\\/|.:\\\\/',$path))	// if absolute path
1486
+				if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) {
1487
+					// if absolute path
1452 1488
 					$p=realpath($path);
1453
-				else
1454
-					$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
1455
-				if($p===false || !is_dir($p))
1456
-					throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
1457
-				if(isset($this->_aliases[$id]))
1458
-					throw new TConfigurationException('appconfig_alias_redefined',$id);
1489
+				} else {
1490
+									$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
1491
+				}
1492
+				if($p===false || !is_dir($p)) {
1493
+									throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
1494
+				}
1495
+				if(isset($this->_aliases[$id])) {
1496
+									throw new TConfigurationException('appconfig_alias_redefined',$id);
1497
+				}
1459 1498
 				$this->_aliases[$id]=$p;
1460 1499
 			}
1461 1500
 		}
@@ -1485,27 +1524,32 @@  discard block
 block discarded – undo
1485 1524
 					if(($id=$element->getAttribute('id'))!==null && ($path=$element->getAttribute('path'))!==null)
1486 1525
 					{
1487 1526
 						$path=str_replace('\\','/',$path);
1488
-						if(preg_match('/^\\/|.:\\/|.:\\\\/',$path))	// if absolute path
1527
+						if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) {
1528
+							// if absolute path
1489 1529
 							$p=realpath($path);
1490
-						else
1491
-							$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
1492
-						if($p===false || !is_dir($p))
1493
-							throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
1494
-						if(isset($this->_aliases[$id]))
1495
-							throw new TConfigurationException('appconfig_alias_redefined',$id);
1530
+						} else {
1531
+													$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
1532
+						}
1533
+						if($p===false || !is_dir($p)) {
1534
+													throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
1535
+						}
1536
+						if(isset($this->_aliases[$id])) {
1537
+													throw new TConfigurationException('appconfig_alias_redefined',$id);
1538
+						}
1496 1539
 						$this->_aliases[$id]=$p;
1540
+					} else {
1541
+											throw new TConfigurationException('appconfig_alias_invalid');
1497 1542
 					}
1498
-					else
1499
-						throw new TConfigurationException('appconfig_alias_invalid');
1500 1543
 					$this->_empty=false;
1501 1544
 					break;
1502 1545
 				}
1503 1546
 				case 'using':
1504 1547
 				{
1505
-					if(($namespace=$element->getAttribute('namespace'))!==null)
1506
-						$this->_usings[]=$namespace;
1507
-					else
1508
-						throw new TConfigurationException('appconfig_using_invalid');
1548
+					if(($namespace=$element->getAttribute('namespace'))!==null) {
1549
+											$this->_usings[]=$namespace;
1550
+					} else {
1551
+											throw new TConfigurationException('appconfig_using_invalid');
1552
+					}
1509 1553
 					$this->_empty=false;
1510 1554
 					break;
1511 1555
 				}
@@ -1524,8 +1568,9 @@  discard block
 block discarded – undo
1524 1568
 	{
1525 1569
 		foreach($modulesNode as $id=>$module)
1526 1570
 		{
1527
-			if(!isset($module['class']))
1528
-				throw new TConfigurationException('appconfig_moduletype_required',$id);
1571
+			if(!isset($module['class'])) {
1572
+							throw new TConfigurationException('appconfig_moduletype_required',$id);
1573
+			}
1529 1574
 			$type = $module['class'];
1530 1575
 			unset($module['class']);
1531 1576
 			$properties = array();
@@ -1554,17 +1599,19 @@  discard block
 block discarded – undo
1554 1599
 				$properties=$element->getAttributes();
1555 1600
 				$id=$properties->itemAt('id');
1556 1601
 				$type=$properties->remove('class');
1557
-				if($type===null)
1558
-					throw new TConfigurationException('appconfig_moduletype_required',$id);
1602
+				if($type===null) {
1603
+									throw new TConfigurationException('appconfig_moduletype_required',$id);
1604
+				}
1559 1605
 				$element->setParent(null);
1560
-				if($id===null)
1561
-					$this->_modules[]=array($type,$properties->toArray(),$element);
1562
-				else
1563
-					$this->_modules[$id]=array($type,$properties->toArray(),$element);
1606
+				if($id===null) {
1607
+									$this->_modules[]=array($type,$properties->toArray(),$element);
1608
+				} else {
1609
+									$this->_modules[$id]=array($type,$properties->toArray(),$element);
1610
+				}
1564 1611
 				$this->_empty=false;
1612
+			} else {
1613
+							throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName());
1565 1614
 			}
1566
-			else
1567
-				throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName());
1568 1615
 		}
1569 1616
 	}
1570 1617
 
@@ -1577,8 +1624,9 @@  discard block
 block discarded – undo
1577 1624
 	{
1578 1625
 		foreach($servicesNode as $id => $service)
1579 1626
 		{
1580
-			if(!isset($service['class']))
1581
-				throw new TConfigurationException('appconfig_servicetype_required');
1627
+			if(!isset($service['class'])) {
1628
+							throw new TConfigurationException('appconfig_servicetype_required');
1629
+			}
1582 1630
 			$type = $service['class'];
1583 1631
 			$properties = isset($service['properties']) ? $service['properties'] : array();
1584 1632
 			unset($service['properties']);
@@ -1600,16 +1648,18 @@  discard block
 block discarded – undo
1600 1648
 			if($element->getTagName()==='service')
1601 1649
 			{
1602 1650
 				$properties=$element->getAttributes();
1603
-				if(($id=$properties->itemAt('id'))===null)
1604
-					throw new TConfigurationException('appconfig_serviceid_required');
1605
-				if(($type=$properties->remove('class'))===null)
1606
-					throw new TConfigurationException('appconfig_servicetype_required',$id);
1651
+				if(($id=$properties->itemAt('id'))===null) {
1652
+									throw new TConfigurationException('appconfig_serviceid_required');
1653
+				}
1654
+				if(($type=$properties->remove('class'))===null) {
1655
+									throw new TConfigurationException('appconfig_servicetype_required',$id);
1656
+				}
1607 1657
 				$element->setParent(null);
1608 1658
 				$this->_services[$id]=array($type,$properties->toArray(),$element);
1609 1659
 				$this->_empty=false;
1660
+			} else {
1661
+							throw new TConfigurationException('appconfig_services_invalid',$element->getTagName());
1610 1662
 			}
1611
-			else
1612
-				throw new TConfigurationException('appconfig_services_invalid',$element->getTagName());
1613 1663
 		}
1614 1664
 	}
1615 1665
 
@@ -1632,8 +1682,7 @@  discard block
 block discarded – undo
1632 1682
 					$properties['id'] = $id;
1633 1683
 					$this->_parameters[$id] = array($type,$properties);
1634 1684
 				}
1635
-			}
1636
-			else
1685
+			} else
1637 1686
 			{
1638 1687
 				$this->_parameters[$id] = $parameter;
1639 1688
 			}
@@ -1652,21 +1701,23 @@  discard block
 block discarded – undo
1652 1701
 			if($element->getTagName()==='parameter')
1653 1702
 			{
1654 1703
 				$properties=$element->getAttributes();
1655
-				if(($id=$properties->remove('id'))===null)
1656
-					throw new TConfigurationException('appconfig_parameterid_required');
1704
+				if(($id=$properties->remove('id'))===null) {
1705
+									throw new TConfigurationException('appconfig_parameterid_required');
1706
+				}
1657 1707
 				if(($type=$properties->remove('class'))===null)
1658 1708
 				{
1659
-					if(($value=$properties->remove('value'))===null)
1660
-						$this->_parameters[$id]=$element;
1661
-					else
1662
-						$this->_parameters[$id]=$value;
1709
+					if(($value=$properties->remove('value'))===null) {
1710
+											$this->_parameters[$id]=$element;
1711
+					} else {
1712
+											$this->_parameters[$id]=$value;
1713
+					}
1714
+				} else {
1715
+									$this->_parameters[$id]=array($type,$properties->toArray());
1663 1716
 				}
1664
-				else
1665
-					$this->_parameters[$id]=array($type,$properties->toArray());
1666 1717
 				$this->_empty=false;
1718
+			} else {
1719
+							throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName());
1667 1720
 			}
1668
-			else
1669
-				throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName());
1670 1721
 		}
1671 1722
 	}
1672 1723
 
@@ -1680,13 +1731,15 @@  discard block
 block discarded – undo
1680 1731
 		foreach($includeNode as $include)
1681 1732
 		{
1682 1733
 			$when = isset($include['when'])?true:false;
1683
-			if(!isset($include['file']))
1684
-				throw new TConfigurationException('appconfig_includefile_required');
1734
+			if(!isset($include['file'])) {
1735
+							throw new TConfigurationException('appconfig_includefile_required');
1736
+			}
1685 1737
 			$filePath = $include['file'];
1686
-			if(isset($this->_includes[$filePath]))
1687
-				$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
1688
-			else
1689
-				$$this->_includes[$filePath]=$when;
1738
+			if(isset($this->_includes[$filePath])) {
1739
+							$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
1740
+			} else {
1741
+							$$this->_includes[$filePath]=$when;
1742
+			}
1690 1743
 			$this->_empty=false;
1691 1744
 		}
1692 1745
 	}
@@ -1698,14 +1751,17 @@  discard block
 block discarded – undo
1698 1751
 	 */
1699 1752
 	protected function loadExternalXml($includeNode,$configPath)
1700 1753
 	{
1701
-		if(($when=$includeNode->getAttribute('when'))===null)
1702
-			$when=true;
1703
-		if(($filePath=$includeNode->getAttribute('file'))===null)
1704
-			throw new TConfigurationException('appconfig_includefile_required');
1705
-		if(isset($this->_includes[$filePath]))
1706
-			$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
1707
-		else
1708
-			$this->_includes[$filePath]=$when;
1754
+		if(($when=$includeNode->getAttribute('when'))===null) {
1755
+					$when=true;
1756
+		}
1757
+		if(($filePath=$includeNode->getAttribute('file'))===null) {
1758
+					throw new TConfigurationException('appconfig_includefile_required');
1759
+		}
1760
+		if(isset($this->_includes[$filePath])) {
1761
+					$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
1762
+		} else {
1763
+					$this->_includes[$filePath]=$when;
1764
+		}
1709 1765
 		$this->_empty=false;
1710 1766
 	}
1711 1767
 
@@ -1838,14 +1894,15 @@  discard block
 block discarded – undo
1838 1894
 	 */
1839 1895
 	public function load()
1840 1896
 	{
1841
-		if(($cache=$this->getApplication()->getCache())!==null && ($value=$cache->get(self::CACHE_NAME))!==false)
1842
-			return unserialize($value);
1843
-		else
1897
+		if(($cache=$this->getApplication()->getCache())!==null && ($value=$cache->get(self::CACHE_NAME))!==false) {
1898
+					return unserialize($value);
1899
+		} else
1844 1900
 		{
1845
-			if(($content=@file_get_contents($this->getStateFilePath()))!==false)
1846
-				return unserialize($content);
1847
-			else
1848
-				return null;
1901
+			if(($content=@file_get_contents($this->getStateFilePath()))!==false) {
1902
+							return unserialize($content);
1903
+			} else {
1904
+							return null;
1905
+			}
1849 1906
 		}
1850 1907
 	}
1851 1908
 
@@ -1859,10 +1916,11 @@  discard block
 block discarded – undo
1859 1916
 		$saveFile=true;
1860 1917
 		if(($cache=$this->getApplication()->getCache())!==null)
1861 1918
 		{
1862
-			if($cache->get(self::CACHE_NAME)===$content)
1863
-				$saveFile=false;
1864
-			else
1865
-				$cache->set(self::CACHE_NAME,$content);
1919
+			if($cache->get(self::CACHE_NAME)===$content) {
1920
+							$saveFile=false;
1921
+			} else {
1922
+							$cache->set(self::CACHE_NAME,$content);
1923
+			}
1866 1924
 		}
1867 1925
 		if($saveFile)
1868 1926
 		{
Please login to merge, or discard this patch.
framework/TApplicationComponent.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -92,6 +92,8 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @param string path of the asset that is relative to the directory containing the specified class file.
94 94
 	 * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this).
95
+	 * @param string $assetPath
96
+	 * @param string $className
95 97
 	 * @return string URL to the asset path.
96 98
 	 */
97 99
 	public function publishAsset($assetPath,$className=null)
@@ -106,6 +108,7 @@  discard block
 block discarded – undo
106 108
 	/**
107 109
 	 * Publishes a file or directory and returns its URL.
108 110
 	 * @param string absolute path of the file or directory to be published
111
+	 * @param string $fullPath
109 112
 	 * @return string URL to the published file or directory
110 113
 	 */
111 114
 	public function publishFilePath($fullPath, $checkTimestamp=false)
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 	 * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this).
95 95
 	 * @return string URL to the asset path.
96 96
 	 */
97
-	public function publishAsset($assetPath,$className=null)
97
+	public function publishAsset($assetPath, $className = null)
98 98
 	{
99
-		if($className===null)
100
-			$className=get_class($this);
101
-		$class=new ReflectionClass($className);
102
-		$fullPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath;
99
+		if ($className === null)
100
+			$className = get_class($this);
101
+		$class = new ReflectionClass($className);
102
+		$fullPath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $assetPath;
103 103
 		return $this->publishFilePath($fullPath);
104 104
 	}
105 105
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @param string absolute path of the file or directory to be published
109 109
 	 * @return string URL to the published file or directory
110 110
 	 */
111
-	public function publishFilePath($fullPath, $checkTimestamp=false)
111
+	public function publishFilePath($fullPath, $checkTimestamp = false)
112 112
 	{
113 113
 		return Prado::getApplication()->getAssetManager()->publishFilePath($fullPath, $checkTimestamp);
114 114
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,8 +96,9 @@
 block discarded – undo
96 96
 	 */
97 97
 	public function publishAsset($assetPath,$className=null)
98 98
 	{
99
-		if($className===null)
100
-			$className=get_class($this);
99
+		if($className===null) {
100
+					$className=get_class($this);
101
+		}
101 102
 		$class=new ReflectionClass($className);
102 103
 		$fullPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath;
103 104
 		return $this->publishFilePath($fullPath);
Please login to merge, or discard this patch.
framework/TComponent.php 3 patches
Doc Comments   +24 added lines, -4 removed lines patch added patch discarded remove patch
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	 * </code>
407 407
 	 * to be executed when listen is called.  All attached behaviors are notified through dyListen.
408 408
 	 *
409
-	 * @return numeric the number of global events that were registered to the global event registry
409
+	 * @return null|integer the number of global events that were registered to the global event registry
410 410
 	 */
411 411
 	public function listen() {
412 412
 		if($this->_listeningenabled)
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	 * </code>
441 441
 	 * to be executed when listen is called.  All attached behaviors are notified through dyUnlisten.
442 442
 	 *
443
-	 * @return numeric the number of global events that were unregistered from the global event registry
443
+	 * @return null|integer the number of global events that were unregistered from the global event registry
444 444
 	 */
445 445
 	public function unlisten() {
446 446
 		if(!$this->_listeningenabled)
@@ -774,6 +774,7 @@  discard block
 block discarded – undo
774 774
 	 * A property is defined if there is a getter or setter method
775 775
 	 * defined in the class. Note, property names are case-insensitive.
776 776
 	 * @param string the property name
777
+	 * @param string $name
777 778
 	 * @return boolean whether the property is defined
778 779
 	 */
779 780
 	public function hasProperty($name)
@@ -1001,6 +1002,7 @@  discard block
 block discarded – undo
1001 1002
 	 * @param callback the event handler
1002 1003
 	 * @param numeric|null the priority of the handler, defaults to null which translates into the
1003 1004
 	 * default priority of 10.0 within {@link TPriorityList}
1005
+	 * @param integer $priority
1004 1006
 	 * @throws TInvalidOperationException if the event does not exist
1005 1007
 	 */
1006 1008
 	public function attachEventHandler($name,$handler,$priority=null)
@@ -1316,6 +1318,7 @@  discard block
 block discarded – undo
1316 1318
 	 * dyAddParsedObject.
1317 1319
 	 *
1318 1320
 	 * @param string|TComponent text string or component parsed and instantiated in template
1321
+	 * @param NewComponentNoListen $object
1319 1322
 	 * @see createdOnTemplate
1320 1323
 	 */
1321 1324
 	public function addParsedObject($object)
@@ -1366,6 +1369,8 @@  discard block
 block discarded – undo
1366 1369
 	 * TPanel::attachClassBehavior('javascripts', (new TJsPanelBehavior())->init($this));
1367 1370
 	 * </code>
1368 1371
 	 * @param numeric|null priority of behavior, default: null the default priority of the {@link TPriorityList}  Optional.
1372
+	 * @param string $name
1373
+	 * @param string $class
1369 1374
 	 * @throws TInvalidOperationException if the class behavior is being added to a {@link TComponent}; due to recursion.
1370 1375
 	 * @throws TInvalidOperationException if the class behavior is already defined
1371 1376
 	 * @since 3.2.3
@@ -1396,8 +1401,8 @@  discard block
 block discarded – undo
1396 1401
 	 *	This will remove a behavior from a class.  It unregisters it from future instances and
1397 1402
 	 * pulls the changes from all the instances that are listening as well.
1398 1403
 	 * PHP 5.3 uses Late Static Binding to derive the static class upon which this method is called.
1399
-	 * @param $name the key of the class behavior
1400
-	 * @param $class string class on which to attach this behavior.  Defaults to null.
1404
+	 * @param string $name the key of the class behavior
1405
+	 * @param string $class string class on which to attach this behavior.  Defaults to null.
1401 1406
 	 * @param $priority numeric|null|false priority.  false is any priority, null is default
1402 1407
 	 *		{@link TPriorityList} priority, and numeric is a specific priority.
1403 1408
 	 * @throws Exception if the the class cannot be derived from Late Static Binding and is not
@@ -1426,6 +1431,7 @@  discard block
 block discarded – undo
1426 1431
 	 * Returns the named behavior object.
1427 1432
 	 * The name 'asa' stands for 'as a'.
1428 1433
 	 * @param string the behavior name
1434
+	 * @param string $behaviorname
1429 1435
 	 * @return IBehavior the behavior object, or null if the behavior does not exist
1430 1436
 	 * @since 3.2.3
1431 1437
 	 */
@@ -1654,6 +1660,7 @@  discard block
 block discarded – undo
1654 1660
 	 * dyEnableBehavior.
1655 1661
 	 *
1656 1662
 	 * @param string the behavior's name. It uniquely identifies the behavior.
1663
+	 * @param string $name
1657 1664
 	 * @since 3.2.3
1658 1665
 	 */
1659 1666
 	public function enableBehavior($name)
@@ -1682,6 +1689,7 @@  discard block
 block discarded – undo
1682 1689
 	 * dyDisableBehavior.
1683 1690
 	 *
1684 1691
 	 * @param string the behavior's name. It uniquely identifies the behavior.
1692
+	 * @param string $name
1685 1693
 	 * @since 3.2.3
1686 1694
 	 */
1687 1695
 	public function disableBehavior($name)
@@ -2087,6 +2095,7 @@  discard block
 block discarded – undo
2087 2095
 	/**
2088 2096
 	 * Constructor.
2089 2097
 	 * @param object|string the component instance or the class name
2098
+	 * @param string $component
2090 2099
 	 * @throws TInvalidDataTypeException if the object is not a component
2091 2100
 	 */
2092 2101
 	public function __construct($component)
@@ -2100,6 +2109,9 @@  discard block
 block discarded – undo
2100 2109
 		$this->reflect();
2101 2110
 	}
2102 2111
 
2112
+	/**
2113
+	 * @param ReflectionMethod $method
2114
+	 */
2103 2115
 	private function isPropertyMethod($method)
2104 2116
 	{
2105 2117
 		$methodName=$method->getName();
@@ -2108,6 +2120,9 @@  discard block
 block discarded – undo
2108 2120
 				&& isset($methodName[3]);
2109 2121
 	}
2110 2122
 
2123
+	/**
2124
+	 * @param ReflectionMethod $method
2125
+	 */
2111 2126
 	private function isEventMethod($method)
2112 2127
 	{
2113 2128
 		$methodName=$method->getName();
@@ -2254,11 +2269,14 @@  discard block
 block discarded – undo
2254 2269
 	/**
2255 2270
 	 * Attaches the behavior object to the component.
2256 2271
 	 * @param CComponent the component that this behavior is to be attached to.
2272
+	 * @param TComponent $component
2273
+	 * @return void
2257 2274
 	 */
2258 2275
 	public function attach($component);
2259 2276
 	/**
2260 2277
 	 * Detaches the behavior object from the component.
2261 2278
 	 * @param CComponent the component that this behavior is to be detached from.
2279
+	 * @return void
2262 2280
 	 */
2263 2281
 	public function detach($component);
2264 2282
 }
@@ -2283,6 +2301,8 @@  discard block
 block discarded – undo
2283 2301
 	public function getEnabled();
2284 2302
 	/**
2285 2303
 	 * @param boolean whether this behavior is enabled
2304
+	 * @param boolean $value
2305
+	 * @return void
2286 2306
 	 */
2287 2307
 	public function setEnabled($value);
2288 2308
 }
Please login to merge, or discard this patch.
Spacing   +408 added lines, -408 removed lines patch added patch discarded remove patch
@@ -284,39 +284,39 @@  discard block
 block discarded – undo
284 284
 	/**
285 285
 	 * @var array event handler lists
286 286
 	 */
287
-	private $_e=array();
287
+	private $_e = array();
288 288
 
289 289
 	/**
290 290
 	 * @var boolean if listening is enabled.  Automatically turned on or off in
291 291
 	 * constructor according to {@link getAutoGlobalListen}.  Default false, off
292 292
 	 */
293
-	private $_listeningenabled=false;
293
+	private $_listeningenabled = false;
294 294
 
295 295
 	/**
296 296
 	 * @var array static registered global event handler lists
297 297
 	 */
298
-	private static $_ue=array();
298
+	private static $_ue = array();
299 299
 
300 300
 	/**
301 301
 	 * @var boolean if object behaviors are on or off.  default true, on
302 302
 	 */
303
-	private $_behaviorsenabled=true;
303
+	private $_behaviorsenabled = true;
304 304
 
305 305
 	/**
306 306
 	 * @var TPriorityMap list of object behaviors
307 307
 	 */
308
-	private $_m=null;
308
+	private $_m = null;
309 309
 
310 310
 	/**
311 311
 	 * @var array static global class behaviors, these behaviors are added upon instantiation of a class
312 312
 	 */
313
-	private static $_um=array();
313
+	private static $_um = array();
314 314
 
315 315
 
316 316
 	/**
317 317
 	 * @const string the name of the global {@link raiseEvent} listener
318 318
 	 */
319
-	const GLOBAL_RAISE_EVENT_LISTENER='fxGlobalListener';
319
+	const GLOBAL_RAISE_EVENT_LISTENER = 'fxGlobalListener';
320 320
 
321 321
 
322 322
 	/**
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
 	 * through each parent to the top most class, TComponent.
328 328
 	 */
329 329
 	public function __construct() {
330
-		if($this->getAutoGlobalListen())
330
+		if ($this->getAutoGlobalListen())
331 331
 			$this->listen();
332 332
 
333
-		$classes=array_reverse($this->getClassHierarchy(true));
334
-		foreach($classes as $class) {
335
-			if(isset(self::$_um[$class]))
333
+		$classes = array_reverse($this->getClassHierarchy(true));
334
+		foreach ($classes as $class) {
335
+			if (isset(self::$_um[$class]))
336 336
 				$this->attachBehaviors(self::$_um[$class]);
337 337
 		}
338 338
 	}
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 * called must be explicitly called.
364 364
 	 */
365 365
 	public function __destruct() {
366
-		if($this->_listeningenabled)
366
+		if ($this->_listeningenabled)
367 367
 			$this->unlisten();
368 368
 	}
369 369
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * that start with 'fx' are filtered in.
374 374
 	 */
375 375
 	private function filter_prado_fx($name) {
376
-		return strncasecmp($name,'fx',2)===0;
376
+		return strncasecmp($name, 'fx', 2) === 0;
377 377
 	}
378 378
 
379 379
 
@@ -385,11 +385,11 @@  discard block
 block discarded – undo
385 385
 	 */
386 386
 	public function getClassHierarchy($lowercase = false)
387 387
 	{
388
-		$class=get_class($this);
389
-		$classes=array($class);
390
-		while($class=get_parent_class($class)){array_unshift($classes,$class);}
391
-		if($lowercase)
392
-			return array_map('strtolower',$classes);
388
+		$class = get_class($this);
389
+		$classes = array($class);
390
+		while ($class = get_parent_class($class)) {array_unshift($classes, $class); }
391
+		if ($lowercase)
392
+			return array_map('strtolower', $classes);
393 393
 		return $classes;
394 394
 	}
395 395
 
@@ -409,20 +409,20 @@  discard block
 block discarded – undo
409 409
 	 * @return numeric the number of global events that were registered to the global event registry
410 410
 	 */
411 411
 	public function listen() {
412
-		if($this->_listeningenabled)
412
+		if ($this->_listeningenabled)
413 413
 			return;
414 414
 
415
-		$fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx'));
415
+		$fx = array_filter(get_class_methods($this), array($this, 'filter_prado_fx'));
416 416
 
417
-		foreach($fx as $func)
418
-			$this->attachEventHandler($func,array($this,$func));
417
+		foreach ($fx as $func)
418
+			$this->attachEventHandler($func, array($this, $func));
419 419
 
420
-		if(is_a($this,'IDynamicMethods')) {
421
-			$this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall'));
422
-			array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER);
420
+		if (is_a($this, 'IDynamicMethods')) {
421
+			$this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall'));
422
+			array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER);
423 423
 		}
424 424
 
425
-		$this->_listeningenabled=true;
425
+		$this->_listeningenabled = true;
426 426
 
427 427
 		$this->dyListen($fx);
428 428
 
@@ -443,20 +443,20 @@  discard block
 block discarded – undo
443 443
 	 * @return numeric the number of global events that were unregistered from the global event registry
444 444
 	 */
445 445
 	public function unlisten() {
446
-		if(!$this->_listeningenabled)
446
+		if (!$this->_listeningenabled)
447 447
 			return;
448 448
 
449
-		$fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx'));
449
+		$fx = array_filter(get_class_methods($this), array($this, 'filter_prado_fx'));
450 450
 
451
-		foreach($fx as $func)
452
-			$this->detachEventHandler($func,array($this,$func));
451
+		foreach ($fx as $func)
452
+			$this->detachEventHandler($func, array($this, $func));
453 453
 
454
-		if(is_a($this,'IDynamicMethods')) {
455
-			$this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall'));
456
-			array_push($fx,TComponent::GLOBAL_RAISE_EVENT_LISTENER);
454
+		if (is_a($this, 'IDynamicMethods')) {
455
+			$this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, array($this, '__dycall'));
456
+			array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER);
457 457
 		}
458 458
 
459
-		$this->_listeningenabled=false;
459
+		$this->_listeningenabled = false;
460 460
 
461 461
 		$this->dyUnlisten($fx);
462 462
 
@@ -498,64 +498,64 @@  discard block
 block discarded – undo
498 498
 	 */
499 499
 	public function __call($method, $args)
500 500
 	{
501
-		$getset=substr($method,0,3);
502
-		if(($getset=='get')||($getset=='set'))
501
+		$getset = substr($method, 0, 3);
502
+		if (($getset == 'get') || ($getset == 'set'))
503 503
 		{
504
-			$propname=substr($method,3);
505
-			$jsmethod=$getset.'js'.$propname;
506
-			if(method_exists($this,$jsmethod))
504
+			$propname = substr($method, 3);
505
+			$jsmethod = $getset . 'js' . $propname;
506
+			if (method_exists($this, $jsmethod))
507 507
 			{
508
-				if(count($args)>0)
509
-					if($args[0]&&!($args[0] instanceof TJavaScriptString))
510
-						$args[0]=new TJavaScriptString($args[0]);
511
-				return call_user_func_array(array($this,$jsmethod),$args);
508
+				if (count($args) > 0)
509
+					if ($args[0] && !($args[0] instanceof TJavaScriptString))
510
+						$args[0] = new TJavaScriptString($args[0]);
511
+				return call_user_func_array(array($this, $jsmethod), $args);
512 512
 			}
513 513
 
514
-			if (($getset=='set')&&method_exists($this,'getjs'.$propname))
515
-				throw new TInvalidOperationException('component_property_readonly',get_class($this),$method);
514
+			if (($getset == 'set') && method_exists($this, 'getjs' . $propname))
515
+				throw new TInvalidOperationException('component_property_readonly', get_class($this), $method);
516 516
 		}
517 517
 
518
-		if($this->_m!==null&&$this->_behaviorsenabled)
518
+		if ($this->_m !== null && $this->_behaviorsenabled)
519 519
 		{
520
-			if(strncasecmp($method,'dy',2)===0)
520
+			if (strncasecmp($method, 'dy', 2) === 0)
521 521
 			{
522
-				$callchain=new TCallChain($method);
523
-				foreach($this->_m->toArray() as $behavior)
522
+				$callchain = new TCallChain($method);
523
+				foreach ($this->_m->toArray() as $behavior)
524 524
 				{
525
-					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&(method_exists($behavior,$method)||($behavior instanceof IDynamicMethods)))
525
+					if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && (method_exists($behavior, $method) || ($behavior instanceof IDynamicMethods)))
526 526
 					{
527
-						$behavior_args=$args;
528
-						if($behavior instanceof IClassBehavior)
529
-							array_unshift($behavior_args,$this);
530
-						$callchain->addCall(array($behavior,$method),$behavior_args);
527
+						$behavior_args = $args;
528
+						if ($behavior instanceof IClassBehavior)
529
+							array_unshift($behavior_args, $this);
530
+						$callchain->addCall(array($behavior, $method), $behavior_args);
531 531
 					}
532 532
 
533 533
 				}
534
-				if($callchain->getCount()>0)
535
-					return call_user_func_array(array($callchain,'call'),$args);
534
+				if ($callchain->getCount() > 0)
535
+					return call_user_func_array(array($callchain, 'call'), $args);
536 536
 			}
537 537
 			else
538 538
 			{
539
-				foreach($this->_m->toArray() as $behavior)
539
+				foreach ($this->_m->toArray() as $behavior)
540 540
 				{
541
-					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&method_exists($behavior,$method))
541
+					if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && method_exists($behavior, $method))
542 542
 					{
543
-						if($behavior instanceof IClassBehavior)
544
-							array_unshift($args,$this);
545
-						return call_user_func_array(array($behavior,$method),$args);
543
+						if ($behavior instanceof IClassBehavior)
544
+							array_unshift($args, $this);
545
+						return call_user_func_array(array($behavior, $method), $args);
546 546
 					}
547 547
 				}
548 548
 			}
549 549
 		}
550 550
 
551
-		if(strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0)
551
+		if (strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0)
552 552
 		{
553
-			if($this instanceof IDynamicMethods)
554
-				return $this->__dycall($method,$args);
555
-			return isset($args[0])?$args[0]:null;
553
+			if ($this instanceof IDynamicMethods)
554
+				return $this->__dycall($method, $args);
555
+			return isset($args[0]) ? $args[0] : null;
556 556
 		}
557 557
 
558
-		throw new TApplicationException('component_method_undefined',get_class($this),$method);
558
+		throw new TApplicationException('component_method_undefined', get_class($this), $method);
559 559
 	}
560 560
 
561 561
 
@@ -584,48 +584,48 @@  discard block
 block discarded – undo
584 584
 	 */
585 585
 	public function __get($name)
586 586
 	{
587
-		if(method_exists($this,$getter='get'.$name))
587
+		if (method_exists($this, $getter = 'get' . $name))
588 588
 		{
589 589
 			// getting a property
590 590
 			return $this->$getter();
591 591
 		}
592
-		else if(method_exists($this,$jsgetter='getjs'.$name))
592
+		else if (method_exists($this, $jsgetter = 'getjs' . $name))
593 593
 		{
594 594
 			// getting a javascript property
595
-			return (string)$this->$jsgetter();
595
+			return (string) $this->$jsgetter();
596 596
 		}
597
-		else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
597
+		else if (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name))
598 598
 		{
599 599
 			// getting an event (handler list)
600
-			$name=strtolower($name);
601
-			if(!isset($this->_e[$name]))
602
-				$this->_e[$name]=new TPriorityList;
600
+			$name = strtolower($name);
601
+			if (!isset($this->_e[$name]))
602
+				$this->_e[$name] = new TPriorityList;
603 603
 			return $this->_e[$name];
604 604
 		}
605
-		else if(strncasecmp($name,'fx',2)===0)
605
+		else if (strncasecmp($name, 'fx', 2) === 0)
606 606
 		{
607 607
 			// getting a global event (handler list)
608
-			$name=strtolower($name);
609
-			if(!isset(self::$_ue[$name]))
610
-				self::$_ue[$name]=new TPriorityList;
608
+			$name = strtolower($name);
609
+			if (!isset(self::$_ue[$name]))
610
+				self::$_ue[$name] = new TPriorityList;
611 611
 			return self::$_ue[$name];
612 612
 		}
613
-		else if($this->_behaviorsenabled)
613
+		else if ($this->_behaviorsenabled)
614 614
 		{
615 615
 			// getting a behavior property/event (handler list)
616
-			if(isset($this->_m[$name]))
616
+			if (isset($this->_m[$name]))
617 617
 				return $this->_m[$name];
618
-			else if($this->_m!==null)
618
+			else if ($this->_m !== null)
619 619
 			{
620
-				foreach($this->_m->toArray() as $behavior)
620
+				foreach ($this->_m->toArray() as $behavior)
621 621
 				{
622
-					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&
623
-						(property_exists($behavior,$name)||$behavior->canGetProperty($name)||$behavior->hasEvent($name)))
622
+					if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) &&
623
+						(property_exists($behavior, $name) || $behavior->canGetProperty($name) || $behavior->hasEvent($name)))
624 624
 						return $behavior->$name;
625 625
 				}
626 626
 			}
627 627
 		}
628
-		throw new TInvalidOperationException('component_property_undefined',get_class($this),$name);
628
+		throw new TInvalidOperationException('component_property_undefined', get_class($this), $name);
629 629
 	}
630 630
 
631 631
 	/**
@@ -643,46 +643,46 @@  discard block
 block discarded – undo
643 643
 	 * @param mixed the property value or event handler
644 644
 	 * @throws TInvalidOperationException If the property is not defined or read-only.
645 645
 	 */
646
-	public function __set($name,$value)
646
+	public function __set($name, $value)
647 647
 	{
648
-		if(method_exists($this,$setter='set'.$name))
648
+		if (method_exists($this, $setter = 'set' . $name))
649 649
 		{
650
-			if(strncasecmp($name,'js',2)===0&&$value&&!($value instanceof TJavaScriptLiteral))
650
+			if (strncasecmp($name, 'js', 2) === 0 && $value && !($value instanceof TJavaScriptLiteral))
651 651
 				$value = new TJavaScriptLiteral($value);
652 652
 			return $this->$setter($value);
653 653
 		}
654
-		else if(method_exists($this,$jssetter='setjs'.$name))
654
+		else if (method_exists($this, $jssetter = 'setjs' . $name))
655 655
 		{
656
-			if($value&&!($value instanceof TJavaScriptString))
657
-				$value=new TJavaScriptString($value);
656
+			if ($value && !($value instanceof TJavaScriptString))
657
+				$value = new TJavaScriptString($value);
658 658
 			return $this->$jssetter($value);
659 659
 		}
660
-		else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0)
660
+		else if ((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0)
661 661
 		{
662
-			return $this->attachEventHandler($name,$value);
662
+			return $this->attachEventHandler($name, $value);
663 663
 		}
664
-		else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled)
664
+		else if ($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled)
665 665
 		{
666
-			$sets=0;
667
-			foreach($this->_m->toArray() as $behavior)
666
+			$sets = 0;
667
+			foreach ($this->_m->toArray() as $behavior)
668 668
 			{
669
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&
670
-					(property_exists($behavior,$name)||$behavior->canSetProperty($name)||$behavior->hasEvent($name))) {
671
-					$behavior->$name=$value;
669
+				if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) &&
670
+					(property_exists($behavior, $name) || $behavior->canSetProperty($name) || $behavior->hasEvent($name))) {
671
+					$behavior->$name = $value;
672 672
 					$sets++;
673 673
 				}
674 674
 			}
675
-			if($sets)return $value;
675
+			if ($sets)return $value;
676 676
 
677 677
 		}
678 678
 
679
-		if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name))
679
+		if (method_exists($this, 'get' . $name) || method_exists($this, 'getjs' . $name))
680 680
 		{
681
-			throw new TInvalidOperationException('component_property_readonly',get_class($this),$name);
681
+			throw new TInvalidOperationException('component_property_readonly', get_class($this), $name);
682 682
 		}
683 683
 		else
684 684
 		{
685
-			throw new TInvalidOperationException('component_property_undefined',get_class($this),$name);
685
+			throw new TInvalidOperationException('component_property_undefined', get_class($this), $name);
686 686
 		}
687 687
 	}
688 688
 
@@ -700,27 +700,27 @@  discard block
 block discarded – undo
700 700
 	 */
701 701
 	public function __isset($name)
702 702
 	{
703
-		if(method_exists($this,$getter='get'.$name))
704
-			return $this->$getter()!==null;
705
-		else if(method_exists($this,$jsgetter='getjs'.$name))
706
-			return $this->$jsgetter()!==null;
707
-		else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name))
703
+		if (method_exists($this, $getter = 'get' . $name))
704
+			return $this->$getter() !== null;
705
+		else if (method_exists($this, $jsgetter = 'getjs' . $name))
706
+			return $this->$jsgetter() !== null;
707
+		else if (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name))
708 708
 		{
709
-			$name=strtolower($name);
710
-			return isset($this->_e[$name])&&$this->_e[$name]->getCount();
709
+			$name = strtolower($name);
710
+			return isset($this->_e[$name]) && $this->_e[$name]->getCount();
711 711
 		}
712
-		else if(strncasecmp($name,'fx',2)===0)
712
+		else if (strncasecmp($name, 'fx', 2) === 0)
713 713
 		{
714
-			$name=strtolower($name);
715
-			return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount();
714
+			$name = strtolower($name);
715
+			return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount();
716 716
 		}
717
-		else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled)
717
+		else if ($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled)
718 718
 		{
719
-			if(isset($this->_m[$name]))
719
+			if (isset($this->_m[$name]))
720 720
 				return true;
721
-			foreach($this->_m->toArray() as $behavior)
721
+			foreach ($this->_m->toArray() as $behavior)
722 722
 			{
723
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled()))
723
+				if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()))
724 724
 					return isset($behavior->$name);
725 725
 			}
726 726
 
@@ -741,32 +741,32 @@  discard block
 block discarded – undo
741 741
 	 */
742 742
 	public function __unset($name)
743 743
 	{
744
-		if(method_exists($this,$setter='set'.$name))
744
+		if (method_exists($this, $setter = 'set' . $name))
745 745
 			$this->$setter(null);
746
-		else if(method_exists($this,$jssetter='setjs'.$name))
746
+		else if (method_exists($this, $jssetter = 'setjs' . $name))
747 747
 			$this->$jssetter(null);
748
-		else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name))
748
+		else if (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name))
749 749
 			$this->_e[strtolower($name)]->clear();
750
-		else if(strncasecmp($name,'fx',2)===0)
750
+		else if (strncasecmp($name, 'fx', 2) === 0)
751 751
 			$this->getEventHandlers($name)->remove(array($this, $name));
752
-		else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled)
752
+		else if ($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled)
753 753
 		{
754
-			if(isset($this->_m[$name]))
754
+			if (isset($this->_m[$name]))
755 755
 				$this->detachBehavior($name);
756 756
 			else {
757
-				$unset=0;
758
-				foreach($this->_m->toArray() as $behavior)
757
+				$unset = 0;
758
+				foreach ($this->_m->toArray() as $behavior)
759 759
 				{
760
-					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) {
760
+					if ((!($behavior instanceof IBehavior) || $behavior->getEnabled())) {
761 761
 						unset($behavior->$name);
762 762
 						$unset++;
763 763
 					}
764 764
 				}
765
-				if(!$unset&&method_exists($this,'get'.$name))
766
-					throw new TInvalidOperationException('component_property_readonly',get_class($this),$name);
765
+				if (!$unset && method_exists($this, 'get' . $name))
766
+					throw new TInvalidOperationException('component_property_readonly', get_class($this), $name);
767 767
 			}
768
-		} else if(method_exists($this,'get'.$name))
769
-			throw new TInvalidOperationException('component_property_readonly',get_class($this),$name);
768
+		} else if (method_exists($this, 'get' . $name))
769
+			throw new TInvalidOperationException('component_property_readonly', get_class($this), $name);
770 770
 	}
771 771
 
772 772
 	/**
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 	 */
779 779
 	public function hasProperty($name)
780 780
 	{
781
-		return $this->canGetProperty($name)||$this->canSetProperty($name);
781
+		return $this->canGetProperty($name) || $this->canSetProperty($name);
782 782
 	}
783 783
 
784 784
 	/**
@@ -792,13 +792,13 @@  discard block
 block discarded – undo
792 792
 	 */
793 793
 	public function canGetProperty($name)
794 794
 	{
795
-		if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name))
795
+		if (method_exists($this, 'get' . $name) || method_exists($this, 'getjs' . $name))
796 796
 			return true;
797
-		else if($this->_m!==null&&$this->_behaviorsenabled)
797
+		else if ($this->_m !== null && $this->_behaviorsenabled)
798 798
 		{
799
-			foreach($this->_m->toArray() as $behavior)
799
+			foreach ($this->_m->toArray() as $behavior)
800 800
 			{
801
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canGetProperty($name))
801
+				if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canGetProperty($name))
802 802
 					return true;
803 803
 			}
804 804
 		}
@@ -816,13 +816,13 @@  discard block
 block discarded – undo
816 816
 	 */
817 817
 	public function canSetProperty($name)
818 818
 	{
819
-		if(method_exists($this,'set'.$name)||method_exists($this,'setjs'.$name))
819
+		if (method_exists($this, 'set' . $name) || method_exists($this, 'setjs' . $name))
820 820
 			return true;
821
-		else if($this->_m!==null&&$this->_behaviorsenabled)
821
+		else if ($this->_m !== null && $this->_behaviorsenabled)
822 822
 		{
823
-			foreach($this->_m->toArray() as $behavior)
823
+			foreach ($this->_m->toArray() as $behavior)
824 824
 			{
825
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canSetProperty($name))
825
+				if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canSetProperty($name))
826 826
 					return true;
827 827
 			}
828 828
 		}
@@ -841,9 +841,9 @@  discard block
 block discarded – undo
841 841
 	 */
842 842
 	public function getSubProperty($path)
843 843
 	{
844
-		$object=$this;
845
-		foreach(explode('.',$path) as $property)
846
-			$object=$object->$property;
844
+		$object = $this;
845
+		foreach (explode('.', $path) as $property)
846
+			$object = $object->$property;
847 847
 		return $object;
848 848
 	}
849 849
 
@@ -857,17 +857,17 @@  discard block
 block discarded – undo
857 857
 	 * @param string property path
858 858
 	 * @param mixed the property path value
859 859
 	 */
860
-	public function setSubProperty($path,$value)
860
+	public function setSubProperty($path, $value)
861 861
 	{
862
-		$object=$this;
863
-		if(($pos=strrpos($path,'.'))===false)
864
-			$property=$path;
862
+		$object = $this;
863
+		if (($pos = strrpos($path, '.')) === false)
864
+			$property = $path;
865 865
 		else
866 866
 		{
867
-			$object=$this->getSubProperty(substr($path,0,$pos));
868
-			$property=substr($path,$pos+1);
867
+			$object = $this->getSubProperty(substr($path, 0, $pos));
868
+			$property = substr($path, $pos + 1);
869 869
 		}
870
-		$object->$property=$value;
870
+		$object->$property = $value;
871 871
 	}
872 872
 
873 873
 	/**
@@ -884,14 +884,14 @@  discard block
 block discarded – undo
884 884
 	 */
885 885
 	public function hasEvent($name)
886 886
 	{
887
-		if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0||strncasecmp($name,'dy',2)===0)
887
+		if ((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0 || strncasecmp($name, 'dy', 2) === 0)
888 888
 			return true;
889 889
 
890
-		else if($this->_m!==null&&$this->_behaviorsenabled)
890
+		else if ($this->_m !== null && $this->_behaviorsenabled)
891 891
 		{
892
-			foreach($this->_m->toArray() as $behavior)
892
+			foreach ($this->_m->toArray() as $behavior)
893 893
 			{
894
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name))
894
+				if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name))
895 895
 					return true;
896 896
 			}
897 897
 		}
@@ -907,17 +907,17 @@  discard block
 block discarded – undo
907 907
 	 */
908 908
 	public function hasEventHandler($name)
909 909
 	{
910
-		$name=strtolower($name);
911
-		if(strncasecmp($name,'fx',2)===0)
912
-			return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount()>0;
910
+		$name = strtolower($name);
911
+		if (strncasecmp($name, 'fx', 2) === 0)
912
+			return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount() > 0;
913 913
 		else
914 914
 		{
915
-			if(isset($this->_e[$name])&&$this->_e[$name]->getCount()>0)
915
+			if (isset($this->_e[$name]) && $this->_e[$name]->getCount() > 0)
916 916
 				return true;
917
-			else if($this->_m!==null&&$this->_behaviorsenabled) {
918
-				foreach($this->_m->toArray() as $behavior)
917
+			else if ($this->_m !== null && $this->_behaviorsenabled) {
918
+				foreach ($this->_m->toArray() as $behavior)
919 919
 				{
920
-					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEventHandler($name))
920
+					if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEventHandler($name))
921 921
 						return true;
922 922
 				}
923 923
 			}
@@ -933,29 +933,29 @@  discard block
 block discarded – undo
933 933
 	 */
934 934
 	public function getEventHandlers($name)
935 935
 	{
936
-		if(strncasecmp($name,'on',2)===0&&method_exists($this,$name))
936
+		if (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name))
937 937
 		{
938
-			$name=strtolower($name);
939
-			if(!isset($this->_e[$name]))
940
-				$this->_e[$name]=new TPriorityList;
938
+			$name = strtolower($name);
939
+			if (!isset($this->_e[$name]))
940
+				$this->_e[$name] = new TPriorityList;
941 941
 			return $this->_e[$name];
942 942
 		}
943
-		else if(strncasecmp($name,'fx',2)===0)
943
+		else if (strncasecmp($name, 'fx', 2) === 0)
944 944
 		{
945
-			$name=strtolower($name);
946
-			if(!isset(self::$_ue[$name]))
947
-				self::$_ue[$name]=new TPriorityList;
945
+			$name = strtolower($name);
946
+			if (!isset(self::$_ue[$name]))
947
+				self::$_ue[$name] = new TPriorityList;
948 948
 			return self::$_ue[$name];
949 949
 		}
950
-		else if($this->_m!==null&&$this->_behaviorsenabled)
950
+		else if ($this->_m !== null && $this->_behaviorsenabled)
951 951
 		{
952
-			foreach($this->_m->toArray() as $behavior)
952
+			foreach ($this->_m->toArray() as $behavior)
953 953
 			{
954
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name))
954
+				if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name))
955 955
 					return $behavior->getEventHandlers($name);
956 956
 			}
957 957
 		}
958
-		throw new TInvalidOperationException('component_event_undefined',get_class($this),$name);
958
+		throw new TInvalidOperationException('component_event_undefined', get_class($this), $name);
959 959
 	}
960 960
 
961 961
 	/**
@@ -1003,9 +1003,9 @@  discard block
 block discarded – undo
1003 1003
 	 * default priority of 10.0 within {@link TPriorityList}
1004 1004
 	 * @throws TInvalidOperationException if the event does not exist
1005 1005
 	 */
1006
-	public function attachEventHandler($name,$handler,$priority=null)
1006
+	public function attachEventHandler($name, $handler, $priority = null)
1007 1007
 	{
1008
-		$this->getEventHandlers($name)->add($handler,$priority);
1008
+		$this->getEventHandlers($name)->add($handler, $priority);
1009 1009
 	}
1010 1010
 
1011 1011
 	/**
@@ -1018,16 +1018,16 @@  discard block
 block discarded – undo
1018 1018
 	 * to an item of any priority within {@link TPriorityList}; null means the default priority
1019 1019
 	 * @return boolean if the removal is successful
1020 1020
 	 */
1021
-	public function detachEventHandler($name,$handler,$priority=false)
1021
+	public function detachEventHandler($name, $handler, $priority = false)
1022 1022
 	{
1023
-		if($this->hasEventHandler($name))
1023
+		if ($this->hasEventHandler($name))
1024 1024
 		{
1025 1025
 			try
1026 1026
 			{
1027
-				$this->getEventHandlers($name)->remove($handler,$priority);
1027
+				$this->getEventHandlers($name)->remove($handler, $priority);
1028 1028
 				return true;
1029 1029
 			}
1030
-			catch(Exception $e)
1030
+			catch (Exception $e)
1031 1031
 			{
1032 1032
 			}
1033 1033
 		}
@@ -1106,105 +1106,105 @@  discard block
 block discarded – undo
1106 1106
 	 * @throws TInvalidOperationException if the event is undefined
1107 1107
 	 * @throws TInvalidDataValueException If an event handler is invalid
1108 1108
 	 */
1109
-	public function raiseEvent($name,$sender,$param,$responsetype=null,$postfunction=null)
1109
+	public function raiseEvent($name, $sender, $param, $responsetype = null, $postfunction = null)
1110 1110
 	{
1111
-		$p=$param;
1112
-		if(is_callable($responsetype))
1111
+		$p = $param;
1112
+		if (is_callable($responsetype))
1113 1113
 		{
1114
-			$postfunction=$responsetype;
1115
-			$responsetype=null;
1114
+			$postfunction = $responsetype;
1115
+			$responsetype = null;
1116 1116
 		}
1117 1117
 
1118
-		if($responsetype===null)
1119
-			$responsetype=TEventResults::EVENT_RESULT_FILTER;
1118
+		if ($responsetype === null)
1119
+			$responsetype = TEventResults::EVENT_RESULT_FILTER;
1120 1120
 
1121
-		$name=strtolower($name);
1122
-		$responses=array();
1121
+		$name = strtolower($name);
1122
+		$responses = array();
1123 1123
 
1124
-		$name=$this->dyPreRaiseEvent($name,$sender,$param,$responsetype,$postfunction);
1124
+		$name = $this->dyPreRaiseEvent($name, $sender, $param, $responsetype, $postfunction);
1125 1125
 
1126
-		if($this->hasEventHandler($name)||$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER))
1126
+		if ($this->hasEventHandler($name) || $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER))
1127 1127
 		{
1128
-			$handlers=$this->getEventHandlers($name);
1129
-			$handlerArray=$handlers->toArray();
1130
-			if(strncasecmp($name,'fx',2)===0&&$this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER))
1128
+			$handlers = $this->getEventHandlers($name);
1129
+			$handlerArray = $handlers->toArray();
1130
+			if (strncasecmp($name, 'fx', 2) === 0 && $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER))
1131 1131
 			{
1132
-				$globalhandlers=$this->getEventHandlers(TComponent::GLOBAL_RAISE_EVENT_LISTENER);
1133
-				$handlerArray=array_merge($globalhandlers->toArrayBelowPriority(0),$handlerArray,$globalhandlers->toArrayAbovePriority(0));
1132
+				$globalhandlers = $this->getEventHandlers(TComponent::GLOBAL_RAISE_EVENT_LISTENER);
1133
+				$handlerArray = array_merge($globalhandlers->toArrayBelowPriority(0), $handlerArray, $globalhandlers->toArrayAbovePriority(0));
1134 1134
 			}
1135
-			$response=null;
1136
-			foreach($handlerArray as $handler)
1135
+			$response = null;
1136
+			foreach ($handlerArray as $handler)
1137 1137
 			{
1138
-				if($this->dyIntraRaiseEventTestHandler($handler,$sender,$param,$name)===false)
1138
+				if ($this->dyIntraRaiseEventTestHandler($handler, $sender, $param, $name) === false)
1139 1139
 					continue;
1140 1140
 
1141
-				if(is_string($handler))
1141
+				if (is_string($handler))
1142 1142
 				{
1143
-					if(($pos=strrpos($handler,'.'))!==false)
1143
+					if (($pos = strrpos($handler, '.')) !== false)
1144 1144
 					{
1145
-						$object=$this->getSubProperty(substr($handler,0,$pos));
1146
-						$method=substr($handler,$pos+1);
1147
-						if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0)
1145
+						$object = $this->getSubProperty(substr($handler, 0, $pos));
1146
+						$method = substr($handler, $pos + 1);
1147
+						if (method_exists($object, $method) || strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0)
1148 1148
 						{
1149
-							if($method=='__dycall')
1150
-								$response=$object->__dycall($name,array($sender,$param,$name));
1149
+							if ($method == '__dycall')
1150
+								$response = $object->__dycall($name, array($sender, $param, $name));
1151 1151
 							else
1152
-								$response=$object->$method($sender,$param,$name);
1152
+								$response = $object->$method($sender, $param, $name);
1153 1153
 						}
1154 1154
 						else
1155
-							throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler);
1155
+							throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler);
1156 1156
 					}
1157 1157
 					else
1158
-						$response=call_user_func($handler,$sender,$param,$name);
1158
+						$response = call_user_func($handler, $sender, $param, $name);
1159 1159
 				}
1160
-				else if(is_callable($handler,true))
1160
+				else if (is_callable($handler, true))
1161 1161
 				{
1162
-					list($object,$method)=$handler;
1163
-					if(is_string($object))
1164
-						$response=call_user_func($handler,$sender,$param,$name);
1162
+					list($object, $method) = $handler;
1163
+					if (is_string($object))
1164
+						$response = call_user_func($handler, $sender, $param, $name);
1165 1165
 					else
1166 1166
 					{
1167
-						if(($pos=strrpos($method,'.'))!==false)
1167
+						if (($pos = strrpos($method, '.')) !== false)
1168 1168
 						{
1169
-							$object=$this->getSubProperty(substr($method,0,$pos));
1170
-							$method=substr($method,$pos+1);
1169
+							$object = $this->getSubProperty(substr($method, 0, $pos));
1170
+							$method = substr($method, $pos + 1);
1171 1171
 						}
1172
-						if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0)
1172
+						if (method_exists($object, $method) || strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0)
1173 1173
 						{
1174
-							if($method=='__dycall')
1175
-								$response=$object->__dycall($name,array($sender,$param,$name));
1174
+							if ($method == '__dycall')
1175
+								$response = $object->__dycall($name, array($sender, $param, $name));
1176 1176
 							else
1177
-								$response=$object->$method($sender,$param,$name);
1177
+								$response = $object->$method($sender, $param, $name);
1178 1178
 						}
1179 1179
 						else
1180
-							throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler[1]);
1180
+							throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, $handler[1]);
1181 1181
 					}
1182 1182
 				}
1183 1183
 				else
1184
-					throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,gettype($handler));
1184
+					throw new TInvalidDataValueException('component_eventhandler_invalid', get_class($this), $name, gettype($handler));
1185 1185
 
1186
-				$this->dyIntraRaiseEventPostHandler($name,$sender,$param,$handler,$response);
1186
+				$this->dyIntraRaiseEventPostHandler($name, $sender, $param, $handler, $response);
1187 1187
 
1188
-				if($postfunction)
1189
-					$response=call_user_func_array($postfunction,array($sender,$param,$this,$response));
1188
+				if ($postfunction)
1189
+					$response = call_user_func_array($postfunction, array($sender, $param, $this, $response));
1190 1190
 
1191
-				if($responsetype&TEventResults::EVENT_RESULT_ALL)
1192
-					$responses[]=array('sender'=>$sender,'param'=>$param,'response'=>$response);
1191
+				if ($responsetype & TEventResults::EVENT_RESULT_ALL)
1192
+					$responses[] = array('sender'=>$sender, 'param'=>$param, 'response'=>$response);
1193 1193
 				else
1194
-					$responses[]=$response;
1194
+					$responses[] = $response;
1195 1195
 
1196
-				if($response!==null&&($responsetype&TEventResults::EVENT_RESULT_FEED_FORWARD))
1197
-					$param=$response;
1196
+				if ($response !== null && ($responsetype & TEventResults::EVENT_RESULT_FEED_FORWARD))
1197
+					$param = $response;
1198 1198
 
1199 1199
 			}
1200 1200
 		}
1201
-		else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name))
1202
-			throw new TInvalidOperationException('component_event_undefined',get_class($this),$name);
1201
+		else if (strncasecmp($name, 'on', 2) === 0 && !$this->hasEvent($name))
1202
+			throw new TInvalidOperationException('component_event_undefined', get_class($this), $name);
1203 1203
 
1204
-		if($responsetype&TEventResults::EVENT_RESULT_FILTER)
1205
-			$responses=array_filter($responses);
1204
+		if ($responsetype & TEventResults::EVENT_RESULT_FILTER)
1205
+			$responses = array_filter($responses);
1206 1206
 
1207
-		$responses=$this->dyPostRaiseEvent($responses,$name,$sender,$param,$responsetype,$postfunction);
1207
+		$responses = $this->dyPostRaiseEvent($responses, $name, $sender, $param, $responsetype, $postfunction);
1208 1208
 
1209 1209
 		return $responses;
1210 1210
 	}
@@ -1228,16 +1228,16 @@  discard block
 block discarded – undo
1228 1228
 	 */
1229 1229
 	public function evaluateExpression($expression)
1230 1230
 	{
1231
-		$expression=$this->dyEvaluateExpressionFilter($expression);
1231
+		$expression = $this->dyEvaluateExpressionFilter($expression);
1232 1232
 		try
1233 1233
 		{
1234
-			if(eval("\$result=$expression;")===false)
1234
+			if (eval("\$result=$expression;") === false)
1235 1235
 				throw new Exception('');
1236 1236
 			return $result;
1237 1237
 		}
1238
-		catch(Exception $e)
1238
+		catch (Exception $e)
1239 1239
 		{
1240
-			throw new TInvalidOperationException('component_expression_invalid',get_class($this),$expression,$e->getMessage());
1240
+			throw new TInvalidOperationException('component_expression_invalid', get_class($this), $expression, $e->getMessage());
1241 1241
 		}
1242 1242
 	}
1243 1243
 
@@ -1260,19 +1260,19 @@  discard block
 block discarded – undo
1260 1260
 	 */
1261 1261
 	public function evaluateStatements($statements)
1262 1262
 	{
1263
-		$statements=$this->dyEvaluateStatementsFilter($statements);
1263
+		$statements = $this->dyEvaluateStatementsFilter($statements);
1264 1264
 		try
1265 1265
 		{
1266 1266
 			ob_start();
1267
-			if(eval($statements)===false)
1267
+			if (eval($statements) === false)
1268 1268
 				throw new Exception('');
1269
-			$content=ob_get_contents();
1269
+			$content = ob_get_contents();
1270 1270
 			ob_end_clean();
1271 1271
 			return $content;
1272 1272
 		}
1273
-		catch(Exception $e)
1273
+		catch (Exception $e)
1274 1274
 		{
1275
-			throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage());
1275
+			throw new TInvalidOperationException('component_statements_invalid', get_class($this), $statements, $e->getMessage());
1276 1276
 		}
1277 1277
 	}
1278 1278
 
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 	 */
1298 1298
 	public function createdOnTemplate($parent)
1299 1299
 	{
1300
-		$parent=$this->dyCreatedOnTemplate($parent);
1300
+		$parent = $this->dyCreatedOnTemplate($parent);
1301 1301
 		$parent->addParsedObject($this);
1302 1302
 	}
1303 1303
 
@@ -1332,9 +1332,9 @@  discard block
 block discarded – undo
1332 1332
 	 * @param $param TClassBehaviorEventParameter
1333 1333
 	 * @since 3.2.3
1334 1334
 	 */
1335
-	public function fxAttachClassBehavior($sender,$param) {
1336
-		if(in_array($param->getClass(),$this->getClassHierarchy(true)))
1337
-			return $this->attachBehavior($param->getName(),$param->getBehavior(),$param->getPriority());
1335
+	public function fxAttachClassBehavior($sender, $param) {
1336
+		if (in_array($param->getClass(), $this->getClassHierarchy(true)))
1337
+			return $this->attachBehavior($param->getName(), $param->getBehavior(), $param->getPriority());
1338 1338
 	}
1339 1339
 
1340 1340
 
@@ -1346,9 +1346,9 @@  discard block
 block discarded – undo
1346 1346
 	 * @param $param TClassBehaviorEventParameter
1347 1347
 	 * @since 3.2.3
1348 1348
 	 */
1349
-	public function fxDetachClassBehavior($sender,$param) {
1350
-		if(in_array($param->getClass(),$this->getClassHierarchy(true)))
1351
-			return $this->detachBehavior($param->getName(),$param->getPriority());
1349
+	public function fxDetachClassBehavior($sender, $param) {
1350
+		if (in_array($param->getClass(), $this->getClassHierarchy(true)))
1351
+			return $this->detachBehavior($param->getName(), $param->getPriority());
1352 1352
 	}
1353 1353
 
1354 1354
 
@@ -1370,25 +1370,25 @@  discard block
 block discarded – undo
1370 1370
 	 * @throws TInvalidOperationException if the class behavior is already defined
1371 1371
 	 * @since 3.2.3
1372 1372
 	 */
1373
-	public static function attachClassBehavior($name,$behavior,$class=null,$priority=null) {
1374
-		if(!$class&&function_exists('get_called_class'))
1375
-			$class=get_called_class();
1376
-		if(!$class)
1373
+	public static function attachClassBehavior($name, $behavior, $class = null, $priority = null) {
1374
+		if (!$class && function_exists('get_called_class'))
1375
+			$class = get_called_class();
1376
+		if (!$class)
1377 1377
 			throw new TInvalidOperationException('component_no_class_provided_nor_late_binding');
1378 1378
 
1379
-		if(!is_string($name))
1380
-			$name=get_class($name);
1381
-		$class=strtolower($class);
1382
-		if($class==='tcomponent')
1379
+		if (!is_string($name))
1380
+			$name = get_class($name);
1381
+		$class = strtolower($class);
1382
+		if ($class === 'tcomponent')
1383 1383
 			throw new TInvalidOperationException('component_no_tcomponent_class_behaviors');
1384
-		if(empty(self::$_um[$class]))
1385
-			self::$_um[$class]=array();
1386
-		if(isset(self::$_um[$class][$name]))
1387
-			throw new TInvalidOperationException('component_class_behavior_defined',$class,$name);
1388
-		$param=new TClassBehaviorEventParameter($class,$name,$behavior,$priority);
1389
-		self::$_um[$class]=array($name=>$param)+self::$_um[$class];
1390
-		$behaviorObject=is_string($behavior)?new $behavior:$behavior;
1391
-		return $behaviorObject->raiseEvent('fxAttachClassBehavior',null,$param);
1384
+		if (empty(self::$_um[$class]))
1385
+			self::$_um[$class] = array();
1386
+		if (isset(self::$_um[$class][$name]))
1387
+			throw new TInvalidOperationException('component_class_behavior_defined', $class, $name);
1388
+		$param = new TClassBehaviorEventParameter($class, $name, $behavior, $priority);
1389
+		self::$_um[$class] = array($name=>$param) + self::$_um[$class];
1390
+		$behaviorObject = is_string($behavior) ? new $behavior : $behavior;
1391
+		return $behaviorObject->raiseEvent('fxAttachClassBehavior', null, $param);
1392 1392
 	}
1393 1393
 
1394 1394
 
@@ -1404,22 +1404,22 @@  discard block
 block discarded – undo
1404 1404
 	 * not supplied as a parameter.
1405 1405
 	 * @since 3.2.3
1406 1406
 	 */
1407
-	public static function detachClassBehavior($name,$class=null,$priority=false) {
1408
-		if(!$class&&function_exists('get_called_class'))
1409
-			$class=get_called_class();
1410
-		if(!$class)
1407
+	public static function detachClassBehavior($name, $class = null, $priority = false) {
1408
+		if (!$class && function_exists('get_called_class'))
1409
+			$class = get_called_class();
1410
+		if (!$class)
1411 1411
 			throw new TInvalidOperationException('component_no_class_provided_nor_late_binding');
1412 1412
 
1413
-		$class=strtolower($class);
1414
-		if(!is_string($name))
1415
-			$name=get_class($name);
1416
-		if(empty(self::$_um[$class])||!isset(self::$_um[$class][$name]))
1413
+		$class = strtolower($class);
1414
+		if (!is_string($name))
1415
+			$name = get_class($name);
1416
+		if (empty(self::$_um[$class]) || !isset(self::$_um[$class][$name]))
1417 1417
 			return false;
1418
-		$param=self::$_um[$class][$name];
1419
-		$behavior=$param->getBehavior();
1418
+		$param = self::$_um[$class][$name];
1419
+		$behavior = $param->getBehavior();
1420 1420
 		unset(self::$_um[$class][$name]);
1421
-		$behaviorObject=is_string($behavior)?new $behavior:$behavior;
1422
-		return $behaviorObject->raiseEvent('fxDetachClassBehavior',null,$param);
1421
+		$behaviorObject = is_string($behavior) ? new $behavior : $behavior;
1422
+		return $behaviorObject->raiseEvent('fxDetachClassBehavior', null, $param);
1423 1423
 	}
1424 1424
 
1425 1425
 	/**
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 	 */
1432 1432
 	public function asa($behaviorname)
1433 1433
 	{
1434
-		return isset($this->_m[$behaviorname])?$this->_m[$behaviorname]:null;
1434
+		return isset($this->_m[$behaviorname]) ? $this->_m[$behaviorname] : null;
1435 1435
 	}
1436 1436
 
1437 1437
 	/**
@@ -1455,17 +1455,17 @@  discard block
 block discarded – undo
1455 1455
 	 */
1456 1456
 	public function isa($class)
1457 1457
 	{
1458
-		if($this instanceof $class)
1458
+		if ($this instanceof $class)
1459 1459
 			return true;
1460
-		if($this->_m!==null&&$this->_behaviorsenabled)
1461
-			foreach($this->_m->toArray() as $behavior){
1462
-				if(($behavior instanceof IBehavior)&&!$behavior->getEnabled())
1460
+		if ($this->_m !== null && $this->_behaviorsenabled)
1461
+			foreach ($this->_m->toArray() as $behavior) {
1462
+				if (($behavior instanceof IBehavior) && !$behavior->getEnabled())
1463 1463
 					continue;
1464 1464
 
1465 1465
 				$check = null;
1466
-				if(($behavior->isa('IInstanceCheck'))&&$check=$behavior->isinstanceof($class,$this))
1466
+				if (($behavior->isa('IInstanceCheck')) && $check = $behavior->isinstanceof($class, $this))
1467 1467
 					return true;
1468
-				if($check===null&&($behavior->isa($class)))
1468
+				if ($check === null && ($behavior->isa($class)))
1469 1469
 					return true;
1470 1470
 			}
1471 1471
 		return false;
@@ -1481,11 +1481,11 @@  discard block
 block discarded – undo
1481 1481
 	 */
1482 1482
 	public function attachBehaviors($behaviors)
1483 1483
 	{
1484
-		foreach($behaviors as $name=>$behavior)
1485
-			if($behavior instanceof TClassBehaviorEventParameter)
1486
-				$this->attachBehavior($behavior->getName(),$behavior->getBehavior(),$behavior->getPriority());
1484
+		foreach ($behaviors as $name=>$behavior)
1485
+			if ($behavior instanceof TClassBehaviorEventParameter)
1486
+				$this->attachBehavior($behavior->getName(), $behavior->getBehavior(), $behavior->getPriority());
1487 1487
 			else
1488
-				$this->attachBehavior($name,$behavior);
1488
+				$this->attachBehavior($name, $behavior);
1489 1489
 	}
1490 1490
 
1491 1491
 	/**
@@ -1498,13 +1498,13 @@  discard block
 block discarded – undo
1498 1498
 	 */
1499 1499
 	public function detachBehaviors($behaviors)
1500 1500
 	{
1501
-		if($this->_m!==null)
1501
+		if ($this->_m !== null)
1502 1502
 		{
1503
-			foreach($behaviors as $name=>$behavior)
1504
-				if($behavior instanceof TClassBehaviorEventParameter)
1505
-					$this->detachBehavior($behavior->getName(),$behavior->getPriority());
1503
+			foreach ($behaviors as $name=>$behavior)
1504
+				if ($behavior instanceof TClassBehaviorEventParameter)
1505
+					$this->detachBehavior($behavior->getName(), $behavior->getPriority());
1506 1506
 				else
1507
-					$this->detachBehavior(is_string($behavior)?$behavior:$name);
1507
+					$this->detachBehavior(is_string($behavior) ? $behavior : $name);
1508 1508
 		}
1509 1509
 	}
1510 1510
 
@@ -1514,11 +1514,11 @@  discard block
 block discarded – undo
1514 1514
 	 */
1515 1515
 	public function clearBehaviors()
1516 1516
 	{
1517
-		if($this->_m!==null)
1517
+		if ($this->_m !== null)
1518 1518
 		{
1519
-			foreach($this->_m->toArray() as $name=>$behavior)
1519
+			foreach ($this->_m->toArray() as $name=>$behavior)
1520 1520
 				$this->detachBehavior($name);
1521
-			$this->_m=null;
1521
+			$this->_m = null;
1522 1522
 		}
1523 1523
 	}
1524 1524
 
@@ -1542,19 +1542,19 @@  discard block
 block discarded – undo
1542 1542
 	 * @return IBehavior the behavior object
1543 1543
 	 * @since 3.2.3
1544 1544
 	 */
1545
-	public function attachBehavior($name,$behavior,$priority=null)
1545
+	public function attachBehavior($name, $behavior, $priority = null)
1546 1546
 	{
1547
-		if(is_string($behavior))
1548
-			$behavior=Prado::createComponent($behavior);
1549
-		if(!($behavior instanceof IBaseBehavior))
1550
-			throw new TInvalidDataTypeException('component_not_a_behavior',get_class($behavior));
1551
-		if($behavior instanceof IBehavior)
1547
+		if (is_string($behavior))
1548
+			$behavior = Prado::createComponent($behavior);
1549
+		if (!($behavior instanceof IBaseBehavior))
1550
+			throw new TInvalidDataTypeException('component_not_a_behavior', get_class($behavior));
1551
+		if ($behavior instanceof IBehavior)
1552 1552
 			$behavior->setEnabled(true);
1553
-		if($this->_m===null)
1554
-			$this->_m=new TPriorityMap;
1553
+		if ($this->_m === null)
1554
+			$this->_m = new TPriorityMap;
1555 1555
 		$behavior->attach($this);
1556
-		$this->dyAttachBehavior($name,$behavior);
1557
-		$this->_m->add($name,$behavior,$priority);
1556
+		$this->dyAttachBehavior($name, $behavior);
1557
+		$this->_m->add($name, $behavior, $priority);
1558 1558
 		return $behavior;
1559 1559
 	}
1560 1560
 
@@ -1575,14 +1575,14 @@  discard block
 block discarded – undo
1575 1575
 	 * @return IBehavior the detached behavior. Null if the behavior does not exist.
1576 1576
 	 * @since 3.2.3
1577 1577
 	 */
1578
-	public function detachBehavior($name,$priority=false)
1578
+	public function detachBehavior($name, $priority = false)
1579 1579
 	{
1580
-		if($this->_m!=null&&isset($this->_m[$name]))
1580
+		if ($this->_m != null && isset($this->_m[$name]))
1581 1581
 		{
1582 1582
 			$this->_m[$name]->detach($this);
1583
-			$behavior=$this->_m->itemAt($name);
1584
-			$this->_m->remove($name,$priority);
1585
-			$this->dyDetachBehavior($name,$behavior);
1583
+			$behavior = $this->_m->itemAt($name);
1584
+			$this->_m->remove($name, $priority);
1585
+			$this->dyDetachBehavior($name, $behavior);
1586 1586
 			return $behavior;
1587 1587
 		}
1588 1588
 	}
@@ -1601,9 +1601,9 @@  discard block
 block discarded – undo
1601 1601
 	 */
1602 1602
 	public function enableBehaviors()
1603 1603
 	{
1604
-		if(!$this->_behaviorsenabled)
1604
+		if (!$this->_behaviorsenabled)
1605 1605
 		{
1606
-			$this->_behaviorsenabled=true;
1606
+			$this->_behaviorsenabled = true;
1607 1607
 			$this->dyEnableBehaviors();
1608 1608
 		}
1609 1609
 	}
@@ -1622,10 +1622,10 @@  discard block
 block discarded – undo
1622 1622
 	 */
1623 1623
 	public function disableBehaviors()
1624 1624
 	{
1625
-		if($this->_behaviorsenabled)
1625
+		if ($this->_behaviorsenabled)
1626 1626
 		{
1627 1627
 			$this->dyDisableBehaviors();
1628
-			$this->_behaviorsenabled=false;
1628
+			$this->_behaviorsenabled = false;
1629 1629
 		}
1630 1630
 	}
1631 1631
 
@@ -1658,10 +1658,10 @@  discard block
 block discarded – undo
1658 1658
 	 */
1659 1659
 	public function enableBehavior($name)
1660 1660
 	{
1661
-		if($this->_m!=null&&isset($this->_m[$name])){
1662
-			if($this->_m[$name] instanceof IBehavior) {
1661
+		if ($this->_m != null && isset($this->_m[$name])) {
1662
+			if ($this->_m[$name] instanceof IBehavior) {
1663 1663
 				$this->_m[$name]->setEnabled(true);
1664
-				$this->dyEnableBehavior($name,$this->_m[$name]);
1664
+				$this->dyEnableBehavior($name, $this->_m[$name]);
1665 1665
 				return true;
1666 1666
 			}
1667 1667
 			return false;
@@ -1686,10 +1686,10 @@  discard block
 block discarded – undo
1686 1686
 	 */
1687 1687
 	public function disableBehavior($name)
1688 1688
 	{
1689
-		if($this->_m!=null&&isset($this->_m[$name])){
1690
-			if($this->_m[$name] instanceof IBehavior) {
1689
+		if ($this->_m != null && isset($this->_m[$name])) {
1690
+			if ($this->_m[$name] instanceof IBehavior) {
1691 1691
 				$this->_m[$name]->setEnabled(false);
1692
-				$this->dyDisableBehavior($name,$this->_m[$name]);
1692
+				$this->dyDisableBehavior($name, $this->_m[$name]);
1693 1693
 				return true;
1694 1694
 			}
1695 1695
 			return false;
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
 	 */
1705 1705
 	public function __sleep()
1706 1706
 	{
1707
-		$a = (array)$this;
1707
+		$a = (array) $this;
1708 1708
 		$a = array_keys($a);
1709 1709
 		$exprops = array();
1710 1710
 		$this->__getZappableSleepProps($exprops);
@@ -1719,13 +1719,13 @@  discard block
 block discarded – undo
1719 1719
 	 */
1720 1720
 	protected function __getZappableSleepProps(&$exprops)
1721 1721
 	{
1722
-		if($this->_listeningenabled===false)
1722
+		if ($this->_listeningenabled === false)
1723 1723
 			$exprops[] = "\0TComponent\0_listeningenabled";
1724
-		if($this->_behaviorsenabled===true)
1724
+		if ($this->_behaviorsenabled === true)
1725 1725
 			$exprops[] = "\0TComponent\0_behaviorsenabled";
1726
-		if ($this->_e===array())
1726
+		if ($this->_e === array())
1727 1727
 			$exprops[] = "\0TComponent\0_e";
1728
-		if ($this->_m===null)
1728
+		if ($this->_m === null)
1729 1729
 			$exprops[] = "\0TComponent\0_m";
1730 1730
 	}
1731 1731
 }
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
  */
1743 1743
 interface IDynamicMethods
1744 1744
 {
1745
-	public function __dycall($method,$args);
1745
+	public function __dycall($method, $args);
1746 1746
 }
1747 1747
 
1748 1748
 
@@ -1769,12 +1769,12 @@  discard block
 block discarded – undo
1769 1769
 	 *	@param string $name the name of the behavior
1770 1770
 	 *	@param object $behavior this is the behavior to implement the class behavior
1771 1771
 	 */
1772
-	public function __construct($class,$name,$behavior,$priority)
1772
+	public function __construct($class, $name, $behavior, $priority)
1773 1773
 	{
1774
-		$this->_class=$class;
1775
-		$this->_name=$name;
1776
-		$this->_behavior=$behavior;
1777
-		$this->_priority=$priority;
1774
+		$this->_class = $class;
1775
+		$this->_name = $name;
1776
+		$this->_behavior = $behavior;
1777
+		$this->_priority = $priority;
1778 1778
 	}
1779 1779
 
1780 1780
 	/**
@@ -1838,11 +1838,11 @@  discard block
 block discarded – undo
1838 1838
  */
1839 1839
 class TEnumerable implements Iterator
1840 1840
 {
1841
-	private $_enums=array();
1841
+	private $_enums = array();
1842 1842
 
1843 1843
 	public function __construct() {
1844
-		$reflection=new ReflectionClass($this);
1845
-		$this->_enums=$reflection->getConstants();
1844
+		$reflection = new ReflectionClass($this);
1845
+		$this->_enums = $reflection->getConstants();
1846 1846
 	}
1847 1847
 
1848 1848
 	public function current() {
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
 	}
1863 1863
 
1864 1864
 	public function valid() {
1865
-		return $this->current()!==false;
1865
+		return $this->current() !== false;
1866 1866
 	}
1867 1867
 }
1868 1868
 
@@ -1911,9 +1911,9 @@  discard block
 block discarded – undo
1911 1911
 	public static function ensureBoolean($value)
1912 1912
 	{
1913 1913
 		if (is_string($value))
1914
-			return strcasecmp($value,'true')==0 || $value!=0;
1914
+			return strcasecmp($value, 'true') == 0 || $value != 0;
1915 1915
 		else
1916
-			return (boolean)$value;
1916
+			return (boolean) $value;
1917 1917
 	}
1918 1918
 
1919 1919
 	/**
@@ -1928,9 +1928,9 @@  discard block
 block discarded – undo
1928 1928
 		if (TJavaScript::isJsLiteral($value))
1929 1929
 			return $value;
1930 1930
 		if (is_bool($value))
1931
-			return $value?'true':'false';
1931
+			return $value ? 'true' : 'false';
1932 1932
 		else
1933
-			return (string)$value;
1933
+			return (string) $value;
1934 1934
 	}
1935 1935
 
1936 1936
 	/**
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
 	 */
1941 1941
 	public static function ensureInteger($value)
1942 1942
 	{
1943
-		return (integer)$value;
1943
+		return (integer) $value;
1944 1944
 	}
1945 1945
 
1946 1946
 	/**
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
 	 */
1951 1951
 	public static function ensureFloat($value)
1952 1952
 	{
1953
-		return (float)$value;
1953
+		return (float) $value;
1954 1954
 	}
1955 1955
 
1956 1956
 	/**
@@ -1964,20 +1964,20 @@  discard block
 block discarded – undo
1964 1964
 	 */
1965 1965
 	public static function ensureArray($value)
1966 1966
 	{
1967
-		if(is_string($value))
1967
+		if (is_string($value))
1968 1968
 		{
1969 1969
 			$value = trim($value);
1970 1970
 			$len = strlen($value);
1971
-			if ($len >= 2 && $value[0] == '(' && $value[$len-1] == ')')
1971
+			if ($len >= 2 && $value[0] == '(' && $value[$len - 1] == ')')
1972 1972
 			{
1973
-				eval('$array=array'.$value.';');
1973
+				eval('$array=array' . $value . ';');
1974 1974
 				return $array;
1975 1975
 			}
1976 1976
 			else
1977
-				return $len>0?array($value):array();
1977
+				return $len > 0 ? array($value) : array();
1978 1978
 		}
1979 1979
 		else
1980
-			return (array)$value;
1980
+			return (array) $value;
1981 1981
 	}
1982 1982
 
1983 1983
 	/**
@@ -1987,7 +1987,7 @@  discard block
 block discarded – undo
1987 1987
 	 */
1988 1988
 	public static function ensureObject($value)
1989 1989
 	{
1990
-		return (object)$value;
1990
+		return (object) $value;
1991 1991
 	}
1992 1992
 
1993 1993
 	/**
@@ -2006,29 +2006,29 @@  discard block
 block discarded – undo
2006 2006
 	 * @return string the valid enumeration value
2007 2007
 	 * @throws TInvalidDataValueException if the original value is not in the string array.
2008 2008
 	 */
2009
-	public static function ensureEnum($value,$enums)
2009
+	public static function ensureEnum($value, $enums)
2010 2010
 	{
2011
-		static $types=array();
2012
-		if(func_num_args()===2 && is_string($enums))
2011
+		static $types = array();
2012
+		if (func_num_args() === 2 && is_string($enums))
2013 2013
 		{
2014
-			if(!isset($types[$enums]))
2015
-				$types[$enums]=new ReflectionClass($enums);
2016
-			if($types[$enums]->hasConstant($value))
2014
+			if (!isset($types[$enums]))
2015
+				$types[$enums] = new ReflectionClass($enums);
2016
+			if ($types[$enums]->hasConstant($value))
2017 2017
 				return $value;
2018 2018
 			else
2019 2019
 				throw new TInvalidDataValueException(
2020
-					'propertyvalue_enumvalue_invalid',$value,
2021
-						implode(' | ',$types[$enums]->getConstants()));
2020
+					'propertyvalue_enumvalue_invalid', $value,
2021
+						implode(' | ', $types[$enums]->getConstants()));
2022 2022
 		}
2023
-		else if(!is_array($enums))
2023
+		else if (!is_array($enums))
2024 2024
 		{
2025
-			$enums=func_get_args();
2025
+			$enums = func_get_args();
2026 2026
 			array_shift($enums);
2027 2027
 		}
2028
-		if(in_array($value,$enums,true))
2028
+		if (in_array($value, $enums, true))
2029 2029
 			return $value;
2030 2030
 		else
2031
-			throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,implode(' | ',$enums));
2031
+			throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid', $value, implode(' | ', $enums));
2032 2032
 	}
2033 2033
 
2034 2034
 	/**
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
 	 */
2039 2039
 	public static function ensureNullIfEmpty($value)
2040 2040
 	{
2041
-		return empty($value)?null:$value;
2041
+		return empty($value) ? null : $value;
2042 2042
 	}
2043 2043
 }
2044 2044
 
@@ -2055,9 +2055,9 @@  discard block
 block discarded – undo
2055 2055
 }
2056 2056
 
2057 2057
 class TEventResults extends TEnumerable {
2058
-	const EVENT_RESULT_FEED_FORWARD=1;
2059
-	const EVENT_RESULT_FILTER=2;
2060
-	const EVENT_RESULT_ALL=4;
2058
+	const EVENT_RESULT_FEED_FORWARD = 1;
2059
+	const EVENT_RESULT_FILTER = 2;
2060
+	const EVENT_RESULT_ALL = 4;
2061 2061
 }
2062 2062
 
2063 2063
 /**
@@ -2080,9 +2080,9 @@  discard block
 block discarded – undo
2080 2080
 class TComponentReflection extends TComponent
2081 2081
 {
2082 2082
 	private $_className;
2083
-	private $_properties=array();
2084
-	private $_events=array();
2085
-	private $_methods=array();
2083
+	private $_properties = array();
2084
+	private $_events = array();
2085
+	private $_methods = array();
2086 2086
 
2087 2087
 	/**
2088 2088
 	 * Constructor.
@@ -2091,10 +2091,10 @@  discard block
 block discarded – undo
2091 2091
 	 */
2092 2092
 	public function __construct($component)
2093 2093
 	{
2094
-		if(is_string($component) && class_exists($component,false))
2095
-			$this->_className=$component;
2096
-		else if(is_object($component))
2097
-			$this->_className=get_class($component);
2094
+		if (is_string($component) && class_exists($component, false))
2095
+			$this->_className = $component;
2096
+		else if (is_object($component))
2097
+			$this->_className = get_class($component);
2098 2098
 		else
2099 2099
 			throw new TInvalidDataTypeException('componentreflection_class_invalid');
2100 2100
 		$this->reflect();
@@ -2102,74 +2102,74 @@  discard block
 block discarded – undo
2102 2102
 
2103 2103
 	private function isPropertyMethod($method)
2104 2104
 	{
2105
-		$methodName=$method->getName();
2106
-		return $method->getNumberOfRequiredParameters()===0
2107
-				&& strncasecmp($methodName,'get',3)===0
2105
+		$methodName = $method->getName();
2106
+		return $method->getNumberOfRequiredParameters() === 0
2107
+				&& strncasecmp($methodName, 'get', 3) === 0
2108 2108
 				&& isset($methodName[3]);
2109 2109
 	}
2110 2110
 
2111 2111
 	private function isEventMethod($method)
2112 2112
 	{
2113
-		$methodName=$method->getName();
2114
-		return strncasecmp($methodName,'on',2)===0
2113
+		$methodName = $method->getName();
2114
+		return strncasecmp($methodName, 'on', 2) === 0
2115 2115
 				&& isset($methodName[2]);
2116 2116
 	}
2117 2117
 
2118 2118
 	private function reflect()
2119 2119
 	{
2120
-		$class=new ReflectionClass($this->_className);
2121
-		$properties=array();
2122
-		$events=array();
2123
-		$methods=array();
2124
-		$isComponent=is_subclass_of($this->_className,'TComponent') || strcasecmp($this->_className,'TComponent')===0;
2125
-		foreach($class->getMethods() as $method)
2120
+		$class = new ReflectionClass($this->_className);
2121
+		$properties = array();
2122
+		$events = array();
2123
+		$methods = array();
2124
+		$isComponent = is_subclass_of($this->_className, 'TComponent') || strcasecmp($this->_className, 'TComponent') === 0;
2125
+		foreach ($class->getMethods() as $method)
2126 2126
 		{
2127
-			if($method->isPublic() || $method->isProtected())
2127
+			if ($method->isPublic() || $method->isProtected())
2128 2128
 			{
2129
-				$methodName=$method->getName();
2130
-				if(!$method->isStatic() && $isComponent)
2129
+				$methodName = $method->getName();
2130
+				if (!$method->isStatic() && $isComponent)
2131 2131
 				{
2132
-					if($this->isPropertyMethod($method))
2133
-						$properties[substr($methodName,3)]=$method;
2134
-					else if($this->isEventMethod($method))
2132
+					if ($this->isPropertyMethod($method))
2133
+						$properties[substr($methodName, 3)] = $method;
2134
+					else if ($this->isEventMethod($method))
2135 2135
 					{
2136
-						$methodName[0]='O';
2137
-						$events[$methodName]=$method;
2136
+						$methodName[0] = 'O';
2137
+						$events[$methodName] = $method;
2138 2138
 					}
2139 2139
 				}
2140
-				if(strncmp($methodName,'__',2)!==0)
2141
-					$methods[$methodName]=$method;
2140
+				if (strncmp($methodName, '__', 2) !== 0)
2141
+					$methods[$methodName] = $method;
2142 2142
 			}
2143 2143
 		}
2144
-		$reserved=array();
2144
+		$reserved = array();
2145 2145
 		ksort($properties);
2146
-		foreach($properties as $name=>$method)
2146
+		foreach ($properties as $name=>$method)
2147 2147
 		{
2148
-			$this->_properties[$name]=array(
2148
+			$this->_properties[$name] = array(
2149 2149
 				'type'=>$this->determinePropertyType($method),
2150
-				'readonly'=>!$class->hasMethod('set'.$name),
2150
+				'readonly'=>!$class->hasMethod('set' . $name),
2151 2151
 				'protected'=>$method->isProtected(),
2152 2152
 				'class'=>$method->getDeclaringClass()->getName(),
2153 2153
 				'comments'=>$method->getDocComment()
2154 2154
 			);
2155
-			$reserved['get'.strtolower($name)]=1;
2156
-			$reserved['set'.strtolower($name)]=1;
2155
+			$reserved['get' . strtolower($name)] = 1;
2156
+			$reserved['set' . strtolower($name)] = 1;
2157 2157
 		}
2158 2158
 		ksort($events);
2159
-		foreach($events as $name=>$method)
2159
+		foreach ($events as $name=>$method)
2160 2160
 		{
2161
-			$this->_events[$name]=array(
2161
+			$this->_events[$name] = array(
2162 2162
 				'class'=>$method->getDeclaringClass()->getName(),
2163 2163
 				'protected'=>$method->isProtected(),
2164 2164
 				'comments'=>$method->getDocComment()
2165 2165
 			);
2166
-			$reserved[strtolower($name)]=1;
2166
+			$reserved[strtolower($name)] = 1;
2167 2167
 		}
2168 2168
 		ksort($methods);
2169
-		foreach($methods as $name=>$method)
2169
+		foreach ($methods as $name=>$method)
2170 2170
 		{
2171
-			if(!isset($reserved[strtolower($name)]))
2172
-				$this->_methods[$name]=array(
2171
+			if (!isset($reserved[strtolower($name)]))
2172
+				$this->_methods[$name] = array(
2173 2173
 					'class'=>$method->getDeclaringClass()->getName(),
2174 2174
 					'protected'=>$method->isProtected(),
2175 2175
 					'static'=>$method->isStatic(),
@@ -2186,8 +2186,8 @@  discard block
 block discarded – undo
2186 2186
 	 */
2187 2187
 	protected function determinePropertyType($method)
2188 2188
 	{
2189
-		$comment=$method->getDocComment();
2190
-		if(preg_match('/@return\\s+(.*?)\\s+/',$comment,$matches))
2189
+		$comment = $method->getDocComment();
2190
+		if (preg_match('/@return\\s+(.*?)\\s+/', $comment, $matches))
2191 2191
 			return $matches[1];
2192 2192
 		else
2193 2193
 			return '{unknown}';
@@ -2345,7 +2345,7 @@  discard block
 block discarded – undo
2345 2345
 	 * @return boolean|null if the this or the instance is of type class.  When null, no information could be derived and
2346 2346
 	 * the default mechanisms take over.
2347 2347
 	 */
2348
-	public function isinstanceof($class,$instance=null);
2348
+	public function isinstanceof($class, $instance = null);
2349 2349
 }
2350 2350
 
2351 2351
 /**
@@ -2380,7 +2380,7 @@  discard block
 block discarded – undo
2380 2380
 
2381 2381
 	public function __toString()
2382 2382
 	{
2383
-		return (string)$this->_s;
2383
+		return (string) $this->_s;
2384 2384
 	}
2385 2385
 
2386 2386
 	public function toJavaScriptLiteral()
@@ -2400,7 +2400,7 @@  discard block
 block discarded – undo
2400 2400
 {
2401 2401
 	public function toJavaScriptLiteral()
2402 2402
 	{
2403
-		return TJavaScript::jsonEncode((string)$this->_s,JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG);
2403
+		return TJavaScript::jsonEncode((string) $this->_s, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG);
2404 2404
 	}
2405 2405
 }
2406 2406
 
Please login to merge, or discard this patch.
Braces   +341 added lines, -278 removed lines patch added patch discarded remove patch
@@ -327,13 +327,15 @@  discard block
 block discarded – undo
327 327
 	 * through each parent to the top most class, TComponent.
328 328
 	 */
329 329
 	public function __construct() {
330
-		if($this->getAutoGlobalListen())
331
-			$this->listen();
330
+		if($this->getAutoGlobalListen()) {
331
+					$this->listen();
332
+		}
332 333
 
333 334
 		$classes=array_reverse($this->getClassHierarchy(true));
334 335
 		foreach($classes as $class) {
335
-			if(isset(self::$_um[$class]))
336
-				$this->attachBehaviors(self::$_um[$class]);
336
+			if(isset(self::$_um[$class])) {
337
+							$this->attachBehaviors(self::$_um[$class]);
338
+			}
337 339
 		}
338 340
 	}
339 341
 
@@ -363,8 +365,9 @@  discard block
 block discarded – undo
363 365
 	 * called must be explicitly called.
364 366
 	 */
365 367
 	public function __destruct() {
366
-		if($this->_listeningenabled)
367
-			$this->unlisten();
368
+		if($this->_listeningenabled) {
369
+					$this->unlisten();
370
+		}
368 371
 	}
369 372
 
370 373
 
@@ -388,8 +391,9 @@  discard block
 block discarded – undo
388 391
 		$class=get_class($this);
389 392
 		$classes=array($class);
390 393
 		while($class=get_parent_class($class)){array_unshift($classes,$class);}
391
-		if($lowercase)
392
-			return array_map('strtolower',$classes);
394
+		if($lowercase) {
395
+					return array_map('strtolower',$classes);
396
+		}
393 397
 		return $classes;
394 398
 	}
395 399
 
@@ -409,13 +413,15 @@  discard block
 block discarded – undo
409 413
 	 * @return numeric the number of global events that were registered to the global event registry
410 414
 	 */
411 415
 	public function listen() {
412
-		if($this->_listeningenabled)
413
-			return;
416
+		if($this->_listeningenabled) {
417
+					return;
418
+		}
414 419
 
415 420
 		$fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx'));
416 421
 
417
-		foreach($fx as $func)
418
-			$this->attachEventHandler($func,array($this,$func));
422
+		foreach($fx as $func) {
423
+					$this->attachEventHandler($func,array($this,$func));
424
+		}
419 425
 
420 426
 		if(is_a($this,'IDynamicMethods')) {
421 427
 			$this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall'));
@@ -443,13 +449,15 @@  discard block
 block discarded – undo
443 449
 	 * @return numeric the number of global events that were unregistered from the global event registry
444 450
 	 */
445 451
 	public function unlisten() {
446
-		if(!$this->_listeningenabled)
447
-			return;
452
+		if(!$this->_listeningenabled) {
453
+					return;
454
+		}
448 455
 
449 456
 		$fx=array_filter(get_class_methods($this),array($this,'filter_prado_fx'));
450 457
 
451
-		foreach($fx as $func)
452
-			$this->detachEventHandler($func,array($this,$func));
458
+		foreach($fx as $func) {
459
+					$this->detachEventHandler($func,array($this,$func));
460
+		}
453 461
 
454 462
 		if(is_a($this,'IDynamicMethods')) {
455 463
 			$this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER,array($this,'__dycall'));
@@ -505,14 +513,16 @@  discard block
 block discarded – undo
505 513
 			$jsmethod=$getset.'js'.$propname;
506 514
 			if(method_exists($this,$jsmethod))
507 515
 			{
508
-				if(count($args)>0)
509
-					if($args[0]&&!($args[0] instanceof TJavaScriptString))
516
+				if(count($args)>0) {
517
+									if($args[0]&&!($args[0] instanceof TJavaScriptString))
510 518
 						$args[0]=new TJavaScriptString($args[0]);
519
+				}
511 520
 				return call_user_func_array(array($this,$jsmethod),$args);
512 521
 			}
513 522
 
514
-			if (($getset=='set')&&method_exists($this,'getjs'.$propname))
515
-				throw new TInvalidOperationException('component_property_readonly',get_class($this),$method);
523
+			if (($getset=='set')&&method_exists($this,'getjs'.$propname)) {
524
+							throw new TInvalidOperationException('component_property_readonly',get_class($this),$method);
525
+			}
516 526
 		}
517 527
 
518 528
 		if($this->_m!==null&&$this->_behaviorsenabled)
@@ -525,23 +535,25 @@  discard block
 block discarded – undo
525 535
 					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&(method_exists($behavior,$method)||($behavior instanceof IDynamicMethods)))
526 536
 					{
527 537
 						$behavior_args=$args;
528
-						if($behavior instanceof IClassBehavior)
529
-							array_unshift($behavior_args,$this);
538
+						if($behavior instanceof IClassBehavior) {
539
+													array_unshift($behavior_args,$this);
540
+						}
530 541
 						$callchain->addCall(array($behavior,$method),$behavior_args);
531 542
 					}
532 543
 
533 544
 				}
534
-				if($callchain->getCount()>0)
535
-					return call_user_func_array(array($callchain,'call'),$args);
536
-			}
537
-			else
545
+				if($callchain->getCount()>0) {
546
+									return call_user_func_array(array($callchain,'call'),$args);
547
+				}
548
+			} else
538 549
 			{
539 550
 				foreach($this->_m->toArray() as $behavior)
540 551
 				{
541 552
 					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&method_exists($behavior,$method))
542 553
 					{
543
-						if($behavior instanceof IClassBehavior)
544
-							array_unshift($args,$this);
554
+						if($behavior instanceof IClassBehavior) {
555
+													array_unshift($args,$this);
556
+						}
545 557
 						return call_user_func_array(array($behavior,$method),$args);
546 558
 					}
547 559
 				}
@@ -550,8 +562,9 @@  discard block
 block discarded – undo
550 562
 
551 563
 		if(strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0)
552 564
 		{
553
-			if($this instanceof IDynamicMethods)
554
-				return $this->__dycall($method,$args);
565
+			if($this instanceof IDynamicMethods) {
566
+							return $this->__dycall($method,$args);
567
+			}
555 568
 			return isset($args[0])?$args[0]:null;
556 569
 		}
557 570
 
@@ -588,40 +601,39 @@  discard block
 block discarded – undo
588 601
 		{
589 602
 			// getting a property
590 603
 			return $this->$getter();
591
-		}
592
-		else if(method_exists($this,$jsgetter='getjs'.$name))
604
+		} else if(method_exists($this,$jsgetter='getjs'.$name))
593 605
 		{
594 606
 			// getting a javascript property
595 607
 			return (string)$this->$jsgetter();
596
-		}
597
-		else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
608
+		} else if(strncasecmp($name,'on',2)===0 && method_exists($this,$name))
598 609
 		{
599 610
 			// getting an event (handler list)
600 611
 			$name=strtolower($name);
601
-			if(!isset($this->_e[$name]))
602
-				$this->_e[$name]=new TPriorityList;
612
+			if(!isset($this->_e[$name])) {
613
+							$this->_e[$name]=new TPriorityList;
614
+			}
603 615
 			return $this->_e[$name];
604
-		}
605
-		else if(strncasecmp($name,'fx',2)===0)
616
+		} else if(strncasecmp($name,'fx',2)===0)
606 617
 		{
607 618
 			// getting a global event (handler list)
608 619
 			$name=strtolower($name);
609
-			if(!isset(self::$_ue[$name]))
610
-				self::$_ue[$name]=new TPriorityList;
620
+			if(!isset(self::$_ue[$name])) {
621
+							self::$_ue[$name]=new TPriorityList;
622
+			}
611 623
 			return self::$_ue[$name];
612
-		}
613
-		else if($this->_behaviorsenabled)
624
+		} else if($this->_behaviorsenabled)
614 625
 		{
615 626
 			// getting a behavior property/event (handler list)
616
-			if(isset($this->_m[$name]))
617
-				return $this->_m[$name];
618
-			else if($this->_m!==null)
627
+			if(isset($this->_m[$name])) {
628
+							return $this->_m[$name];
629
+			} else if($this->_m!==null)
619 630
 			{
620 631
 				foreach($this->_m->toArray() as $behavior)
621 632
 				{
622 633
 					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&
623
-						(property_exists($behavior,$name)||$behavior->canGetProperty($name)||$behavior->hasEvent($name)))
624
-						return $behavior->$name;
634
+						(property_exists($behavior,$name)||$behavior->canGetProperty($name)||$behavior->hasEvent($name))) {
635
+											return $behavior->$name;
636
+					}
625 637
 				}
626 638
 			}
627 639
 		}
@@ -647,21 +659,20 @@  discard block
 block discarded – undo
647 659
 	{
648 660
 		if(method_exists($this,$setter='set'.$name))
649 661
 		{
650
-			if(strncasecmp($name,'js',2)===0&&$value&&!($value instanceof TJavaScriptLiteral))
651
-				$value = new TJavaScriptLiteral($value);
662
+			if(strncasecmp($name,'js',2)===0&&$value&&!($value instanceof TJavaScriptLiteral)) {
663
+							$value = new TJavaScriptLiteral($value);
664
+			}
652 665
 			return $this->$setter($value);
653
-		}
654
-		else if(method_exists($this,$jssetter='setjs'.$name))
666
+		} else if(method_exists($this,$jssetter='setjs'.$name))
655 667
 		{
656
-			if($value&&!($value instanceof TJavaScriptString))
657
-				$value=new TJavaScriptString($value);
668
+			if($value&&!($value instanceof TJavaScriptString)) {
669
+							$value=new TJavaScriptString($value);
670
+			}
658 671
 			return $this->$jssetter($value);
659
-		}
660
-		else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0)
672
+		} else if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0)
661 673
 		{
662 674
 			return $this->attachEventHandler($name,$value);
663
-		}
664
-		else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled)
675
+		} else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled)
665 676
 		{
666 677
 			$sets=0;
667 678
 			foreach($this->_m->toArray() as $behavior)
@@ -672,15 +683,16 @@  discard block
 block discarded – undo
672 683
 					$sets++;
673 684
 				}
674 685
 			}
675
-			if($sets)return $value;
686
+			if($sets) {
687
+				return $value;
688
+			}
676 689
 
677 690
 		}
678 691
 
679 692
 		if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name))
680 693
 		{
681 694
 			throw new TInvalidOperationException('component_property_readonly',get_class($this),$name);
682
-		}
683
-		else
695
+		} else
684 696
 		{
685 697
 			throw new TInvalidOperationException('component_property_undefined',get_class($this),$name);
686 698
 		}
@@ -700,33 +712,33 @@  discard block
 block discarded – undo
700 712
 	 */
701 713
 	public function __isset($name)
702 714
 	{
703
-		if(method_exists($this,$getter='get'.$name))
704
-			return $this->$getter()!==null;
705
-		else if(method_exists($this,$jsgetter='getjs'.$name))
706
-			return $this->$jsgetter()!==null;
707
-		else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name))
715
+		if(method_exists($this,$getter='get'.$name)) {
716
+					return $this->$getter()!==null;
717
+		} else if(method_exists($this,$jsgetter='getjs'.$name)) {
718
+					return $this->$jsgetter()!==null;
719
+		} else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name))
708 720
 		{
709 721
 			$name=strtolower($name);
710 722
 			return isset($this->_e[$name])&&$this->_e[$name]->getCount();
711
-		}
712
-		else if(strncasecmp($name,'fx',2)===0)
723
+		} else if(strncasecmp($name,'fx',2)===0)
713 724
 		{
714 725
 			$name=strtolower($name);
715 726
 			return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount();
716
-		}
717
-		else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled)
727
+		} else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled)
718 728
 		{
719
-			if(isset($this->_m[$name]))
720
-				return true;
729
+			if(isset($this->_m[$name])) {
730
+							return true;
731
+			}
721 732
 			foreach($this->_m->toArray() as $behavior)
722 733
 			{
723
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled()))
724
-					return isset($behavior->$name);
734
+				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())) {
735
+									return isset($behavior->$name);
736
+				}
725 737
 			}
726 738
 
739
+		} else {
740
+					return false;
727 741
 		}
728
-		else
729
-			return false;
730 742
 	}
731 743
 
732 744
 	/**
@@ -741,19 +753,19 @@  discard block
 block discarded – undo
741 753
 	 */
742 754
 	public function __unset($name)
743 755
 	{
744
-		if(method_exists($this,$setter='set'.$name))
745
-			$this->$setter(null);
746
-		else if(method_exists($this,$jssetter='setjs'.$name))
747
-			$this->$jssetter(null);
748
-		else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name))
749
-			$this->_e[strtolower($name)]->clear();
750
-		else if(strncasecmp($name,'fx',2)===0)
751
-			$this->getEventHandlers($name)->remove(array($this, $name));
752
-		else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled)
756
+		if(method_exists($this,$setter='set'.$name)) {
757
+					$this->$setter(null);
758
+		} else if(method_exists($this,$jssetter='setjs'.$name)) {
759
+					$this->$jssetter(null);
760
+		} else if(strncasecmp($name,'on',2)===0&&method_exists($this,$name)) {
761
+					$this->_e[strtolower($name)]->clear();
762
+		} else if(strncasecmp($name,'fx',2)===0) {
763
+					$this->getEventHandlers($name)->remove(array($this, $name));
764
+		} else if($this->_m!==null&&$this->_m->getCount()>0&&$this->_behaviorsenabled)
753 765
 		{
754
-			if(isset($this->_m[$name]))
755
-				$this->detachBehavior($name);
756
-			else {
766
+			if(isset($this->_m[$name])) {
767
+							$this->detachBehavior($name);
768
+			} else {
757 769
 				$unset=0;
758 770
 				foreach($this->_m->toArray() as $behavior)
759 771
 				{
@@ -762,11 +774,13 @@  discard block
 block discarded – undo
762 774
 						$unset++;
763 775
 					}
764 776
 				}
765
-				if(!$unset&&method_exists($this,'get'.$name))
766
-					throw new TInvalidOperationException('component_property_readonly',get_class($this),$name);
777
+				if(!$unset&&method_exists($this,'get'.$name)) {
778
+									throw new TInvalidOperationException('component_property_readonly',get_class($this),$name);
779
+				}
767 780
 			}
768
-		} else if(method_exists($this,'get'.$name))
769
-			throw new TInvalidOperationException('component_property_readonly',get_class($this),$name);
781
+		} else if(method_exists($this,'get'.$name)) {
782
+					throw new TInvalidOperationException('component_property_readonly',get_class($this),$name);
783
+		}
770 784
 	}
771 785
 
772 786
 	/**
@@ -792,14 +806,15 @@  discard block
 block discarded – undo
792 806
 	 */
793 807
 	public function canGetProperty($name)
794 808
 	{
795
-		if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name))
796
-			return true;
797
-		else if($this->_m!==null&&$this->_behaviorsenabled)
809
+		if(method_exists($this,'get'.$name)||method_exists($this,'getjs'.$name)) {
810
+					return true;
811
+		} else if($this->_m!==null&&$this->_behaviorsenabled)
798 812
 		{
799 813
 			foreach($this->_m->toArray() as $behavior)
800 814
 			{
801
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canGetProperty($name))
802
-					return true;
815
+				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canGetProperty($name)) {
816
+									return true;
817
+				}
803 818
 			}
804 819
 		}
805 820
 		return false;
@@ -816,14 +831,15 @@  discard block
 block discarded – undo
816 831
 	 */
817 832
 	public function canSetProperty($name)
818 833
 	{
819
-		if(method_exists($this,'set'.$name)||method_exists($this,'setjs'.$name))
820
-			return true;
821
-		else if($this->_m!==null&&$this->_behaviorsenabled)
834
+		if(method_exists($this,'set'.$name)||method_exists($this,'setjs'.$name)) {
835
+					return true;
836
+		} else if($this->_m!==null&&$this->_behaviorsenabled)
822 837
 		{
823 838
 			foreach($this->_m->toArray() as $behavior)
824 839
 			{
825
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canSetProperty($name))
826
-					return true;
840
+				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->canSetProperty($name)) {
841
+									return true;
842
+				}
827 843
 			}
828 844
 		}
829 845
 		return false;
@@ -842,8 +858,9 @@  discard block
 block discarded – undo
842 858
 	public function getSubProperty($path)
843 859
 	{
844 860
 		$object=$this;
845
-		foreach(explode('.',$path) as $property)
846
-			$object=$object->$property;
861
+		foreach(explode('.',$path) as $property) {
862
+					$object=$object->$property;
863
+		}
847 864
 		return $object;
848 865
 	}
849 866
 
@@ -860,9 +877,9 @@  discard block
 block discarded – undo
860 877
 	public function setSubProperty($path,$value)
861 878
 	{
862 879
 		$object=$this;
863
-		if(($pos=strrpos($path,'.'))===false)
864
-			$property=$path;
865
-		else
880
+		if(($pos=strrpos($path,'.'))===false) {
881
+					$property=$path;
882
+		} else
866 883
 		{
867 884
 			$object=$this->getSubProperty(substr($path,0,$pos));
868 885
 			$property=substr($path,$pos+1);
@@ -884,15 +901,15 @@  discard block
 block discarded – undo
884 901
 	 */
885 902
 	public function hasEvent($name)
886 903
 	{
887
-		if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0||strncasecmp($name,'dy',2)===0)
888
-			return true;
889
-
890
-		else if($this->_m!==null&&$this->_behaviorsenabled)
904
+		if((strncasecmp($name,'on',2)===0&&method_exists($this,$name))||strncasecmp($name,'fx',2)===0||strncasecmp($name,'dy',2)===0) {
905
+					return true;
906
+		} else if($this->_m!==null&&$this->_behaviorsenabled)
891 907
 		{
892 908
 			foreach($this->_m->toArray() as $behavior)
893 909
 			{
894
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name))
895
-					return true;
910
+				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) {
911
+									return true;
912
+				}
896 913
 			}
897 914
 		}
898 915
 		return false;
@@ -908,17 +925,18 @@  discard block
 block discarded – undo
908 925
 	public function hasEventHandler($name)
909 926
 	{
910 927
 		$name=strtolower($name);
911
-		if(strncasecmp($name,'fx',2)===0)
912
-			return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount()>0;
913
-		else
928
+		if(strncasecmp($name,'fx',2)===0) {
929
+					return isset(self::$_ue[$name])&&self::$_ue[$name]->getCount()>0;
930
+		} else
914 931
 		{
915
-			if(isset($this->_e[$name])&&$this->_e[$name]->getCount()>0)
916
-				return true;
917
-			else if($this->_m!==null&&$this->_behaviorsenabled) {
932
+			if(isset($this->_e[$name])&&$this->_e[$name]->getCount()>0) {
933
+							return true;
934
+			} else if($this->_m!==null&&$this->_behaviorsenabled) {
918 935
 				foreach($this->_m->toArray() as $behavior)
919 936
 				{
920
-					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEventHandler($name))
921
-						return true;
937
+					if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEventHandler($name)) {
938
+											return true;
939
+					}
922 940
 				}
923 941
 			}
924 942
 		}
@@ -936,23 +954,24 @@  discard block
 block discarded – undo
936 954
 		if(strncasecmp($name,'on',2)===0&&method_exists($this,$name))
937 955
 		{
938 956
 			$name=strtolower($name);
939
-			if(!isset($this->_e[$name]))
940
-				$this->_e[$name]=new TPriorityList;
957
+			if(!isset($this->_e[$name])) {
958
+							$this->_e[$name]=new TPriorityList;
959
+			}
941 960
 			return $this->_e[$name];
942
-		}
943
-		else if(strncasecmp($name,'fx',2)===0)
961
+		} else if(strncasecmp($name,'fx',2)===0)
944 962
 		{
945 963
 			$name=strtolower($name);
946
-			if(!isset(self::$_ue[$name]))
947
-				self::$_ue[$name]=new TPriorityList;
964
+			if(!isset(self::$_ue[$name])) {
965
+							self::$_ue[$name]=new TPriorityList;
966
+			}
948 967
 			return self::$_ue[$name];
949
-		}
950
-		else if($this->_m!==null&&$this->_behaviorsenabled)
968
+		} else if($this->_m!==null&&$this->_behaviorsenabled)
951 969
 		{
952 970
 			foreach($this->_m->toArray() as $behavior)
953 971
 			{
954
-				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name))
955
-					return $behavior->getEventHandlers($name);
972
+				if((!($behavior instanceof IBehavior)||$behavior->getEnabled())&&$behavior->hasEvent($name)) {
973
+									return $behavior->getEventHandlers($name);
974
+				}
956 975
 			}
957 976
 		}
958 977
 		throw new TInvalidOperationException('component_event_undefined',get_class($this),$name);
@@ -1026,8 +1045,7 @@  discard block
 block discarded – undo
1026 1045
 			{
1027 1046
 				$this->getEventHandlers($name)->remove($handler,$priority);
1028 1047
 				return true;
1029
-			}
1030
-			catch(Exception $e)
1048
+			} catch(Exception $e)
1031 1049
 			{
1032 1050
 			}
1033 1051
 		}
@@ -1115,8 +1133,9 @@  discard block
 block discarded – undo
1115 1133
 			$responsetype=null;
1116 1134
 		}
1117 1135
 
1118
-		if($responsetype===null)
1119
-			$responsetype=TEventResults::EVENT_RESULT_FILTER;
1136
+		if($responsetype===null) {
1137
+					$responsetype=TEventResults::EVENT_RESULT_FILTER;
1138
+		}
1120 1139
 
1121 1140
 		$name=strtolower($name);
1122 1141
 		$responses=array();
@@ -1135,8 +1154,9 @@  discard block
 block discarded – undo
1135 1154
 			$response=null;
1136 1155
 			foreach($handlerArray as $handler)
1137 1156
 			{
1138
-				if($this->dyIntraRaiseEventTestHandler($handler,$sender,$param,$name)===false)
1139
-					continue;
1157
+				if($this->dyIntraRaiseEventTestHandler($handler,$sender,$param,$name)===false) {
1158
+									continue;
1159
+				}
1140 1160
 
1141 1161
 				if(is_string($handler))
1142 1162
 				{
@@ -1146,23 +1166,23 @@  discard block
 block discarded – undo
1146 1166
 						$method=substr($handler,$pos+1);
1147 1167
 						if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0)
1148 1168
 						{
1149
-							if($method=='__dycall')
1150
-								$response=$object->__dycall($name,array($sender,$param,$name));
1151
-							else
1152
-								$response=$object->$method($sender,$param,$name);
1169
+							if($method=='__dycall') {
1170
+															$response=$object->__dycall($name,array($sender,$param,$name));
1171
+							} else {
1172
+															$response=$object->$method($sender,$param,$name);
1173
+							}
1174
+						} else {
1175
+													throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler);
1153 1176
 						}
1154
-						else
1155
-							throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler);
1177
+					} else {
1178
+											$response=call_user_func($handler,$sender,$param,$name);
1156 1179
 					}
1157
-					else
1158
-						$response=call_user_func($handler,$sender,$param,$name);
1159
-				}
1160
-				else if(is_callable($handler,true))
1180
+				} else if(is_callable($handler,true))
1161 1181
 				{
1162 1182
 					list($object,$method)=$handler;
1163
-					if(is_string($object))
1164
-						$response=call_user_func($handler,$sender,$param,$name);
1165
-					else
1183
+					if(is_string($object)) {
1184
+											$response=call_user_func($handler,$sender,$param,$name);
1185
+					} else
1166 1186
 					{
1167 1187
 						if(($pos=strrpos($method,'.'))!==false)
1168 1188
 						{
@@ -1171,38 +1191,43 @@  discard block
 block discarded – undo
1171 1191
 						}
1172 1192
 						if(method_exists($object,$method)||strncasecmp($method,'dy',2)===0||strncasecmp($method,'fx',2)===0)
1173 1193
 						{
1174
-							if($method=='__dycall')
1175
-								$response=$object->__dycall($name,array($sender,$param,$name));
1176
-							else
1177
-								$response=$object->$method($sender,$param,$name);
1194
+							if($method=='__dycall') {
1195
+															$response=$object->__dycall($name,array($sender,$param,$name));
1196
+							} else {
1197
+															$response=$object->$method($sender,$param,$name);
1198
+							}
1199
+						} else {
1200
+													throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler[1]);
1178 1201
 						}
1179
-						else
1180
-							throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,$handler[1]);
1181 1202
 					}
1203
+				} else {
1204
+									throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,gettype($handler));
1182 1205
 				}
1183
-				else
1184
-					throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name,gettype($handler));
1185 1206
 
1186 1207
 				$this->dyIntraRaiseEventPostHandler($name,$sender,$param,$handler,$response);
1187 1208
 
1188
-				if($postfunction)
1189
-					$response=call_user_func_array($postfunction,array($sender,$param,$this,$response));
1209
+				if($postfunction) {
1210
+									$response=call_user_func_array($postfunction,array($sender,$param,$this,$response));
1211
+				}
1190 1212
 
1191
-				if($responsetype&TEventResults::EVENT_RESULT_ALL)
1192
-					$responses[]=array('sender'=>$sender,'param'=>$param,'response'=>$response);
1193
-				else
1194
-					$responses[]=$response;
1213
+				if($responsetype&TEventResults::EVENT_RESULT_ALL) {
1214
+									$responses[]=array('sender'=>$sender,'param'=>$param,'response'=>$response);
1215
+				} else {
1216
+									$responses[]=$response;
1217
+				}
1195 1218
 
1196
-				if($response!==null&&($responsetype&TEventResults::EVENT_RESULT_FEED_FORWARD))
1197
-					$param=$response;
1219
+				if($response!==null&&($responsetype&TEventResults::EVENT_RESULT_FEED_FORWARD)) {
1220
+									$param=$response;
1221
+				}
1198 1222
 
1199 1223
 			}
1224
+		} else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name)) {
1225
+					throw new TInvalidOperationException('component_event_undefined',get_class($this),$name);
1200 1226
 		}
1201
-		else if(strncasecmp($name,'on',2)===0&&!$this->hasEvent($name))
1202
-			throw new TInvalidOperationException('component_event_undefined',get_class($this),$name);
1203 1227
 
1204
-		if($responsetype&TEventResults::EVENT_RESULT_FILTER)
1205
-			$responses=array_filter($responses);
1228
+		if($responsetype&TEventResults::EVENT_RESULT_FILTER) {
1229
+					$responses=array_filter($responses);
1230
+		}
1206 1231
 
1207 1232
 		$responses=$this->dyPostRaiseEvent($responses,$name,$sender,$param,$responsetype,$postfunction);
1208 1233
 
@@ -1231,11 +1256,11 @@  discard block
 block discarded – undo
1231 1256
 		$expression=$this->dyEvaluateExpressionFilter($expression);
1232 1257
 		try
1233 1258
 		{
1234
-			if(eval("\$result=$expression;")===false)
1235
-				throw new Exception('');
1259
+			if(eval("\$result=$expression;")===false) {
1260
+							throw new Exception('');
1261
+			}
1236 1262
 			return $result;
1237
-		}
1238
-		catch(Exception $e)
1263
+		} catch(Exception $e)
1239 1264
 		{
1240 1265
 			throw new TInvalidOperationException('component_expression_invalid',get_class($this),$expression,$e->getMessage());
1241 1266
 		}
@@ -1264,13 +1289,13 @@  discard block
 block discarded – undo
1264 1289
 		try
1265 1290
 		{
1266 1291
 			ob_start();
1267
-			if(eval($statements)===false)
1268
-				throw new Exception('');
1292
+			if(eval($statements)===false) {
1293
+							throw new Exception('');
1294
+			}
1269 1295
 			$content=ob_get_contents();
1270 1296
 			ob_end_clean();
1271 1297
 			return $content;
1272
-		}
1273
-		catch(Exception $e)
1298
+		} catch(Exception $e)
1274 1299
 		{
1275 1300
 			throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage());
1276 1301
 		}
@@ -1333,8 +1358,9 @@  discard block
 block discarded – undo
1333 1358
 	 * @since 3.2.3
1334 1359
 	 */
1335 1360
 	public function fxAttachClassBehavior($sender,$param) {
1336
-		if(in_array($param->getClass(),$this->getClassHierarchy(true)))
1337
-			return $this->attachBehavior($param->getName(),$param->getBehavior(),$param->getPriority());
1361
+		if(in_array($param->getClass(),$this->getClassHierarchy(true))) {
1362
+					return $this->attachBehavior($param->getName(),$param->getBehavior(),$param->getPriority());
1363
+		}
1338 1364
 	}
1339 1365
 
1340 1366
 
@@ -1347,8 +1373,9 @@  discard block
 block discarded – undo
1347 1373
 	 * @since 3.2.3
1348 1374
 	 */
1349 1375
 	public function fxDetachClassBehavior($sender,$param) {
1350
-		if(in_array($param->getClass(),$this->getClassHierarchy(true)))
1351
-			return $this->detachBehavior($param->getName(),$param->getPriority());
1376
+		if(in_array($param->getClass(),$this->getClassHierarchy(true))) {
1377
+					return $this->detachBehavior($param->getName(),$param->getPriority());
1378
+		}
1352 1379
 	}
1353 1380
 
1354 1381
 
@@ -1371,20 +1398,26 @@  discard block
 block discarded – undo
1371 1398
 	 * @since 3.2.3
1372 1399
 	 */
1373 1400
 	public static function attachClassBehavior($name,$behavior,$class=null,$priority=null) {
1374
-		if(!$class&&function_exists('get_called_class'))
1375
-			$class=get_called_class();
1376
-		if(!$class)
1377
-			throw new TInvalidOperationException('component_no_class_provided_nor_late_binding');
1401
+		if(!$class&&function_exists('get_called_class')) {
1402
+					$class=get_called_class();
1403
+		}
1404
+		if(!$class) {
1405
+					throw new TInvalidOperationException('component_no_class_provided_nor_late_binding');
1406
+		}
1378 1407
 
1379
-		if(!is_string($name))
1380
-			$name=get_class($name);
1408
+		if(!is_string($name)) {
1409
+					$name=get_class($name);
1410
+		}
1381 1411
 		$class=strtolower($class);
1382
-		if($class==='tcomponent')
1383
-			throw new TInvalidOperationException('component_no_tcomponent_class_behaviors');
1384
-		if(empty(self::$_um[$class]))
1385
-			self::$_um[$class]=array();
1386
-		if(isset(self::$_um[$class][$name]))
1387
-			throw new TInvalidOperationException('component_class_behavior_defined',$class,$name);
1412
+		if($class==='tcomponent') {
1413
+					throw new TInvalidOperationException('component_no_tcomponent_class_behaviors');
1414
+		}
1415
+		if(empty(self::$_um[$class])) {
1416
+					self::$_um[$class]=array();
1417
+		}
1418
+		if(isset(self::$_um[$class][$name])) {
1419
+					throw new TInvalidOperationException('component_class_behavior_defined',$class,$name);
1420
+		}
1388 1421
 		$param=new TClassBehaviorEventParameter($class,$name,$behavior,$priority);
1389 1422
 		self::$_um[$class]=array($name=>$param)+self::$_um[$class];
1390 1423
 		$behaviorObject=is_string($behavior)?new $behavior:$behavior;
@@ -1405,16 +1438,20 @@  discard block
 block discarded – undo
1405 1438
 	 * @since 3.2.3
1406 1439
 	 */
1407 1440
 	public static function detachClassBehavior($name,$class=null,$priority=false) {
1408
-		if(!$class&&function_exists('get_called_class'))
1409
-			$class=get_called_class();
1410
-		if(!$class)
1411
-			throw new TInvalidOperationException('component_no_class_provided_nor_late_binding');
1441
+		if(!$class&&function_exists('get_called_class')) {
1442
+					$class=get_called_class();
1443
+		}
1444
+		if(!$class) {
1445
+					throw new TInvalidOperationException('component_no_class_provided_nor_late_binding');
1446
+		}
1412 1447
 
1413 1448
 		$class=strtolower($class);
1414
-		if(!is_string($name))
1415
-			$name=get_class($name);
1416
-		if(empty(self::$_um[$class])||!isset(self::$_um[$class][$name]))
1417
-			return false;
1449
+		if(!is_string($name)) {
1450
+					$name=get_class($name);
1451
+		}
1452
+		if(empty(self::$_um[$class])||!isset(self::$_um[$class][$name])) {
1453
+					return false;
1454
+		}
1418 1455
 		$param=self::$_um[$class][$name];
1419 1456
 		$behavior=$param->getBehavior();
1420 1457
 		unset(self::$_um[$class][$name]);
@@ -1455,18 +1492,22 @@  discard block
 block discarded – undo
1455 1492
 	 */
1456 1493
 	public function isa($class)
1457 1494
 	{
1458
-		if($this instanceof $class)
1459
-			return true;
1460
-		if($this->_m!==null&&$this->_behaviorsenabled)
1461
-			foreach($this->_m->toArray() as $behavior){
1495
+		if($this instanceof $class) {
1496
+					return true;
1497
+		}
1498
+		if($this->_m!==null&&$this->_behaviorsenabled) {
1499
+					foreach($this->_m->toArray() as $behavior){
1462 1500
 				if(($behavior instanceof IBehavior)&&!$behavior->getEnabled())
1463 1501
 					continue;
1502
+		}
1464 1503
 
1465 1504
 				$check = null;
1466
-				if(($behavior->isa('IInstanceCheck'))&&$check=$behavior->isinstanceof($class,$this))
1467
-					return true;
1468
-				if($check===null&&($behavior->isa($class)))
1469
-					return true;
1505
+				if(($behavior->isa('IInstanceCheck'))&&$check=$behavior->isinstanceof($class,$this)) {
1506
+									return true;
1507
+				}
1508
+				if($check===null&&($behavior->isa($class))) {
1509
+									return true;
1510
+				}
1470 1511
 			}
1471 1512
 		return false;
1472 1513
 	}
@@ -1481,11 +1522,13 @@  discard block
 block discarded – undo
1481 1522
 	 */
1482 1523
 	public function attachBehaviors($behaviors)
1483 1524
 	{
1484
-		foreach($behaviors as $name=>$behavior)
1485
-			if($behavior instanceof TClassBehaviorEventParameter)
1525
+		foreach($behaviors as $name=>$behavior) {
1526
+					if($behavior instanceof TClassBehaviorEventParameter)
1486 1527
 				$this->attachBehavior($behavior->getName(),$behavior->getBehavior(),$behavior->getPriority());
1487
-			else
1488
-				$this->attachBehavior($name,$behavior);
1528
+		}
1529
+			else {
1530
+							$this->attachBehavior($name,$behavior);
1531
+			}
1489 1532
 	}
1490 1533
 
1491 1534
 	/**
@@ -1500,11 +1543,13 @@  discard block
 block discarded – undo
1500 1543
 	{
1501 1544
 		if($this->_m!==null)
1502 1545
 		{
1503
-			foreach($behaviors as $name=>$behavior)
1504
-				if($behavior instanceof TClassBehaviorEventParameter)
1546
+			foreach($behaviors as $name=>$behavior) {
1547
+							if($behavior instanceof TClassBehaviorEventParameter)
1505 1548
 					$this->detachBehavior($behavior->getName(),$behavior->getPriority());
1506
-				else
1507
-					$this->detachBehavior(is_string($behavior)?$behavior:$name);
1549
+			}
1550
+				else {
1551
+									$this->detachBehavior(is_string($behavior)?$behavior:$name);
1552
+				}
1508 1553
 		}
1509 1554
 	}
1510 1555
 
@@ -1516,8 +1561,9 @@  discard block
 block discarded – undo
1516 1561
 	{
1517 1562
 		if($this->_m!==null)
1518 1563
 		{
1519
-			foreach($this->_m->toArray() as $name=>$behavior)
1520
-				$this->detachBehavior($name);
1564
+			foreach($this->_m->toArray() as $name=>$behavior) {
1565
+							$this->detachBehavior($name);
1566
+			}
1521 1567
 			$this->_m=null;
1522 1568
 		}
1523 1569
 	}
@@ -1544,14 +1590,18 @@  discard block
 block discarded – undo
1544 1590
 	 */
1545 1591
 	public function attachBehavior($name,$behavior,$priority=null)
1546 1592
 	{
1547
-		if(is_string($behavior))
1548
-			$behavior=Prado::createComponent($behavior);
1549
-		if(!($behavior instanceof IBaseBehavior))
1550
-			throw new TInvalidDataTypeException('component_not_a_behavior',get_class($behavior));
1551
-		if($behavior instanceof IBehavior)
1552
-			$behavior->setEnabled(true);
1553
-		if($this->_m===null)
1554
-			$this->_m=new TPriorityMap;
1593
+		if(is_string($behavior)) {
1594
+					$behavior=Prado::createComponent($behavior);
1595
+		}
1596
+		if(!($behavior instanceof IBaseBehavior)) {
1597
+					throw new TInvalidDataTypeException('component_not_a_behavior',get_class($behavior));
1598
+		}
1599
+		if($behavior instanceof IBehavior) {
1600
+					$behavior->setEnabled(true);
1601
+		}
1602
+		if($this->_m===null) {
1603
+					$this->_m=new TPriorityMap;
1604
+		}
1555 1605
 		$behavior->attach($this);
1556 1606
 		$this->dyAttachBehavior($name,$behavior);
1557 1607
 		$this->_m->add($name,$behavior,$priority);
@@ -1719,14 +1769,18 @@  discard block
 block discarded – undo
1719 1769
 	 */
1720 1770
 	protected function __getZappableSleepProps(&$exprops)
1721 1771
 	{
1722
-		if($this->_listeningenabled===false)
1723
-			$exprops[] = "\0TComponent\0_listeningenabled";
1724
-		if($this->_behaviorsenabled===true)
1725
-			$exprops[] = "\0TComponent\0_behaviorsenabled";
1726
-		if ($this->_e===array())
1727
-			$exprops[] = "\0TComponent\0_e";
1728
-		if ($this->_m===null)
1729
-			$exprops[] = "\0TComponent\0_m";
1772
+		if($this->_listeningenabled===false) {
1773
+					$exprops[] = "\0TComponent\0_listeningenabled";
1774
+		}
1775
+		if($this->_behaviorsenabled===true) {
1776
+					$exprops[] = "\0TComponent\0_behaviorsenabled";
1777
+		}
1778
+		if ($this->_e===array()) {
1779
+					$exprops[] = "\0TComponent\0_e";
1780
+		}
1781
+		if ($this->_m===null) {
1782
+					$exprops[] = "\0TComponent\0_m";
1783
+		}
1730 1784
 	}
1731 1785
 }
1732 1786
 
@@ -1910,10 +1964,11 @@  discard block
 block discarded – undo
1910 1964
 	 */
1911 1965
 	public static function ensureBoolean($value)
1912 1966
 	{
1913
-		if (is_string($value))
1914
-			return strcasecmp($value,'true')==0 || $value!=0;
1915
-		else
1916
-			return (boolean)$value;
1967
+		if (is_string($value)) {
1968
+					return strcasecmp($value,'true')==0 || $value!=0;
1969
+		} else {
1970
+					return (boolean)$value;
1971
+		}
1917 1972
 	}
1918 1973
 
1919 1974
 	/**
@@ -1925,12 +1980,14 @@  discard block
 block discarded – undo
1925 1980
 	 */
1926 1981
 	public static function ensureString($value)
1927 1982
 	{
1928
-		if (TJavaScript::isJsLiteral($value))
1929
-			return $value;
1930
-		if (is_bool($value))
1931
-			return $value?'true':'false';
1932
-		else
1933
-			return (string)$value;
1983
+		if (TJavaScript::isJsLiteral($value)) {
1984
+					return $value;
1985
+		}
1986
+		if (is_bool($value)) {
1987
+					return $value?'true':'false';
1988
+		} else {
1989
+					return (string)$value;
1990
+		}
1934 1991
 	}
1935 1992
 
1936 1993
 	/**
@@ -1972,12 +2029,12 @@  discard block
 block discarded – undo
1972 2029
 			{
1973 2030
 				eval('$array=array'.$value.';');
1974 2031
 				return $array;
2032
+			} else {
2033
+							return $len>0?array($value):array();
1975 2034
 			}
1976
-			else
1977
-				return $len>0?array($value):array();
2035
+		} else {
2036
+					return (array)$value;
1978 2037
 		}
1979
-		else
1980
-			return (array)$value;
1981 2038
 	}
1982 2039
 
1983 2040
 	/**
@@ -2011,24 +2068,26 @@  discard block
 block discarded – undo
2011 2068
 		static $types=array();
2012 2069
 		if(func_num_args()===2 && is_string($enums))
2013 2070
 		{
2014
-			if(!isset($types[$enums]))
2015
-				$types[$enums]=new ReflectionClass($enums);
2016
-			if($types[$enums]->hasConstant($value))
2017
-				return $value;
2018
-			else
2019
-				throw new TInvalidDataValueException(
2071
+			if(!isset($types[$enums])) {
2072
+							$types[$enums]=new ReflectionClass($enums);
2073
+			}
2074
+			if($types[$enums]->hasConstant($value)) {
2075
+							return $value;
2076
+			} else {
2077
+							throw new TInvalidDataValueException(
2020 2078
 					'propertyvalue_enumvalue_invalid',$value,
2021 2079
 						implode(' | ',$types[$enums]->getConstants()));
2022
-		}
2023
-		else if(!is_array($enums))
2080
+			}
2081
+		} else if(!is_array($enums))
2024 2082
 		{
2025 2083
 			$enums=func_get_args();
2026 2084
 			array_shift($enums);
2027 2085
 		}
2028
-		if(in_array($value,$enums,true))
2029
-			return $value;
2030
-		else
2031
-			throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,implode(' | ',$enums));
2086
+		if(in_array($value,$enums,true)) {
2087
+					return $value;
2088
+		} else {
2089
+					throw new TInvalidDataValueException('propertyvalue_enumvalue_invalid',$value,implode(' | ',$enums));
2090
+		}
2032 2091
 	}
2033 2092
 
2034 2093
 	/**
@@ -2091,12 +2150,13 @@  discard block
 block discarded – undo
2091 2150
 	 */
2092 2151
 	public function __construct($component)
2093 2152
 	{
2094
-		if(is_string($component) && class_exists($component,false))
2095
-			$this->_className=$component;
2096
-		else if(is_object($component))
2097
-			$this->_className=get_class($component);
2098
-		else
2099
-			throw new TInvalidDataTypeException('componentreflection_class_invalid');
2153
+		if(is_string($component) && class_exists($component,false)) {
2154
+					$this->_className=$component;
2155
+		} else if(is_object($component)) {
2156
+					$this->_className=get_class($component);
2157
+		} else {
2158
+					throw new TInvalidDataTypeException('componentreflection_class_invalid');
2159
+		}
2100 2160
 		$this->reflect();
2101 2161
 	}
2102 2162
 
@@ -2129,16 +2189,17 @@  discard block
 block discarded – undo
2129 2189
 				$methodName=$method->getName();
2130 2190
 				if(!$method->isStatic() && $isComponent)
2131 2191
 				{
2132
-					if($this->isPropertyMethod($method))
2133
-						$properties[substr($methodName,3)]=$method;
2134
-					else if($this->isEventMethod($method))
2192
+					if($this->isPropertyMethod($method)) {
2193
+											$properties[substr($methodName,3)]=$method;
2194
+					} else if($this->isEventMethod($method))
2135 2195
 					{
2136 2196
 						$methodName[0]='O';
2137 2197
 						$events[$methodName]=$method;
2138 2198
 					}
2139 2199
 				}
2140
-				if(strncmp($methodName,'__',2)!==0)
2141
-					$methods[$methodName]=$method;
2200
+				if(strncmp($methodName,'__',2)!==0) {
2201
+									$methods[$methodName]=$method;
2202
+				}
2142 2203
 			}
2143 2204
 		}
2144 2205
 		$reserved=array();
@@ -2168,13 +2229,14 @@  discard block
 block discarded – undo
2168 2229
 		ksort($methods);
2169 2230
 		foreach($methods as $name=>$method)
2170 2231
 		{
2171
-			if(!isset($reserved[strtolower($name)]))
2172
-				$this->_methods[$name]=array(
2232
+			if(!isset($reserved[strtolower($name)])) {
2233
+							$this->_methods[$name]=array(
2173 2234
 					'class'=>$method->getDeclaringClass()->getName(),
2174 2235
 					'protected'=>$method->isProtected(),
2175 2236
 					'static'=>$method->isStatic(),
2176 2237
 					'comments'=>$method->getDocComment()
2177 2238
 				);
2239
+			}
2178 2240
 		}
2179 2241
 	}
2180 2242
 
@@ -2187,10 +2249,11 @@  discard block
 block discarded – undo
2187 2249
 	protected function determinePropertyType($method)
2188 2250
 	{
2189 2251
 		$comment=$method->getDocComment();
2190
-		if(preg_match('/@return\\s+(.*?)\\s+/',$comment,$matches))
2191
-			return $matches[1];
2192
-		else
2193
-			return '{unknown}';
2252
+		if(preg_match('/@return\\s+(.*?)\\s+/',$comment,$matches)) {
2253
+					return $matches[1];
2254
+		} else {
2255
+					return '{unknown}';
2256
+		}
2194 2257
 	}
2195 2258
 
2196 2259
 	/**
Please login to merge, or discard this patch.
framework/Util/TDateTimeStamp.php 4 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,6 +82,9 @@  discard block
 block discarded – undo
82 82
 		return $y;
83 83
 	}
84 84
 
85
+	/**
86
+	 * @param integer $y
87
+	 */
85 88
 	public function get4DigitYear($y)
86 89
 	{
87 90
 		return $this->digitCheck($y);
@@ -172,6 +175,7 @@  discard block
 block discarded – undo
172 175
 	}
173 176
 
174 177
 	/**
178
+	 * @param string $fmt
175 179
 	 * @return string formatted date based on timestamp $d
176 180
 	 */
177 181
 	function formatDate($fmt,$ts=false,$is_gmt=false)
@@ -185,7 +189,7 @@  discard block
 block discarded – undo
185 189
 	}
186 190
 
187 191
 	/**
188
-	 * @return integer|float a timestamp given a local time
192
+	 * @return integer a timestamp given a local time
189 193
      */
190 194
 	function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false)
191 195
 	{
Please login to merge, or discard this patch.
Indentation   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,13 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TDateTimeStamp class file.
4
-
5
- * @author Fabio Bas ctrlaltca[AT]gmail[DOT]com
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Util
10
- */
3
+	 * TDateTimeStamp class file.
4
+	 * @author Fabio Bas ctrlaltca[AT]gmail[DOT]com
5
+	 * @link https://github.com/pradosoft/prado
6
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
7
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
8
+	 * @package System.Util
9
+	 */
11 10
 
12 11
 /**
13 12
  * TDateTimeStamp Class
@@ -186,7 +185,7 @@  discard block
 block discarded – undo
186 185
 
187 186
 	/**
188 187
 	 * @return integer|float a timestamp given a local time
189
-     */
188
+	 */
190 189
 	function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false)
191 190
 	{
192 191
 		$dt = new DateTime();
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class TDateTimeStamp
27 27
 {
28
-	protected static $_month_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31);
29
-	protected static $_month_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31);
28
+	protected static $_month_normal = array("", 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
29
+	protected static $_month_leaf = array("", 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
30 30
 
31 31
 	/**
32 32
 	 * Returns the day of the week (0=Sunday, 1=Monday, .. 6=Saturday)
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	protected function digitCheck($y)
64 64
 	{
65
-		if ($y < 100){
65
+		if ($y < 100) {
66 66
 			$yr = (integer) date("Y");
67
-			$century = (integer) ($yr /100);
67
+			$century = (integer) ($yr / 100);
68 68
 
69
-			if ($yr%100 > 50) {
69
+			if ($yr % 100 > 50) {
70 70
 				$c1 = $century + 1;
71 71
 				$c0 = $century;
72 72
 			} else {
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 			$c1 *= 100;
77 77
 			// if 2-digit year is less than 30 years in future, set it to this century
78 78
 			// otherwise if more than 30 years in future, then we set 2-digit year to the prev century.
79
-			if (($y + $c1) < $yr+30) $y = $y + $c1;
80
-			else $y = $y + $c0*100;
79
+			if (($y + $c1) < $yr + 30) $y = $y + $c1;
80
+			else $y = $y + $c0 * 100;
81 81
 		}
82 82
 		return $y;
83 83
 	}
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	/**
91 91
 	 * @return integer get local time zone offset from GMT
92 92
 	 */
93
-	public function getGMTDiff($ts=false)
93
+	public function getGMTDiff($ts = false)
94 94
 	{
95 95
 		$dt = new DateTime();
96
-		if($ts)
96
+		if ($ts)
97 97
 			$dt->setTimeStamp($ts);
98 98
 		else
99 99
 		 	$dt->setDate(1970, 1, 2);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	/**
105 105
 	 * @return array an array with date info.
106 106
 	 */
107
-	function parseDate($txt=false)
107
+	function parseDate($txt = false)
108 108
 	{
109 109
 		if ($txt === false) return getdate();
110 110
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	/**
129 129
 	 * @return array an array with date info.
130 130
 	 */
131
-	function getDate($d=false,$fast=false)
131
+	function getDate($d = false, $fast = false)
132 132
 	{
133 133
 		if ($d === false) return getdate();
134 134
 
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 	/**
154 154
 	 * @return boolean true if valid date, semantic check only.
155 155
 	 */
156
-	public function isValidDate($y,$m,$d)
156
+	public function isValidDate($y, $m, $d)
157 157
 	{
158 158
 		if ($this->isLeapYear($y))
159
-			$marr =& self::$_month_leaf;
159
+			$marr = & self::$_month_leaf;
160 160
 		else
161
-			$marr =& self::$_month_normal;
161
+			$marr = & self::$_month_normal;
162 162
 
163 163
 		if ($m > 12 || $m < 1) return false;
164 164
 
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 	/**
175 175
 	 * @return string formatted date based on timestamp $d
176 176
 	 */
177
-	function formatDate($fmt,$ts=false,$is_gmt=false)
177
+	function formatDate($fmt, $ts = false, $is_gmt = false)
178 178
 	{
179 179
 		$dt = new DateTime();
180
-		if($is_gmt)
180
+		if ($is_gmt)
181 181
 			$dt->setTimeZone(new DateTimeZone('UTC'));
182 182
 		$dt->setTimestamp($ts);
183 183
 
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
 	/**
188 188
 	 * @return integer|float a timestamp given a local time
189 189
      */
190
-	function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false)
190
+	function getTimeStamp($hr, $min, $sec, $mon = false, $day = false, $year = false, $is_gmt = false)
191 191
 	{
192 192
 		$dt = new DateTime();
193
-		if($is_gmt)
193
+		if ($is_gmt)
194 194
 			$dt->setTimeZone(new DateTimeZone('UTC'));
195
-		$dt->setDate($year!==false ? $year : date('Y'),
196
-			$mon!==false ? $mon : date('m'),
197
-			$day!==false ? $day : date('d'));
195
+		$dt->setDate($year !== false ? $year : date('Y'),
196
+			$mon !== false ? $mon : date('m'),
197
+			$day !== false ? $day : date('d'));
198 198
 		$dt->setTime($hr, $min, $sec);
199 199
 		return (int) $dt->format('U');
200 200
 	}
Please login to merge, or discard this patch.
Braces   +39 added lines, -20 removed lines patch added patch discarded remove patch
@@ -76,8 +76,11 @@  discard block
 block discarded – undo
76 76
 			$c1 *= 100;
77 77
 			// if 2-digit year is less than 30 years in future, set it to this century
78 78
 			// otherwise if more than 30 years in future, then we set 2-digit year to the prev century.
79
-			if (($y + $c1) < $yr+30) $y = $y + $c1;
80
-			else $y = $y + $c0*100;
79
+			if (($y + $c1) < $yr+30) {
80
+				$y = $y + $c1;
81
+			} else {
82
+				$y = $y + $c0*100;
83
+			}
81 84
 		}
82 85
 		return $y;
83 86
 	}
@@ -93,10 +96,11 @@  discard block
 block discarded – undo
93 96
 	public function getGMTDiff($ts=false)
94 97
 	{
95 98
 		$dt = new DateTime();
96
-		if($ts)
97
-			$dt->setTimeStamp($ts);
98
-		else
99
-		 	$dt->setDate(1970, 1, 2);
99
+		if($ts) {
100
+					$dt->setTimeStamp($ts);
101
+		} else {
102
+				 	$dt->setDate(1970, 1, 2);
103
+		}
100 104
 
101 105
 		return (int) $dt->format('Z');
102 106
 	}
@@ -106,7 +110,9 @@  discard block
 block discarded – undo
106 110
 	 */
107 111
 	function parseDate($txt=false)
108 112
 	{
109
-		if ($txt === false) return getdate();
113
+		if ($txt === false) {
114
+			return getdate();
115
+		}
110 116
 
111 117
 		$dt = new DateTime($txt);
112 118
 
@@ -130,7 +136,9 @@  discard block
 block discarded – undo
130 136
 	 */
131 137
 	function getDate($d=false,$fast=false)
132 138
 	{
133
-		if ($d === false) return getdate();
139
+		if ($d === false) {
140
+			return getdate();
141
+		}
134 142
 
135 143
 		$dt = new DateTime();
136 144
 		$dt->setTimestamp($d);
@@ -155,18 +163,27 @@  discard block
 block discarded – undo
155 163
 	 */
156 164
 	public function isValidDate($y,$m,$d)
157 165
 	{
158
-		if ($this->isLeapYear($y))
159
-			$marr =& self::$_month_leaf;
160
-		else
161
-			$marr =& self::$_month_normal;
166
+		if ($this->isLeapYear($y)) {
167
+					$marr =& self::$_month_leaf;
168
+		} else {
169
+					$marr =& self::$_month_normal;
170
+		}
162 171
 
163
-		if ($m > 12 || $m < 1) return false;
172
+		if ($m > 12 || $m < 1) {
173
+			return false;
174
+		}
164 175
 
165
-		if ($d > 31 || $d < 1) return false;
176
+		if ($d > 31 || $d < 1) {
177
+			return false;
178
+		}
166 179
 
167
-		if ($marr[$m] < $d) return false;
180
+		if ($marr[$m] < $d) {
181
+			return false;
182
+		}
168 183
 
169
-		if ($y < 1000 && $y > 3000) return false;
184
+		if ($y < 1000 && $y > 3000) {
185
+			return false;
186
+		}
170 187
 
171 188
 		return true;
172 189
 	}
@@ -177,8 +194,9 @@  discard block
 block discarded – undo
177 194
 	function formatDate($fmt,$ts=false,$is_gmt=false)
178 195
 	{
179 196
 		$dt = new DateTime();
180
-		if($is_gmt)
181
-			$dt->setTimeZone(new DateTimeZone('UTC'));
197
+		if($is_gmt) {
198
+					$dt->setTimeZone(new DateTimeZone('UTC'));
199
+		}
182 200
 		$dt->setTimestamp($ts);
183 201
 
184 202
 		return $dt->format($fmt);
@@ -190,8 +208,9 @@  discard block
 block discarded – undo
190 208
 	function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false)
191 209
 	{
192 210
 		$dt = new DateTime();
193
-		if($is_gmt)
194
-			$dt->setTimeZone(new DateTimeZone('UTC'));
211
+		if($is_gmt) {
212
+					$dt->setTimeZone(new DateTimeZone('UTC'));
213
+		}
195 214
 		$dt->setDate($year!==false ? $year : date('Y'),
196 215
 			$mon!==false ? $mon : date('m'),
197 216
 			$day!==false ? $day : date('d'));
Please login to merge, or discard this patch.
framework/Util/TLogger.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -98,6 +98,7 @@
 block discarded – undo
98 98
 	 * @param integer level filter
99 99
 	 * @param array category filter
100 100
 	 * @param array control filter
101
+	 * @param integer $levels
101 102
 	 * @return array list of messages. Each array elements represents one message
102 103
 	 * with the following structure:
103 104
 	 * array(
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TLogger class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Util
10
- */
3
+	 * TLogger class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Util
10
+	 */
11 11
 
12 12
 /**
13 13
  * TLogger class.
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * Log levels.
27 27
 	 */
28
-	const DEBUG=0x01;
29
-	const INFO=0x02;
30
-	const NOTICE=0x04;
31
-	const WARNING=0x08;
32
-	const ERROR=0x10;
33
-	const ALERT=0x20;
34
-	const FATAL=0x40;
28
+	const DEBUG = 0x01;
29
+	const INFO = 0x02;
30
+	const NOTICE = 0x04;
31
+	const WARNING = 0x08;
32
+	const ERROR = 0x10;
33
+	const ALERT = 0x20;
34
+	const FATAL = 0x40;
35 35
 	/**
36 36
 	 * @var array log messages
37 37
 	 */
38
-	private $_logs=array();
38
+	private $_logs = array();
39 39
 	/**
40 40
 	 * @var integer log levels (bits) to be filtered
41 41
 	 */
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 	 * @param string category of the message
64 64
 	 * @param string|TControl control of the message
65 65
 	 */
66
-	public function log($message,$level,$category='Uncategorized', $ctl=null)
66
+	public function log($message, $level, $category = 'Uncategorized', $ctl = null)
67 67
 	{
68
-		if($ctl) {
69
-			if($ctl instanceof TControl)
68
+		if ($ctl) {
69
+			if ($ctl instanceof TControl)
70 70
 				$ctl = $ctl->ClientId;
71
-			else if(!is_string($ctl))
71
+			else if (!is_string($ctl))
72 72
 				$ctl = null;
73 73
 		} else
74 74
 			$ctl = null;
75
-		$this->_logs[]=array($message,$level,$category,microtime(true),memory_get_usage(),$ctl);
75
+		$this->_logs[] = array($message, $level, $category, microtime(true), memory_get_usage(), $ctl);
76 76
 	}
77 77
 
78 78
 	/**
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 	 *   [4] => memory in bytes
109 109
 	 *   [5] => control client id
110 110
 	 */
111
-	public function getLogs($levels=null,$categories=null,$controls=null,$timestamp=null)
111
+	public function getLogs($levels = null, $categories = null, $controls = null, $timestamp = null)
112 112
 	{
113
-		$this->_levels=$levels;
114
-		$this->_categories=$categories;
115
-		$this->_controls=$controls;
116
-		$this->_timestamp=$timestamp;
117
-		if(empty($levels) && empty($categories) && empty($controls) && is_null($timestamp))
113
+		$this->_levels = $levels;
114
+		$this->_categories = $categories;
115
+		$this->_controls = $controls;
116
+		$this->_timestamp = $timestamp;
117
+		if (empty($levels) && empty($categories) && empty($controls) && is_null($timestamp))
118 118
 			return $this->_logs;
119 119
 		$logs = $this->_logs;
120
-		if(!empty($levels))
121
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByLevels')) ));
122
-		if(!empty($categories))
123
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByCategories')) ));
124
-		if(!empty($controls))
125
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByControl')) ));
126
-		if(!is_null($timestamp))
127
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByTimeStamp')) ));
120
+		if (!empty($levels))
121
+			$logs = array_values(array_filter(array_filter($logs, array($this, 'filterByLevels'))));
122
+		if (!empty($categories))
123
+			$logs = array_values(array_filter(array_filter($logs, array($this, 'filterByCategories'))));
124
+		if (!empty($controls))
125
+			$logs = array_values(array_filter(array_filter($logs, array($this, 'filterByControl'))));
126
+		if (!is_null($timestamp))
127
+			$logs = array_values(array_filter(array_filter($logs, array($this, 'filterByTimeStamp'))));
128 128
 		return $logs;
129 129
 	}
130 130
 
@@ -152,27 +152,27 @@  discard block
 block discarded – undo
152 152
 	 * @param array category filter
153 153
 	 * @param array control filter
154 154
 	 */
155
-	public function deleteLogs($levels=null,$categories=null,$controls=null,$timestamp=null)
155
+	public function deleteLogs($levels = null, $categories = null, $controls = null, $timestamp = null)
156 156
 	{
157
-		$this->_levels=$levels;
158
-		$this->_categories=$categories;
159
-		$this->_controls=$controls;
160
-		$this->_timestamp=$timestamp;
161
-		if(empty($levels) && empty($categories) && empty($controls) && is_null($timestamp))
157
+		$this->_levels = $levels;
158
+		$this->_categories = $categories;
159
+		$this->_controls = $controls;
160
+		$this->_timestamp = $timestamp;
161
+		if (empty($levels) && empty($categories) && empty($controls) && is_null($timestamp))
162 162
 		{
163
-			$this->_logs=array();
163
+			$this->_logs = array();
164 164
 			return;
165 165
 		}
166 166
 		$logs = $this->_logs;
167
-		if(!empty($levels))
168
-			$logs = array_filter( array_filter($logs,array($this,'filterByLevels')) );
169
-		if(!empty($categories))
170
-			$logs = array_filter( array_filter($logs,array($this,'filterByCategories')) );
171
-		if(!empty($controls))
172
-			$logs = array_filter( array_filter($logs,array($this,'filterByControl')) );
173
-		if(!is_null($timestamp))
174
-			$logs = array_filter( array_filter($logs,array($this,'filterByTimeStamp')) );
175
-		$this->_logs = array_values( array_diff_key($this->_logs, $logs) );
167
+		if (!empty($levels))
168
+			$logs = array_filter(array_filter($logs, array($this, 'filterByLevels')));
169
+		if (!empty($categories))
170
+			$logs = array_filter(array_filter($logs, array($this, 'filterByCategories')));
171
+		if (!empty($controls))
172
+			$logs = array_filter(array_filter($logs, array($this, 'filterByControl')));
173
+		if (!is_null($timestamp))
174
+			$logs = array_filter(array_filter($logs, array($this, 'filterByTimeStamp')));
175
+		$this->_logs = array_values(array_diff_key($this->_logs, $logs));
176 176
 	}
177 177
 
178 178
 	/**
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	private function filterByCategories($value)
183 183
 	{
184
-		foreach($this->_categories as $category)
184
+		foreach ($this->_categories as $category)
185 185
 		{
186 186
 			// element 2 is the category
187
-			if($value[2]===$category || strpos($value[2],$category.'.')===0)
187
+			if ($value[2] === $category || strpos($value[2], $category . '.') === 0)
188 188
 				return $value;
189 189
 		}
190 190
 		return false;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	private function filterByLevels($value)
198 198
 	{
199 199
 		// element 1 are the levels
200
-		if($value[1] & $this->_levels)
200
+		if ($value[1] & $this->_levels)
201 201
 			return $value;
202 202
 		else
203 203
 			return false;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	private function filterByControl($value)
211 211
 	{
212 212
 		// element 5 are the control client ids
213
-		foreach($this->_controls as $control)
213
+		foreach ($this->_controls as $control)
214 214
 		{
215
-			if($value[5]===$control || strpos($value[5],$control)===0)
215
+			if ($value[5] === $control || strpos($value[5], $control) === 0)
216 216
 				return $value;
217 217
 		}
218 218
 		return false;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	private function filterByTimeStamp($value)
226 226
 	{
227 227
 		// element 3 is the timestamp
228
-		if($value[3] <= $this->_timestamp)
228
+		if ($value[3] <= $this->_timestamp)
229 229
 			return $value;
230 230
 		else
231 231
 			return false;
Please login to merge, or discard this patch.
Braces   +51 added lines, -36 removed lines patch added patch discarded remove patch
@@ -66,12 +66,14 @@  discard block
 block discarded – undo
66 66
 	public function log($message,$level,$category='Uncategorized', $ctl=null)
67 67
 	{
68 68
 		if($ctl) {
69
-			if($ctl instanceof TControl)
70
-				$ctl = $ctl->ClientId;
71
-			else if(!is_string($ctl))
72
-				$ctl = null;
73
-		} else
74
-			$ctl = null;
69
+			if($ctl instanceof TControl) {
70
+							$ctl = $ctl->ClientId;
71
+			} else if(!is_string($ctl)) {
72
+							$ctl = null;
73
+			}
74
+		} else {
75
+					$ctl = null;
76
+		}
75 77
 		$this->_logs[]=array($message,$level,$category,microtime(true),memory_get_usage(),$ctl);
76 78
 	}
77 79
 
@@ -114,17 +116,22 @@  discard block
 block discarded – undo
114 116
 		$this->_categories=$categories;
115 117
 		$this->_controls=$controls;
116 118
 		$this->_timestamp=$timestamp;
117
-		if(empty($levels) && empty($categories) && empty($controls) && is_null($timestamp))
118
-			return $this->_logs;
119
+		if(empty($levels) && empty($categories) && empty($controls) && is_null($timestamp)) {
120
+					return $this->_logs;
121
+		}
119 122
 		$logs = $this->_logs;
120
-		if(!empty($levels))
121
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByLevels')) ));
122
-		if(!empty($categories))
123
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByCategories')) ));
124
-		if(!empty($controls))
125
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByControl')) ));
126
-		if(!is_null($timestamp))
127
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByTimeStamp')) ));
123
+		if(!empty($levels)) {
124
+					$logs = array_values(array_filter( array_filter($logs,array($this,'filterByLevels')) ));
125
+		}
126
+		if(!empty($categories)) {
127
+					$logs = array_values(array_filter( array_filter($logs,array($this,'filterByCategories')) ));
128
+		}
129
+		if(!empty($controls)) {
130
+					$logs = array_values(array_filter( array_filter($logs,array($this,'filterByControl')) ));
131
+		}
132
+		if(!is_null($timestamp)) {
133
+					$logs = array_values(array_filter( array_filter($logs,array($this,'filterByTimeStamp')) ));
134
+		}
128 135
 		return $logs;
129 136
 	}
130 137
 
@@ -164,14 +171,18 @@  discard block
 block discarded – undo
164 171
 			return;
165 172
 		}
166 173
 		$logs = $this->_logs;
167
-		if(!empty($levels))
168
-			$logs = array_filter( array_filter($logs,array($this,'filterByLevels')) );
169
-		if(!empty($categories))
170
-			$logs = array_filter( array_filter($logs,array($this,'filterByCategories')) );
171
-		if(!empty($controls))
172
-			$logs = array_filter( array_filter($logs,array($this,'filterByControl')) );
173
-		if(!is_null($timestamp))
174
-			$logs = array_filter( array_filter($logs,array($this,'filterByTimeStamp')) );
174
+		if(!empty($levels)) {
175
+					$logs = array_filter( array_filter($logs,array($this,'filterByLevels')) );
176
+		}
177
+		if(!empty($categories)) {
178
+					$logs = array_filter( array_filter($logs,array($this,'filterByCategories')) );
179
+		}
180
+		if(!empty($controls)) {
181
+					$logs = array_filter( array_filter($logs,array($this,'filterByControl')) );
182
+		}
183
+		if(!is_null($timestamp)) {
184
+					$logs = array_filter( array_filter($logs,array($this,'filterByTimeStamp')) );
185
+		}
175 186
 		$this->_logs = array_values( array_diff_key($this->_logs, $logs) );
176 187
 	}
177 188
 
@@ -184,8 +195,9 @@  discard block
 block discarded – undo
184 195
 		foreach($this->_categories as $category)
185 196
 		{
186 197
 			// element 2 is the category
187
-			if($value[2]===$category || strpos($value[2],$category.'.')===0)
188
-				return $value;
198
+			if($value[2]===$category || strpos($value[2],$category.'.')===0) {
199
+							return $value;
200
+			}
189 201
 		}
190 202
 		return false;
191 203
 	}
@@ -197,10 +209,11 @@  discard block
 block discarded – undo
197 209
 	private function filterByLevels($value)
198 210
 	{
199 211
 		// element 1 are the levels
200
-		if($value[1] & $this->_levels)
201
-			return $value;
202
-		else
203
-			return false;
212
+		if($value[1] & $this->_levels) {
213
+					return $value;
214
+		} else {
215
+					return false;
216
+		}
204 217
 	}
205 218
 
206 219
 	/**
@@ -212,8 +225,9 @@  discard block
 block discarded – undo
212 225
 		// element 5 are the control client ids
213 226
 		foreach($this->_controls as $control)
214 227
 		{
215
-			if($value[5]===$control || strpos($value[5],$control)===0)
216
-				return $value;
228
+			if($value[5]===$control || strpos($value[5],$control)===0) {
229
+							return $value;
230
+			}
217 231
 		}
218 232
 		return false;
219 233
 	}
@@ -225,10 +239,11 @@  discard block
 block discarded – undo
225 239
 	private function filterByTimeStamp($value)
226 240
 	{
227 241
 		// element 3 is the timestamp
228
-		if($value[3] <= $this->_timestamp)
229
-			return $value;
230
-		else
231
-			return false;
242
+		if($value[3] <= $this->_timestamp) {
243
+					return $value;
244
+		} else {
245
+					return false;
246
+		}
232 247
 	}
233 248
 }
234 249
 
Please login to merge, or discard this patch.
framework/Util/TRpcClient.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -105,6 +105,9 @@
 block discarded – undo
105 105
 	 * @param string RPC server URL
106 106
 	 * @param array payload data
107 107
 	 * @param string request mime type
108
+	 * @param string $serverUrl
109
+	 * @param string $mimeType
110
+	 * @return string
108 111
 	 */
109 112
 	protected function performRequest($serverUrl, $payload, $mimeType)
110 113
 	{
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public static function create($type, $serverUrl, $isNotification = false)
80 80
 	{
81
-		if(($_handler = constant('TRpcClientTypesEnumerable::'.strtoupper($type))) === null)
81
+		if (($_handler = constant('TRpcClientTypesEnumerable::' . strtoupper($type))) === null)
82 82
 			throw new TApplicationException('rpcclient_unsupported_handler');
83 83
 
84 84
 		return new $_handler($serverUrl, $isNotification);
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	protected function performRequest($serverUrl, $payload, $mimeType)
110 110
 	{
111
-		if(($_response = @file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType))) === false)
112
-			throw new TRpcClientRequestException('Request failed ("'.$http_response_header[0].'")');
111
+		if (($_response = @file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType))) === false)
112
+			throw new TRpcClientRequestException('Request failed ("' . $http_response_header[0] . '")');
113 113
 
114 114
 		return $_response;
115 115
 	}
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
 		$_response = $this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'application/json');
243 243
 
244 244
 		// skip response handling if the request was just a notification request
245
-		if($this->isNotification)
245
+		if ($this->isNotification)
246 246
 			return true;
247 247
 
248 248
 		// decode response
249
-		if(($_response = json_decode($_response, true)) === null)
249
+		if (($_response = json_decode($_response, true)) === null)
250 250
 			throw new TRpcClientResponseException('Empty response received');
251 251
 
252 252
 		// handle error response
253
-		if(!is_null($_response['error']))
253
+		if (!is_null($_response['error']))
254 254
 			throw new TRpcClientResponseException($_response['error']);
255 255
 
256 256
 		return $_response['result'];
@@ -320,15 +320,15 @@  discard block
 block discarded – undo
320 320
 		$_response = $this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'text/xml');
321 321
 
322 322
 		// skip response handling if the request was just a notification request
323
-		if($this->isNotification)
323
+		if ($this->isNotification)
324 324
 			return true;
325 325
 
326 326
 		// decode response
327
-		if(($_response = xmlrpc_decode($_response)) === null)
327
+		if (($_response = xmlrpc_decode($_response)) === null)
328 328
 			throw new TRpcClientResponseException('Empty response received');
329 329
 
330 330
 		// handle error response
331
-		if(xmlrpc_is_fault($_response))
331
+		if (xmlrpc_is_fault($_response))
332 332
 			throw new TRpcClientResponseException($_response['faultString'], $_response['faultCode']);
333 333
 
334 334
 		return $_response;
Please login to merge, or discard this patch.
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -78,8 +78,9 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public static function create($type, $serverUrl, $isNotification = false)
80 80
 	{
81
-		if(($_handler = constant('TRpcClientTypesEnumerable::'.strtoupper($type))) === null)
82
-			throw new TApplicationException('rpcclient_unsupported_handler');
81
+		if(($_handler = constant('TRpcClientTypesEnumerable::'.strtoupper($type))) === null) {
82
+					throw new TApplicationException('rpcclient_unsupported_handler');
83
+		}
83 84
 
84 85
 		return new $_handler($serverUrl, $isNotification);
85 86
 	}
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 	 */
109 110
 	protected function performRequest($serverUrl, $payload, $mimeType)
110 111
 	{
111
-		if(($_response = @file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType))) === false)
112
-			throw new TRpcClientRequestException('Request failed ("'.$http_response_header[0].'")');
112
+		if(($_response = @file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType))) === false) {
113
+					throw new TRpcClientRequestException('Request failed ("'.$http_response_header[0].'")');
114
+		}
113 115
 
114 116
 		return $_response;
115 117
 	}
@@ -242,16 +244,19 @@  discard block
 block discarded – undo
242 244
 		$_response = $this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'application/json');
243 245
 
244 246
 		// skip response handling if the request was just a notification request
245
-		if($this->isNotification)
246
-			return true;
247
+		if($this->isNotification) {
248
+					return true;
249
+		}
247 250
 
248 251
 		// decode response
249
-		if(($_response = json_decode($_response, true)) === null)
250
-			throw new TRpcClientResponseException('Empty response received');
252
+		if(($_response = json_decode($_response, true)) === null) {
253
+					throw new TRpcClientResponseException('Empty response received');
254
+		}
251 255
 
252 256
 		// handle error response
253
-		if(!is_null($_response['error']))
254
-			throw new TRpcClientResponseException($_response['error']);
257
+		if(!is_null($_response['error'])) {
258
+					throw new TRpcClientResponseException($_response['error']);
259
+		}
255 260
 
256 261
 		return $_response['result'];
257 262
 	}
@@ -320,16 +325,19 @@  discard block
 block discarded – undo
320 325
 		$_response = $this->performRequest($this->getServerUrl(), $this->encodeRequest($method, $parameters), 'text/xml');
321 326
 
322 327
 		// skip response handling if the request was just a notification request
323
-		if($this->isNotification)
324
-			return true;
328
+		if($this->isNotification) {
329
+					return true;
330
+		}
325 331
 
326 332
 		// decode response
327
-		if(($_response = xmlrpc_decode($_response)) === null)
328
-			throw new TRpcClientResponseException('Empty response received');
333
+		if(($_response = xmlrpc_decode($_response)) === null) {
334
+					throw new TRpcClientResponseException('Empty response received');
335
+		}
329 336
 
330 337
 		// handle error response
331
-		if(xmlrpc_is_fault($_response))
332
-			throw new TRpcClientResponseException($_response['faultString'], $_response['faultCode']);
338
+		if(xmlrpc_is_fault($_response)) {
339
+					throw new TRpcClientResponseException($_response['faultString'], $_response['faultCode']);
340
+		}
333 341
 
334 342
 		return $_response;
335 343
 	}
Please login to merge, or discard this patch.