@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function addFilter($newFilter) |
| 107 | 107 | { |
| 108 | - if($this->headFilter === null) { |
|
| 108 | + if ($this->headFilter === null) { |
|
| 109 | 109 | $this->headFilter = $newFilter; |
| 110 | - $this->tailFilter =& $this->headFilter; |
|
| 110 | + $this->tailFilter = & $this->headFilter; |
|
| 111 | 111 | } else { |
| 112 | 112 | $this->tailFilter->next = $newFilter; |
| 113 | - $this->tailFilter =& $this->tailFilter->next; |
|
| 113 | + $this->tailFilter = & $this->tailFilter->next; |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | LoggerLog::debug("LoggerAppenderSkeleton::doAppend() Attempted to append to closed appender named [{$this->name}]."); |
| 255 | 255 | return; |
| 256 | 256 | } |
| 257 | - if(!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
| 257 | + if (!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
| 258 | 258 | LoggerLog::debug("LoggerAppenderSkeleton::doAppend() event level is less severe than threshold."); |
| 259 | 259 | return; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $f = $this->getFirstFilter(); |
| 263 | 263 | |
| 264 | - while($f !== null) { |
|
| 264 | + while ($f !== null) { |
|
| 265 | 265 | switch ($f->decide($event)) { |
| 266 | 266 | case LOG4PHP_LOGGER_FILTER_DENY: return; |
| 267 | 267 | case LOG4PHP_LOGGER_FILTER_ACCEPT: return $this->append($event); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public function setErrorHandler($errorHandler) |
| 289 | 289 | { |
| 290 | - if($errorHandler === null) { |
|
| 290 | + if ($errorHandler === null) { |
|
| 291 | 291 | // We do not throw exception here since the cause is probably a |
| 292 | 292 | // bad config file. |
| 293 | 293 | LoggerLog::warn("You have tried to set a null error-handler."); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | $GLOBALS['log4php.LoggerPatternConverter.spaces'] = array(" ", " ", " ", " ", //1,2,4,8 spaces |
| 34 | 34 | " ", // 16 spaces |
| 35 | - " " ); // 32 spaces |
|
| 35 | + " "); // 32 spaces |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * LoggerPatternConverter is an abstract class that provides the formatting |
@@ -97,18 +97,18 @@ discard block |
||
| 97 | 97 | LoggerLog::debug("LoggerPatternConverter::format() converted event is '$s'"); |
| 98 | 98 | |
| 99 | 99 | |
| 100 | - if($s === null || empty($s)) { |
|
| 101 | - if(0 < $this->min) |
|
| 100 | + if ($s === null || empty($s)) { |
|
| 101 | + if (0 < $this->min) |
|
| 102 | 102 | $this->spacePad($sbuf, $this->min); |
| 103 | 103 | return; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $len = strlen($s); |
| 107 | 107 | |
| 108 | - if($len > $this->max) { |
|
| 109 | - $sbuf .= substr($s , 0, ($len - $this->max)); |
|
| 110 | - } elseif($len < $this->min) { |
|
| 111 | - if($this->leftAlign) { |
|
| 108 | + if ($len > $this->max) { |
|
| 109 | + $sbuf .= substr($s, 0, ($len - $this->max)); |
|
| 110 | + } elseif ($len < $this->min) { |
|
| 111 | + if ($this->leftAlign) { |
|
| 112 | 112 | $sbuf .= $s; |
| 113 | 113 | $this->spacePad($sbuf, ($this->min - $len)); |
| 114 | 114 | } else { |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | LoggerLog::debug("LoggerPatternConverter::spacePad() sbuf='$sbuf' len='$length'"); |
| 135 | 135 | |
| 136 | - while($length >= 32) { |
|
| 136 | + while ($length >= 32) { |
|
| 137 | 137 | $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5]; |
| 138 | 138 | $length -= 32; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - for($i = 4; $i >= 0; $i--) { |
|
| 142 | - if(($length & (1<<$i)) != 0) { |
|
| 141 | + for ($i = 4; $i >= 0; $i--) { |
|
| 142 | + if (($length & (1 << $i)) != 0) { |
|
| 143 | 143 | $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i]; |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -184,11 +184,11 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function convert($event) |
| 186 | 186 | { |
| 187 | - switch($this->type) { |
|
| 187 | + switch ($this->type) { |
|
| 188 | 188 | case LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER: |
| 189 | 189 | $timeStamp = $event->getTimeStamp(); |
| 190 | 190 | $startTime = LoggerLoggingEvent::getStartTime(); |
| 191 | - return (string)(int)($timeStamp * 1000 - $startTime * 1000); |
|
| 191 | + return (string) (int) ($timeStamp * 1000 - $startTime * 1000); |
|
| 192 | 192 | |
| 193 | 193 | case LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER: |
| 194 | 194 | return $event->getThreadName(); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | public function convert($event) |
| 286 | 286 | { |
| 287 | 287 | $timeStamp = $event->getTimeStamp(); |
| 288 | - $usecs = round(($timeStamp - (int)$timeStamp) * 1000); |
|
| 288 | + $usecs = round(($timeStamp - (int) $timeStamp) * 1000); |
|
| 289 | 289 | $this->df = str_replace("\u", "u", ereg_replace("[^\\]u", sprintf(',%03d', $usecs), $this->df)); |
| 290 | 290 | |
| 291 | 291 | return date($this->df, $event->getTimeStamp()); |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | public function convert($event) |
| 363 | 363 | { |
| 364 | 364 | $locationInfo = $event->getLocationInformation(); |
| 365 | - switch($this->type) { |
|
| 365 | + switch ($this->type) { |
|
| 366 | 366 | case LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER: |
| 367 | 367 | return $locationInfo->fullInfo; |
| 368 | 368 | case LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER: |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | LoggerLog::debug("LoggerNamedPatternConverter::LoggerNamedPatternConverter() precision='$precision'"); |
| 402 | 402 | |
| 403 | 403 | $this->LoggerPatternConverter($formattingInfo); |
| 404 | - $this->precision = $precision; |
|
| 404 | + $this->precision = $precision; |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | // We substract 1 from 'len' when assigning to 'end' to avoid out of |
| 431 | 431 | // bounds exception in return r.substring(end+1, len). This can happen if |
| 432 | 432 | // precision is 1 and the category name ends with a dot. |
| 433 | - $end = $len -1 ; |
|
| 434 | - for($i = $this->precision; $i > 0; $i--) { |
|
| 433 | + $end = $len - 1; |
|
| 434 | + for ($i = $this->precision; $i > 0; $i--) { |
|
| 435 | 435 | $end = strrpos(substr($n, 0, ($end - 1)), '.'); |
| 436 | 436 | if ($end === false) |
| 437 | 437 | return $n; |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | require_once(LOG4PHP_DIR . '/LoggerLevel.php'); |
| 26 | 26 | |
| 27 | -define('LOG4PHP_OPTION_CONVERTER_DELIM_START', '${'); |
|
| 28 | -define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP', '}'); |
|
| 29 | -define('LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN', 2); |
|
| 30 | -define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN', 1); |
|
| 27 | +define('LOG4PHP_OPTION_CONVERTER_DELIM_START', '${'); |
|
| 28 | +define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP', '}'); |
|
| 29 | +define('LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN', 2); |
|
| 30 | +define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN', 1); |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * A convenience class to convert property values to specific types. |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | LoggerLog::debug("LoggerOptionConverter::getSystemProperty():key=[{$key}]:def=[{$def}]."); |
| 82 | 82 | |
| 83 | 83 | if (defined($key)) { |
| 84 | - return (string)constant($key); |
|
| 84 | + return (string) constant($key); |
|
| 85 | 85 | } elseif (isset($_ENV[$key])) { |
| 86 | - return (string)$_ENV[$key]; |
|
| 86 | + return (string) $_ENV[$key]; |
|
| 87 | 87 | } else { |
| 88 | 88 | return $def; |
| 89 | 89 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function toBoolean($value, $default) |
| 107 | 107 | { |
| 108 | - if($value === null) |
|
| 108 | + if ($value === null) |
|
| 109 | 109 | return $default; |
| 110 | 110 | if ($value == 1) |
| 111 | 111 | return true; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | { |
| 128 | 128 | $value = trim($value); |
| 129 | 129 | if (is_numeric($value)) { |
| 130 | - return (int)$value; |
|
| 130 | + return (int) $value; |
|
| 131 | 131 | } else { |
| 132 | 132 | return $default; |
| 133 | 133 | } |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function toLevel($value, $defaultValue) |
| 164 | 164 | { |
| 165 | - if($value === null) |
|
| 165 | + if ($value === null) |
|
| 166 | 166 | return $defaultValue; |
| 167 | 167 | |
| 168 | 168 | $hashIndex = strpos($value, '#'); |
| 169 | 169 | if ($hashIndex === false) { |
| 170 | - if("NULL" == strtoupper($value)) { |
|
| 170 | + if ("NULL" == strtoupper($value)) { |
|
| 171 | 171 | return null; |
| 172 | 172 | } else { |
| 173 | 173 | // no class name specified : use standard Level class |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $levelName = substr($value, 0, $hashIndex); |
| 182 | 182 | |
| 183 | 183 | // This is degenerate case but you never know. |
| 184 | - if("NULL" == strtoupper($levelName)) { |
|
| 184 | + if ("NULL" == strtoupper($levelName)) { |
|
| 185 | 185 | return null; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -217,19 +217,19 @@ discard block |
||
| 217 | 217 | return $default; |
| 218 | 218 | |
| 219 | 219 | $s = strtoupper(trim($value)); |
| 220 | - $multiplier = (float)1; |
|
| 221 | - if(($index = strpos($s, 'KB')) !== false) { |
|
| 220 | + $multiplier = (float) 1; |
|
| 221 | + if (($index = strpos($s, 'KB')) !== false) { |
|
| 222 | 222 | $multiplier = 1024; |
| 223 | 223 | $s = substr($s, 0, $index); |
| 224 | - } elseif(($index = strpos($s, 'MB')) !== false) { |
|
| 224 | + } elseif (($index = strpos($s, 'MB')) !== false) { |
|
| 225 | 225 | $multiplier = 1024 * 1024; |
| 226 | 226 | $s = substr($s, 0, $index); |
| 227 | - } elseif(($index = strpos($s, 'GB')) !== false) { |
|
| 227 | + } elseif (($index = strpos($s, 'GB')) !== false) { |
|
| 228 | 228 | $multiplier = 1024 * 1024 * 1024; |
| 229 | 229 | $s = substr($s, 0, $index); |
| 230 | 230 | } |
| 231 | - if(is_numeric($s)) { |
|
| 232 | - return (float)$s * $multiplier; |
|
| 231 | + if (is_numeric($s)) { |
|
| 232 | + return (float) $s * $multiplier; |
|
| 233 | 233 | } else { |
| 234 | 234 | LoggerLog::warn("LoggerOptionConverter::toFileSize() [{$s}] is not in proper form."); |
| 235 | 235 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | public function findAndSubst($key, $props) |
| 251 | 251 | { |
| 252 | 252 | $value = @$props[$key]; |
| 253 | - if(empty($value)) { |
|
| 253 | + if (empty($value)) { |
|
| 254 | 254 | return null; |
| 255 | 255 | } |
| 256 | 256 | return LoggerOptionConverter::substVars($value, $props); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | |
| 298 | 298 | $sbuf = ''; |
| 299 | 299 | $i = 0; |
| 300 | - while(true) { |
|
| 300 | + while (true) { |
|
| 301 | 301 | $j = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_START, $i); |
| 302 | 302 | if ($j === false) { |
| 303 | 303 | LoggerLog::debug("LoggerOptionConverter::substVars() no more variables"); |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | } else { |
| 314 | 314 | |
| 315 | - $sbuf .= substr($val, $i, $j-$i); |
|
| 315 | + $sbuf .= substr($val, $i, $j - $i); |
|
| 316 | 316 | LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]:i={$i}:j={$j}."); |
| 317 | 317 | $k = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_STOP, $j); |
| 318 | 318 | if ($k === false) { |
@@ -327,11 +327,11 @@ discard block |
||
| 327 | 327 | // first try in System properties |
| 328 | 328 | $replacement = LoggerOptionConverter::getSystemProperty($key, null); |
| 329 | 329 | // then try props parameter |
| 330 | - if($replacement === null && $props !== null) { |
|
| 330 | + if ($replacement === null && $props !== null) { |
|
| 331 | 331 | $replacement = @$props[$key]; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if(!empty($replacement)) { |
|
| 334 | + if (!empty($replacement)) { |
|
| 335 | 335 | // Do variable substitution on the replacement string |
| 336 | 336 | // such that we can solve "Hello ${x2}" as "Hello p1" |
| 337 | 337 | // the where the properties are |
@@ -42,30 +42,30 @@ discard block |
||
| 42 | 42 | require_once(LOG4PHP_DIR . '/helpers/LoggerPatternConverter.php'); |
| 43 | 43 | require_once(LOG4PHP_DIR . '/LoggerLog.php'); |
| 44 | 44 | |
| 45 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR', '%'); |
|
| 45 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR', '%'); |
|
| 46 | 46 | |
| 47 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE', 0); |
|
| 48 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE', 1); |
|
| 49 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_MINUS_STATE', 2); |
|
| 50 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE', 3); |
|
| 51 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE', 4); |
|
| 52 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE', 5); |
|
| 47 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE', 0); |
|
| 48 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE', 1); |
|
| 49 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_MINUS_STATE', 2); |
|
| 50 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE', 3); |
|
| 51 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE', 4); |
|
| 52 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE', 5); |
|
| 53 | 53 | |
| 54 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER', 1000); |
|
| 55 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER', 1001); |
|
| 56 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_CLASS_LOCATION_CONVERTER', 1002); |
|
| 57 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER', 1003); |
|
| 58 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER', 1004); |
|
| 54 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER', 1000); |
|
| 55 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER', 1001); |
|
| 56 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_CLASS_LOCATION_CONVERTER', 1002); |
|
| 57 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER', 1003); |
|
| 58 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER', 1004); |
|
| 59 | 59 | |
| 60 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER', 2000); |
|
| 61 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER', 2001); |
|
| 62 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER', 2002); |
|
| 63 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER', 2003); |
|
| 64 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER', 2004); |
|
| 60 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER', 2000); |
|
| 61 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER', 2001); |
|
| 62 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER', 2002); |
|
| 63 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER', 2003); |
|
| 64 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER', 2004); |
|
| 65 | 65 | |
| 66 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601', 'Y-m-d H:i:s,u'); |
|
| 67 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE', 'H:i:s'); |
|
| 68 | -define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE', 'd M Y H:i:s,u'); |
|
| 66 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601', 'Y-m-d H:i:s,u'); |
|
| 67 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE', 'H:i:s'); |
|
| 68 | +define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE', 'd M Y H:i:s,u'); |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Most of the work of the {@link LoggerPatternLayout} class |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | LoggerLog::debug("LoggerPatternParser::LoggerPatternParser() pattern='$pattern'"); |
| 119 | 119 | |
| 120 | 120 | $this->pattern = $pattern; |
| 121 | - $this->patternLength = strlen($pattern); |
|
| 121 | + $this->patternLength = strlen($pattern); |
|
| 122 | 122 | $this->formattingInfo = new LoggerFormattingInfo(); |
| 123 | 123 | $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE; |
| 124 | 124 | } |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | // LoggerLog::debug("LoggerPatternParser::addToList()"); |
| 132 | 132 | |
| 133 | - if($this->head === null) { |
|
| 133 | + if ($this->head === null) { |
|
| 134 | 134 | $this->head = $pc; |
| 135 | - $this->tail =& $this->head; |
|
| 135 | + $this->tail = & $this->head; |
|
| 136 | 136 | } else { |
| 137 | 137 | $this->tail->next = $pc; |
| 138 | - $this->tail =& $this->tail->next; |
|
| 138 | + $this->tail = & $this->tail->next; |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function extractOption() |
| 146 | 146 | { |
| 147 | - if(($this->i < $this->patternLength) && ($this->pattern{$this->i} == '{')) { |
|
| 148 | - $end = strpos($this->pattern, '}' , $this->i); |
|
| 147 | + if (($this->i < $this->patternLength) && ($this->pattern{$this->i} == '{')) { |
|
| 148 | + $end = strpos($this->pattern, '}', $this->i); |
|
| 149 | 149 | if ($end !== false) { |
| 150 | 150 | $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
| 151 | - $this->i= $end + 1; |
|
| 151 | + $this->i = $end + 1; |
|
| 152 | 152 | return $r; |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | $r = 0; |
| 166 | 166 | if ($opt !== null) { |
| 167 | 167 | if (is_numeric($opt)) { |
| 168 | - $r = (int)$opt; |
|
| 169 | - if($r <= 0) { |
|
| 168 | + $r = (int) $opt; |
|
| 169 | + if ($r <= 0) { |
|
| 170 | 170 | LoggerLog::warn("Precision option ({$opt}) isn't a positive integer."); |
| 171 | 171 | $r = 0; |
| 172 | 172 | } |
@@ -187,18 +187,18 @@ discard block |
||
| 187 | 187 | while ($this->i < $this->patternLength) { |
| 188 | 188 | $c = $this->pattern{$this->i++}; |
| 189 | 189 | // LoggerLog::debug("LoggerPatternParser::parse() char is now '$c' and currentLiteral is '{$this->currentLiteral}'"); |
| 190 | - switch($this->state) { |
|
| 190 | + switch ($this->state) { |
|
| 191 | 191 | case LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE: |
| 192 | 192 | // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE'"); |
| 193 | 193 | // In literal state, the last char is always a literal. |
| 194 | - if($this->i == $this->patternLength) { |
|
| 194 | + if ($this->i == $this->patternLength) { |
|
| 195 | 195 | $this->currentLiteral .= $c; |
| 196 | 196 | continue; |
| 197 | 197 | } |
| 198 | - if($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) { |
|
| 198 | + if ($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) { |
|
| 199 | 199 | // LoggerLog::debug("LoggerPatternParser::parse() char is an escape char"); |
| 200 | 200 | // peek at the next char. |
| 201 | - switch($this->pattern{$this->i}) { |
|
| 201 | + switch ($this->pattern{$this->i}) { |
|
| 202 | 202 | case LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR: |
| 203 | 203 | // LoggerLog::debug("LoggerPatternParser::parse() next char is an escape char"); |
| 204 | 204 | $this->currentLiteral .= $c; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $this->i++; // move pointer |
| 211 | 211 | break; |
| 212 | 212 | default: |
| 213 | - if(strlen($this->currentLiteral) != 0) { |
|
| 213 | + if (strlen($this->currentLiteral) != 0) { |
|
| 214 | 214 | $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
| 215 | 215 | LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\"."); |
| 216 | 216 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | case LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE: |
| 226 | 226 | // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE'"); |
| 227 | 227 | $this->currentLiteral .= $c; |
| 228 | - switch($c) { |
|
| 228 | + switch ($c) { |
|
| 229 | 229 | case '-': |
| 230 | 230 | $this->formattingInfo->leftAlign = true; |
| 231 | 231 | break; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE; |
| 234 | 234 | break; |
| 235 | 235 | default: |
| 236 | - if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 236 | + if (ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 237 | 237 | $this->formattingInfo->min = ord($c) - ord('0'); |
| 238 | 238 | $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE; |
| 239 | 239 | } else { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | case LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE: |
| 245 | 245 | // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE'"); |
| 246 | 246 | $this->currentLiteral .= $c; |
| 247 | - if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 247 | + if (ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 248 | 248 | $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord(c) - ord('0')); |
| 249 | 249 | } elseif ($c == '.') { |
| 250 | 250 | $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE; |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | case LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE: |
| 256 | 256 | // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE'"); |
| 257 | 257 | $this->currentLiteral .= $c; |
| 258 | - if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 258 | + if (ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 259 | 259 | $this->formattingInfo->max = ord($c) - ord('0'); |
| 260 | 260 | $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE; |
| 261 | 261 | } else { |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | case LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE: |
| 267 | 267 | // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE'"); |
| 268 | 268 | $this->currentLiteral .= $c; |
| 269 | - if(ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 269 | + if (ord($c) >= ord('0') && ord($c) <= ord('9')) { |
|
| 270 | 270 | $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
| 271 | 271 | } else { |
| 272 | 272 | $this->finalizeConverter($c); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | break; |
| 276 | 276 | } // switch |
| 277 | 277 | } // while |
| 278 | - if(strlen($this->currentLiteral) != 0) { |
|
| 278 | + if (strlen($this->currentLiteral) != 0) { |
|
| 279 | 279 | $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
| 280 | 280 | // LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\"."); |
| 281 | 281 | } |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | LoggerLog::debug("LoggerPatternParser::finalizeConverter() with char '$c'"); |
| 288 | 288 | |
| 289 | 289 | $pc = null; |
| 290 | - switch($c) { |
|
| 290 | + switch ($c) { |
|
| 291 | 291 | case 'c': |
| 292 | 292 | $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
| 293 | 293 | LoggerLog::debug("LoggerPatternParser::finalizeConverter() CATEGORY converter."); |
@@ -302,14 +302,14 @@ discard block |
||
| 302 | 302 | $dateFormatStr = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
| 303 | 303 | $dOpt = $this->extractOption(); |
| 304 | 304 | |
| 305 | - if($dOpt !== null) |
|
| 305 | + if ($dOpt !== null) |
|
| 306 | 306 | $dateFormatStr = $dOpt; |
| 307 | 307 | |
| 308 | 308 | if ($dateFormatStr == 'ISO8601') { |
| 309 | 309 | $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; |
| 310 | - } elseif($dateFormatStr == 'ABSOLUTE') { |
|
| 310 | + } elseif ($dateFormatStr == 'ABSOLUTE') { |
|
| 311 | 311 | $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE; |
| 312 | - } elseif($dateFormatStr == 'DATE') { |
|
| 312 | + } elseif ($dateFormatStr == 'DATE') { |
|
| 313 | 313 | $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE; |
| 314 | 314 | } else { |
| 315 | 315 | $df = $dateFormatStr; |
@@ -369,10 +369,10 @@ discard block |
||
| 369 | 369 | $this->currentLiteral = ''; |
| 370 | 370 | break; |
| 371 | 371 | case 'u': |
| 372 | - if($this->i < $this->patternLength) { |
|
| 372 | + if ($this->i < $this->patternLength) { |
|
| 373 | 373 | $cNext = $this->pattern{$this->i}; |
| 374 | - if(ord($cNext) >= ord('0') && ord($cNext) <= ord('9')) { |
|
| 375 | - $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
| 374 | + if (ord($cNext) >= ord('0') && ord($cNext) <= ord('9')) { |
|
| 375 | + $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string) (ord($cNext) - ord('0'))); |
|
| 376 | 376 | LoggerLog::debug("LoggerPatternParser::finalizeConverter() USER converter [{$cNext}]."); |
| 377 | 377 | // formattingInfo.dump(); |
| 378 | 378 | $this->currentLiteral = ''; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | LoggerLog::debug("LoggerRendererMap::addRenderer() Rendering class: [{$renderingClassName}], Rendered class: [{$renderedClassName}]."); |
| 73 | 73 | $renderer = LoggerObjectRenderer::factory($renderingClassName); |
| 74 | - if($renderer === null) { |
|
| 74 | + if ($renderer === null) { |
|
| 75 | 75 | LoggerLog::warn("LoggerRendererMap::addRenderer() Could not instantiate renderer [{$renderingClassName}]."); |
| 76 | 76 | return; |
| 77 | 77 | } else { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function findAndRender($o) |
| 96 | 96 | { |
| 97 | - if($o === null) { |
|
| 97 | + if ($o === null) { |
|
| 98 | 98 | return null; |
| 99 | 99 | } else { |
| 100 | 100 | if (is_object($o)) { |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | public function &getByClassName($class) |
| 137 | 137 | { |
| 138 | 138 | $r = null; |
| 139 | - for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
| 139 | + for ($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
| 140 | 140 | if (isset($this->map[$c])) { |
| 141 | 141 | return $this->map[$c]; |
| 142 | 142 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | { |
| 177 | 177 | $class = basename($class); |
| 178 | 178 | if (!class_exists($class)) { |
| 179 | - @include_once(LOG4PHP_DIR ."/or/{$class}.php"); |
|
| 179 | + @include_once(LOG4PHP_DIR . "/or/{$class}.php"); |
|
| 180 | 180 | } |
| 181 | 181 | return class_exists($class); |
| 182 | 182 | } |
@@ -5,13 +5,13 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | /** Copy data in string to a local char array */ |
| 7 | 7 | public function __construct($input) { |
| 8 | - $this->p=0; |
|
| 8 | + $this->p = 0; |
|
| 9 | 9 | $this->line = 1; |
| 10 | 10 | $this->charPositionInLine = 0; |
| 11 | 11 | $this->markDepth = 0; |
| 12 | 12 | $this->markers = null; |
| 13 | - $this->lastMarker=0; |
|
| 14 | - $this->name=null; |
|
| 13 | + $this->lastMarker = 0; |
|
| 14 | + $this->name = null; |
|
| 15 | 15 | |
| 16 | 16 | $this->data = strToIntArray($input); |
| 17 | 17 | $this->n = strlen($input); |
@@ -29,34 +29,34 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function consume() { |
| 32 | - if ( $this->p < $this->n ) { |
|
| 32 | + if ($this->p < $this->n) { |
|
| 33 | 33 | $this->charPositionInLine++; |
| 34 | - if ( $this->data[$this->p]==ord("\n") ) { |
|
| 34 | + if ($this->data[$this->p] == ord("\n")) { |
|
| 35 | 35 | $this->line++; |
| 36 | - $this->charPositionInLine=0; |
|
| 36 | + $this->charPositionInLine = 0; |
|
| 37 | 37 | } |
| 38 | 38 | $this->p++; |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function LA($i) { |
| 43 | - if ( $i==0 ) { |
|
| 43 | + if ($i == 0) { |
|
| 44 | 44 | return 0; // undefined |
| 45 | 45 | } |
| 46 | - if ( $i<0 ) { |
|
| 46 | + if ($i < 0) { |
|
| 47 | 47 | $i++; // e.g., translate LA(-1) to use offset i=0; then data[p+0-1] |
| 48 | - if ( ($this->p+$i-1) < 0 ) { |
|
| 48 | + if (($this->p + $i - 1) < 0) { |
|
| 49 | 49 | return CharStreamConst::$EOF; // invalid; no char before first char |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if ( ($this->p+$i-1) >= $this->n ) { |
|
| 53 | + if (($this->p + $i - 1) >= $this->n) { |
|
| 54 | 54 | //System.out.println("char LA("+i+")=EOF; p="+p); |
| 55 | 55 | return CharStreamConst::$EOF; |
| 56 | 56 | } |
| 57 | 57 | //System.out.println("char LA("+i+")="+(char)data[p+i-1]+"; p="+p); |
| 58 | 58 | //System.out.println("LA("+i+"); p="+p+" n="+n+" data.length="+data.length); |
| 59 | - return $this->data[$this->p+$i-1]; |
|
| 59 | + return $this->data[$this->p + $i - 1]; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | public function LT($i) { |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public function mark() { |
| 79 | - if ( $this->markers === null) { |
|
| 79 | + if ($this->markers === null) { |
|
| 80 | 80 | $this->markers = array(); |
| 81 | 81 | $this->markers[] = null; // depth 0 means no backtracking, leave blank |
| 82 | 82 | } |
| 83 | 83 | $this->markDepth++; |
| 84 | 84 | $state = null; |
| 85 | - if ($this->markDepth>=sizeof($this->markers)) { |
|
| 85 | + if ($this->markDepth >= sizeof($this->markers)) { |
|
| 86 | 86 | $state = new CharStreamState(); |
| 87 | 87 | $this->markers[] = $state; |
| 88 | 88 | } |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | return $this->markDepth; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - public function rewind($m=null) { |
|
| 100 | - if($m===null){ |
|
| 101 | - $this->rewind((int)$this->lastMarker); |
|
| 102 | - }else{ |
|
| 99 | + public function rewind($m = null) { |
|
| 100 | + if ($m === null) { |
|
| 101 | + $this->rewind((int) $this->lastMarker); |
|
| 102 | + } else { |
|
| 103 | 103 | $state = $this->markers[$m]; |
| 104 | 104 | // restore stream state |
| 105 | 105 | $this->seek($state->p); |
@@ -120,18 +120,18 @@ discard block |
||
| 120 | 120 | * update line and charPositionInLine. |
| 121 | 121 | */ |
| 122 | 122 | public function seek($index) { |
| 123 | - if ( $index<=$this->p ) { |
|
| 123 | + if ($index <= $this->p) { |
|
| 124 | 124 | $this->p = $index; // just jump; don't update stream state (line, ...) |
| 125 | 125 | return; |
| 126 | 126 | } |
| 127 | 127 | // seek forward, consume until p hits index |
| 128 | - while ( $this->p<$index ) { |
|
| 128 | + while ($this->p < $index) { |
|
| 129 | 129 | $this->consume(); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function substring($start, $stop) { |
| 134 | - return implode(array_map('chr', array_slice($this->data, $start, $stop-$start+1))); |
|
| 134 | + return implode(array_map('chr', array_slice($this->data, $start, $stop - $start + 1))); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public function getLine() { |