@@ -38,16 +38,16 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | public function __construct($statusCode, $errorMessage) |
| 40 | 40 | { |
| 41 | - $this->_statusCode = $statusCode; |
|
| 41 | + $this->_statusCode=$statusCode; |
|
| 42 | 42 | $this->setErrorCode($errorMessage); |
| 43 | - $errorMessage = $this->translateErrorMessage($errorMessage); |
|
| 44 | - $args = func_get_args(); |
|
| 43 | + $errorMessage=$this->translateErrorMessage($errorMessage); |
|
| 44 | + $args=func_get_args(); |
|
| 45 | 45 | array_shift($args); |
| 46 | 46 | array_shift($args); |
| 47 | - $n = count($args); |
|
| 48 | - $tokens = []; |
|
| 49 | - for($i = 0;$i < $n;++$i) |
|
| 50 | - $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]); |
|
| 47 | + $n=count($args); |
|
| 48 | + $tokens=[]; |
|
| 49 | + for($i=0; $i < $n; ++$i) |
|
| 50 | + $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
|
| 51 | 51 | parent::__construct(strtr($errorMessage, $tokens)); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -57,19 +57,19 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * error template file basename |
| 59 | 59 | */ |
| 60 | - const ERROR_FILE_NAME = 'error'; |
|
| 60 | + const ERROR_FILE_NAME='error'; |
|
| 61 | 61 | /** |
| 62 | 62 | * exception template file basename |
| 63 | 63 | */ |
| 64 | - const EXCEPTION_FILE_NAME = 'exception'; |
|
| 64 | + const EXCEPTION_FILE_NAME='exception'; |
|
| 65 | 65 | /** |
| 66 | 66 | * number of lines before and after the error line to be displayed in case of an exception |
| 67 | 67 | */ |
| 68 | - const SOURCE_LINES = 12; |
|
| 68 | + const SOURCE_LINES=12; |
|
| 69 | 69 | /** |
| 70 | 70 | * number of prado internal function calls to be dropped from stack traces on fatal errors |
| 71 | 71 | */ |
| 72 | - const FATAL_ERROR_TRACE_DROP_LINES = 5; |
|
| 72 | + const FATAL_ERROR_TRACE_DROP_LINES=5; |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @var string error template directory |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function getErrorTemplatePath() |
| 93 | 93 | { |
| 94 | - if($this->_templatePath === null) |
|
| 95 | - $this->_templatePath = Prado::getFrameworkPath() . '/Exceptions/templates'; |
|
| 94 | + if($this->_templatePath===null) |
|
| 95 | + $this->_templatePath=Prado::getFrameworkPath().'/Exceptions/templates'; |
|
| 96 | 96 | return $this->_templatePath; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function setErrorTemplatePath($value) |
| 106 | 106 | { |
| 107 | - if(($templatePath = Prado::getPathOfNamespace($value)) !== null && is_dir($templatePath)) |
|
| 108 | - $this->_templatePath = $templatePath; |
|
| 107 | + if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath)) |
|
| 108 | + $this->_templatePath=$templatePath; |
|
| 109 | 109 | else |
| 110 | 110 | throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value); |
| 111 | 111 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function handleError($sender, $param) |
| 123 | 123 | { |
| 124 | - static $handling = false; |
|
| 124 | + static $handling=false; |
|
| 125 | 125 | // We need to restore error and exception handlers, |
| 126 | 126 | // because within error and exception handlers, new errors and exceptions |
| 127 | 127 | // cannot be handled properly by PHP |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | $this->handleRecursiveError($param); |
| 133 | 133 | else |
| 134 | 134 | { |
| 135 | - $handling = true; |
|
| 136 | - if(($response = $this->getResponse()) !== null) |
|
| 135 | + $handling=true; |
|
| 136 | + if(($response=$this->getResponse())!==null) |
|
| 137 | 137 | $response->clear(); |
| 138 | 138 | if(!headers_sent()) |
| 139 | 139 | header('Content-Type: text/html; charset=UTF-8'); |
| 140 | 140 | if($param instanceof THttpException) |
| 141 | 141 | $this->handleExternalError($param->getStatusCode(), $param); |
| 142 | - elseif($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 142 | + elseif($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 143 | 143 | $this->displayException($param); |
| 144 | 144 | else |
| 145 | 145 | $this->handleExternalError(500, $param); |
@@ -153,30 +153,30 @@ discard block |
||
| 153 | 153 | * @return string |
| 154 | 154 | * @since 3.1.6 |
| 155 | 155 | */ |
| 156 | - protected static function hideSecurityRelated($value, $exception = null) |
|
| 156 | + protected static function hideSecurityRelated($value, $exception=null) |
|
| 157 | 157 | { |
| 158 | - $aRpl = []; |
|
| 159 | - if($exception !== null && $exception instanceof \Exception) |
|
| 158 | + $aRpl=[]; |
|
| 159 | + if($exception!==null && $exception instanceof \Exception) |
|
| 160 | 160 | { |
| 161 | 161 | if($exception instanceof TPhpFatalErrorException && |
| 162 | 162 | function_exists('xdebug_get_function_stack')) |
| 163 | 163 | { |
| 164 | - $aTrace = array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1); |
|
| 164 | + $aTrace=array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1); |
|
| 165 | 165 | } else { |
| 166 | - $aTrace = $exception->getTrace(); |
|
| 166 | + $aTrace=$exception->getTrace(); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | foreach($aTrace as $item) |
| 170 | 170 | { |
| 171 | 171 | if(isset($item['file'])) |
| 172 | - $aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR; |
|
| 172 | + $aRpl[dirname($item['file']).DIRECTORY_SEPARATOR]='<hidden>'.DIRECTORY_SEPARATOR; |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | - $aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}'; |
|
| 176 | - $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}'; |
|
| 177 | - $aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR; |
|
| 175 | + $aRpl[$_SERVER['DOCUMENT_ROOT']]='${DocumentRoot}'; |
|
| 176 | + $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])]='${DocumentRoot}'; |
|
| 177 | + $aRpl[PRADO_DIR.DIRECTORY_SEPARATOR]='${PradoFramework}'.DIRECTORY_SEPARATOR; |
|
| 178 | 178 | if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]); |
| 179 | - $aRpl = array_reverse($aRpl, true); |
|
| 179 | + $aRpl=array_reverse($aRpl, true); |
|
| 180 | 180 | |
| 181 | 181 | return str_replace(array_keys($aRpl), $aRpl, $value); |
| 182 | 182 | } |
@@ -193,21 +193,21 @@ discard block |
||
| 193 | 193 | if(!($exception instanceof THttpException)) |
| 194 | 194 | error_log($exception->__toString()); |
| 195 | 195 | |
| 196 | - $content = $this->getErrorTemplate($statusCode, $exception); |
|
| 196 | + $content=$this->getErrorTemplate($statusCode, $exception); |
|
| 197 | 197 | |
| 198 | - $serverAdmin = isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:''; |
|
| 198 | + $serverAdmin=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : ''; |
|
| 199 | 199 | |
| 200 | - $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
|
| 200 | + $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
| 201 | 201 | |
| 202 | - $errorMessage = $exception->getMessage(); |
|
| 202 | + $errorMessage=$exception->getMessage(); |
|
| 203 | 203 | if($isDebug) |
| 204 | - $version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion(); |
|
| 204 | + $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
|
| 205 | 205 | else |
| 206 | 206 | { |
| 207 | - $version = ''; |
|
| 208 | - $errorMessage = self::hideSecurityRelated($errorMessage, $exception); |
|
| 207 | + $version=''; |
|
| 208 | + $errorMessage=self::hideSecurityRelated($errorMessage, $exception); |
|
| 209 | 209 | } |
| 210 | - $tokens = [ |
|
| 210 | + $tokens=[ |
|
| 211 | 211 | '%%StatusCode%%' => "$statusCode", |
| 212 | 212 | '%%ErrorMessage%%' => htmlspecialchars($errorMessage), |
| 213 | 213 | '%%ServerAdmin%%' => $serverAdmin, |
@@ -229,16 +229,16 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | protected function handleRecursiveError($exception) |
| 231 | 231 | { |
| 232 | - if($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 232 | + if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 233 | 233 | { |
| 234 | 234 | echo "<html><head><title>Recursive Error</title></head>\n"; |
| 235 | 235 | echo "<body><h1>Recursive Error</h1>\n"; |
| 236 | - echo "<pre>" . $exception->__toString() . "</pre>\n"; |
|
| 236 | + echo "<pre>".$exception->__toString()."</pre>\n"; |
|
| 237 | 237 | echo "</body></html>"; |
| 238 | 238 | } |
| 239 | 239 | else |
| 240 | 240 | { |
| 241 | - error_log("Error happened while processing an existing error:\n" . $exception->__toString()); |
|
| 241 | + error_log("Error happened while processing an existing error:\n".$exception->__toString()); |
|
| 242 | 242 | header('HTTP/1.0 500 Internal Error'); |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -252,53 +252,53 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | protected function displayException($exception) |
| 254 | 254 | { |
| 255 | - if(php_sapi_name() === 'cli') |
|
| 255 | + if(php_sapi_name()==='cli') |
|
| 256 | 256 | { |
| 257 | - echo $exception->getMessage() . "\n"; |
|
| 257 | + echo $exception->getMessage()."\n"; |
|
| 258 | 258 | echo $this->getExactTraceAsString($exception); |
| 259 | 259 | return; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | if($exception instanceof TTemplateException) |
| 263 | 263 | { |
| 264 | - $fileName = $exception->getTemplateFile(); |
|
| 265 | - $lines = empty($fileName)?explode("\n", $exception->getTemplateSource()):@file($fileName); |
|
| 266 | - $source = $this->getSourceCode($lines, $exception->getLineNumber()); |
|
| 267 | - if($fileName === '') |
|
| 268 | - $fileName = '---embedded template---'; |
|
| 269 | - $errorLine = $exception->getLineNumber(); |
|
| 264 | + $fileName=$exception->getTemplateFile(); |
|
| 265 | + $lines=empty($fileName) ?explode("\n", $exception->getTemplateSource()) : @file($fileName); |
|
| 266 | + $source=$this->getSourceCode($lines, $exception->getLineNumber()); |
|
| 267 | + if($fileName==='') |
|
| 268 | + $fileName='---embedded template---'; |
|
| 269 | + $errorLine=$exception->getLineNumber(); |
|
| 270 | 270 | } |
| 271 | 271 | else |
| 272 | 272 | { |
| 273 | - if(($trace = $this->getExactTrace($exception)) !== null) |
|
| 273 | + if(($trace=$this->getExactTrace($exception))!==null) |
|
| 274 | 274 | { |
| 275 | - $fileName = $trace['file']; |
|
| 276 | - $errorLine = $trace['line']; |
|
| 275 | + $fileName=$trace['file']; |
|
| 276 | + $errorLine=$trace['line']; |
|
| 277 | 277 | } |
| 278 | 278 | else |
| 279 | 279 | { |
| 280 | - $fileName = $exception->getFile(); |
|
| 281 | - $errorLine = $exception->getLine(); |
|
| 280 | + $fileName=$exception->getFile(); |
|
| 281 | + $errorLine=$exception->getLine(); |
|
| 282 | 282 | } |
| 283 | - $source = $this->getSourceCode(@file($fileName), $errorLine); |
|
| 283 | + $source=$this->getSourceCode(@file($fileName), $errorLine); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - if($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 287 | - $version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion(); |
|
| 286 | + if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 287 | + $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
|
| 288 | 288 | else |
| 289 | - $version = ''; |
|
| 289 | + $version=''; |
|
| 290 | 290 | |
| 291 | - $tokens = [ |
|
| 291 | + $tokens=[ |
|
| 292 | 292 | '%%ErrorType%%' => get_class($exception), |
| 293 | 293 | '%%ErrorMessage%%' => $this->addLink(htmlspecialchars($exception->getMessage())), |
| 294 | - '%%SourceFile%%' => htmlspecialchars($fileName) . ' (' . $errorLine . ')', |
|
| 294 | + '%%SourceFile%%' => htmlspecialchars($fileName).' ('.$errorLine.')', |
|
| 295 | 295 | '%%SourceCode%%' => $source, |
| 296 | 296 | '%%StackTrace%%' => htmlspecialchars($this->getExactTraceAsString($exception)), |
| 297 | 297 | '%%Version%%' => $version, |
| 298 | 298 | '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
| 299 | 299 | ]; |
| 300 | 300 | |
| 301 | - $content = $this->getExceptionTemplate($exception); |
|
| 301 | + $content=$this->getExceptionTemplate($exception); |
|
| 302 | 302 | |
| 303 | 303 | echo strtr($content, $tokens); |
| 304 | 304 | } |
@@ -312,11 +312,11 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | protected function getExceptionTemplate($exception) |
| 314 | 314 | { |
| 315 | - $lang = Prado::getPreferredLanguage(); |
|
| 316 | - $exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '-' . $lang . '.html'; |
|
| 315 | + $lang=Prado::getPreferredLanguage(); |
|
| 316 | + $exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'-'.$lang.'.html'; |
|
| 317 | 317 | if(!is_file($exceptionFile)) |
| 318 | - $exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '.html'; |
|
| 319 | - if(($content = @file_get_contents($exceptionFile)) === false) |
|
| 318 | + $exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'.html'; |
|
| 319 | + if(($content=@file_get_contents($exceptionFile))===false) |
|
| 320 | 320 | die("Unable to open exception template file '$exceptionFile'."); |
| 321 | 321 | return $content; |
| 322 | 322 | } |
@@ -339,45 +339,45 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | protected function getErrorTemplate($statusCode, $exception) |
| 341 | 341 | { |
| 342 | - $base = $this->getErrorTemplatePath() . DIRECTORY_SEPARATOR . self::ERROR_FILE_NAME; |
|
| 343 | - $lang = Prado::getPreferredLanguage(); |
|
| 342 | + $base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME; |
|
| 343 | + $lang=Prado::getPreferredLanguage(); |
|
| 344 | 344 | if(is_file("$base$statusCode-$lang.html")) |
| 345 | - $errorFile = "$base$statusCode-$lang.html"; |
|
| 345 | + $errorFile="$base$statusCode-$lang.html"; |
|
| 346 | 346 | elseif(is_file("$base$statusCode.html")) |
| 347 | - $errorFile = "$base$statusCode.html"; |
|
| 347 | + $errorFile="$base$statusCode.html"; |
|
| 348 | 348 | elseif(is_file("$base-$lang.html")) |
| 349 | - $errorFile = "$base-$lang.html"; |
|
| 349 | + $errorFile="$base-$lang.html"; |
|
| 350 | 350 | else |
| 351 | - $errorFile = "$base.html"; |
|
| 352 | - if(($content = @file_get_contents($errorFile)) === false) |
|
| 351 | + $errorFile="$base.html"; |
|
| 352 | + if(($content=@file_get_contents($errorFile))===false) |
|
| 353 | 353 | die("Unable to open error template file '$errorFile'."); |
| 354 | 354 | return $content; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | private function getExactTrace($exception) |
| 358 | 358 | { |
| 359 | - $result = null; |
|
| 359 | + $result=null; |
|
| 360 | 360 | if($exception instanceof TPhpFatalErrorException && |
| 361 | 361 | function_exists('xdebug_get_function_stack')) |
| 362 | 362 | { |
| 363 | - $trace = array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1); |
|
| 363 | + $trace=array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1); |
|
| 364 | 364 | } else { |
| 365 | - $trace = $exception->getTrace(); |
|
| 365 | + $trace=$exception->getTrace(); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // if PHP exception, we want to show the 2nd stack level context |
| 369 | 369 | // because the 1st stack level is of little use (it's in error handler) |
| 370 | 370 | if($exception instanceof TPhpErrorException) { |
| 371 | 371 | if(isset($trace[0]['file'])) |
| 372 | - $result = $trace[0]; |
|
| 372 | + $result=$trace[0]; |
|
| 373 | 373 | elseif(isset($trace[1])) |
| 374 | - $result = $trace[1]; |
|
| 374 | + $result=$trace[1]; |
|
| 375 | 375 | } elseif($exception instanceof TInvalidOperationException) { |
| 376 | 376 | // in case of getter or setter error, find out the exact file and row |
| 377 | - if(($result = $this->getPropertyAccessTrace($trace, '__get')) === null) |
|
| 378 | - $result = $this->getPropertyAccessTrace($trace, '__set'); |
|
| 377 | + if(($result=$this->getPropertyAccessTrace($trace, '__get'))===null) |
|
| 378 | + $result=$this->getPropertyAccessTrace($trace, '__set'); |
|
| 379 | 379 | } |
| 380 | - if($result !== null && strpos($result['file'], ': eval()\'d code') !== false) |
|
| 380 | + if($result!==null && strpos($result['file'], ': eval()\'d code')!==false) |
|
| 381 | 381 | return null; |
| 382 | 382 | |
| 383 | 383 | return $result; |
@@ -388,19 +388,19 @@ discard block |
||
| 388 | 388 | if($exception instanceof TPhpFatalErrorException && |
| 389 | 389 | function_exists('xdebug_get_function_stack')) |
| 390 | 390 | { |
| 391 | - $trace = array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1); |
|
| 392 | - $txt = ''; |
|
| 393 | - $row = 0; |
|
| 391 | + $trace=array_slice(array_reverse(xdebug_get_function_stack()), self::FATAL_ERROR_TRACE_DROP_LINES, -1); |
|
| 392 | + $txt=''; |
|
| 393 | + $row=0; |
|
| 394 | 394 | |
| 395 | 395 | // try to mimic Exception::getTraceAsString() |
| 396 | 396 | foreach($trace as $line) |
| 397 | 397 | { |
| 398 | 398 | if(array_key_exists('function', $line)) |
| 399 | - $func = $line['function'] . '(' . implode(',', $line['params']) . ')'; |
|
| 399 | + $func=$line['function'].'('.implode(',', $line['params']).')'; |
|
| 400 | 400 | else |
| 401 | - $func = 'unknown'; |
|
| 401 | + $func='unknown'; |
|
| 402 | 402 | |
| 403 | - $txt .= '#' . $row . ' ' . $line['file'] . '(' . $line['line'] . '): ' . $func . "\n"; |
|
| 403 | + $txt.='#'.$row.' '.$line['file'].'('.$line['line'].'): '.$func."\n"; |
|
| 404 | 404 | $row++; |
| 405 | 405 | } |
| 406 | 406 | |
@@ -412,11 +412,11 @@ discard block |
||
| 412 | 412 | |
| 413 | 413 | private function getPropertyAccessTrace($trace, $pattern) |
| 414 | 414 | { |
| 415 | - $result = null; |
|
| 415 | + $result=null; |
|
| 416 | 416 | foreach($trace as $t) |
| 417 | 417 | { |
| 418 | - if(isset($t['function']) && $t['function'] === $pattern) |
|
| 419 | - $result = $t; |
|
| 418 | + if(isset($t['function']) && $t['function']===$pattern) |
|
| 419 | + $result=$t; |
|
| 420 | 420 | else |
| 421 | 421 | break; |
| 422 | 422 | } |
@@ -425,44 +425,44 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | private function getSourceCode($lines, $errorLine) |
| 427 | 427 | { |
| 428 | - $beginLine = $errorLine - self::SOURCE_LINES >= 0?$errorLine - self::SOURCE_LINES:0; |
|
| 429 | - $endLine = $errorLine + self::SOURCE_LINES <= count($lines)?$errorLine + self::SOURCE_LINES:count($lines); |
|
| 428 | + $beginLine=$errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0; |
|
| 429 | + $endLine=$errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines); |
|
| 430 | 430 | |
| 431 | - $source = ''; |
|
| 432 | - for($i = $beginLine;$i < $endLine;++$i) |
|
| 431 | + $source=''; |
|
| 432 | + for($i=$beginLine; $i < $endLine; ++$i) |
|
| 433 | 433 | { |
| 434 | - if($i === $errorLine - 1) |
|
| 434 | + if($i===$errorLine - 1) |
|
| 435 | 435 | { |
| 436 | - $line = htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
| 437 | - $source .= "<div class=\"error\">" . $line . "</div>"; |
|
| 436 | + $line=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
| 437 | + $source.="<div class=\"error\">".$line."</div>"; |
|
| 438 | 438 | } |
| 439 | 439 | else |
| 440 | - $source .= htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
| 440 | + $source.=htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
| 441 | 441 | } |
| 442 | 442 | return $source; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | private function addLink($message) { |
| 446 | - if (null !== ($class = $this->getErrorClassNameSpace($message))) { |
|
| 447 | - return str_replace($class['name'], '<a href="' . $class['url'] . '" target="_blank">' . $class['name'] . '</a>', $message); |
|
| 446 | + if(null!==($class=$this->getErrorClassNameSpace($message))) { |
|
| 447 | + return str_replace($class['name'], '<a href="'.$class['url'].'" target="_blank">'.$class['name'].'</a>', $message); |
|
| 448 | 448 | } |
| 449 | 449 | return $message; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | private function getErrorClassNameSpace($message) { |
| 453 | - $matches = []; |
|
| 453 | + $matches=[]; |
|
| 454 | 454 | preg_match('/\b(T[A-Z]\w+)\b/', $message, $matches); |
| 455 | - if (is_array($matches) && count($matches) > 0) { |
|
| 456 | - $class = $matches[0]; |
|
| 455 | + if(is_array($matches) && count($matches) > 0) { |
|
| 456 | + $class=$matches[0]; |
|
| 457 | 457 | try { |
| 458 | - $function = new \ReflectionClass($class); |
|
| 458 | + $function=new \ReflectionClass($class); |
|
| 459 | 459 | } |
| 460 | - catch (\Exception $e) { |
|
| 460 | + catch(\Exception $e) { |
|
| 461 | 461 | return null; |
| 462 | 462 | } |
| 463 | - $classname = $function->getNamespaceName(); |
|
| 463 | + $classname=$function->getNamespaceName(); |
|
| 464 | 464 | return [ |
| 465 | - 'url' => 'http://pradosoft.github.io/docs/manual/class-' . str_replace('\\', '.', (string) $classname) . '.' . $class . '.html', |
|
| 465 | + 'url' => 'http://pradosoft.github.io/docs/manual/class-'.str_replace('\\', '.', (string) $classname).'.'.$class.'.html', |
|
| 466 | 466 | 'name' => $class, |
| 467 | 467 | ]; |
| 468 | 468 | } |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | class TTemplateException extends TConfigurationException |
| 26 | 26 | { |
| 27 | - private $_template = ''; |
|
| 28 | - private $_lineNumber = 0; |
|
| 29 | - private $_fileName = ''; |
|
| 27 | + private $_template=''; |
|
| 28 | + private $_lineNumber=0; |
|
| 29 | + private $_fileName=''; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * @return string the template source code that causes the exception. This is empty if {@link getTemplateFile TemplateFile} is not empty. |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function setTemplateSource($value) |
| 43 | 43 | { |
| 44 | - $this->_template = $value; |
|
| 44 | + $this->_template=$value; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function setTemplateFile($value) |
| 59 | 59 | { |
| 60 | - $this->_fileName = $value; |
|
| 60 | + $this->_fileName=$value; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -73,6 +73,6 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function setLineNumber($value) |
| 75 | 75 | { |
| 76 | - $this->_lineNumber = TPropertyValue::ensureInteger($value); |
|
| 76 | + $this->_lineNumber=TPropertyValue::ensureInteger($value); |
|
| 77 | 77 | } |
| 78 | 78 | } |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | class TException extends \Exception |
| 39 | 39 | { |
| 40 | - private $_errorCode = ''; |
|
| 41 | - protected static $_messageCache = []; |
|
| 40 | + private $_errorCode=''; |
|
| 41 | + protected static $_messageCache=[]; |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Constructor. |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function __construct($errorMessage) |
| 51 | 51 | { |
| 52 | - $this->_errorCode = $errorMessage; |
|
| 53 | - $errorMessage = $this->translateErrorMessage($errorMessage); |
|
| 54 | - $args = func_get_args(); |
|
| 52 | + $this->_errorCode=$errorMessage; |
|
| 53 | + $errorMessage=$this->translateErrorMessage($errorMessage); |
|
| 54 | + $args=func_get_args(); |
|
| 55 | 55 | array_shift($args); |
| 56 | - $n = count($args); |
|
| 57 | - $tokens = []; |
|
| 58 | - for($i = 0;$i < $n;++$i) |
|
| 59 | - $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]); |
|
| 56 | + $n=count($args); |
|
| 57 | + $tokens=[]; |
|
| 58 | + for($i=0; $i < $n; ++$i) |
|
| 59 | + $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
|
| 60 | 60 | parent::__construct(strtr($errorMessage, $tokens)); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | protected function translateErrorMessage($key) |
| 69 | 69 | { |
| 70 | - $msgFile = $this->getErrorMessageFile(); |
|
| 70 | + $msgFile=$this->getErrorMessageFile(); |
|
| 71 | 71 | |
| 72 | 72 | // Cache messages |
| 73 | - if (!isset(self::$_messageCache[$msgFile])) |
|
| 73 | + if(!isset(self::$_messageCache[$msgFile])) |
|
| 74 | 74 | { |
| 75 | - if(($entries = @file($msgFile)) !== false) |
|
| 75 | + if(($entries=@file($msgFile))!==false) |
|
| 76 | 76 | { |
| 77 | 77 | foreach($entries as $entry) |
| 78 | 78 | { |
| 79 | - list($code, $message) = array_merge(explode('=', $entry, 2), [ '' ]); |
|
| 80 | - self::$_messageCache[$msgFile][trim($code)] = trim($message); |
|
| 79 | + list($code, $message)=array_merge(explode('=', $entry, 2), ['']); |
|
| 80 | + self::$_messageCache[$msgFile][trim($code)]=trim($message); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | protected function getErrorMessageFile() |
| 91 | 91 | { |
| 92 | - $lang = Prado::getPreferredLanguage(); |
|
| 93 | - $msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages-' . $lang . '.txt'; |
|
| 92 | + $lang=Prado::getPreferredLanguage(); |
|
| 93 | + $msgFile=Prado::getFrameworkPath().'/Exceptions/messages/messages-'.$lang.'.txt'; |
|
| 94 | 94 | if(!is_file($msgFile)) |
| 95 | - $msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages.txt'; |
|
| 95 | + $msgFile=Prado::getFrameworkPath().'/Exceptions/messages/messages.txt'; |
|
| 96 | 96 | return $msgFile; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function setErrorCode($code) |
| 111 | 111 | { |
| 112 | - $this->_errorCode = $code; |
|
| 112 | + $this->_errorCode=$code; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -125,6 +125,6 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | protected function setErrorMessage($message) |
| 127 | 127 | { |
| 128 | - $this->message = $message; |
|
| 128 | + $this->message=$message; |
|
| 129 | 129 | } |
| 130 | 130 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function __construct($errno, $errstr, $errfile, $errline) |
| 34 | 34 | { |
| 35 | - static $errorTypes = [ |
|
| 35 | + static $errorTypes=[ |
|
| 36 | 36 | E_ERROR => "Error", |
| 37 | 37 | E_WARNING => "Warning", |
| 38 | 38 | E_PARSE => "Parsing Error", |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | E_USER_NOTICE => "User Notice", |
| 47 | 47 | E_STRICT => "Runtime Notice" |
| 48 | 48 | ]; |
| 49 | - $errorType = isset($errorTypes[$errno])?$errorTypes[$errno]:'Unknown Error'; |
|
| 49 | + $errorType=isset($errorTypes[$errno]) ? $errorTypes[$errno] : 'Unknown Error'; |
|
| 50 | 50 | parent::__construct("[$errorType] $errstr (@line $errline in file $errfile)."); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -29,35 +29,35 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @var array list of application initial property values, indexed by property names |
| 31 | 31 | */ |
| 32 | - private $_properties = []; |
|
| 32 | + private $_properties=[]; |
|
| 33 | 33 | /** |
| 34 | 34 | * @var array list of namespaces to be used |
| 35 | 35 | */ |
| 36 | - private $_usings = []; |
|
| 36 | + private $_usings=[]; |
|
| 37 | 37 | /** |
| 38 | 38 | * @var array list of path aliases, indexed by alias names |
| 39 | 39 | */ |
| 40 | - private $_aliases = []; |
|
| 40 | + private $_aliases=[]; |
|
| 41 | 41 | /** |
| 42 | 42 | * @var array list of module configurations |
| 43 | 43 | */ |
| 44 | - private $_modules = []; |
|
| 44 | + private $_modules=[]; |
|
| 45 | 45 | /** |
| 46 | 46 | * @var array list of service configurations |
| 47 | 47 | */ |
| 48 | - private $_services = []; |
|
| 48 | + private $_services=[]; |
|
| 49 | 49 | /** |
| 50 | 50 | * @var array list of parameters |
| 51 | 51 | */ |
| 52 | - private $_parameters = []; |
|
| 52 | + private $_parameters=[]; |
|
| 53 | 53 | /** |
| 54 | 54 | * @var array list of included configurations |
| 55 | 55 | */ |
| 56 | - private $_includes = []; |
|
| 56 | + private $_includes=[]; |
|
| 57 | 57 | /** |
| 58 | 58 | * @var boolean whether this configuration contains actual stuff |
| 59 | 59 | */ |
| 60 | - private $_empty = true; |
|
| 60 | + private $_empty=true; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * Parses the application configuration file. |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function loadFromFile($fname) |
| 68 | 68 | { |
| 69 | - if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
| 69 | + if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
|
| 70 | 70 | { |
| 71 | - $fcontent = include $fname; |
|
| 71 | + $fcontent=include $fname; |
|
| 72 | 72 | $this->loadFromPhp($fcontent, dirname($fname)); |
| 73 | 73 | } |
| 74 | 74 | else |
| 75 | 75 | { |
| 76 | - $dom = new TXmlDocument; |
|
| 76 | + $dom=new TXmlDocument; |
|
| 77 | 77 | $dom->loadFromFile($fname); |
| 78 | 78 | $this->loadFromXml($dom, dirname($fname)); |
| 79 | 79 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | foreach($config['application'] as $name => $value) |
| 101 | 101 | { |
| 102 | - $this->_properties[$name] = $value; |
|
| 102 | + $this->_properties[$name]=$value; |
|
| 103 | 103 | } |
| 104 | - $this->_empty = false; |
|
| 104 | + $this->_empty=false; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | if(isset($config['paths']) && is_array($config['paths'])) |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | // application properties |
| 131 | 131 | foreach($dom->getAttributes() as $name => $value) |
| 132 | 132 | { |
| 133 | - $this->_properties[$name] = $value; |
|
| 134 | - $this->_empty = false; |
|
| 133 | + $this->_properties[$name]=$value; |
|
| 134 | + $this->_empty=false; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | foreach($dom->getElements() as $element) |
@@ -171,16 +171,16 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | foreach($pathsNode['aliases'] as $id => $path) |
| 173 | 173 | { |
| 174 | - $path = str_replace('\\', '/', $path); |
|
| 174 | + $path=str_replace('\\', '/', $path); |
|
| 175 | 175 | if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
| 176 | - $p = realpath($path); |
|
| 176 | + $p=realpath($path); |
|
| 177 | 177 | else |
| 178 | - $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
| 179 | - if($p === false || !is_dir($p)) |
|
| 178 | + $p=realpath($configPath.DIRECTORY_SEPARATOR.$path); |
|
| 179 | + if($p===false || !is_dir($p)) |
|
| 180 | 180 | throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
| 181 | 181 | if(isset($this->_aliases[$id])) |
| 182 | 182 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
| 183 | - $this->_aliases[$id] = $p; |
|
| 183 | + $this->_aliases[$id]=$p; |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | foreach($pathsNode['using'] as $namespace) |
| 190 | 190 | { |
| 191 | - $this->_usings[] = $namespace; |
|
| 191 | + $this->_usings[]=$namespace; |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -206,31 +206,31 @@ discard block |
||
| 206 | 206 | { |
| 207 | 207 | case 'alias': |
| 208 | 208 | { |
| 209 | - if(($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null) |
|
| 209 | + if(($id=$element->getAttribute('id'))!==null && ($path=$element->getAttribute('path'))!==null) |
|
| 210 | 210 | { |
| 211 | - $path = str_replace('\\', '/', $path); |
|
| 211 | + $path=str_replace('\\', '/', $path); |
|
| 212 | 212 | if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
| 213 | - $p = realpath($path); |
|
| 213 | + $p=realpath($path); |
|
| 214 | 214 | else |
| 215 | - $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
| 216 | - if($p === false || !is_dir($p)) |
|
| 215 | + $p=realpath($configPath.DIRECTORY_SEPARATOR.$path); |
|
| 216 | + if($p===false || !is_dir($p)) |
|
| 217 | 217 | throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
| 218 | 218 | if(isset($this->_aliases[$id])) |
| 219 | 219 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
| 220 | - $this->_aliases[$id] = $p; |
|
| 220 | + $this->_aliases[$id]=$p; |
|
| 221 | 221 | } |
| 222 | 222 | else |
| 223 | 223 | throw new TConfigurationException('appconfig_alias_invalid'); |
| 224 | - $this->_empty = false; |
|
| 224 | + $this->_empty=false; |
|
| 225 | 225 | break; |
| 226 | 226 | } |
| 227 | 227 | case 'using': |
| 228 | 228 | { |
| 229 | - if(($namespace = $element->getAttribute('namespace')) !== null) |
|
| 230 | - $this->_usings[] = $namespace; |
|
| 229 | + if(($namespace=$element->getAttribute('namespace'))!==null) |
|
| 230 | + $this->_usings[]=$namespace; |
|
| 231 | 231 | else |
| 232 | 232 | throw new TConfigurationException('appconfig_using_invalid'); |
| 233 | - $this->_empty = false; |
|
| 233 | + $this->_empty=false; |
|
| 234 | 234 | break; |
| 235 | 235 | } |
| 236 | 236 | default: |
@@ -250,17 +250,17 @@ discard block |
||
| 250 | 250 | { |
| 251 | 251 | if(!isset($module['class'])) |
| 252 | 252 | throw new TConfigurationException('appconfig_moduletype_required', $id); |
| 253 | - $type = $module['class']; |
|
| 253 | + $type=$module['class']; |
|
| 254 | 254 | unset($module['class']); |
| 255 | - $properties = []; |
|
| 255 | + $properties=[]; |
|
| 256 | 256 | if(isset($module['properties'])) |
| 257 | 257 | { |
| 258 | - $properties = $module['properties']; |
|
| 258 | + $properties=$module['properties']; |
|
| 259 | 259 | unset($module['properties']); |
| 260 | 260 | } |
| 261 | - $properties['id'] = $id; |
|
| 262 | - $this->_modules[$id] = [$type,$properties,$module]; |
|
| 263 | - $this->_empty = false; |
|
| 261 | + $properties['id']=$id; |
|
| 262 | + $this->_modules[$id]=[$type, $properties, $module]; |
|
| 263 | + $this->_empty=false; |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | |
@@ -273,19 +273,19 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | foreach($modulesNode->getElements() as $element) |
| 275 | 275 | { |
| 276 | - if($element->getTagName() === 'module') |
|
| 276 | + if($element->getTagName()==='module') |
|
| 277 | 277 | { |
| 278 | - $properties = $element->getAttributes(); |
|
| 279 | - $id = $properties->itemAt('id'); |
|
| 280 | - $type = $properties->remove('class'); |
|
| 281 | - if($type === null) |
|
| 278 | + $properties=$element->getAttributes(); |
|
| 279 | + $id=$properties->itemAt('id'); |
|
| 280 | + $type=$properties->remove('class'); |
|
| 281 | + if($type===null) |
|
| 282 | 282 | throw new TConfigurationException('appconfig_moduletype_required', $id); |
| 283 | 283 | $element->setParent(null); |
| 284 | - if($id === null) |
|
| 285 | - $this->_modules[] = [$type,$properties->toArray(),$element]; |
|
| 284 | + if($id===null) |
|
| 285 | + $this->_modules[]=[$type, $properties->toArray(), $element]; |
|
| 286 | 286 | else |
| 287 | - $this->_modules[$id] = [$type,$properties->toArray(),$element]; |
|
| 288 | - $this->_empty = false; |
|
| 287 | + $this->_modules[$id]=[$type, $properties->toArray(), $element]; |
|
| 288 | + $this->_empty=false; |
|
| 289 | 289 | } |
| 290 | 290 | else |
| 291 | 291 | throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName()); |
@@ -303,12 +303,12 @@ discard block |
||
| 303 | 303 | { |
| 304 | 304 | if(!isset($service['class'])) |
| 305 | 305 | throw new TConfigurationException('appconfig_servicetype_required'); |
| 306 | - $type = $service['class']; |
|
| 307 | - $properties = isset($service['properties']) ? $service['properties'] : []; |
|
| 306 | + $type=$service['class']; |
|
| 307 | + $properties=isset($service['properties']) ? $service['properties'] : []; |
|
| 308 | 308 | unset($service['properties']); |
| 309 | - $properties['id'] = $id; |
|
| 310 | - $this->_services[$id] = [$type,$properties,$service]; |
|
| 311 | - $this->_empty = false; |
|
| 309 | + $properties['id']=$id; |
|
| 310 | + $this->_services[$id]=[$type, $properties, $service]; |
|
| 311 | + $this->_empty=false; |
|
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
@@ -321,16 +321,16 @@ discard block |
||
| 321 | 321 | { |
| 322 | 322 | foreach($servicesNode->getElements() as $element) |
| 323 | 323 | { |
| 324 | - if($element->getTagName() === 'service') |
|
| 324 | + if($element->getTagName()==='service') |
|
| 325 | 325 | { |
| 326 | - $properties = $element->getAttributes(); |
|
| 327 | - if(($id = $properties->itemAt('id')) === null) |
|
| 326 | + $properties=$element->getAttributes(); |
|
| 327 | + if(($id=$properties->itemAt('id'))===null) |
|
| 328 | 328 | throw new TConfigurationException('appconfig_serviceid_required'); |
| 329 | - if(($type = $properties->remove('class')) === null) |
|
| 329 | + if(($type=$properties->remove('class'))===null) |
|
| 330 | 330 | throw new TConfigurationException('appconfig_servicetype_required', $id); |
| 331 | 331 | $element->setParent(null); |
| 332 | - $this->_services[$id] = [$type,$properties->toArray(),$element]; |
|
| 333 | - $this->_empty = false; |
|
| 332 | + $this->_services[$id]=[$type, $properties->toArray(), $element]; |
|
| 333 | + $this->_empty=false; |
|
| 334 | 334 | } |
| 335 | 335 | else |
| 336 | 336 | throw new TConfigurationException('appconfig_services_invalid', $element->getTagName()); |
@@ -350,16 +350,16 @@ discard block |
||
| 350 | 350 | { |
| 351 | 351 | if(isset($parameter['class'])) |
| 352 | 352 | { |
| 353 | - $type = $parameter['class']; |
|
| 353 | + $type=$parameter['class']; |
|
| 354 | 354 | unset($parameter['class']); |
| 355 | - $properties = isset($service['properties']) ? $service['properties'] : []; |
|
| 356 | - $properties['id'] = $id; |
|
| 357 | - $this->_parameters[$id] = [$type,$properties]; |
|
| 355 | + $properties=isset($service['properties']) ? $service['properties'] : []; |
|
| 356 | + $properties['id']=$id; |
|
| 357 | + $this->_parameters[$id]=[$type, $properties]; |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | else |
| 361 | 361 | { |
| 362 | - $this->_parameters[$id] = $parameter; |
|
| 362 | + $this->_parameters[$id]=$parameter; |
|
| 363 | 363 | } |
| 364 | 364 | } |
| 365 | 365 | } |
@@ -373,21 +373,21 @@ discard block |
||
| 373 | 373 | { |
| 374 | 374 | foreach($parametersNode->getElements() as $element) |
| 375 | 375 | { |
| 376 | - if($element->getTagName() === 'parameter') |
|
| 376 | + if($element->getTagName()==='parameter') |
|
| 377 | 377 | { |
| 378 | - $properties = $element->getAttributes(); |
|
| 379 | - if(($id = $properties->remove('id')) === null) |
|
| 378 | + $properties=$element->getAttributes(); |
|
| 379 | + if(($id=$properties->remove('id'))===null) |
|
| 380 | 380 | throw new TConfigurationException('appconfig_parameterid_required'); |
| 381 | - if(($type = $properties->remove('class')) === null) |
|
| 381 | + if(($type=$properties->remove('class'))===null) |
|
| 382 | 382 | { |
| 383 | - if(($value = $properties->remove('value')) === null) |
|
| 384 | - $this->_parameters[$id] = $element; |
|
| 383 | + if(($value=$properties->remove('value'))===null) |
|
| 384 | + $this->_parameters[$id]=$element; |
|
| 385 | 385 | else |
| 386 | - $this->_parameters[$id] = $value; |
|
| 386 | + $this->_parameters[$id]=$value; |
|
| 387 | 387 | } |
| 388 | 388 | else |
| 389 | - $this->_parameters[$id] = [$type,$properties->toArray()]; |
|
| 390 | - $this->_empty = false; |
|
| 389 | + $this->_parameters[$id]=[$type, $properties->toArray()]; |
|
| 390 | + $this->_empty=false; |
|
| 391 | 391 | } |
| 392 | 392 | else |
| 393 | 393 | throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName()); |
@@ -403,15 +403,15 @@ discard block |
||
| 403 | 403 | { |
| 404 | 404 | foreach($includeNode as $include) |
| 405 | 405 | { |
| 406 | - $when = isset($include['when'])?true:false; |
|
| 406 | + $when=isset($include['when']) ?true:false; |
|
| 407 | 407 | if(!isset($include['file'])) |
| 408 | 408 | throw new TConfigurationException('appconfig_includefile_required'); |
| 409 | - $filePath = $include['file']; |
|
| 409 | + $filePath=$include['file']; |
|
| 410 | 410 | if(isset($this->_includes[$filePath])) |
| 411 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
| 411 | + $this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')'; |
|
| 412 | 412 | else |
| 413 | - $$this->_includes[$filePath] = $when; |
|
| 414 | - $this->_empty = false; |
|
| 413 | + $$this->_includes[$filePath]=$when; |
|
| 414 | + $this->_empty=false; |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | |
@@ -422,15 +422,15 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | protected function loadExternalXml($includeNode, $configPath) |
| 424 | 424 | { |
| 425 | - if(($when = $includeNode->getAttribute('when')) === null) |
|
| 426 | - $when = true; |
|
| 427 | - if(($filePath = $includeNode->getAttribute('file')) === null) |
|
| 425 | + if(($when=$includeNode->getAttribute('when'))===null) |
|
| 426 | + $when=true; |
|
| 427 | + if(($filePath=$includeNode->getAttribute('file'))===null) |
|
| 428 | 428 | throw new TConfigurationException('appconfig_includefile_required'); |
| 429 | 429 | if(isset($this->_includes[$filePath])) |
| 430 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
| 430 | + $this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')'; |
|
| 431 | 431 | else |
| 432 | - $this->_includes[$filePath] = $when; |
|
| 433 | - $this->_empty = false; |
|
| 432 | + $this->_includes[$filePath]=$when; |
|
| 433 | + $this->_empty=false; |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -34,10 +34,10 @@ |
||
| 34 | 34 | { |
| 35 | 35 | if($user instanceof IUser) |
| 36 | 36 | { |
| 37 | - $verb = strtolower(trim($verb)); |
|
| 37 | + $verb=strtolower(trim($verb)); |
|
| 38 | 38 | foreach($this as $rule) |
| 39 | 39 | { |
| 40 | - if(($decision = $rule->isUserAllowed($user, $verb, $ip)) !== 0) |
|
| 40 | + if(($decision=$rule->isUserAllowed($user, $verb, $ip))!==0) |
|
| 41 | 41 | return ($decision > 0); |
| 42 | 42 | } |
| 43 | 43 | return true; |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class TUserManagerPasswordMode extends \Prado\TEnumerable |
| 29 | 29 | { |
| 30 | - const Clear = 'Clear'; |
|
| 31 | - const MD5 = 'MD5'; |
|
| 32 | - const SHA1 = 'SHA1'; |
|
| 30 | + const Clear='Clear'; |
|
| 31 | + const MD5='MD5'; |
|
| 32 | + const SHA1='SHA1'; |
|
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |
@@ -37,19 +37,19 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | public function getDbConnection() |
| 39 | 39 | { |
| 40 | - if($this->_connection === null) |
|
| 40 | + if($this->_connection===null) |
|
| 41 | 41 | { |
| 42 | - $userManager = $this->getManager(); |
|
| 42 | + $userManager=$this->getManager(); |
|
| 43 | 43 | if($userManager instanceof TDbUserManager) |
| 44 | 44 | { |
| 45 | - $connection = $userManager->getDbConnection(); |
|
| 45 | + $connection=$userManager->getDbConnection(); |
|
| 46 | 46 | if($connection instanceof TDbConnection) |
| 47 | 47 | { |
| 48 | 48 | $connection->setActive(true); |
| 49 | - $this->_connection = $connection; |
|
| 49 | + $this->_connection=$connection; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | - if($this->_connection === null) |
|
| 52 | + if($this->_connection===null) |
|
| 53 | 53 | throw new TConfigurationException('dbuser_dbconnection_invalid'); |
| 54 | 54 | } |
| 55 | 55 | return $this->_connection; |