Completed
Push — master ( 30c366...8af042 )
by Fabio
07:43
created
framework/Exceptions/TErrorHandler.php 3 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -117,6 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * It terminates the application immediately after the error is displayed.
118 118
 	 * @param mixed sender of the event
119 119
 	 * @param mixed event parameter (if the event is raised by TApplication, it refers to the exception instance)
120
+	 * @param null|\Prado\TApplication $sender
120 121
 	 */
121 122
 	public function handleError($sender,$param)
122 123
 	{
@@ -186,6 +187,7 @@  discard block
 block discarded – undo
186 187
 	 * mode will be displayed to the client user.
187 188
 	 * @param integer response status code
188 189
 	 * @param Exception exception instance
190
+	 * @param integer $statusCode
189 191
 	 */
190 192
 	protected function handleExternalError($statusCode,$exception)
191 193
 	{
@@ -382,6 +384,9 @@  discard block
 block discarded – undo
382 384
 		return $result;
383 385
 	}
384 386
 
387
+	/**
388
+	 * @return string
389
+	 */
385 390
 	private function getExactTraceAsString($exception)
386 391
 	{
387 392
 		if($exception instanceof TPhpFatalErrorException && 
@@ -409,6 +414,9 @@  discard block
 block discarded – undo
409 414
 		return $exception->getTraceAsString();
410 415
 	}
411 416
 
417
+	/**
418
+	 * @param string $pattern
419
+	 */
412 420
 	private function getPropertyAccessTrace($trace,$pattern)
413 421
 	{
414 422
 		$result=null;
@@ -441,6 +449,9 @@  discard block
 block discarded – undo
441 449
 		return $source;
442 450
 	}
443 451
 
452
+	/**
453
+	 * @param string $message
454
+	 */
444 455
 	private function addLink($message)
445 456
 	{
446 457
 		$baseUrl='http://pradosoft.github.io/docs/manual/class-';
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath))
107 107
 			$this->_templatePath=$templatePath;
108 108
 		else
109
-			throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value);
109
+			throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value);
110 110
 	}
111 111
 
112 112
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @param mixed sender of the event
119 119
 	 * @param mixed event parameter (if the event is raised by TApplication, it refers to the exception instance)
120 120
 	 */
121
-	public function handleError($sender,$param)
121
+	public function handleError($sender, $param)
122 122
 	{
123 123
 		static $handling=false;
124 124
 		// We need to restore error and exception handlers,
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 			if(!headers_sent())
138 138
 				header('Content-Type: text/html; charset=UTF-8');
139 139
 			if($param instanceof THttpException)
140
-				$this->handleExternalError($param->getStatusCode(),$param);
140
+				$this->handleExternalError($param->getStatusCode(), $param);
141 141
 			else if($this->getApplication()->getMode()===TApplicationMode::Debug)
142 142
 				$this->displayException($param);
143 143
 			else
144
-				$this->handleExternalError(500,$param);
144
+				$this->handleExternalError(500, $param);
145 145
 		}
146 146
 	}
147 147
 
@@ -154,28 +154,28 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	protected static function hideSecurityRelated($value, $exception=null)
156 156
 	{
157
-		$aRpl = array();
158
-		if($exception !== null && $exception instanceof \Exception)
157
+		$aRpl=array();
158
+		if($exception!==null && $exception instanceof \Exception)
159 159
 		{
160 160
 			if($exception instanceof TPhpFatalErrorException && 
161 161
 				function_exists('xdebug_get_function_stack'))
162 162
 			{
163
-				$aTrace = array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1);
163
+				$aTrace=array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1);
164 164
 			} else {
165
-				$aTrace = $exception->getTrace();
165
+				$aTrace=$exception->getTrace();
166 166
 			}
167 167
 
168 168
 			foreach($aTrace as $item)
169 169
 			{
170 170
 				if(isset($item['file']))
171
-					$aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR;
171
+					$aRpl[dirname($item['file']).DIRECTORY_SEPARATOR]='<hidden>'.DIRECTORY_SEPARATOR;
172 172
 			}
173 173
 		}
174
-		$aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}';
175
-		$aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}';
176
-		$aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR;
174
+		$aRpl[$_SERVER['DOCUMENT_ROOT']]='${DocumentRoot}';
175
+		$aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])]='${DocumentRoot}';
176
+		$aRpl[PRADO_DIR.DIRECTORY_SEPARATOR]='${PradoFramework}'.DIRECTORY_SEPARATOR;
177 177
 		if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]);
178
-		$aRpl = array_reverse($aRpl, true);
178
+		$aRpl=array_reverse($aRpl, true);
179 179
 
180 180
 		return str_replace(array_keys($aRpl), $aRpl, $value);
181 181
 	}
@@ -187,36 +187,36 @@  discard block
 block discarded – undo
187 187
 	 * @param integer response status code
188 188
 	 * @param Exception exception instance
189 189
 	 */
190
-	protected function handleExternalError($statusCode,$exception)
190
+	protected function handleExternalError($statusCode, $exception)
191 191
 	{
192 192
 		if(!($exception instanceof THttpException))
193 193
 			error_log($exception->__toString());
194 194
 
195
-		$content=$this->getErrorTemplate($statusCode,$exception);
195
+		$content=$this->getErrorTemplate($statusCode, $exception);
196 196
 
197
-		$serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:'';
197
+		$serverAdmin=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : '';
198 198
 
199
-		$isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug;
199
+		$isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug;
200 200
 
201
-		$errorMessage = $exception->getMessage();
201
+		$errorMessage=$exception->getMessage();
202 202
 		if($isDebug)
203 203
 			$version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
204 204
 		else
205 205
 		{
206 206
 			$version='';
207
-			$errorMessage = self::hideSecurityRelated($errorMessage, $exception);
207
+			$errorMessage=self::hideSecurityRelated($errorMessage, $exception);
208 208
 		}
209 209
 		$tokens=array(
210 210
 			'%%StatusCode%%' => "$statusCode",
211 211
 			'%%ErrorMessage%%' => htmlspecialchars($errorMessage),
212 212
 			'%%ServerAdmin%%' => $serverAdmin,
213 213
 			'%%Version%%' => $version,
214
-			'%%Time%%' => @strftime('%Y-%m-%d %H:%M',time())
214
+			'%%Time%%' => @strftime('%Y-%m-%d %H:%M', time())
215 215
 		);
216 216
 
217 217
 		$this->getApplication()->getResponse()->setStatusCode($statusCode, $isDebug ? $exception->getMessage() : null);
218 218
 
219
-		echo strtr($content,$tokens);
219
+		echo strtr($content, $tokens);
220 220
 	}
221 221
 
222 222
 	/**
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 		if($exception instanceof TTemplateException)
262 262
 		{
263 263
 			$fileName=$exception->getTemplateFile();
264
-			$lines=empty($fileName)?explode("\n",$exception->getTemplateSource()):@file($fileName);
265
-			$source=$this->getSourceCode($lines,$exception->getLineNumber());
264
+			$lines=empty($fileName) ? explode("\n", $exception->getTemplateSource()) : @file($fileName);
265
+			$source=$this->getSourceCode($lines, $exception->getLineNumber());
266 266
 			if($fileName==='')
267 267
 				$fileName='---embedded template---';
268 268
 			$errorLine=$exception->getLineNumber();
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 				$fileName=$exception->getFile();
280 280
 				$errorLine=$exception->getLine();
281 281
 			}
282
-			$source=$this->getSourceCode(@file($fileName),$errorLine);
282
+			$source=$this->getSourceCode(@file($fileName), $errorLine);
283 283
 		}
284 284
 
285 285
 		if($this->getApplication()->getMode()===TApplicationMode::Debug)
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 			'%%SourceCode%%' => $source,
295 295
 			'%%StackTrace%%' => htmlspecialchars($this->getExactTraceAsString($exception)),
296 296
 			'%%Version%%' => $version,
297
-			'%%Time%%' => @strftime('%Y-%m-%d %H:%M',time())
297
+			'%%Time%%' => @strftime('%Y-%m-%d %H:%M', time())
298 298
 		);
299 299
 
300 300
 		$content=$this->getExceptionTemplate($exception);
301 301
 
302
-		echo strtr($content,$tokens);
302
+		echo strtr($content, $tokens);
303 303
 	}
304 304
 
305 305
 	/**
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 	 * @param Exception the exception to be displayed
337 337
 	 * @return string the template content
338 338
 	 */
339
-	protected function getErrorTemplate($statusCode,$exception)
339
+	protected function getErrorTemplate($statusCode, $exception)
340 340
 	{
341 341
 		$base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME;
342 342
 		$lang=Prado::getPreferredLanguage();
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		if($exception instanceof TPhpFatalErrorException && 
360 360
 			function_exists('xdebug_get_function_stack'))
361 361
 		{
362
-			$trace = array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1);
362
+			$trace=array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1);
363 363
 		} else {
364 364
 			$trace=$exception->getTrace();
365 365
 		}
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
 				$result=$trace[1];
374 374
 		} elseif($exception instanceof TInvalidOperationException) {
375 375
 			// in case of getter or setter error, find out the exact file and row
376
-			if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null)
377
-				$result=$this->getPropertyAccessTrace($trace,'__set');
376
+			if(($result=$this->getPropertyAccessTrace($trace, '__get'))===null)
377
+				$result=$this->getPropertyAccessTrace($trace, '__set');
378 378
 		}
379
-		if($result!==null && strpos($result['file'],': eval()\'d code')!==false)
379
+		if($result!==null && strpos($result['file'], ': eval()\'d code')!==false)
380 380
 			return null;
381 381
 
382 382
 		return $result;
@@ -387,19 +387,19 @@  discard block
 block discarded – undo
387 387
 		if($exception instanceof TPhpFatalErrorException && 
388 388
 			function_exists('xdebug_get_function_stack'))
389 389
 		{
390
-			$trace = array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1);
391
-			$txt = '';
392
-			$row = 0;
390
+			$trace=array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1);
391
+			$txt='';
392
+			$row=0;
393 393
 
394 394
 			// try to mimic Exception::getTraceAsString()
395 395
 			foreach($trace as $line)
396 396
 			{
397 397
 				if(array_key_exists('function', $line))
398
-					$func = $line['function'] . '(' . implode(',', $line['params']) . ')';
398
+					$func=$line['function'].'('.implode(',', $line['params']).')';
399 399
 				else
400
-					$func = 'unknown';
400
+					$func='unknown';
401 401
 
402
-				$txt .= '#' . $row . ' ' . $line['file'] . '(' . $line['line'] . '): ' . $func . "\n";
402
+				$txt.='#'.$row.' '.$line['file'].'('.$line['line'].'): '.$func."\n";
403 403
 				$row++;
404 404
 			}
405 405
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		return $exception->getTraceAsString();
410 410
 	}
411 411
 
412
-	private function getPropertyAccessTrace($trace,$pattern)
412
+	private function getPropertyAccessTrace($trace, $pattern)
413 413
 	{
414 414
 		$result=null;
415 415
 		foreach($trace as $t)
@@ -422,21 +422,21 @@  discard block
 block discarded – undo
422 422
 		return $result;
423 423
 	}
424 424
 
425
-	private function getSourceCode($lines,$errorLine)
425
+	private function getSourceCode($lines, $errorLine)
426 426
 	{
427
-		$beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0;
428
-		$endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines);
427
+		$beginLine=$errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0;
428
+		$endLine=$errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines);
429 429
 
430 430
 		$source='';
431
-		for($i=$beginLine;$i<$endLine;++$i)
431
+		for($i=$beginLine; $i < $endLine; ++$i)
432 432
 		{
433
-			if($i===$errorLine-1)
433
+			if($i===$errorLine - 1)
434 434
 			{
435
-				$line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",'    ',$lines[$i])));
435
+				$line=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", '    ', $lines[$i])));
436 436
 				$source.="<div class=\"error\">".$line."</div>";
437 437
 			}
438 438
 			else
439
-				$source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",'    ',$lines[$i])));
439
+				$source.=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", '    ', $lines[$i])));
440 440
 		}
441 441
 		return $source;
442 442
 	}
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	private function addLink($message)
445 445
 	{
446 446
 		$baseUrl='http://pradosoft.github.io/docs/manual/class-';
447
-		return preg_replace('/\b(T[A-Z]\w+)\b/',"<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>",$message);
447
+		return preg_replace('/\b(T[A-Z]\w+)\b/', "<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>", $message);
448 448
 	}
449 449
 }
450 450
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -234,8 +234,7 @@  discard block
 block discarded – undo
234 234
 			echo "<body><h1>Recursive Error</h1>\n";
235 235
 			echo "<pre>".$exception->__toString()."</pre>\n";
236 236
 			echo "</body></html>";
237
-		}
238
-		else
237
+		} else
239 238
 		{
240 239
 			error_log("Error happened while processing an existing error:\n".$exception->__toString());
241 240
 			header('HTTP/1.0 500 Internal Error');
@@ -266,15 +265,13 @@  discard block
 block discarded – undo
266 265
 			if($fileName==='')
267 266
 				$fileName='---embedded template---';
268 267
 			$errorLine=$exception->getLineNumber();
269
-		}
270
-		else
268
+		} else
271 269
 		{
272 270
 			if(($trace=$this->getExactTrace($exception))!==null)
273 271
 			{
274 272
 				$fileName=$trace['file'];
275 273
 				$errorLine=$trace['line'];
276
-			}
277
-			else
274
+			} else
278 275
 			{
279 276
 				$fileName=$exception->getFile();
280 277
 				$errorLine=$exception->getLine();
@@ -434,8 +431,7 @@  discard block
 block discarded – undo
434 431
 			{
435 432
 				$line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",'    ',$lines[$i])));
436 433
 				$source.="<div class=\"error\">".$line."</div>";
437
-			}
438
-			else
434
+			} else
439 435
 				$source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",'    ',$lines[$i])));
440 436
 		}
441 437
 		return $source;
Please login to merge, or discard this patch.
framework/PradoBase.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * module of the Prado application to handle the exception.
206 206
 	 * If the application or the module does not exist, it simply echoes the
207 207
 	 * exception.
208
-	 * @param Exception exception that is not caught
208
+	 * @param Exception TPhpFatalErrorException that is not caught
209 209
 	 */
210 210
 	public static function exceptionHandler($exception)
211 211
 	{
@@ -227,6 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * will cause the throw of an exception.
228 228
 	 * This method should only be used by framework developers.
229 229
 	 * @param TApplication the application instance
230
+	 * @param TApplication $application
230 231
 	 * @throws TInvalidOperationException if this method is invoked twice or more.
231 232
 	 */
232 233
 	public static function setApplication($application)
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
  * Defines the default permission for writable directories and files
31 31
  */
32 32
 if(!defined('PRADO_CHMOD'))
33
-	define('PRADO_CHMOD',0777);
33
+	define('PRADO_CHMOD', 0777);
34 34
 /**
35 35
  * Defines the Composer's vendor/ path.
36 36
  */
37 37
 if(!defined('PRADO_VENDORDIR'))
38 38
 {
39
-	$reflector = new \ReflectionClass('\Composer\Autoload\ClassLoader');
40
-	define('PRADO_VENDORDIR',dirname(dirname($reflector->getFileName())));
39
+	$reflector=new \ReflectionClass('\Composer\Autoload\ClassLoader');
40
+	define('PRADO_VENDORDIR', dirname(dirname($reflector->getFileName())));
41 41
 }
42 42
 
43 43
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	/**
89 89
 	 * @var array list of class exists checks
90 90
 	 */
91
-	protected static $classExists = array();
91
+	protected static $classExists=array();
92 92
 	/**
93 93
 	 * @return string the version of Prado framework
94 94
 	 */
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public static function initAutoloader()
110 110
 	{
111
-		self::$classMap = require(__DIR__ . '/classes.php');
111
+		self::$classMap=require(__DIR__.'/classes.php');
112 112
 
113 113
 		spl_autoload_register(array(get_called_class(), 'autoload'));
114 114
 	}
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
 		/**
124 124
 		 * Sets error handler to be Prado::phpErrorHandler
125 125
 		 */
126
-		set_error_handler(array('\Prado\PradoBase','phpErrorHandler'));
126
+		set_error_handler(array('\Prado\PradoBase', 'phpErrorHandler'));
127 127
 		/**
128 128
 		 * Sets shutdown function to be Prado::phpFatalErrorHandler
129 129
 		 */
130
-		register_shutdown_function(array('PradoBase','phpFatalErrorHandler'));
130
+		register_shutdown_function(array('PradoBase', 'phpFatalErrorHandler'));
131 131
 		/**
132 132
 		 * Sets exception handler to be Prado::exceptionHandler
133 133
 		 */
134
-		set_exception_handler(array('\Prado\PradoBase','exceptionHandler'));
134
+		set_exception_handler(array('\Prado\PradoBase', 'exceptionHandler'));
135 135
 		/**
136 136
 		 * Disable php's builtin error reporting to avoid duplicated reports
137 137
 		 */
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public static function poweredByPrado($logoType=0)
156 156
 	{
157
-		$logoName=$logoType==1?'powered2':'powered';
157
+		$logoName=$logoType==1 ? 'powered2' : 'powered';
158 158
 		if(self::$_application!==null)
159 159
 		{
160 160
 			$am=self::$_application->getAssetManager();
161
-			$url=$am->publishFilePath(self::getPathOfNamespace('Prado\\'.$logoName,'.gif'));
161
+			$url=$am->publishFilePath(self::getPathOfNamespace('Prado\\'.$logoName, '.gif'));
162 162
 		}
163 163
 		else
164 164
 			$url='http://pradosoft.github.io/docs/'.$logoName.'.gif';
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	 * @param string the filename that the error was raised in
176 176
 	 * @param integer the line number the error was raised at
177 177
 	 */
178
-	public static function phpErrorHandler($errno,$errstr,$errfile,$errline)
178
+	public static function phpErrorHandler($errno, $errstr, $errfile, $errline)
179 179
 	{
180 180
 		if(error_reporting() & $errno)
181
-			throw new TPhpErrorException($errno,$errstr,$errfile,$errline);
181
+			throw new TPhpErrorException($errno, $errstr, $errfile, $errline);
182 182
 	}
183 183
 
184 184
 	/**
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	public static function phpFatalErrorHandler()
191 191
 	{
192
-		$error = error_get_last();
192
+		$error=error_get_last();
193 193
 		if($error && 
194 194
 			TPhpErrorException::isFatalError($error) &&
195 195
 			error_reporting() & $error['type'])
196 196
 		{
197
-			self::exceptionHandler(new TPhpFatalErrorException($error['type'],$error['message'],$error['file'],$error['line']));
197
+			self::exceptionHandler(new TPhpFatalErrorException($error['type'], $error['message'], $error['file'], $error['line']));
198 198
 		}
199 199
 	}
200 200
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	{
212 212
 		if(self::$_application!==null && ($errorHandler=self::$_application->getErrorHandler())!==null)
213 213
 		{
214
-			$errorHandler->handleError(null,$exception);
214
+			$errorHandler->handleError(null, $exception);
215 215
 		}
216 216
 		else
217 217
 		{
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 
261 261
 	protected static function prado3NamespaceToPhpNamespace($type)
262 262
 	{
263
-		if(substr($type, 0, 6) === 'System')
263
+		if(substr($type, 0, 6)==='System')
264 264
 			$type='Prado'.substr($type, 6);
265 265
 
266
-		if(false === strpos($type, '\\'))
266
+		if(false===strpos($type, '\\'))
267 267
 			return str_replace('.', '\\', $type);
268 268
 		else
269 269
 			return $type;
@@ -284,13 +284,13 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	public static function createComponent($requestedType)
286 286
 	{
287
-		$type = static::prado3NamespaceToPhpNamespace($requestedType);
287
+		$type=static::prado3NamespaceToPhpNamespace($requestedType);
288 288
 		if(!isset(self::$classExists[$type]))
289
-			self::$classExists[$type] = class_exists($type, false);
289
+			self::$classExists[$type]=class_exists($type, false);
290 290
 
291
-		if( !isset(self::$_usings[$type]) && !self::$classExists[$type]) {
291
+		if(!isset(self::$_usings[$type]) && !self::$classExists[$type]) {
292 292
 			static::using($type);
293
-			self::$classExists[$type] = class_exists($type, false);
293
+			self::$classExists[$type]=class_exists($type, false);
294 294
 		}
295 295
 
296 296
 		/*
@@ -300,12 +300,12 @@  discard block
 block discarded – undo
300 300
 		 * \Application\Common\MyDataModule)
301 301
 		 * Skip this if the class is inside the Prado\* namespace, since all Prado classes are now namespaced
302 302
 		 */
303
-		if( ($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0)
304
-			$type = substr($type,$pos+1);
303
+		if(($pos=strrpos($type, '\\'))!==false && ($requestedType!=$type) && strpos($type, 'Prado\\')!==0)
304
+			$type=substr($type, $pos + 1);
305 305
 
306
-		if(($n=func_num_args())>1)
306
+		if(($n=func_num_args()) > 1)
307 307
 		{
308
-			$args = func_get_args();
308
+			$args=func_get_args();
309 309
 			switch($n) {
310 310
 				case 2:
311 311
 					return new $type($args[1]);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 				break;
322 322
 				default:
323 323
 					$s='$args[1]';
324
-					for($i=2;$i<$n;++$i)
324
+					for($i=2; $i < $n; ++$i)
325 325
 						$s.=",\$args[$i]";
326 326
 					eval("\$component=new $type($s);");
327 327
 					return $component;
@@ -341,31 +341,31 @@  discard block
 block discarded – undo
341 341
 	 * @param boolean whether to check the existence of the class after the class file is included
342 342
 	 * @throws TInvalidDataValueException if the namespace is invalid
343 343
 	 */
344
-	public static function using($namespace,$checkClassExistence=true)
344
+	public static function using($namespace, $checkClassExistence=true)
345 345
 	{
346
-		$namespace = static::prado3NamespaceToPhpNamespace($namespace);
346
+		$namespace=static::prado3NamespaceToPhpNamespace($namespace);
347 347
 
348
-		if(isset(self::$_usings[$namespace]) || class_exists($namespace,false))
348
+		if(isset(self::$_usings[$namespace]) || class_exists($namespace, false))
349 349
 			return;
350 350
 
351 351
 		if(array_key_exists($namespace, self::$classMap))
352 352
 		{
353 353
 			// fast autoload a Prado3 class name
354
-			$phpNamespace = self::$classMap[$namespace];
354
+			$phpNamespace=self::$classMap[$namespace];
355 355
 			if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true))
356 356
 			{
357 357
 				if(!class_exists($namespace) && !interface_exists($namespace))
358 358
 					class_alias($phpNamespace, $namespace);
359 359
 				return;
360 360
 			}			
361
-		} elseif(($pos=strrpos($namespace,'\\'))===false) {
361
+		} elseif(($pos=strrpos($namespace, '\\'))===false) {
362 362
 			// trying to autoload an old class name
363 363
 			foreach(self::$_usings as $k => $v)
364 364
 			{
365
-				$path = $v . DIRECTORY_SEPARATOR . $namespace . self::CLASS_FILE_EXT;
365
+				$path=$v.DIRECTORY_SEPARATOR.$namespace.self::CLASS_FILE_EXT;
366 366
 				if(file_exists($path))
367 367
 				{
368
-					$phpNamespace = '\\'. $k.'\\'.$namespace;
368
+					$phpNamespace='\\'.$k.'\\'.$namespace;
369 369
 					if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true))
370 370
 					{
371 371
 						if(!class_exists($namespace) && !interface_exists($namespace))
@@ -375,10 +375,10 @@  discard block
 block discarded – undo
375 375
 				}
376 376
 			}
377 377
 
378
-			if($checkClassExistence && !class_exists($namespace,false) && !interface_exists($namespace,false))
379
-				throw new TInvalidOperationException('prado_component_unknown',$namespace,'');
380
-		} elseif(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null) {
381
-			$className=substr($namespace,$pos+1);
378
+			if($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false))
379
+				throw new TInvalidOperationException('prado_component_unknown', $namespace, '');
380
+		} elseif(($path=self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT))!==null) {
381
+			$className=substr($namespace, $pos + 1);
382 382
 			if($className==='*')  // a directory
383 383
 			{
384 384
 				self::$_usings[substr($namespace, 0, $pos)]=$path;
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			else  // a file
387 387
 			{
388 388
 				//self::$_usings[$namespace]=$path;
389
-				if(!$checkClassExistence || (!class_exists($className,false) && !interface_exists($className, false)))
389
+				if(!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false)))
390 390
 				{
391 391
 					try
392 392
 					{
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 					}
397 397
 					catch(\Exception $e)
398 398
 					{
399
-						if($checkClassExistence && !class_exists($className,false))
400
-							throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage());
399
+						if($checkClassExistence && !class_exists($className, false))
400
+							throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage());
401 401
 						else
402 402
 							throw $e;
403 403
 					}
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 	 */
421 421
 	public static function getPathOfNamespace($namespace, $ext='')
422 422
 	{
423
-		$namespace = static::prado3NamespaceToPhpNamespace($namespace);
423
+		$namespace=static::prado3NamespaceToPhpNamespace($namespace);
424 424
 
425
-		if(self::CLASS_FILE_EXT === $ext || empty($ext))
425
+		if(self::CLASS_FILE_EXT===$ext || empty($ext))
426 426
 		{
427 427
 			if(isset(self::$_usings[$namespace]))
428 428
 				return self::$_usings[$namespace];
@@ -431,11 +431,11 @@  discard block
 block discarded – undo
431 431
 				return self::$_aliases[$namespace];
432 432
 		}
433 433
 
434
-		$segs = explode('\\',$namespace);
435
-		$alias = array_shift($segs);
434
+		$segs=explode('\\', $namespace);
435
+		$alias=array_shift($segs);
436 436
 
437
-		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
438
-			return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext);
437
+		if(null!==($file=array_pop($segs)) && null!==($root=self::getPathOfAlias($alias)))
438
+			return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $segs), '/\\').(($file==='*') ? '' : DIRECTORY_SEPARATOR.$file.$ext);
439 439
 
440 440
 		return null;
441 441
 	}
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	 */
447 447
 	public static function getPathOfAlias($alias)
448 448
 	{
449
-		return isset(self::$_aliases[$alias])?self::$_aliases[$alias]:null;
449
+		return isset(self::$_aliases[$alias]) ? self::$_aliases[$alias] : null;
450 450
 	}
451 451
 
452 452
 	protected static function getPathAliases()
@@ -460,19 +460,19 @@  discard block
 block discarded – undo
460 460
 	 * @throws TInvalidOperationException if the alias is already defined
461 461
 	 * @throws TInvalidDataValueException if the path is not a valid file path
462 462
 	 */
463
-	public static function setPathOfAlias($alias,$path)
463
+	public static function setPathOfAlias($alias, $path)
464 464
 	{
465 465
 		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
466
-			throw new TInvalidOperationException('prado_alias_redefined',$alias);
466
+			throw new TInvalidOperationException('prado_alias_redefined', $alias);
467 467
 		else if(($rp=realpath($path))!==false && is_dir($rp))
468 468
 		{
469
-			if(strpos($alias,'.')===false)
469
+			if(strpos($alias, '.')===false)
470 470
 				self::$_aliases[$alias]=$rp;
471 471
 			else
472
-				throw new TInvalidDataValueException('prado_aliasname_invalid',$alias);
472
+				throw new TInvalidDataValueException('prado_aliasname_invalid', $alias);
473 473
 		}
474 474
 		else
475
-			throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path);
475
+			throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path);
476 476
 	}
477 477
 
478 478
 	/**
@@ -497,13 +497,13 @@  discard block
 block discarded – undo
497 497
 				continue;
498 498
 			echo '#'.$index.' ';
499 499
 			if(isset($t['file']))
500
-				echo basename($t['file']) . ':' . $t['line'];
500
+				echo basename($t['file']).':'.$t['line'];
501 501
 			else
502 502
 				 echo '<PHP inner-code>';
503 503
 			echo ' -- ';
504 504
 			if(isset($t['class']))
505
-				echo $t['class'] . $t['type'];
506
-			echo $t['function'] . '(';
505
+				echo $t['class'].$t['type'];
506
+			echo $t['function'].'(';
507 507
 			if(isset($t['args']) && sizeof($t['args']) > 0)
508 508
 			{
509 509
 				$count=0;
@@ -512,25 +512,25 @@  discard block
 block discarded – undo
512 512
 					if(is_string($item))
513 513
 					{
514 514
 						$str=htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
515
-						if (strlen($item) > 70)
516
-							echo "'". substr($str, 0, 70) . "...'";
515
+						if(strlen($item) > 70)
516
+							echo "'".substr($str, 0, 70)."...'";
517 517
 						else
518
-							echo "'" . $str . "'";
518
+							echo "'".$str."'";
519 519
 					}
520
-					else if (is_int($item) || is_float($item))
520
+					else if(is_int($item) || is_float($item))
521 521
 						echo $item;
522
-					else if (is_object($item))
522
+					else if(is_object($item))
523 523
 						echo get_class($item);
524
-					else if (is_array($item))
525
-						echo 'array(' . count($item) . ')';
526
-					else if (is_bool($item))
524
+					else if(is_array($item))
525
+						echo 'array('.count($item).')';
526
+					else if(is_bool($item))
527 527
 						echo $item ? 'true' : 'false';
528
-					else if ($item === null)
528
+					else if($item===null)
529 529
 						echo 'NULL';
530
-					else if (is_resource($item))
530
+					else if(is_resource($item))
531 531
 						echo get_resource_type($item);
532 532
 					$count++;
533
-					if (count($t['args']) > $count)
533
+					if(count($t['args']) > $count)
534 534
 						echo ', ';
535 535
 				}
536 536
 			}
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
 			else
558 558
 			{
559 559
 				$languages=array();
560
-				foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
560
+				foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
561 561
 				{
562
-					$array=explode(';q=',trim($language));
563
-					$languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0;
562
+					$array=explode(';q=', trim($language));
563
+					$languages[trim($array[0])]=isset($array[1]) ? (float) $array[1] : 1.0;
564 564
 				}
565 565
 				arsort($languages);
566 566
 				$languages=array_keys($languages);
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		if($language===null)
582 582
 		{
583 583
 			$langs=Prado::getUserLanguages();
584
-			$lang=explode('-',$langs[0]);
584
+			$lang=explode('-', $langs[0]);
585 585
 			if(empty($lang[0]) || !ctype_alpha($lang[0]))
586 586
 				$language='en';
587 587
 			else
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	 * @param (string|TControl) control of the message
603 603
 	 * @see log, getLogger
604 604
 	 */
605
-	public static function trace($msg,$category='Uncategorized',$ctl=null)
605
+	public static function trace($msg, $category='Uncategorized', $ctl=null)
606 606
 	{
607 607
 		if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance)
608 608
 			return;
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 		}
616 616
 		else
617 617
 			$level=TLogger::INFO;
618
-		self::log($msg,$level,$category,$ctl);
618
+		self::log($msg, $level, $category, $ctl);
619 619
 	}
620 620
 
621 621
 	/**
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
 	 * @param string category of the message
631 631
 	 * @param (string|TControl) control of the message
632 632
 	 */
633
-	public static function log($msg,$level=TLogger::INFO,$category='Uncategorized',$ctl=null)
633
+	public static function log($msg, $level=TLogger::INFO, $category='Uncategorized', $ctl=null)
634 634
 	{
635 635
 		if(self::$_logger===null)
636 636
 			self::$_logger=new TLogger;
637
-		self::$_logger->log($msg,$level,$category,$ctl);
637
+		self::$_logger->log($msg, $level, $category, $ctl);
638 638
 	}
639 639
 
640 640
 	/**
@@ -656,9 +656,9 @@  discard block
 block discarded – undo
656 656
 	 * @param boolean whether to syntax highlight the output. Defaults to false.
657 657
 	 * @return string the string representation of the variable
658 658
 	 */
659
-	public static function varDump($var,$depth=10,$highlight=false)
659
+	public static function varDump($var, $depth=10, $highlight=false)
660 660
 	{
661
-		return TVarDumper::dump($var,$depth,$highlight);
661
+		return TVarDumper::dump($var, $depth, $highlight);
662 662
 	}
663 663
 
664 664
 	/**
@@ -673,31 +673,31 @@  discard block
 block discarded – undo
673 673
 	 */
674 674
 	public static function localize($text, $parameters=array(), $catalogue=null, $charset=null)
675 675
 	{
676
-		$app = Prado::getApplication()->getGlobalization(false);
676
+		$app=Prado::getApplication()->getGlobalization(false);
677 677
 
678
-		$params = array();
678
+		$params=array();
679 679
 		foreach($parameters as $key => $value)
680
-			$params['{'.$key.'}'] = $value;
680
+			$params['{'.$key.'}']=$value;
681 681
 
682 682
 		//no translation handler provided
683
-		if($app===null || ($config = $app->getTranslationConfiguration())===null)
683
+		if($app===null || ($config=$app->getTranslationConfiguration())===null)
684 684
 			return strtr($text, $params);
685 685
 
686
-		if ($catalogue===null)
687
-			$catalogue=isset($config['catalogue'])?$config['catalogue']:'messages';
686
+		if($catalogue===null)
687
+			$catalogue=isset($config['catalogue']) ? $config['catalogue'] : 'messages';
688 688
 
689 689
 		Translation::init($catalogue);
690 690
 
691 691
 		//globalization charset
692
-		$appCharset = $app===null ? '' : $app->getCharset();
692
+		$appCharset=$app===null ? '' : $app->getCharset();
693 693
 
694 694
 		//default charset
695
-		$defaultCharset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset();
695
+		$defaultCharset=($app===null) ? 'UTF-8' : $app->getDefaultCharset();
696 696
 
697 697
 		//fall back
698
-		if(empty($charset)) $charset = $appCharset;
699
-		if(empty($charset)) $charset = $defaultCharset;
698
+		if(empty($charset)) $charset=$appCharset;
699
+		if(empty($charset)) $charset=$defaultCharset;
700 700
 
701
-		return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset);
701
+		return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset);
702 702
 	}
703 703
 }
Please login to merge, or discard this patch.