Passed
Branch php-cs-fixer (b9836a)
by Fabio
15:58
created
framework/Web/Services/TSoapService.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function init($config)
121 121
 	{
122
-		if($this->_configFile !== null)
122
+		if ($this->_configFile !== null)
123 123
 		{
124
-			if(is_file($this->_configFile))
124
+			if (is_file($this->_configFile))
125 125
 			{
126 126
 				$dom = new TXmlDocument;
127 127
 				$dom->loadFromFile($this->_configFile);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	protected function resolveRequest()
146 146
 	{
147 147
 		$serverID = $this->getRequest()->getServiceParameter();
148
-		if(($pos = strrpos($serverID, '.wsdl')) === strlen($serverID) - 5)
148
+		if (($pos = strrpos($serverID, '.wsdl')) === strlen($serverID) - 5)
149 149
 		{
150 150
 			$serverID = substr($serverID, 0, $pos);
151 151
 			$this->_wsdlRequest = true;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		else
154 154
 			$this->_wsdlRequest = false;
155 155
 		$this->_serverID = $serverID;
156
-		if(!isset($this->_servers[$serverID]))
156
+		if (!isset($this->_servers[$serverID]))
157 157
 			throw new THttpException(400, 'soapservice_request_invalid', $serverID);
158 158
 	}
159 159
 
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	private function loadConfig($config)
166 166
 	{
167
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
167
+		if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
168 168
 		{
169
-			if(is_array($config))
169
+			if (is_array($config))
170 170
 			{
171
-				foreach($config['soap'] as $id => $server)
171
+				foreach ($config['soap'] as $id => $server)
172 172
 				{
173
-					$properties = isset($server['properties'])?$server['properties']:[];
174
-					if(isset($this->_servers[$id]))
173
+					$properties = isset($server['properties']) ? $server['properties'] : [];
174
+					if (isset($this->_servers[$id]))
175 175
 						throw new TConfigurationException('soapservice_serverid_duplicated', $id);
176 176
 					$this->_servers[$id] = $properties;
177 177
 				}
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 		}
180 180
 		else
181 181
 		{
182
-			foreach($config->getElementsByTagName('soap') as $serverXML)
182
+			foreach ($config->getElementsByTagName('soap') as $serverXML)
183 183
 			{
184 184
 				$properties = $serverXML->getAttributes();
185
-				if(($id = $properties->remove('id')) === null)
185
+				if (($id = $properties->remove('id')) === null)
186 186
 					throw new TConfigurationException('soapservice_serverid_required');
187
-				if(isset($this->_servers[$id]))
187
+				if (isset($this->_servers[$id]))
188 188
 					throw new TConfigurationException('soapservice_serverid_duplicated', $id);
189 189
 				$this->_servers[$id] = $properties;
190 190
 			}
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function setConfigFile($value)
208 208
 	{
209
-		if(($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null)
209
+		if (($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null)
210 210
 			throw new TConfigurationException('soapservice_configfile_invalid', $value);
211 211
 	}
212 212
 
@@ -249,19 +249,19 @@  discard block
 block discarded – undo
249 249
 	{
250 250
 		$properties = $this->_servers[$this->_serverID];
251 251
 		$serverClass = null;
252
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class']))
252
+		if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class']))
253 253
 			$serverClass = $config['class'];
254
-		elseif($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML)
254
+		elseif ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML)
255 255
 			$serverClass = $properties->remove('class');
256
-		if($serverClass === null)
256
+		if ($serverClass === null)
257 257
 			$serverClass = self::DEFAULT_SOAP_SERVER;
258 258
 		Prado::using($serverClass);
259
-		$className = ($pos = strrpos($serverClass, '.')) !== false?substr($serverClass, $pos + 1):$serverClass;
260
-		if($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER))
259
+		$className = ($pos = strrpos($serverClass, '.')) !== false ?substr($serverClass, $pos + 1) : $serverClass;
260
+		if ($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER))
261 261
 			throw new TConfigurationException('soapservice_server_invalid', $serverClass);
262 262
 		$server = new $className;
263 263
 		$server->setID($this->_serverID);
264
-		foreach($properties as $name => $value)
264
+		foreach ($properties as $name => $value)
265 265
 			$server->setSubproperty($name, $value);
266 266
 		return $server;
267 267
 	}
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		$server = $this->createServer();
279 279
 		$this->getResponse()->setContentType('text/xml');
280 280
 		$this->getResponse()->setCharset($server->getEncoding());
281
-		if($this->getIsWsdlRequest())
281
+		if ($this->getIsWsdlRequest())
282 282
 		{
283 283
 			// server WSDL file
284 284
 			Prado::trace("Generating WSDL", 'Prado\Web\Services\TSoapService');
Please login to merge, or discard this patch.
Braces   +35 added lines, -28 removed lines patch added patch discarded remove patch
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 				$dom = new TXmlDocument;
127 127
 				$dom->loadFromFile($this->_configFile);
128 128
 				$this->loadConfig($dom);
129
+			} else {
130
+							throw new TConfigurationException('soapservice_configfile_invalid', $this->_configFile);
129 131
 			}
130
-			else
131
-				throw new TConfigurationException('soapservice_configfile_invalid', $this->_configFile);
132 132
 		}
133 133
 		$this->loadConfig($config);
134 134
 
@@ -149,12 +149,13 @@  discard block
 block discarded – undo
149 149
 		{
150 150
 			$serverID = substr($serverID, 0, $pos);
151 151
 			$this->_wsdlRequest = true;
152
+		} else {
153
+					$this->_wsdlRequest = false;
152 154
 		}
153
-		else
154
-			$this->_wsdlRequest = false;
155 155
 		$this->_serverID = $serverID;
156
-		if(!isset($this->_servers[$serverID]))
157
-			throw new THttpException(400, 'soapservice_request_invalid', $serverID);
156
+		if(!isset($this->_servers[$serverID])) {
157
+					throw new THttpException(400, 'soapservice_request_invalid', $serverID);
158
+		}
158 159
 	}
159 160
 
160 161
 	/**
@@ -171,21 +172,23 @@  discard block
 block discarded – undo
171 172
 				foreach($config['soap'] as $id => $server)
172 173
 				{
173 174
 					$properties = isset($server['properties'])?$server['properties']:[];
174
-					if(isset($this->_servers[$id]))
175
-						throw new TConfigurationException('soapservice_serverid_duplicated', $id);
175
+					if(isset($this->_servers[$id])) {
176
+											throw new TConfigurationException('soapservice_serverid_duplicated', $id);
177
+					}
176 178
 					$this->_servers[$id] = $properties;
177 179
 				}
178 180
 			}
179
-		}
180
-		else
181
+		} else
181 182
 		{
182 183
 			foreach($config->getElementsByTagName('soap') as $serverXML)
183 184
 			{
184 185
 				$properties = $serverXML->getAttributes();
185
-				if(($id = $properties->remove('id')) === null)
186
-					throw new TConfigurationException('soapservice_serverid_required');
187
-				if(isset($this->_servers[$id]))
188
-					throw new TConfigurationException('soapservice_serverid_duplicated', $id);
186
+				if(($id = $properties->remove('id')) === null) {
187
+									throw new TConfigurationException('soapservice_serverid_required');
188
+				}
189
+				if(isset($this->_servers[$id])) {
190
+									throw new TConfigurationException('soapservice_serverid_duplicated', $id);
191
+				}
189 192
 				$this->_servers[$id] = $properties;
190 193
 			}
191 194
 		}
@@ -206,8 +209,9 @@  discard block
 block discarded – undo
206 209
 	 */
207 210
 	public function setConfigFile($value)
208 211
 	{
209
-		if(($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null)
210
-			throw new TConfigurationException('soapservice_configfile_invalid', $value);
212
+		if(($this->_configFile = Prado::getPathOfNamespace($value, Prado::getApplication()->getConfigurationFileExt())) === null) {
213
+					throw new TConfigurationException('soapservice_configfile_invalid', $value);
214
+		}
211 215
 	}
212 216
 
213 217
 	/**
@@ -249,20 +253,24 @@  discard block
 block discarded – undo
249 253
 	{
250 254
 		$properties = $this->_servers[$this->_serverID];
251 255
 		$serverClass = null;
252
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class']))
253
-			$serverClass = $config['class'];
254
-		elseif($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML)
255
-			$serverClass = $properties->remove('class');
256
-		if($serverClass === null)
257
-			$serverClass = self::DEFAULT_SOAP_SERVER;
256
+		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP && isset($config['class'])) {
257
+					$serverClass = $config['class'];
258
+		} elseif($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML) {
259
+					$serverClass = $properties->remove('class');
260
+		}
261
+		if($serverClass === null) {
262
+					$serverClass = self::DEFAULT_SOAP_SERVER;
263
+		}
258 264
 		Prado::using($serverClass);
259 265
 		$className = ($pos = strrpos($serverClass, '.')) !== false?substr($serverClass, $pos + 1):$serverClass;
260
-		if($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER))
261
-			throw new TConfigurationException('soapservice_server_invalid', $serverClass);
266
+		if($className !== self::DEFAULT_SOAP_SERVER && !is_subclass_of($className, self::DEFAULT_SOAP_SERVER)) {
267
+					throw new TConfigurationException('soapservice_server_invalid', $serverClass);
268
+		}
262 269
 		$server = new $className;
263 270
 		$server->setID($this->_serverID);
264
-		foreach($properties as $name => $value)
265
-			$server->setSubproperty($name, $value);
271
+		foreach($properties as $name => $value) {
272
+					$server->setSubproperty($name, $value);
273
+		}
266 274
 		return $server;
267 275
 	}
268 276
 
@@ -284,8 +292,7 @@  discard block
 block discarded – undo
284 292
 			Prado::trace("Generating WSDL", 'Prado\Web\Services\TSoapService');
285 293
 			$this->getResponse()->clear();
286 294
 			$this->getResponse()->write($server->getWsdl());
287
-		}
288
-		else
295
+		} else
289 296
 		{
290 297
 			// provide SOAP service
291 298
 			Prado::trace("Handling SOAP request", 'Prado\Web\Services\TSoapService');
Please login to merge, or discard this patch.
framework/Web/Services/TRpcProtocol.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,13 +85,13 @@
 block discarded – undo
85 85
 	 */
86 86
 	public function callApiMethod($methodName, $parameters)
87 87
 	{
88
-		if(!isset($this->rpcMethods[$methodName]))
89
-			throw new TRpcException('Method "' . $methodName . '" not found');
88
+		if (!isset($this->rpcMethods[$methodName]))
89
+			throw new TRpcException('Method "'.$methodName.'" not found');
90 90
 
91
-		if($parameters === null)
91
+		if ($parameters === null)
92 92
 			$parameters = [];
93 93
 
94
-		if(!is_array($parameters))
94
+		if (!is_array($parameters))
95 95
 			$parameters = [$parameters];
96 96
 		return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters);
97 97
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -85,14 +85,17 @@
 block discarded – undo
85 85
 	 */
86 86
 	public function callApiMethod($methodName, $parameters)
87 87
 	{
88
-		if(!isset($this->rpcMethods[$methodName]))
89
-			throw new TRpcException('Method "' . $methodName . '" not found');
88
+		if(!isset($this->rpcMethods[$methodName])) {
89
+					throw new TRpcException('Method "' . $methodName . '" not found');
90
+		}
90 91
 
91
-		if($parameters === null)
92
-			$parameters = [];
92
+		if($parameters === null) {
93
+					$parameters = [];
94
+		}
93 95
 
94
-		if(!is_array($parameters))
95
-			$parameters = [$parameters];
96
+		if(!is_array($parameters)) {
97
+					$parameters = [$parameters];
98
+		}
96 99
 		return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters);
97 100
 	}
98 101
 }
99 102
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Web/Services/TPageConfiguration.php 2 patches
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
 		$fileName = Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP
115 115
 			? TPageService::CONFIG_FILE_PHP
116 116
 			: TPageService::CONFIG_FILE_XML;
117
-		foreach($paths as $p)
117
+		foreach ($paths as $p)
118 118
 		{
119
-			$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
120
-			$path .= DIRECTORY_SEPARATOR . $p;
121
-			if($configPagePath === '')
119
+			$this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath);
120
+			$path .= DIRECTORY_SEPARATOR.$p;
121
+			if ($configPagePath === '')
122 122
 				$configPagePath = $p;
123 123
 			else
124
-				$configPagePath .= '.' . $p;
124
+				$configPagePath .= '.'.$p;
125 125
 		}
126
-		$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
126
+		$this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName, $configPagePath);
127 127
 		$this->_rules = new TAuthorizationRuleCollection($this->_rules);
128 128
 	}
129 129
 
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 	public function loadFromFile($fname, $configPagePath)
136 136
 	{
137 137
 		Prado::trace("Loading page configuration file $fname", 'System.Web.Services.TPageService');
138
-		if(empty($fname) || !is_file($fname))
138
+		if (empty($fname) || !is_file($fname))
139 139
 			return;
140 140
 
141
-		if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
141
+		if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
142 142
 		{
143 143
 			$fcontent = include $fname;
144 144
 			$this->loadFromPhp($fcontent, dirname($fname), $configPagePath);
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		else
147 147
 		{
148 148
 			$dom = new TXmlDocument;
149
-			if($dom->loadFromFile($fname))
149
+			if ($dom->loadFromFile($fname))
150 150
 				$this->loadFromXml($dom, dirname($fname), $configPagePath);
151 151
 			else
152 152
 				throw new TConfigurationException('pageserviceconf_file_invalid', $fname);
@@ -195,32 +195,32 @@  discard block
 block discarded – undo
195 195
 	public function loadPageConfigurationFromPhp($config, $configPath, $configPagePath)
196 196
 	{
197 197
 		// authorization
198
-		if(isset($config['authorization']) && is_array($config['authorization']))
198
+		if (isset($config['authorization']) && is_array($config['authorization']))
199 199
 		{
200 200
 			$rules = [];
201
-			foreach($config['authorization'] as $authorization)
201
+			foreach ($config['authorization'] as $authorization)
202 202
 			{
203
-				$patterns = isset($authorization['pages'])?$authorization['pages']:'';
203
+				$patterns = isset($authorization['pages']) ? $authorization['pages'] : '';
204 204
 				$ruleApplies = false;
205
-				if(empty($patterns) || trim($patterns) === '*') // null or empty string
205
+				if (empty($patterns) || trim($patterns) === '*') // null or empty string
206 206
 					$ruleApplies = true;
207 207
 				else
208 208
 				{
209
-					foreach(explode(',', $patterns) as $pattern)
209
+					foreach (explode(',', $patterns) as $pattern)
210 210
 					{
211
-						if(($pattern = trim($pattern)) !== '')
211
+						if (($pattern = trim($pattern)) !== '')
212 212
 						{
213 213
 							// we know $configPagePath and $this->_pagePath
214
-							if($configPagePath !== '')  // prepend the pattern with ConfigPagePath
215
-								$pattern = $configPagePath . '.' . $pattern;
216
-							if(strcasecmp($pattern, $this->_pagePath) === 0)
214
+							if ($configPagePath !== '')  // prepend the pattern with ConfigPagePath
215
+								$pattern = $configPagePath.'.'.$pattern;
216
+							if (strcasecmp($pattern, $this->_pagePath) === 0)
217 217
 							{
218 218
 								$ruleApplies = true;
219 219
 								break;
220 220
 							}
221
-							if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
221
+							if ($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
222 222
 							{
223
-								if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
223
+								if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
224 224
 								{
225 225
 									$ruleApplies = true;
226 226
 									break;
@@ -229,58 +229,58 @@  discard block
 block discarded – undo
229 229
 						}
230 230
 					}
231 231
 				}
232
-				if($ruleApplies)
232
+				if ($ruleApplies)
233 233
 				{
234
-					$action = isset($authorization['action'])?$authorization['action']:'';
235
-					$users = isset($authorization['users'])?$authorization['users']:'';
236
-					$roles = isset($authorization['roles'])?$authorization['roles']:'';
237
-					$verb = isset($authorization['verb'])?$authorization['verb']:'';
238
-					$ips = isset($authorization['ips'])?$authorization['ips']:'';
234
+					$action = isset($authorization['action']) ? $authorization['action'] : '';
235
+					$users = isset($authorization['users']) ? $authorization['users'] : '';
236
+					$roles = isset($authorization['roles']) ? $authorization['roles'] : '';
237
+					$verb = isset($authorization['verb']) ? $authorization['verb'] : '';
238
+					$ips = isset($authorization['ips']) ? $authorization['ips'] : '';
239 239
 					$rules[] = new TAuthorizationRule($action, $users, $roles, $verb, $ips);
240 240
 				}
241 241
 			}
242 242
 			$this->_rules = array_merge($rules, $this->_rules);
243 243
 		}
244 244
 		// pages
245
-		if(isset($config['pages']) && is_array($config['pages']))
245
+		if (isset($config['pages']) && is_array($config['pages']))
246 246
 		{
247
-			if(isset($config['pages']['properties']))
247
+			if (isset($config['pages']['properties']))
248 248
 			{
249 249
 				$this->_properties = array_merge($this->_properties, $config['pages']['properties']);
250 250
 				unset($config['pages']['properties']);
251 251
 			}
252
-			foreach($config['pages'] as $id => $page)
252
+			foreach ($config['pages'] as $id => $page)
253 253
 			{
254 254
 				$properties = [];
255
-				if(isset($page['properties']))
255
+				if (isset($page['properties']))
256 256
 				{
257 257
 					$properties = $page['properties'];
258 258
 					unset($page['properties']);
259 259
 				}
260 260
 				$matching = false;
261
-				$id = ($configPagePath === '')?$id:$configPagePath . '.' . $id;
262
-				if(strcasecmp($id, $this->_pagePath) === 0)
261
+				$id = ($configPagePath === '') ? $id : $configPagePath.'.'.$id;
262
+				if (strcasecmp($id, $this->_pagePath) === 0)
263 263
 					$matching = true;
264
-				elseif($id[strlen($id) - 1] === '*') // try wildcard matching
264
+				elseif ($id[strlen($id) - 1] === '*') // try wildcard matching
265 265
 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
266
-				if($matching)
266
+				if ($matching)
267 267
 					$this->_properties = array_merge($this->_properties, $properties);
268 268
 			}
269 269
 		}
270 270
 
271 271
 		// external configurations
272
-		if(isset($config['includes']) && is_array($config['includes']))
272
+		if (isset($config['includes']) && is_array($config['includes']))
273 273
 		{
274
-			foreach($config['includes'] as $include)
274
+			foreach ($config['includes'] as $include)
275 275
 			{
276
-				$when = isset($include['when'])?true:false;
277
-				if(!isset($include['file']))
276
+				$when = isset($include['when']) ?true:false;
277
+				if (!isset($include['file']))
278 278
 					throw new TConfigurationException('pageserviceconf_includefile_required');
279 279
 				$filePath = $include['file'];
280
-				if(isset($this->_includes[$filePath]))
281
-					$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
280
+				if (isset($this->_includes[$filePath]))
281
+					$this->_includes[$filePath] = [$configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'];
282 282
 				else
283
-					$this->_includes[$filePath] = [$configPagePath,$when];
283
+					$this->_includes[$filePath] = [$configPagePath, $when];
284 284
 			}
285 285
 		}
286 286
 	}
@@ -294,32 +294,32 @@  discard block
 block discarded – undo
294 294
 	public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath)
295 295
 	{
296 296
 		// authorization
297
-		if(($authorizationNode = $dom->getElementByTagName('authorization')) !== null)
297
+		if (($authorizationNode = $dom->getElementByTagName('authorization')) !== null)
298 298
 		{
299 299
 			$rules = [];
300
-			foreach($authorizationNode->getElements() as $node)
300
+			foreach ($authorizationNode->getElements() as $node)
301 301
 			{
302 302
 				$patterns = $node->getAttribute('pages');
303 303
 				$ruleApplies = false;
304
-				if(empty($patterns) || trim($patterns) === '*') // null or empty string
304
+				if (empty($patterns) || trim($patterns) === '*') // null or empty string
305 305
 					$ruleApplies = true;
306 306
 				else
307 307
 				{
308
-					foreach(explode(',', $patterns) as $pattern)
308
+					foreach (explode(',', $patterns) as $pattern)
309 309
 					{
310
-						if(($pattern = trim($pattern)) !== '')
310
+						if (($pattern = trim($pattern)) !== '')
311 311
 						{
312 312
 							// we know $configPagePath and $this->_pagePath
313
-							if($configPagePath !== '')  // prepend the pattern with ConfigPagePath
314
-								$pattern = $configPagePath . '.' . $pattern;
315
-							if(strcasecmp($pattern, $this->_pagePath) === 0)
313
+							if ($configPagePath !== '')  // prepend the pattern with ConfigPagePath
314
+								$pattern = $configPagePath.'.'.$pattern;
315
+							if (strcasecmp($pattern, $this->_pagePath) === 0)
316 316
 							{
317 317
 								$ruleApplies = true;
318 318
 								break;
319 319
 							}
320
-							if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
320
+							if ($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
321 321
 							{
322
-								if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
322
+								if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
323 323
 								{
324 324
 									$ruleApplies = true;
325 325
 									break;
@@ -328,45 +328,45 @@  discard block
 block discarded – undo
328 328
 						}
329 329
 					}
330 330
 				}
331
-				if($ruleApplies)
331
+				if ($ruleApplies)
332 332
 					$rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips'));
333 333
 			}
334 334
 			$this->_rules = array_merge($rules, $this->_rules);
335 335
 		}
336 336
 
337 337
 		// pages
338
-		if(($pagesNode = $dom->getElementByTagName('pages')) !== null)
338
+		if (($pagesNode = $dom->getElementByTagName('pages')) !== null)
339 339
 		{
340 340
 			$this->_properties = array_merge($this->_properties, $pagesNode->getAttributes()->toArray());
341 341
 			// at the page folder
342
-			foreach($pagesNode->getElementsByTagName('page') as $node)
342
+			foreach ($pagesNode->getElementsByTagName('page') as $node)
343 343
 			{
344 344
 				$properties = $node->getAttributes();
345 345
 				$id = $properties->remove('id');
346
-				if(empty($id))
346
+				if (empty($id))
347 347
 					throw new TConfigurationException('pageserviceconf_page_invalid', $configPath);
348 348
 				$matching = false;
349
-				$id = ($configPagePath === '')?$id:$configPagePath . '.' . $id;
350
-				if(strcasecmp($id, $this->_pagePath) === 0)
349
+				$id = ($configPagePath === '') ? $id : $configPagePath.'.'.$id;
350
+				if (strcasecmp($id, $this->_pagePath) === 0)
351 351
 					$matching = true;
352
-				elseif($id[strlen($id) - 1] === '*') // try wildcard matching
352
+				elseif ($id[strlen($id) - 1] === '*') // try wildcard matching
353 353
 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
354
-				if($matching)
354
+				if ($matching)
355 355
 					$this->_properties = array_merge($this->_properties, $properties->toArray());
356 356
 			}
357 357
 		}
358 358
 
359 359
 		// external configurations
360
-		foreach($dom->getElementsByTagName('include') as $node)
360
+		foreach ($dom->getElementsByTagName('include') as $node)
361 361
 		{
362
-			if(($when = $node->getAttribute('when')) === null)
362
+			if (($when = $node->getAttribute('when')) === null)
363 363
 				$when = true;
364
-			if(($filePath = $node->getAttribute('file')) === null)
364
+			if (($filePath = $node->getAttribute('file')) === null)
365 365
 				throw new TConfigurationException('pageserviceconf_includefile_required');
366
-			if(isset($this->_includes[$filePath]))
367
-				$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
366
+			if (isset($this->_includes[$filePath]))
367
+				$this->_includes[$filePath] = [$configPagePath, '('.$this->_includes[$filePath][1].') || ('.$when.')'];
368 368
 			else
369
-				$this->_includes[$filePath] = [$configPagePath,$when];
369
+				$this->_includes[$filePath] = [$configPagePath, $when];
370 370
 		}
371 371
 	}
372 372
 }
373 373
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +73 added lines, -48 removed lines patch added patch discarded remove patch
@@ -118,10 +118,11 @@  discard block
 block discarded – undo
118 118
 		{
119 119
 			$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
120 120
 			$path .= DIRECTORY_SEPARATOR . $p;
121
-			if($configPagePath === '')
122
-				$configPagePath = $p;
123
-			else
124
-				$configPagePath .= '.' . $p;
121
+			if($configPagePath === '') {
122
+							$configPagePath = $p;
123
+			} else {
124
+							$configPagePath .= '.' . $p;
125
+			}
125 126
 		}
126 127
 		$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
127 128
 		$this->_rules = new TAuthorizationRuleCollection($this->_rules);
@@ -135,21 +136,22 @@  discard block
 block discarded – undo
135 136
 	public function loadFromFile($fname, $configPagePath)
136 137
 	{
137 138
 		Prado::trace("Loading page configuration file $fname", 'System.Web.Services.TPageService');
138
-		if(empty($fname) || !is_file($fname))
139
-			return;
139
+		if(empty($fname) || !is_file($fname)) {
140
+					return;
141
+		}
140 142
 
141 143
 		if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
142 144
 		{
143 145
 			$fcontent = include $fname;
144 146
 			$this->loadFromPhp($fcontent, dirname($fname), $configPagePath);
145
-		}
146
-		else
147
+		} else
147 148
 		{
148 149
 			$dom = new TXmlDocument;
149
-			if($dom->loadFromFile($fname))
150
-				$this->loadFromXml($dom, dirname($fname), $configPagePath);
151
-			else
152
-				throw new TConfigurationException('pageserviceconf_file_invalid', $fname);
150
+			if($dom->loadFromFile($fname)) {
151
+							$this->loadFromXml($dom, dirname($fname), $configPagePath);
152
+			} else {
153
+							throw new TConfigurationException('pageserviceconf_file_invalid', $fname);
154
+			}
153 155
 		}
154 156
 	}
155 157
 
@@ -202,27 +204,32 @@  discard block
 block discarded – undo
202 204
 			{
203 205
 				$patterns = isset($authorization['pages'])?$authorization['pages']:'';
204 206
 				$ruleApplies = false;
205
-				if(empty($patterns) || trim($patterns) === '*') // null or empty string
207
+				if(empty($patterns) || trim($patterns) === '*') {
208
+					// null or empty string
206 209
 					$ruleApplies = true;
207
-				else
210
+				} else
208 211
 				{
209 212
 					foreach(explode(',', $patterns) as $pattern)
210 213
 					{
211 214
 						if(($pattern = trim($pattern)) !== '')
212 215
 						{
213 216
 							// we know $configPagePath and $this->_pagePath
214
-							if($configPagePath !== '')  // prepend the pattern with ConfigPagePath
217
+							if($configPagePath !== '') {
218
+								// prepend the pattern with ConfigPagePath
215 219
 								$pattern = $configPagePath . '.' . $pattern;
220
+							}
216 221
 							if(strcasecmp($pattern, $this->_pagePath) === 0)
217 222
 							{
218 223
 								$ruleApplies = true;
219 224
 								break;
220 225
 							}
221
-							if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
226
+							if($pattern[strlen($pattern) - 1] === '*') {
227
+								// try wildcard matching
222 228
 							{
223 229
 								if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
224 230
 								{
225 231
 									$ruleApplies = true;
232
+							}
226 233
 									break;
227 234
 								}
228 235
 							}
@@ -259,12 +266,15 @@  discard block
 block discarded – undo
259 266
 				}
260 267
 				$matching = false;
261 268
 				$id = ($configPagePath === '')?$id:$configPagePath . '.' . $id;
262
-				if(strcasecmp($id, $this->_pagePath) === 0)
263
-					$matching = true;
264
-				elseif($id[strlen($id) - 1] === '*') // try wildcard matching
269
+				if(strcasecmp($id, $this->_pagePath) === 0) {
270
+									$matching = true;
271
+				} elseif($id[strlen($id) - 1] === '*') {
272
+					// try wildcard matching
265 273
 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
266
-				if($matching)
267
-					$this->_properties = array_merge($this->_properties, $properties);
274
+				}
275
+				if($matching) {
276
+									$this->_properties = array_merge($this->_properties, $properties);
277
+				}
268 278
 			}
269 279
 		}
270 280
 
@@ -274,13 +284,15 @@  discard block
 block discarded – undo
274 284
 			foreach($config['includes'] as $include)
275 285
 			{
276 286
 				$when = isset($include['when'])?true:false;
277
-				if(!isset($include['file']))
278
-					throw new TConfigurationException('pageserviceconf_includefile_required');
287
+				if(!isset($include['file'])) {
288
+									throw new TConfigurationException('pageserviceconf_includefile_required');
289
+				}
279 290
 				$filePath = $include['file'];
280
-				if(isset($this->_includes[$filePath]))
281
-					$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
282
-				else
283
-					$this->_includes[$filePath] = [$configPagePath,$when];
291
+				if(isset($this->_includes[$filePath])) {
292
+									$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
293
+				} else {
294
+									$this->_includes[$filePath] = [$configPagePath,$when];
295
+				}
284 296
 			}
285 297
 		}
286 298
 	}
@@ -301,35 +313,41 @@  discard block
 block discarded – undo
301 313
 			{
302 314
 				$patterns = $node->getAttribute('pages');
303 315
 				$ruleApplies = false;
304
-				if(empty($patterns) || trim($patterns) === '*') // null or empty string
316
+				if(empty($patterns) || trim($patterns) === '*') {
317
+					// null or empty string
305 318
 					$ruleApplies = true;
306
-				else
319
+				} else
307 320
 				{
308 321
 					foreach(explode(',', $patterns) as $pattern)
309 322
 					{
310 323
 						if(($pattern = trim($pattern)) !== '')
311 324
 						{
312 325
 							// we know $configPagePath and $this->_pagePath
313
-							if($configPagePath !== '')  // prepend the pattern with ConfigPagePath
326
+							if($configPagePath !== '') {
327
+								// prepend the pattern with ConfigPagePath
314 328
 								$pattern = $configPagePath . '.' . $pattern;
329
+							}
315 330
 							if(strcasecmp($pattern, $this->_pagePath) === 0)
316 331
 							{
317 332
 								$ruleApplies = true;
318 333
 								break;
319 334
 							}
320
-							if($pattern[strlen($pattern) - 1] === '*') // try wildcard matching
335
+							if($pattern[strlen($pattern) - 1] === '*') {
336
+								// try wildcard matching
321 337
 							{
322 338
 								if(strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
323 339
 								{
324 340
 									$ruleApplies = true;
341
+							}
325 342
 									break;
326 343
 								}
327 344
 							}
328 345
 						}
329 346
 					}
330 347
 				}
331
-				if($ruleApplies)
332
-					$rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips'));
348
+				if($ruleApplies) {
349
+									$rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips'));
350
+				}
333 351
 			}
334 352
 			$this->_rules = array_merge($rules, $this->_rules);
335 353
 		}
@@ -343,30 +361,37 @@  discard block
 block discarded – undo
343 361
 			{
344 362
 				$properties = $node->getAttributes();
345 363
 				$id = $properties->remove('id');
346
-				if(empty($id))
347
-					throw new TConfigurationException('pageserviceconf_page_invalid', $configPath);
364
+				if(empty($id)) {
365
+									throw new TConfigurationException('pageserviceconf_page_invalid', $configPath);
366
+				}
348 367
 				$matching = false;
349 368
 				$id = ($configPagePath === '')?$id:$configPagePath . '.' . $id;
350
-				if(strcasecmp($id, $this->_pagePath) === 0)
351
-					$matching = true;
352
-				elseif($id[strlen($id) - 1] === '*') // try wildcard matching
369
+				if(strcasecmp($id, $this->_pagePath) === 0) {
370
+									$matching = true;
371
+				} elseif($id[strlen($id) - 1] === '*') {
372
+					// try wildcard matching
353 373
 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
354
-				if($matching)
355
-					$this->_properties = array_merge($this->_properties, $properties->toArray());
374
+				}
375
+				if($matching) {
376
+									$this->_properties = array_merge($this->_properties, $properties->toArray());
377
+				}
356 378
 			}
357 379
 		}
358 380
 
359 381
 		// external configurations
360 382
 		foreach($dom->getElementsByTagName('include') as $node)
361 383
 		{
362
-			if(($when = $node->getAttribute('when')) === null)
363
-				$when = true;
364
-			if(($filePath = $node->getAttribute('file')) === null)
365
-				throw new TConfigurationException('pageserviceconf_includefile_required');
366
-			if(isset($this->_includes[$filePath]))
367
-				$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
368
-			else
369
-				$this->_includes[$filePath] = [$configPagePath,$when];
384
+			if(($when = $node->getAttribute('when')) === null) {
385
+							$when = true;
386
+			}
387
+			if(($filePath = $node->getAttribute('file')) === null) {
388
+							throw new TConfigurationException('pageserviceconf_includefile_required');
389
+			}
390
+			if(isset($this->_includes[$filePath])) {
391
+							$this->_includes[$filePath] = [$configPagePath,'(' . $this->_includes[$filePath][1] . ') || (' . $when . ')'];
392
+			} else {
393
+							$this->_includes[$filePath] = [$configPagePath,$when];
394
+			}
370 395
 		}
371 396
 	}
372 397
 }
373 398
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Web/Services/TPageService.php 2 patches
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	protected function initPageContext($pageConfig)
175 175
 	{
176 176
 		$application = $this->getApplication();
177
-		foreach($pageConfig->getApplicationConfigurations() as $appConfig)
177
+		foreach ($pageConfig->getApplicationConfigurations() as $appConfig)
178 178
 			$application->applyConfiguration($appConfig);
179 179
 
180 180
 		$this->applyConfiguration($pageConfig);
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 		$this->getApplication()->getAuthorizationRules()->mergeWith($config->getRules());
192 192
 		$pagePath = $this->getRequestedPagePath();
193 193
 		// external configurations
194
-		foreach($config->getExternalConfigurations() as $filePath => $params)
194
+		foreach ($config->getExternalConfigurations() as $filePath => $params)
195 195
 		{
196 196
 			list($configPagePath, $condition) = $params;
197
-			if($condition !== true)
197
+			if ($condition !== true)
198 198
 				$condition = $this->evaluateExpression($condition);
199
-			if($condition)
199
+			if ($condition)
200 200
 			{
201
-				if(($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path))
201
+				if (($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path))
202 202
 					throw new TConfigurationException('pageservice_includefile_invalid', $filePath);
203 203
 				$c = new TPageConfiguration($pagePath);
204 204
 				$c->loadFromFile($path, $configPagePath);
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	protected function determineRequestedPagePath()
216 216
 	{
217 217
 		$pagePath = $this->getRequest()->getServiceParameter();
218
-		if(empty($pagePath))
218
+		if (empty($pagePath))
219 219
 			$pagePath = $this->getDefaultPage();
220 220
 		return $pagePath;
221 221
 	}
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
 	{
230 230
 		$application = $this->getApplication();
231 231
 		$pagePath = $this->getRequestedPagePath();
232
-		if(($cache = $application->getCache()) === null)
232
+		if (($cache = $application->getCache()) === null)
233 233
 		{
234 234
 			$pageConfig = new TPageConfiguration($pagePath);
235
-			if($config !== null)
235
+			if ($config !== null)
236 236
 			{
237
-				if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
237
+				if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
238 238
 					$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
239 239
 				else
240 240
 					$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
@@ -245,25 +245,25 @@  discard block
 block discarded – undo
245 245
 		{
246 246
 			$configCached = true;
247 247
 			$currentTimestamp = [];
248
-			$arr = $cache->get(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath);
249
-			if(is_array($arr))
248
+			$arr = $cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath);
249
+			if (is_array($arr))
250 250
 			{
251 251
 				list($pageConfig, $timestamps) = $arr;
252
-				if($application->getMode() !== TApplicationMode::Performance)
252
+				if ($application->getMode() !== TApplicationMode::Performance)
253 253
 				{
254
-					foreach($timestamps as $fileName => $timestamp)
254
+					foreach ($timestamps as $fileName => $timestamp)
255 255
 					{
256
-						if($fileName === 0) // application config file
256
+						if ($fileName === 0) // application config file
257 257
 						{
258 258
 							$appConfigFile = $application->getConfigurationFile();
259
-							$currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile);
260
-							if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0]))
259
+							$currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile);
260
+							if ($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0]))
261 261
 								$configCached = false;
262 262
 						}
263 263
 						else
264 264
 						{
265 265
 							$currentTimestamp[$fileName] = @filemtime($fileName);
266
-							if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName]))
266
+							if ($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName]))
267 267
 								$configCached = false;
268 268
 						}
269 269
 					}
@@ -277,27 +277,27 @@  discard block
 block discarded – undo
277 277
 				$fileName = $this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP
278 278
 					? self::CONFIG_FILE_PHP
279 279
 					: self::CONFIG_FILE_XML;
280
-				foreach($paths as $path)
280
+				foreach ($paths as $path)
281 281
 				{
282
-					$configFile = $configPath . DIRECTORY_SEPARATOR . $fileName;
282
+					$configFile = $configPath.DIRECTORY_SEPARATOR.$fileName;
283 283
 					$currentTimestamp[$configFile] = @filemtime($configFile);
284
-					$configPath .= DIRECTORY_SEPARATOR . $path;
284
+					$configPath .= DIRECTORY_SEPARATOR.$path;
285 285
 				}
286 286
 				$appConfigFile = $application->getConfigurationFile();
287
-				$currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile);
287
+				$currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile);
288 288
 			}
289
-			if(!$configCached)
289
+			if (!$configCached)
290 290
 			{
291 291
 				$pageConfig = new TPageConfiguration($pagePath);
292
-				if($config !== null)
292
+				if ($config !== null)
293 293
 				{
294
-					if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
294
+					if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
295 295
 						$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
296 296
 					else
297 297
 						$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
298 298
 				}
299 299
 				$pageConfig->loadFromFiles($this->getBasePath());
300
-				$cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, [$pageConfig,$currentTimestamp]);
300
+				$cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath, [$pageConfig, $currentTimestamp]);
301 301
 			}
302 302
 		}
303 303
 		return $pageConfig;
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 */
309 309
 	public function getTemplateManager()
310 310
 	{
311
-		if(!$this->_templateManager)
311
+		if (!$this->_templateManager)
312 312
 		{
313 313
 			$this->_templateManager = new TTemplateManager;
314 314
 			$this->_templateManager->init(null);
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	 */
330 330
 	public function getThemeManager()
331 331
 	{
332
-		if(!$this->_themeManager)
332
+		if (!$this->_themeManager)
333 333
 		{
334 334
 			$this->_themeManager = new TThemeManager;
335 335
 			$this->_themeManager->init(null);
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
 	 */
351 351
 	public function getRequestedPagePath()
352 352
 	{
353
-		if($this->_pagePath === null)
353
+		if ($this->_pagePath === null)
354 354
 		{
355 355
 			$this->_pagePath = strtr($this->determineRequestedPagePath(), '/\\', '..');
356
-			if(empty($this->_pagePath))
356
+			if (empty($this->_pagePath))
357 357
 				throw new THttpException(404, 'pageservice_page_required');
358 358
 		}
359 359
 		return $this->_pagePath;
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 	 */
382 382
 	public function setDefaultPage($value)
383 383
 	{
384
-		if($this->_initialized)
384
+		if ($this->_initialized)
385 385
 			throw new TInvalidOperationException('pageservice_defaultpage_unchangeable');
386 386
 		else
387 387
 			$this->_defaultPage = $value;
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 	 */
401 401
 	public function getBasePath()
402 402
 	{
403
-		if($this->_basePath === null)
403
+		if ($this->_basePath === null)
404 404
 		{
405
-			$basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH;
406
-			if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
405
+			$basePath = $this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH;
406
+			if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
407 407
 			{
408
-				$basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::FALLBACK_BASEPATH;
409
-				if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
408
+				$basePath = $this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH;
409
+				if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
410 410
 					throw new TConfigurationException('pageservice_basepath_invalid', $basePath);
411 411
 			}
412 412
 		}
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
 	 */
420 420
 	public function setBasePath($value)
421 421
 	{
422
-		if($this->_initialized)
422
+		if ($this->_initialized)
423 423
 			throw new TInvalidOperationException('pageservice_basepath_unchangeable');
424
-		elseif(($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path))
424
+		elseif (($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path))
425 425
 			throw new TConfigurationException('pageservice_basepath_invalid', $value);
426 426
 		$this->_basePath = realpath($path);
427 427
 	}
@@ -485,40 +485,40 @@  discard block
 block discarded – undo
485 485
 	 */
486 486
 	protected function createPage($pagePath)
487 487
 	{
488
-		$path = $this->getBasePath() . DIRECTORY_SEPARATOR . strtr($pagePath, '.', DIRECTORY_SEPARATOR);
489
-		$hasTemplateFile = is_file($path . self::PAGE_FILE_EXT);
490
-		$hasClassFile = is_file($path . Prado::CLASS_FILE_EXT);
488
+		$path = $this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath, '.', DIRECTORY_SEPARATOR);
489
+		$hasTemplateFile = is_file($path.self::PAGE_FILE_EXT);
490
+		$hasClassFile = is_file($path.Prado::CLASS_FILE_EXT);
491 491
 
492
-		if(!$hasTemplateFile && !$hasClassFile)
492
+		if (!$hasTemplateFile && !$hasClassFile)
493 493
 			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
494 494
 
495
-		if($hasClassFile)
495
+		if ($hasClassFile)
496 496
 		{
497 497
 			$className = basename($path);
498
-			$namespacedClassName = static::PAGE_NAMESPACE_PREFIX . str_replace('.', '\\', $pagePath);
498
+			$namespacedClassName = static::PAGE_NAMESPACE_PREFIX.str_replace('.', '\\', $pagePath);
499 499
 
500
-			if(!class_exists($className, false) && !class_exists($namespacedClassName, false))
501
-				include_once($path . Prado::CLASS_FILE_EXT);
500
+			if (!class_exists($className, false) && !class_exists($namespacedClassName, false))
501
+				include_once($path.Prado::CLASS_FILE_EXT);
502 502
 
503
-			if(!class_exists($className, false))
503
+			if (!class_exists($className, false))
504 504
 				$className = $namespacedClassName;
505 505
 		}
506 506
 		else
507 507
 		{
508 508
 			$className = $this->getBasePageClass();
509 509
 			Prado::using($className);
510
-			if(($pos = strrpos($className, '.')) !== false)
510
+			if (($pos = strrpos($className, '.')) !== false)
511 511
 				$className = substr($className, $pos + 1);
512 512
 		}
513 513
 
514
-		if($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage'))
514
+		if ($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage'))
515 515
 			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
516 516
 
517 517
 		$page = Prado::createComponent($className);
518 518
 		$page->setPagePath($pagePath);
519 519
 
520
-		if($hasTemplateFile)
521
-			$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT));
520
+		if ($hasTemplateFile)
521
+			$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT));
522 522
 
523 523
 		return $page;
524 524
 	}
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 */
531 531
 	protected function runPage($page, $properties)
532 532
 	{
533
-		foreach($properties as $name => $value)
533
+		foreach ($properties as $name => $value)
534 534
 			$page->setSubProperty($name, $value);
535 535
 		$page->run($this->getResponse()->createHtmlWriter());
536 536
 	}
Please login to merge, or discard this patch.
Braces   +72 added lines, -55 removed lines patch added patch discarded remove patch
@@ -174,8 +174,9 @@  discard block
 block discarded – undo
174 174
 	protected function initPageContext($pageConfig)
175 175
 	{
176 176
 		$application = $this->getApplication();
177
-		foreach($pageConfig->getApplicationConfigurations() as $appConfig)
178
-			$application->applyConfiguration($appConfig);
177
+		foreach($pageConfig->getApplicationConfigurations() as $appConfig) {
178
+					$application->applyConfiguration($appConfig);
179
+		}
179 180
 
180 181
 		$this->applyConfiguration($pageConfig);
181 182
 	}
@@ -194,12 +195,14 @@  discard block
 block discarded – undo
194 195
 		foreach($config->getExternalConfigurations() as $filePath => $params)
195 196
 		{
196 197
 			list($configPagePath, $condition) = $params;
197
-			if($condition !== true)
198
-				$condition = $this->evaluateExpression($condition);
198
+			if($condition !== true) {
199
+							$condition = $this->evaluateExpression($condition);
200
+			}
199 201
 			if($condition)
200 202
 			{
201
-				if(($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path))
202
-					throw new TConfigurationException('pageservice_includefile_invalid', $filePath);
203
+				if(($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path)) {
204
+									throw new TConfigurationException('pageservice_includefile_invalid', $filePath);
205
+				}
203 206
 				$c = new TPageConfiguration($pagePath);
204 207
 				$c->loadFromFile($path, $configPagePath);
205 208
 				$this->applyConfiguration($c);
@@ -215,8 +218,9 @@  discard block
 block discarded – undo
215 218
 	protected function determineRequestedPagePath()
216 219
 	{
217 220
 		$pagePath = $this->getRequest()->getServiceParameter();
218
-		if(empty($pagePath))
219
-			$pagePath = $this->getDefaultPage();
221
+		if(empty($pagePath)) {
222
+					$pagePath = $this->getDefaultPage();
223
+		}
220 224
 		return $pagePath;
221 225
 	}
222 226
 
@@ -234,14 +238,14 @@  discard block
 block discarded – undo
234 238
 			$pageConfig = new TPageConfiguration($pagePath);
235 239
 			if($config !== null)
236 240
 			{
237
-				if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
238
-					$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
239
-				else
240
-					$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
241
+				if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
242
+									$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
243
+				} else {
244
+									$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
245
+				}
241 246
 			}
242 247
 			$pageConfig->loadFromFiles($this->getBasePath());
243
-		}
244
-		else
248
+		} else
245 249
 		{
246 250
 			$configCached = true;
247 251
 			$currentTimestamp = [];
@@ -253,23 +257,25 @@  discard block
 block discarded – undo
253 257
 				{
254 258
 					foreach($timestamps as $fileName => $timestamp)
255 259
 					{
256
-						if($fileName === 0) // application config file
260
+						if($fileName === 0) {
261
+							// application config file
257 262
 						{
258 263
 							$appConfigFile = $application->getConfigurationFile();
259
-							$currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile);
260
-							if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0]))
261
-								$configCached = false;
262 264
 						}
263
-						else
265
+							$currentTimestamp[0] = $appConfigFile === null?0:@filemtime($appConfigFile);
266
+							if($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0])) {
267
+															$configCached = false;
268
+							}
269
+						} else
264 270
 						{
265 271
 							$currentTimestamp[$fileName] = @filemtime($fileName);
266
-							if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName]))
267
-								$configCached = false;
272
+							if($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName])) {
273
+															$configCached = false;
274
+							}
268 275
 						}
269 276
 					}
270 277
 				}
271
-			}
272
-			else
278
+			} else
273 279
 			{
274 280
 				$configCached = false;
275 281
 				$paths = explode('.', $pagePath);
@@ -291,10 +297,11 @@  discard block
 block discarded – undo
291 297
 				$pageConfig = new TPageConfiguration($pagePath);
292 298
 				if($config !== null)
293 299
 				{
294
-					if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
295
-						$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
296
-					else
297
-						$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
300
+					if($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
301
+											$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
302
+					} else {
303
+											$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
304
+					}
298 305
 				}
299 306
 				$pageConfig->loadFromFiles($this->getBasePath());
300 307
 				$cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, [$pageConfig,$currentTimestamp]);
@@ -353,8 +360,9 @@  discard block
 block discarded – undo
353 360
 		if($this->_pagePath === null)
354 361
 		{
355 362
 			$this->_pagePath = strtr($this->determineRequestedPagePath(), '/\\', '..');
356
-			if(empty($this->_pagePath))
357
-				throw new THttpException(404, 'pageservice_page_required');
363
+			if(empty($this->_pagePath)) {
364
+							throw new THttpException(404, 'pageservice_page_required');
365
+			}
358 366
 		}
359 367
 		return $this->_pagePath;
360 368
 	}
@@ -381,10 +389,11 @@  discard block
 block discarded – undo
381 389
 	 */
382 390
 	public function setDefaultPage($value)
383 391
 	{
384
-		if($this->_initialized)
385
-			throw new TInvalidOperationException('pageservice_defaultpage_unchangeable');
386
-		else
387
-			$this->_defaultPage = $value;
392
+		if($this->_initialized) {
393
+					throw new TInvalidOperationException('pageservice_defaultpage_unchangeable');
394
+		} else {
395
+					$this->_defaultPage = $value;
396
+		}
388 397
 	}
389 398
 
390 399
 	/**
@@ -406,8 +415,9 @@  discard block
 block discarded – undo
406 415
 			if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
407 416
 			{
408 417
 				$basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::FALLBACK_BASEPATH;
409
-				if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
410
-					throw new TConfigurationException('pageservice_basepath_invalid', $basePath);
418
+				if(($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath)) {
419
+									throw new TConfigurationException('pageservice_basepath_invalid', $basePath);
420
+				}
411 421
 			}
412 422
 		}
413 423
 		return $this->_basePath;
@@ -419,10 +429,11 @@  discard block
 block discarded – undo
419 429
 	 */
420 430
 	public function setBasePath($value)
421 431
 	{
422
-		if($this->_initialized)
423
-			throw new TInvalidOperationException('pageservice_basepath_unchangeable');
424
-		elseif(($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path))
425
-			throw new TConfigurationException('pageservice_basepath_invalid', $value);
432
+		if($this->_initialized) {
433
+					throw new TInvalidOperationException('pageservice_basepath_unchangeable');
434
+		} elseif(($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path)) {
435
+					throw new TConfigurationException('pageservice_basepath_invalid', $value);
436
+		}
426 437
 		$this->_basePath = realpath($path);
427 438
 	}
428 439
 
@@ -489,36 +500,41 @@  discard block
 block discarded – undo
489 500
 		$hasTemplateFile = is_file($path . self::PAGE_FILE_EXT);
490 501
 		$hasClassFile = is_file($path . Prado::CLASS_FILE_EXT);
491 502
 
492
-		if(!$hasTemplateFile && !$hasClassFile)
493
-			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
503
+		if(!$hasTemplateFile && !$hasClassFile) {
504
+					throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
505
+		}
494 506
 
495 507
 		if($hasClassFile)
496 508
 		{
497 509
 			$className = basename($path);
498 510
 			$namespacedClassName = static::PAGE_NAMESPACE_PREFIX . str_replace('.', '\\', $pagePath);
499 511
 
500
-			if(!class_exists($className, false) && !class_exists($namespacedClassName, false))
501
-				include_once($path . Prado::CLASS_FILE_EXT);
512
+			if(!class_exists($className, false) && !class_exists($namespacedClassName, false)) {
513
+							include_once($path . Prado::CLASS_FILE_EXT);
514
+			}
502 515
 
503
-			if(!class_exists($className, false))
504
-				$className = $namespacedClassName;
505
-		}
506
-		else
516
+			if(!class_exists($className, false)) {
517
+							$className = $namespacedClassName;
518
+			}
519
+		} else
507 520
 		{
508 521
 			$className = $this->getBasePageClass();
509 522
 			Prado::using($className);
510
-			if(($pos = strrpos($className, '.')) !== false)
511
-				$className = substr($className, $pos + 1);
523
+			if(($pos = strrpos($className, '.')) !== false) {
524
+							$className = substr($className, $pos + 1);
525
+			}
512 526
 		}
513 527
 
514
-		if($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage'))
515
-			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
528
+		if($className !== '\Prado\Web\UI\TPage' && !is_subclass_of($className, '\Prado\Web\UI\TPage')) {
529
+					throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
530
+		}
516 531
 
517 532
 		$page = Prado::createComponent($className);
518 533
 		$page->setPagePath($pagePath);
519 534
 
520
-		if($hasTemplateFile)
521
-			$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT));
535
+		if($hasTemplateFile) {
536
+					$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT));
537
+		}
522 538
 
523 539
 		return $page;
524 540
 	}
@@ -530,8 +546,9 @@  discard block
 block discarded – undo
530 546
 	 */
531 547
 	protected function runPage($page, $properties)
532 548
 	{
533
-		foreach($properties as $name => $value)
534
-			$page->setSubProperty($name, $value);
549
+		foreach($properties as $name => $value) {
550
+					$page->setSubProperty($name, $value);
551
+		}
535 552
 		$page->run($this->getResponse()->createHtmlWriter());
536 553
 	}
537 554
 
Please login to merge, or discard this patch.
framework/Web/Services/TJsonRpcProtocol.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -40,31 +40,31 @@  discard block
 block discarded – undo
40 40
 		{
41 41
 			$_request = $this->decode($requestPayload);
42 42
 
43
-			if(isset($_request['jsonrpc']))
43
+			if (isset($_request['jsonrpc']))
44 44
 			{
45 45
 				$this->_specificationVersion = $_request['jsonrpc'];
46
-				if($this->_specificationVersion > 2.0)
46
+				if ($this->_specificationVersion > 2.0)
47 47
 					throw new TRpcException('Unsupported specification version', '-32600');
48 48
 			}
49 49
 
50
-			if(isset($_request['id']))
50
+			if (isset($_request['id']))
51 51
 				$this->_id = $_request['id'];
52 52
 
53
-			if(!isset($_request['method']))
53
+			if (!isset($_request['method']))
54 54
 					throw new TRpcException('Missing request method', '-32600');
55 55
 
56
-			if(!isset($_request['params']))
56
+			if (!isset($_request['params']))
57 57
 				$parameters = [];
58 58
 			else
59 59
 				$parameters = $_request['params'];
60 60
 
61
-			if(!is_array($parameters))
61
+			if (!is_array($parameters))
62 62
 				$parameters = [$parameters];
63 63
 
64 64
 			// a request without an id is a notification that doesn't need a response
65
-			if($this->_id !== null)
65
+			if ($this->_id !== null)
66 66
 			{
67
-				if($this->_specificationVersion == 2.0)
67
+				if ($this->_specificationVersion == 2.0)
68 68
 				{
69 69
 					return $this->encode([
70 70
 						'jsonrpc' => '2.0',
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 				}
81 81
 			}
82 82
 		}
83
-		catch(TRpcException $e)
83
+		catch (TRpcException $e)
84 84
 		{
85 85
 			return $this->createErrorResponse($e);
86 86
 		}
87
-		catch(THttpException $e)
87
+		catch (THttpException $e)
88 88
 		{
89 89
 			throw $e;
90 90
 		}
91
-		catch(\Exception $e)
91
+		catch (\Exception $e)
92 92
 		{
93 93
 			return $this->createErrorResponse(new TRpcException('An internal error occured', '-32603'));
94 94
 		}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function createErrorResponse(TRpcException $exception)
103 103
 	{
104
-		if($this->_specificationVersion == 2.0)
104
+		if ($this->_specificationVersion == 2.0)
105 105
 		{
106 106
 			return $this->encode([
107 107
 				'id' => $this->_id,
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	private static function checkJsonError()
162 162
 	{
163 163
 		$errnum = json_last_error();
164
-		if($errnum != JSON_ERROR_NONE)
164
+		if ($errnum != JSON_ERROR_NONE)
165 165
 			throw new \Exception("JSON error: $msg", $err);
166 166
 	}
167 167
 
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	public function callApiMethod($methodName, $parameters)
176 176
 	{
177
-		if(!isset($this->rpcMethods[$methodName]))
178
-			throw new TRpcException('Method "' . $methodName . '" not found', '-32601');
177
+		if (!isset($this->rpcMethods[$methodName]))
178
+			throw new TRpcException('Method "'.$methodName.'" not found', '-32601');
179 179
 
180 180
 		return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters);
181 181
 	}
Please login to merge, or discard this patch.
Braces   +26 added lines, -22 removed lines patch added patch discarded remove patch
@@ -43,23 +43,28 @@  discard block
 block discarded – undo
43 43
 			if(isset($_request['jsonrpc']))
44 44
 			{
45 45
 				$this->_specificationVersion = $_request['jsonrpc'];
46
-				if($this->_specificationVersion > 2.0)
47
-					throw new TRpcException('Unsupported specification version', '-32600');
46
+				if($this->_specificationVersion > 2.0) {
47
+									throw new TRpcException('Unsupported specification version', '-32600');
48
+				}
48 49
 			}
49 50
 
50
-			if(isset($_request['id']))
51
-				$this->_id = $_request['id'];
51
+			if(isset($_request['id'])) {
52
+							$this->_id = $_request['id'];
53
+			}
52 54
 
53
-			if(!isset($_request['method']))
54
-					throw new TRpcException('Missing request method', '-32600');
55
+			if(!isset($_request['method'])) {
56
+								throw new TRpcException('Missing request method', '-32600');
57
+			}
55 58
 
56
-			if(!isset($_request['params']))
57
-				$parameters = [];
58
-			else
59
-				$parameters = $_request['params'];
59
+			if(!isset($_request['params'])) {
60
+							$parameters = [];
61
+			} else {
62
+							$parameters = $_request['params'];
63
+			}
60 64
 
61
-			if(!is_array($parameters))
62
-				$parameters = [$parameters];
65
+			if(!is_array($parameters)) {
66
+							$parameters = [$parameters];
67
+			}
63 68
 
64 69
 			// a request without an id is a notification that doesn't need a response
65 70
 			if($this->_id !== null)
@@ -79,16 +84,13 @@  discard block
 block discarded – undo
79 84
 					]);
80 85
 				}
81 86
 			}
82
-		}
83
-		catch(TRpcException $e)
87
+		} catch(TRpcException $e)
84 88
 		{
85 89
 			return $this->createErrorResponse($e);
86
-		}
87
-		catch(THttpException $e)
90
+		} catch(THttpException $e)
88 91
 		{
89 92
 			throw $e;
90
-		}
91
-		catch(\Exception $e)
93
+		} catch(\Exception $e)
92 94
 		{
93 95
 			return $this->createErrorResponse(new TRpcException('An internal error occured', '-32603'));
94 96
 		}
@@ -161,8 +163,9 @@  discard block
 block discarded – undo
161 163
 	private static function checkJsonError()
162 164
 	{
163 165
 		$errnum = json_last_error();
164
-		if($errnum != JSON_ERROR_NONE)
165
-			throw new \Exception("JSON error: $msg", $err);
166
+		if($errnum != JSON_ERROR_NONE) {
167
+					throw new \Exception("JSON error: $msg", $err);
168
+		}
166 169
 	}
167 170
 
168 171
 	/**
@@ -174,8 +177,9 @@  discard block
 block discarded – undo
174 177
 	 */
175 178
 	public function callApiMethod($methodName, $parameters)
176 179
 	{
177
-		if(!isset($this->rpcMethods[$methodName]))
178
-			throw new TRpcException('Method "' . $methodName . '" not found', '-32601');
180
+		if(!isset($this->rpcMethods[$methodName])) {
181
+					throw new TRpcException('Method "' . $methodName . '" not found', '-32601');
182
+		}
179 183
 
180 184
 		return call_user_func_array($this->rpcMethods[$methodName]['method'], $parameters);
181 185
 	}
Please login to merge, or discard this patch.
framework/Web/Services/TRpcService.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -94,28 +94,28 @@  discard block
 block discarded – undo
94 94
 	{
95 95
 		$_properties = $this->apiProviders[$providerId];
96 96
 
97
-		if(($_providerClass = $_properties->remove('class')) === null)
97
+		if (($_providerClass = $_properties->remove('class')) === null)
98 98
 			throw new TConfigurationException('rpcservice_apiprovider_required');
99 99
 
100 100
 		Prado::using($_providerClass);
101 101
 
102 102
 		$_providerClassName = ($_pos = strrpos($_providerClass, '.')) !== false ? substr($_providerClass, $_pos + 1) : $_providerClass;
103
-		if(!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER))
103
+		if (!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER))
104 104
 			throw new TConfigurationException('rpcservice_apiprovider_invalid');
105 105
 
106
-		if(($_rpcServerClass = $_properties->remove('server')) === null)
106
+		if (($_rpcServerClass = $_properties->remove('server')) === null)
107 107
 			$_rpcServerClass = self::BASE_RPC_SERVER;
108 108
 
109 109
 		Prado::using($_rpcServerClass);
110 110
 
111 111
 		$_rpcServerClassName = ($_pos = strrpos($_rpcServerClass, '.')) !== false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass;
112
-		if($_rpcServerClassName !== self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER))
112
+		if ($_rpcServerClassName !== self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER))
113 113
 			throw new TConfigurationException('rpcservice_rpcserver_invalid');
114 114
 
115 115
 		$_apiProvider = new $_providerClassName(new $_rpcServerClassName($protocolHandler));
116 116
 		$_apiProvider->setId($providerId);
117 117
 
118
-		foreach($_properties as $_key => $_value)
118
+		foreach ($_properties as $_key => $_value)
119 119
 			$_apiProvider->setSubProperty($_key, $_value);
120 120
 
121 121
 		return $_apiProvider;
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	public function loadConfig(TXmlElement $xml)
138 138
 	{
139
-		foreach($xml->getElementsByTagName('rpcapi') as $_apiProviderXml)
139
+		foreach ($xml->getElementsByTagName('rpcapi') as $_apiProviderXml)
140 140
 		{
141 141
 			$_properties = $_apiProviderXml->getAttributes();
142 142
 
143
-			if(($_id = $_properties->remove('id')) === null || $_id == "")
143
+			if (($_id = $_properties->remove('id')) === null || $_id == "")
144 144
 				throw new TConfigurationException('rpcservice_apiproviderid_required');
145 145
 
146
-			if(isset($this->apiProviders[$_id]))
146
+			if (isset($this->apiProviders[$_id]))
147 147
 				throw new TConfigurationException('rpcservice_apiproviderid_duplicated');
148 148
 
149 149
 			$this->apiProviders[$_id] = $_properties;
@@ -157,22 +157,22 @@  discard block
 block discarded – undo
157 157
 	{
158 158
 		$_request = $this->getRequest();
159 159
 
160
-		if(($_providerId = $_request->getServiceParameter()) == "")
160
+		if (($_providerId = $_request->getServiceParameter()) == "")
161 161
 			throw new THttpException(400, 'RPC API-Provider id required');
162 162
 		
163
-		if(($_method = $_request->getRequestType()) != 'POST')
164
-			throw new THttpException(405, 'Invalid request method "' . $_method . '"!'); // TODO Exception muss "Allow POST" Header setzen
163
+		if (($_method = $_request->getRequestType()) != 'POST')
164
+			throw new THttpException(405, 'Invalid request method "'.$_method.'"!'); // TODO Exception muss "Allow POST" Header setzen
165 165
 
166
-		if(($_mimeType = $_request->getContentType()) === null)
166
+		if (($_mimeType = $_request->getContentType()) === null)
167 167
 			throw new THttpException(406, 'Content-Type is missing!'); // TODO Exception muss gültige Content-Type werte zurück geben
168 168
 
169
-		if(!in_array($_mimeType, array_keys($this->protocolHandlers)))
169
+		if (!in_array($_mimeType, array_keys($this->protocolHandlers)))
170 170
 			throw new THttpException(406, 'Unsupported Content-Type!'); // TODO see previous
171 171
 
172 172
 		$_protocolHandlerClass = $this->protocolHandlers[$_mimeType];
173 173
 		$_protocolHandler = new $_protocolHandlerClass;
174 174
 
175
-		if(($_result = $this->createApiProvider($_protocolHandler, $_providerId)->processRequest()) !== null)
175
+		if (($_result = $this->createApiProvider($_protocolHandler, $_providerId)->processRequest()) !== null)
176 176
 		{
177 177
 			$_response = $this->getResponse();
178 178
 			$_protocolHandler->createResponseHeaders($_response);
Please login to merge, or discard this patch.
Braces   +36 added lines, -22 removed lines patch added patch discarded remove patch
@@ -94,29 +94,34 @@  discard block
 block discarded – undo
94 94
 	{
95 95
 		$_properties = $this->apiProviders[$providerId];
96 96
 
97
-		if(($_providerClass = $_properties->remove('class')) === null)
98
-			throw new TConfigurationException('rpcservice_apiprovider_required');
97
+		if(($_providerClass = $_properties->remove('class')) === null) {
98
+					throw new TConfigurationException('rpcservice_apiprovider_required');
99
+		}
99 100
 
100 101
 		Prado::using($_providerClass);
101 102
 
102 103
 		$_providerClassName = ($_pos = strrpos($_providerClass, '.')) !== false ? substr($_providerClass, $_pos + 1) : $_providerClass;
103
-		if(!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER))
104
-			throw new TConfigurationException('rpcservice_apiprovider_invalid');
104
+		if(!is_subclass_of($_providerClassName, self::BASE_API_PROVIDER)) {
105
+					throw new TConfigurationException('rpcservice_apiprovider_invalid');
106
+		}
105 107
 
106
-		if(($_rpcServerClass = $_properties->remove('server')) === null)
107
-			$_rpcServerClass = self::BASE_RPC_SERVER;
108
+		if(($_rpcServerClass = $_properties->remove('server')) === null) {
109
+					$_rpcServerClass = self::BASE_RPC_SERVER;
110
+		}
108 111
 
109 112
 		Prado::using($_rpcServerClass);
110 113
 
111 114
 		$_rpcServerClassName = ($_pos = strrpos($_rpcServerClass, '.')) !== false ? substr($_rpcServerClass, $_pos + 1) : $_rpcServerClass;
112
-		if($_rpcServerClassName !== self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER))
113
-			throw new TConfigurationException('rpcservice_rpcserver_invalid');
115
+		if($_rpcServerClassName !== self::BASE_RPC_SERVER && !is_subclass_of($_rpcServerClassName, self::BASE_RPC_SERVER)) {
116
+					throw new TConfigurationException('rpcservice_rpcserver_invalid');
117
+		}
114 118
 
115 119
 		$_apiProvider = new $_providerClassName(new $_rpcServerClassName($protocolHandler));
116 120
 		$_apiProvider->setId($providerId);
117 121
 
118
-		foreach($_properties as $_key => $_value)
119
-			$_apiProvider->setSubProperty($_key, $_value);
122
+		foreach($_properties as $_key => $_value) {
123
+					$_apiProvider->setSubProperty($_key, $_value);
124
+		}
120 125
 
121 126
 		return $_apiProvider;
122 127
 	}
@@ -140,11 +145,13 @@  discard block
 block discarded – undo
140 145
 		{
141 146
 			$_properties = $_apiProviderXml->getAttributes();
142 147
 
143
-			if(($_id = $_properties->remove('id')) === null || $_id == "")
144
-				throw new TConfigurationException('rpcservice_apiproviderid_required');
148
+			if(($_id = $_properties->remove('id')) === null || $_id == "") {
149
+							throw new TConfigurationException('rpcservice_apiproviderid_required');
150
+			}
145 151
 
146
-			if(isset($this->apiProviders[$_id]))
147
-				throw new TConfigurationException('rpcservice_apiproviderid_duplicated');
152
+			if(isset($this->apiProviders[$_id])) {
153
+							throw new TConfigurationException('rpcservice_apiproviderid_duplicated');
154
+			}
148 155
 
149 156
 			$this->apiProviders[$_id] = $_properties;
150 157
 		}
@@ -157,17 +164,24 @@  discard block
 block discarded – undo
157 164
 	{
158 165
 		$_request = $this->getRequest();
159 166
 
160
-		if(($_providerId = $_request->getServiceParameter()) == "")
161
-			throw new THttpException(400, 'RPC API-Provider id required');
167
+		if(($_providerId = $_request->getServiceParameter()) == "") {
168
+					throw new THttpException(400, 'RPC API-Provider id required');
169
+		}
162 170
 		
163
-		if(($_method = $_request->getRequestType()) != 'POST')
164
-			throw new THttpException(405, 'Invalid request method "' . $_method . '"!'); // TODO Exception muss "Allow POST" Header setzen
171
+		if(($_method = $_request->getRequestType()) != 'POST') {
172
+					throw new THttpException(405, 'Invalid request method "' . $_method . '"!');
173
+		}
174
+		// TODO Exception muss "Allow POST" Header setzen
165 175
 
166
-		if(($_mimeType = $_request->getContentType()) === null)
167
-			throw new THttpException(406, 'Content-Type is missing!'); // TODO Exception muss gültige Content-Type werte zurück geben
176
+		if(($_mimeType = $_request->getContentType()) === null) {
177
+					throw new THttpException(406, 'Content-Type is missing!');
178
+		}
179
+		// TODO Exception muss gültige Content-Type werte zurück geben
168 180
 
169
-		if(!in_array($_mimeType, array_keys($this->protocolHandlers)))
170
-			throw new THttpException(406, 'Unsupported Content-Type!'); // TODO see previous
181
+		if(!in_array($_mimeType, array_keys($this->protocolHandlers))) {
182
+					throw new THttpException(406, 'Unsupported Content-Type!');
183
+		}
184
+		// TODO see previous
171 185
 
172 186
 		$_protocolHandlerClass = $this->protocolHandlers[$_mimeType];
173 187
 		$_protocolHandler = new $_protocolHandlerClass;
Please login to merge, or discard this patch.
framework/Web/Services/TJsonService.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	protected function loadJsonServices($config)
82 82
 	{
83
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
83
+		if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
84 84
 		{
85
-			if(is_array($config))
85
+			if (is_array($config))
86 86
 			{
87
-				foreach($config['json'] as $id => $json)
87
+				foreach ($config['json'] as $id => $json)
88 88
 					$this->_services[$id] = $json;
89 89
 			}
90 90
 		}
91 91
 		else
92 92
 		{
93
-			foreach($config->getElementsByTagName('json') as $json)
93
+			foreach ($config->getElementsByTagName('json') as $json)
94 94
 			{
95
-				if(($id = $json->getAttribute('id')) !== null)
95
+				if (($id = $json->getAttribute('id')) !== null)
96 96
 					$this->_services[$id] = $json;
97 97
 				else
98 98
 					throw new TConfigurationException('jsonservice_id_required');
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 	public function run()
108 108
 	{
109 109
 		$id = $this->getRequest()->getServiceParameter();
110
-		if(isset($this->_services[$id]))
110
+		if (isset($this->_services[$id]))
111 111
 		{
112 112
 			$serviceConfig = $this->_services[$id];
113
-			if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
113
+			if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
114 114
 			{
115
-				if(isset($serviceConfig['class']))
115
+				if (isset($serviceConfig['class']))
116 116
 				{
117 117
 					$service = Prado::createComponent($serviceConfig['class']);
118
-					if($service instanceof TJsonResponse)
118
+					if ($service instanceof TJsonResponse)
119 119
 					{
120
-						$properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:[];
120
+						$properties = isset($serviceConfig['properties']) ? $serviceConfig['properties'] : [];
121 121
 						$this->createJsonResponse($service, $properties, $serviceConfig);
122 122
 					}
123 123
 					else
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
 			else
130 130
 			{
131 131
 				$properties = $serviceConfig->getAttributes();
132
-				if(($class = $properties->remove('class')) !== null)
132
+				if (($class = $properties->remove('class')) !== null)
133 133
 				{
134 134
 					$service = Prado::createComponent($class);
135
-					if($service instanceof TJsonResponse)
135
+					if ($service instanceof TJsonResponse)
136 136
 						$this->createJsonResponse($service, $properties, $serviceConfig);
137 137
 					else
138 138
 						throw new TConfigurationException('jsonservice_response_type_invalid', $id);
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	protected function createJsonResponse($service, $properties, $config)
153 153
 	{
154 154
 		// init service properties
155
-		foreach($properties as $name => $value)
155
+		foreach ($properties as $name => $value)
156 156
 			$service->setSubproperty($name, $value);
157 157
 		$service->init($config);
158 158
 
159 159
 		//send content if not null
160
-		if(($content = $service->getJsonContent()) !== null)
160
+		if (($content = $service->getJsonContent()) !== null)
161 161
 		{
162 162
 			$response = $this->getResponse();
163 163
 			$response->setContentType('application/json');
Please login to merge, or discard this patch.
Braces   +26 added lines, -24 removed lines patch added patch discarded remove patch
@@ -84,18 +84,19 @@  discard block
 block discarded – undo
84 84
 		{
85 85
 			if(is_array($config))
86 86
 			{
87
-				foreach($config['json'] as $id => $json)
88
-					$this->_services[$id] = $json;
87
+				foreach($config['json'] as $id => $json) {
88
+									$this->_services[$id] = $json;
89
+				}
89 90
 			}
90
-		}
91
-		else
91
+		} else
92 92
 		{
93 93
 			foreach($config->getElementsByTagName('json') as $json)
94 94
 			{
95
-				if(($id = $json->getAttribute('id')) !== null)
96
-					$this->_services[$id] = $json;
97
-				else
98
-					throw new TConfigurationException('jsonservice_id_required');
95
+				if(($id = $json->getAttribute('id')) !== null) {
96
+									$this->_services[$id] = $json;
97
+				} else {
98
+									throw new TConfigurationException('jsonservice_id_required');
99
+				}
99 100
 			}
100 101
 		}
101 102
 	}
@@ -119,30 +120,30 @@  discard block
 block discarded – undo
119 120
 					{
120 121
 						$properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:[];
121 122
 						$this->createJsonResponse($service, $properties, $serviceConfig);
123
+					} else {
124
+											throw new TConfigurationException('jsonservice_response_type_invalid', $id);
122 125
 					}
123
-					else
124
-						throw new TConfigurationException('jsonservice_response_type_invalid', $id);
126
+				} else {
127
+									throw new TConfigurationException('jsonservice_class_required', $id);
125 128
 				}
126
-				else
127
-					throw new TConfigurationException('jsonservice_class_required', $id);
128
-			}
129
-			else
129
+			} else
130 130
 			{
131 131
 				$properties = $serviceConfig->getAttributes();
132 132
 				if(($class = $properties->remove('class')) !== null)
133 133
 				{
134 134
 					$service = Prado::createComponent($class);
135
-					if($service instanceof TJsonResponse)
136
-						$this->createJsonResponse($service, $properties, $serviceConfig);
137
-					else
138
-						throw new TConfigurationException('jsonservice_response_type_invalid', $id);
135
+					if($service instanceof TJsonResponse) {
136
+											$this->createJsonResponse($service, $properties, $serviceConfig);
137
+					} else {
138
+											throw new TConfigurationException('jsonservice_response_type_invalid', $id);
139
+					}
140
+				} else {
141
+									throw new TConfigurationException('jsonservice_class_required', $id);
139 142
 				}
140
-				else
141
-					throw new TConfigurationException('jsonservice_class_required', $id);
142 143
 			}
144
+		} else {
145
+					throw new THttpException(404, 'jsonservice_provider_unknown', $id);
143 146
 		}
144
-		else
145
-			throw new THttpException(404, 'jsonservice_provider_unknown', $id);
146 147
 	}
147 148
 
148 149
 	/**
@@ -152,8 +153,9 @@  discard block
 block discarded – undo
152 153
 	protected function createJsonResponse($service, $properties, $config)
153 154
 	{
154 155
 		// init service properties
155
-		foreach($properties as $name => $value)
156
-			$service->setSubproperty($name, $value);
156
+		foreach($properties as $name => $value) {
157
+					$service->setSubproperty($name, $value);
158
+		}
157 159
 		$service->init($config);
158 160
 
159 161
 		//send content if not null
Please login to merge, or discard this patch.
framework/Web/Services/TSoapServer.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function setID($id)
64 64
 	{
65
-		if(strrpos($this->_id, '.wsdl') === strlen($this->_id) - 5)
65
+		if (strrpos($this->_id, '.wsdl') === strlen($this->_id) - 5)
66 66
 			throw new TInvalidDataValueException('soapserver_id_invalid', $id);
67 67
 		$this->_id = $id;
68 68
 	}
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function run()
74 74
 	{
75
-		if(($provider = $this->getProvider()) !== null)
75
+		if (($provider = $this->getProvider()) !== null)
76 76
 		{
77 77
 			Prado::using($provider);
78
-			$providerClass = ($pos = strrpos($provider, '.')) !== false?substr($provider, $pos + 1):$provider;
78
+			$providerClass = ($pos = strrpos($provider, '.')) !== false ?substr($provider, $pos + 1) : $provider;
79 79
 			$this->guessMethodCallRequested($providerClass);
80 80
 			$server = $this->createServer();
81 81
 			$server->setClass($providerClass, $this);
82
-			if($this->_persistent)
82
+			if ($this->_persistent)
83 83
 				$server->setPersistence(SOAP_PERSISTENCE_SESSION);
84 84
 		}
85 85
 		else
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		}
91 91
 		catch (\Exception $e)
92 92
 		{
93
-			if($this->getApplication()->getMode() === TApplicationMode::Debug)
93
+			if ($this->getApplication()->getMode() === TApplicationMode::Debug)
94 94
 				$this->fault($e->getMessage(), $e->__toString());
95 95
 			else
96 96
 				$this->fault($e->getMessage());
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function fault($title, $details = '', $code = 'SERVER', $actor = '', $name = '')
109 109
 	{
110
-		Prado::trace('SOAP-Fault ' . $code . ' ' . $title . ' : ' . $details, 'Prado\Web\Services\TSoapService');
110
+		Prado::trace('SOAP-Fault '.$code.' '.$title.' : '.$details, 'Prado\Web\Services\TSoapService');
111 111
 		$this->_server->fault($code, $title, $actor, $details, $name);
112 112
 	}
113 113
 
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	protected function guessMethodCallRequested($class)
120 120
 	{
121
-		$namespace = $class . 'wsdl';
121
+		$namespace = $class.'wsdl';
122 122
 		$message = file_get_contents("php://input");
123 123
 		$matches = [];
124
-		if(preg_match('/xmlns:([^=]+)="urn:' . $namespace . '"/', $message, $matches))
124
+		if (preg_match('/xmlns:([^=]+)="urn:'.$namespace.'"/', $message, $matches))
125 125
 		{
126
-			if(preg_match('/<' . $matches[1] . ':([a-zA-Z_]+[a-zA-Z0-9_]+)/', $message, $method))
126
+			if (preg_match('/<'.$matches[1].':([a-zA-Z_]+[a-zA-Z0-9_]+)/', $message, $method))
127 127
 			{
128 128
 				$this->_requestedMethod = $method[1];
129 129
 			}
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	protected function createServer()
147 147
 	{
148
-		if($this->_server === null)
148
+		if ($this->_server === null)
149 149
 		{
150
-			if($this->getApplication()->getMode() === TApplicationMode::Debug)
150
+			if ($this->getApplication()->getMode() === TApplicationMode::Debug)
151 151
 				ini_set("soap.wsdl_cache_enabled", 0);
152 152
 			$this->_server = new \SoapServer($this->getWsdlUri(), $this->getOptions());
153 153
 		}
@@ -160,19 +160,19 @@  discard block
 block discarded – undo
160 160
 	protected function getOptions()
161 161
 	{
162 162
 		$options = [];
163
-		if($this->_version === '1.1')
163
+		if ($this->_version === '1.1')
164 164
 			$options['soap_version'] = SOAP_1_1;
165
-		elseif($this->_version === '1.2')
165
+		elseif ($this->_version === '1.2')
166 166
 			$options['soap_version'] = SOAP_1_2;
167
-		if(!empty($this->_actor))
167
+		if (!empty($this->_actor))
168 168
 			$options['actor'] = $this->_actor;
169
-		if(!empty($this->_encoding))
169
+		if (!empty($this->_encoding))
170 170
 			$options['encoding'] = $this->_encoding;
171
-		if(!empty($this->_uri))
171
+		if (!empty($this->_uri))
172 172
 			$options['uri'] = $this->_uri;
173
-		if(is_string($this->_classMap))
173
+		if (is_string($this->_classMap))
174 174
 		{
175
-			foreach(preg_split('/\s*,\s*/', $this->_classMap) as $className)
175
+			foreach (preg_split('/\s*,\s*/', $this->_classMap) as $className)
176 176
 				$options['classmap'][$className] = $className; //complex type uses the class name in the wsdl
177 177
 		}
178 178
 		return $options;
@@ -187,18 +187,18 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	public function getWsdl()
189 189
 	{
190
-		if($this->_wsdlUri === '')
190
+		if ($this->_wsdlUri === '')
191 191
 		{
192 192
 			$provider = $this->getProvider();
193
-			$providerClass = ($pos = strrpos($provider, '.')) !== false?substr($provider, $pos + 1):$provider;
193
+			$providerClass = ($pos = strrpos($provider, '.')) !== false ?substr($provider, $pos + 1) : $provider;
194 194
 			Prado::using($provider);
195
-			if($this->getApplication()->getMode() === TApplicationMode::Performance && ($cache = $this->getApplication()->getCache()) !== null)
195
+			if ($this->getApplication()->getMode() === TApplicationMode::Performance && ($cache = $this->getApplication()->getCache()) !== null)
196 196
 			{
197
-				$wsdl = $cache->get(self::WSDL_CACHE_PREFIX . $providerClass);
198
-				if(is_string($wsdl))
197
+				$wsdl = $cache->get(self::WSDL_CACHE_PREFIX.$providerClass);
198
+				if (is_string($wsdl))
199 199
 					return $wsdl;
200 200
 				$wsdl = WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding());
201
-				$cache->set(self::WSDL_CACHE_PREFIX . $providerClass, $wsdl);
201
+				$cache->set(self::WSDL_CACHE_PREFIX.$providerClass, $wsdl);
202 202
 				return $wsdl;
203 203
 			}
204 204
 			else
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function getWsdlUri()
217 217
 	{
218
-		if($this->_wsdlUri === '')
219
-			return $this->getRequest()->getBaseUrl() . $this->getService()->constructUrl($this->getID() . '.wsdl', false);
218
+		if ($this->_wsdlUri === '')
219
+			return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID().'.wsdl', false);
220 220
 		else
221 221
 			return $this->_wsdlUri;
222 222
 	}
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 	 */
235 235
 	public function getUri()
236 236
 	{
237
-		if($this->_uri === '')
238
-			return $this->getRequest()->getBaseUrl() . $this->getService()->constructUrl($this->getID(), false);
237
+		if ($this->_uri === '')
238
+			return $this->getRequest()->getBaseUrl().$this->getService()->constructUrl($this->getID(), false);
239 239
 		else
240 240
 			return $this->_uri;
241 241
 	}
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	public function setVersion($value)
280 280
 	{
281
-		if($value === '1.1' || $value === '1.2' || $value === '')
281
+		if ($value === '1.1' || $value === '1.2' || $value === '')
282 282
 			$this->_version = $value;
283 283
 		else
284 284
 			throw new TInvalidDataValueException('soapserver_version_invalid', $value);
Please login to merge, or discard this patch.
Braces   +56 added lines, -44 removed lines patch added patch discarded remove patch
@@ -62,8 +62,9 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function setID($id)
64 64
 	{
65
-		if(strrpos($this->_id, '.wsdl') === strlen($this->_id) - 5)
66
-			throw new TInvalidDataValueException('soapserver_id_invalid', $id);
65
+		if(strrpos($this->_id, '.wsdl') === strlen($this->_id) - 5) {
66
+					throw new TInvalidDataValueException('soapserver_id_invalid', $id);
67
+		}
67 68
 		$this->_id = $id;
68 69
 	}
69 70
 
@@ -79,21 +80,22 @@  discard block
 block discarded – undo
79 80
 			$this->guessMethodCallRequested($providerClass);
80 81
 			$server = $this->createServer();
81 82
 			$server->setClass($providerClass, $this);
82
-			if($this->_persistent)
83
-				$server->setPersistence(SOAP_PERSISTENCE_SESSION);
83
+			if($this->_persistent) {
84
+							$server->setPersistence(SOAP_PERSISTENCE_SESSION);
85
+			}
86
+		} else {
87
+					$server = $this->createServer();
84 88
 		}
85
-		else
86
-			$server = $this->createServer();
87 89
 		try
88 90
 		{
89 91
 			$server->handle();
90
-		}
91
-		catch (\Exception $e)
92
+		} catch (\Exception $e)
92 93
 		{
93
-			if($this->getApplication()->getMode() === TApplicationMode::Debug)
94
-				$this->fault($e->getMessage(), $e->__toString());
95
-			else
96
-				$this->fault($e->getMessage());
94
+			if($this->getApplication()->getMode() === TApplicationMode::Debug) {
95
+							$this->fault($e->getMessage(), $e->__toString());
96
+			} else {
97
+							$this->fault($e->getMessage());
98
+			}
97 99
 		}
98 100
 	}
99 101
 
@@ -147,8 +149,9 @@  discard block
 block discarded – undo
147 149
 	{
148 150
 		if($this->_server === null)
149 151
 		{
150
-			if($this->getApplication()->getMode() === TApplicationMode::Debug)
151
-				ini_set("soap.wsdl_cache_enabled", 0);
152
+			if($this->getApplication()->getMode() === TApplicationMode::Debug) {
153
+							ini_set("soap.wsdl_cache_enabled", 0);
154
+			}
152 155
 			$this->_server = new \SoapServer($this->getWsdlUri(), $this->getOptions());
153 156
 		}
154 157
 		return $this->_server;
@@ -160,20 +163,26 @@  discard block
 block discarded – undo
160 163
 	protected function getOptions()
161 164
 	{
162 165
 		$options = [];
163
-		if($this->_version === '1.1')
164
-			$options['soap_version'] = SOAP_1_1;
165
-		elseif($this->_version === '1.2')
166
-			$options['soap_version'] = SOAP_1_2;
167
-		if(!empty($this->_actor))
168
-			$options['actor'] = $this->_actor;
169
-		if(!empty($this->_encoding))
170
-			$options['encoding'] = $this->_encoding;
171
-		if(!empty($this->_uri))
172
-			$options['uri'] = $this->_uri;
166
+		if($this->_version === '1.1') {
167
+					$options['soap_version'] = SOAP_1_1;
168
+		} elseif($this->_version === '1.2') {
169
+					$options['soap_version'] = SOAP_1_2;
170
+		}
171
+		if(!empty($this->_actor)) {
172
+					$options['actor'] = $this->_actor;
173
+		}
174
+		if(!empty($this->_encoding)) {
175
+					$options['encoding'] = $this->_encoding;
176
+		}
177
+		if(!empty($this->_uri)) {
178
+					$options['uri'] = $this->_uri;
179
+		}
173 180
 		if(is_string($this->_classMap))
174 181
 		{
175
-			foreach(preg_split('/\s*,\s*/', $this->_classMap) as $className)
176
-				$options['classmap'][$className] = $className; //complex type uses the class name in the wsdl
182
+			foreach(preg_split('/\s*,\s*/', $this->_classMap) as $className) {
183
+							$options['classmap'][$className] = $className;
184
+			}
185
+			//complex type uses the class name in the wsdl
177 186
 		}
178 187
 		return $options;
179 188
 	}
@@ -195,19 +204,19 @@  discard block
 block discarded – undo
195 204
 			if($this->getApplication()->getMode() === TApplicationMode::Performance && ($cache = $this->getApplication()->getCache()) !== null)
196 205
 			{
197 206
 				$wsdl = $cache->get(self::WSDL_CACHE_PREFIX . $providerClass);
198
-				if(is_string($wsdl))
199
-					return $wsdl;
207
+				if(is_string($wsdl)) {
208
+									return $wsdl;
209
+				}
200 210
 				$wsdl = WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding());
201 211
 				$cache->set(self::WSDL_CACHE_PREFIX . $providerClass, $wsdl);
202 212
 				return $wsdl;
203
-			}
204
-			else
213
+			} else
205 214
 			{
206 215
 				return WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding());
207 216
 			}
217
+		} else {
218
+					return file_get_contents($this->_wsdlUri);
208 219
 		}
209
-		else
210
-			return file_get_contents($this->_wsdlUri);
211 220
 	}
212 221
 
213 222
 	/**
@@ -215,10 +224,11 @@  discard block
 block discarded – undo
215 224
 	 */
216 225
 	public function getWsdlUri()
217 226
 	{
218
-		if($this->_wsdlUri === '')
219
-			return $this->getRequest()->getBaseUrl() . $this->getService()->constructUrl($this->getID() . '.wsdl', false);
220
-		else
221
-			return $this->_wsdlUri;
227
+		if($this->_wsdlUri === '') {
228
+					return $this->getRequest()->getBaseUrl() . $this->getService()->constructUrl($this->getID() . '.wsdl', false);
229
+		} else {
230
+					return $this->_wsdlUri;
231
+		}
222 232
 	}
223 233
 
224 234
 	/**
@@ -234,10 +244,11 @@  discard block
 block discarded – undo
234 244
 	 */
235 245
 	public function getUri()
236 246
 	{
237
-		if($this->_uri === '')
238
-			return $this->getRequest()->getBaseUrl() . $this->getService()->constructUrl($this->getID(), false);
239
-		else
240
-			return $this->_uri;
247
+		if($this->_uri === '') {
248
+					return $this->getRequest()->getBaseUrl() . $this->getService()->constructUrl($this->getID(), false);
249
+		} else {
250
+					return $this->_uri;
251
+		}
241 252
 	}
242 253
 
243 254
 	/**
@@ -278,10 +289,11 @@  discard block
 block discarded – undo
278 289
 	 */
279 290
 	public function setVersion($value)
280 291
 	{
281
-		if($value === '1.1' || $value === '1.2' || $value === '')
282
-			$this->_version = $value;
283
-		else
284
-			throw new TInvalidDataValueException('soapserver_version_invalid', $value);
292
+		if($value === '1.1' || $value === '1.2' || $value === '') {
293
+					$this->_version = $value;
294
+		} else {
295
+					throw new TInvalidDataValueException('soapserver_version_invalid', $value);
296
+		}
285 297
 	}
286 298
 
287 299
 	/**
Please login to merge, or discard this patch.
framework/Web/Javascripts/TJavaScript.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	public static function renderScriptFiles($files)
35 35
 	{
36 36
 		$str = '';
37
-		foreach($files as $file)
37
+		foreach ($files as $file)
38 38
 			$str .= self::renderScriptFile($file);
39 39
 		return $str;
40 40
 	}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public static function renderScriptFile($file)
48 48
 	{
49
-		return '<script type="text/javascript" src="' . THttpUtility::htmlEncode($file) . "\"></script>\n";
49
+		return '<script type="text/javascript" src="'.THttpUtility::htmlEncode($file)."\"></script>\n";
50 50
 	}
51 51
 
52 52
 	/**
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public static function renderScriptBlocks($scripts)
58 58
 	{
59
-		if(count($scripts))
60
-			return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n" . implode("\n", $scripts) . "\n/*]]>*/\n</script>\n";
59
+		if (count($scripts))
60
+			return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n", $scripts)."\n/*]]>*/\n</script>\n";
61 61
 		else
62 62
 			return '';
63 63
 	}
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public static function renderScriptBlocksCallback($scripts)
71 71
 	{
72
-		if(count($scripts))
73
-			return implode("\n", $scripts) . "\n";
72
+		if (count($scripts))
73
+			return implode("\n", $scripts)."\n";
74 74
 		else
75 75
 			return '';
76 76
 	}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public static function quoteJsLiteral($js)
105 105
 	{
106
-		if($js instanceof TJavaScriptLiteral)
106
+		if ($js instanceof TJavaScriptLiteral)
107 107
 			return $js;
108 108
 		else
109 109
 			return new TJavaScriptLiteral($js);
@@ -141,45 +141,45 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public static function encode($value, $toMap = true, $encodeEmptyStrings = false)
143 143
 	{
144
-		if(is_string($value))
144
+		if (is_string($value))
145 145
 			return self::quoteString($value);
146
-		elseif(is_bool($value))
147
-			return $value?'true':'false';
148
-		elseif(is_array($value))
146
+		elseif (is_bool($value))
147
+			return $value ? 'true' : 'false';
148
+		elseif (is_array($value))
149 149
 		{
150 150
 			$results = '';
151
-			if(($n = count($value)) > 0 && array_keys($value) !== range(0, $n - 1))
151
+			if (($n = count($value)) > 0 && array_keys($value) !== range(0, $n - 1))
152 152
 			{
153
-				foreach($value as $k => $v)
153
+				foreach ($value as $k => $v)
154 154
 				{
155
-					if($v !== '' || $encodeEmptyStrings)
155
+					if ($v !== '' || $encodeEmptyStrings)
156 156
 					{
157
-						if($results !== '')
157
+						if ($results !== '')
158 158
 							$results .= ',';
159
-						$results .= "'$k':" . self::encode($v, $toMap, $encodeEmptyStrings);
159
+						$results .= "'$k':".self::encode($v, $toMap, $encodeEmptyStrings);
160 160
 					}
161 161
 				}
162
-				return '{' . $results . '}';
162
+				return '{'.$results.'}';
163 163
 			}
164 164
 			else
165 165
 			{
166
-				foreach($value as $v)
166
+				foreach ($value as $v)
167 167
 				{
168
-					if($v !== '' || $encodeEmptyStrings)
168
+					if ($v !== '' || $encodeEmptyStrings)
169 169
 					{
170
-						if($results !== '')
170
+						if ($results !== '')
171 171
 							$results .= ',';
172 172
 						$results .= self::encode($v, $toMap, $encodeEmptyStrings);
173 173
 					}
174 174
 				}
175
-				return '[' . $results . ']';
175
+				return '['.$results.']';
176 176
 			}
177 177
 		}
178
-		elseif(is_int($value))
178
+		elseif (is_int($value))
179 179
 			return "$value";
180
-		elseif(is_float($value))
180
+		elseif (is_float($value))
181 181
 		{
182
-			switch($value)
182
+			switch ($value)
183 183
 			{
184 184
 				case -INF:
185 185
 					return 'Number.NEGATIVE_INFINITY';
@@ -189,19 +189,19 @@  discard block
 block discarded – undo
189 189
 					break;
190 190
 				default:
191 191
 					$locale = localeConv();
192
-					if($locale['decimal_point'] == '.')
192
+					if ($locale['decimal_point'] == '.')
193 193
 						return "$value";
194 194
 					else
195 195
 						return str_replace($locale['decimal_point'], '.', "$value");
196 196
 					break;
197 197
 			}
198 198
 		}
199
-		elseif(is_object($value))
199
+		elseif (is_object($value))
200 200
 			if ($value instanceof TJavaScriptLiteral)
201 201
 				return $value->toJavaScriptLiteral();
202 202
 			else
203 203
 				return self::encode(get_object_vars($value), $toMap);
204
-		elseif($value === null)
204
+		elseif ($value === null)
205 205
 			return 'null';
206 206
 		else
207 207
 			return '';
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	 * @param string $sourceEncoding
231 231
 	 */
232 232
 	private static function convertToUtf8(&$value, $sourceEncoding) {
233
-		if(is_string($value))
233
+		if (is_string($value))
234 234
 			$value = iconv($sourceEncoding, 'UTF-8', $value);
235 235
 		elseif (is_array($value))
236 236
 		{
237
-			foreach($value as &$element)
237
+			foreach ($value as &$element)
238 238
 				self::convertToUtf8($element, $sourceEncoding);
239 239
 		}
240 240
 	}
Please login to merge, or discard this patch.
Braces   +54 added lines, -47 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@  discard block
 block discarded – undo
34 34
 	public static function renderScriptFiles($files)
35 35
 	{
36 36
 		$str = '';
37
-		foreach($files as $file)
38
-			$str .= self::renderScriptFile($file);
37
+		foreach($files as $file) {
38
+					$str .= self::renderScriptFile($file);
39
+		}
39 40
 		return $str;
40 41
 	}
41 42
 
@@ -56,10 +57,11 @@  discard block
 block discarded – undo
56 57
 	 */
57 58
 	public static function renderScriptBlocks($scripts)
58 59
 	{
59
-		if(count($scripts))
60
-			return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n" . implode("\n", $scripts) . "\n/*]]>*/\n</script>\n";
61
-		else
62
-			return '';
60
+		if(count($scripts)) {
61
+					return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n" . implode("\n", $scripts) . "\n/*]]>*/\n</script>\n";
62
+		} else {
63
+					return '';
64
+		}
63 65
 	}
64 66
 
65 67
 	/**
@@ -69,10 +71,11 @@  discard block
 block discarded – undo
69 71
 	 */
70 72
 	public static function renderScriptBlocksCallback($scripts)
71 73
 	{
72
-		if(count($scripts))
73
-			return implode("\n", $scripts) . "\n";
74
-		else
75
-			return '';
74
+		if(count($scripts)) {
75
+					return implode("\n", $scripts) . "\n";
76
+		} else {
77
+					return '';
78
+		}
76 79
 	}
77 80
 
78 81
 	/**
@@ -103,10 +106,11 @@  discard block
 block discarded – undo
103 106
 	 */
104 107
 	public static function quoteJsLiteral($js)
105 108
 	{
106
-		if($js instanceof TJavaScriptLiteral)
107
-			return $js;
108
-		else
109
-			return new TJavaScriptLiteral($js);
109
+		if($js instanceof TJavaScriptLiteral) {
110
+					return $js;
111
+		} else {
112
+					return new TJavaScriptLiteral($js);
113
+		}
110 114
 	}
111 115
 
112 116
 	/**
@@ -141,11 +145,11 @@  discard block
 block discarded – undo
141 145
 	 */
142 146
 	public static function encode($value, $toMap = true, $encodeEmptyStrings = false)
143 147
 	{
144
-		if(is_string($value))
145
-			return self::quoteString($value);
146
-		elseif(is_bool($value))
147
-			return $value?'true':'false';
148
-		elseif(is_array($value))
148
+		if(is_string($value)) {
149
+					return self::quoteString($value);
150
+		} elseif(is_bool($value)) {
151
+					return $value?'true':'false';
152
+		} elseif(is_array($value))
149 153
 		{
150 154
 			$results = '';
151 155
 			if(($n = count($value)) > 0 && array_keys($value) !== range(0, $n - 1))
@@ -154,30 +158,30 @@  discard block
 block discarded – undo
154 158
 				{
155 159
 					if($v !== '' || $encodeEmptyStrings)
156 160
 					{
157
-						if($results !== '')
158
-							$results .= ',';
161
+						if($results !== '') {
162
+													$results .= ',';
163
+						}
159 164
 						$results .= "'$k':" . self::encode($v, $toMap, $encodeEmptyStrings);
160 165
 					}
161 166
 				}
162 167
 				return '{' . $results . '}';
163
-			}
164
-			else
168
+			} else
165 169
 			{
166 170
 				foreach($value as $v)
167 171
 				{
168 172
 					if($v !== '' || $encodeEmptyStrings)
169 173
 					{
170
-						if($results !== '')
171
-							$results .= ',';
174
+						if($results !== '') {
175
+													$results .= ',';
176
+						}
172 177
 						$results .= self::encode($v, $toMap, $encodeEmptyStrings);
173 178
 					}
174 179
 				}
175 180
 				return '[' . $results . ']';
176 181
 			}
177
-		}
178
-		elseif(is_int($value))
179
-			return "$value";
180
-		elseif(is_float($value))
182
+		} elseif(is_int($value)) {
183
+					return "$value";
184
+		} elseif(is_float($value))
181 185
 		{
182 186
 			switch($value)
183 187
 			{
@@ -189,22 +193,24 @@  discard block
 block discarded – undo
189 193
 					break;
190 194
 				default:
191 195
 					$locale = localeConv();
192
-					if($locale['decimal_point'] == '.')
193
-						return "$value";
194
-					else
195
-						return str_replace($locale['decimal_point'], '.', "$value");
196
+					if($locale['decimal_point'] == '.') {
197
+											return "$value";
198
+					} else {
199
+											return str_replace($locale['decimal_point'], '.', "$value");
200
+					}
196 201
 					break;
197 202
 			}
198
-		}
199
-		elseif(is_object($value))
200
-			if ($value instanceof TJavaScriptLiteral)
203
+		} elseif(is_object($value)) {
204
+					if ($value instanceof TJavaScriptLiteral)
201 205
 				return $value->toJavaScriptLiteral();
202
-			else
203
-				return self::encode(get_object_vars($value), $toMap);
204
-		elseif($value === null)
205
-			return 'null';
206
-		else
207
-			return '';
206
+		} else {
207
+							return self::encode(get_object_vars($value), $toMap);
208
+			}
209
+		elseif($value === null) {
210
+					return 'null';
211
+		} else {
212
+					return '';
213
+		}
208 214
 	}
209 215
 	/**
210 216
 	 * Encodes a PHP variable into javascript string.
@@ -230,12 +236,13 @@  discard block
 block discarded – undo
230 236
 	 * @param string $sourceEncoding
231 237
 	 */
232 238
 	private static function convertToUtf8(&$value, $sourceEncoding) {
233
-		if(is_string($value))
234
-			$value = iconv($sourceEncoding, 'UTF-8', $value);
235
-		elseif (is_array($value))
239
+		if(is_string($value)) {
240
+					$value = iconv($sourceEncoding, 'UTF-8', $value);
241
+		} elseif (is_array($value))
236 242
 		{
237
-			foreach($value as &$element)
238
-				self::convertToUtf8($element, $sourceEncoding);
243
+			foreach($value as &$element) {
244
+							self::convertToUtf8($element, $sourceEncoding);
245
+			}
239 246
 		}
240 247
 	}
241 248
 
Please login to merge, or discard this patch.