From 36b52fa8ecbcd3b1559a1f49cbfdb4bf413e2773 Mon Sep 17 00:00:00 2001
From: xue <>
Date: Thu, 9 Mar 2006 02:18:49 +0000
Subject: Many small fixes due to the result of zend analyzer.
---
framework/Data/TMemCache.php | 4 +--
framework/Data/TSimpleDateFormatter.php | 41 ++++++++++++----------
framework/Exceptions/TErrorHandler.php | 2 +-
framework/Log/TLogRouter.php | 9 ++---
framework/Web/Services/TPageService.php | 1 -
framework/Web/THttpSession.php | 2 +-
framework/Web/UI/TTemplateManager.php | 3 +-
framework/Web/UI/WebControls/TBoundColumn.php | 2 +-
framework/Web/UI/WebControls/TBulletedList.php | 4 ++-
framework/Web/UI/WebControls/TCheckBoxColumn.php | 2 +-
framework/Web/UI/WebControls/TDataList.php | 1 -
framework/Web/UI/WebControls/TDatePicker.php | 1 -
framework/Web/UI/WebControls/TImage.php | 2 +-
framework/Web/UI/WebControls/TInlineFrame.php | 2 +-
framework/Web/UI/WebControls/TMultiView.php | 2 +-
framework/Web/UI/WebControls/TRatingList.php | 2 +-
framework/Web/UI/WebControls/TSafeHtml.php | 2 +-
framework/Web/UI/WebControls/TTextBox.php | 4 +--
.../Web/UI/WebControls/TValidationSummary.php | 8 ++---
19 files changed, 49 insertions(+), 45 deletions(-)
diff --git a/framework/Data/TMemCache.php b/framework/Data/TMemCache.php
index b2b1643d..4a8527c8 100644
--- a/framework/Data/TMemCache.php
+++ b/framework/Data/TMemCache.php
@@ -201,7 +201,7 @@ class TMemCache extends TModule implements ICache
*/
public function add($key,$value,$expiry=0)
{
- return $this->_cache->add($this->generateUniqueKey($key),$value,0,$expire);
+ return $this->_cache->add($this->generateUniqueKey($key),$value,0,$expiry);
}
/**
@@ -217,7 +217,7 @@ class TMemCache extends TModule implements ICache
*/
public function replace($key,$value,$expiry=0)
{
- return $this->_cache->replace($this->generateUniqueKey($key),$value,0,$expire);
+ return $this->_cache->replace($this->generateUniqueKey($key),$value,0,$expiry);
}
/**
diff --git a/framework/Data/TSimpleDateFormatter.php b/framework/Data/TSimpleDateFormatter.php
index f6c04027..ec69a045 100644
--- a/framework/Data/TSimpleDateFormatter.php
+++ b/framework/Data/TSimpleDateFormatter.php
@@ -30,7 +30,7 @@
* Usage example, to format a date
*
* $formatter = new TSimpleDateFormatter("dd/MM/yyy");
- * echo $formatter->format(time());
+ * echo $formatter->format(time());
*
*
* To parse the date string into a date timestamp.
@@ -117,7 +117,7 @@ class TSimpleDateFormatter
$bits['dd'] = str_pad("{$date['mday']}", 2, '0', STR_PAD_LEFT);
$bits['d'] = $date['mday'];
-
+
return str_replace(array_keys($bits), $bits, $this->pattern);
}
@@ -131,6 +131,7 @@ class TSimpleDateFormatter
return 'MM';
if(is_int(strpos($this->pattern, 'M')))
return 'M';
+ return false;
}
public function getDayPattern()
@@ -139,6 +140,7 @@ class TSimpleDateFormatter
return 'dd';
if(is_int(strpos($this->pattern, 'd')))
return 'd';
+ return false;
}
public function getYearPattern()
@@ -147,6 +149,7 @@ class TSimpleDateFormatter
return 'yyyy';
if(is_int(strpos($this->pattern, 'yy')))
return 'yy';
+ return false;
}
public function getDayMonthYearOrdering()
@@ -176,7 +179,7 @@ class TSimpleDateFormatter
throw new TInvalidDataValueException('invalid_date', $value);
return @getdate($date);
}
-
+
/**
* @return boolean true if the given value matches with the date pattern.
*/
@@ -199,7 +202,7 @@ class TSimpleDateFormatter
if(empty($this->pattern)) return time();
$date = $this->getDate(time());
-
+
if($this->length(trim($value)) < 1)
return $defaultToCurrentTime ? $date : null;
@@ -211,7 +214,7 @@ class TSimpleDateFormatter
$c = '';
$token='';
$x=null; $y=null;
-
+
if($defaultToCurrentTime)
{
@@ -230,19 +233,19 @@ class TSimpleDateFormatter
{
$c = $this->charAt($pattern,$i_format);
$token='';
- while ($this->charEqual($pattern, $i_format, $c)
+ while ($this->charEqual($pattern, $i_format, $c)
&& ($i_format < $pattern_length))
{
$token .= $this->charAt($pattern, $i_format++);
}
-
- if ($token=='yyyy' || $token=='yy' || $token=='y')
+
+ if ($token=='yyyy' || $token=='yy' || $token=='y')
{
if ($token=='yyyy') { $x=4;$y=4; }
if ($token=='yy') { $x=2;$y=2; }
if ($token=='y') { $x=2;$y=4; }
$year = $this->getInteger($value,$i_val,$x,$y);
- if(is_null($year))
+ if(is_null($year))
throw new TInvalidDataValueException('Invalid year', $value);
$i_val += strlen($year);
if(strlen($year) == 2)
@@ -257,7 +260,7 @@ class TSimpleDateFormatter
}
elseif($token=='MM' || $token=='M')
{
- $month=$this->getInteger($value,$i_val,
+ $month=$this->getInteger($value,$i_val,
$this->length($token),2);
$iMonth = intval($month);
if(is_null($month) || $iMonth < 1 || $iMonth > 12 )
@@ -265,7 +268,7 @@ class TSimpleDateFormatter
$i_val += strlen($month);
$month = $iMonth;
}
- elseif ($token=='dd' || $token=='d')
+ elseif ($token=='dd' || $token=='d')
{
$day = $this->getInteger($value,$i_val,
$this->length($token), 2);
@@ -275,20 +278,20 @@ class TSimpleDateFormatter
$i_val += strlen($day);
$day = $iDay;
}
- else
+ else
{
if($this->substring($value, $i_val, $this->length($token)) != $token)
throw new TInvalidDataValueException("Subpattern '{$this->pattern}' mismatch", $value);
- else
+ else
$i_val += $this->length($token);
}
}
- if ($i_val != $this->length($value))
+ if ($i_val != $this->length($value))
throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value);
if(!$defaultToCurrentTime && (is_null($month) || is_null($day) || is_null($year)))
return null;
- else
+ else
return $this->getDate(@mktime(0, 0, 0, $month, $day, $year));
}
@@ -333,15 +336,15 @@ class TSimpleDateFormatter
* @param int maximum integer length
* @return string integer portition of the string, null otherwise
*/
- private function getInteger($str,$i,$minlength,$maxlength)
+ private function getInteger($str,$i,$minlength,$maxlength)
{
//match for digits backwards
- for ($x = $maxlength; $x >= $minlength; $x--)
+ for ($x = $maxlength; $x >= $minlength; $x--)
{
$token= $this->substring($str, $i,$x);
- if ($this->length($token) < $minlength)
+ if ($this->length($token) < $minlength)
return null;
- if (preg_match('/^\d+$/', $token))
+ if (preg_match('/^\d+$/', $token))
return $token;
}
return null;
diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php
index 449f8c96..a1632271 100644
--- a/framework/Exceptions/TErrorHandler.php
+++ b/framework/Exceptions/TErrorHandler.php
@@ -192,7 +192,7 @@ class TErrorHandler extends TModule
}
else
{
- error_log("Error happened while processing an existing error:\n".$param->__toString());
+ error_log("Error happened while processing an existing error:\n".$exception->__toString());
header('HTTP/1.0 500 Internal Error');
}
}
diff --git a/framework/Log/TLogRouter.php b/framework/Log/TLogRouter.php
index 3b8bef94..d5bf3cb1 100644
--- a/framework/Log/TLogRouter.php
+++ b/framework/Log/TLogRouter.php
@@ -584,13 +584,15 @@ class TBrowserLogRoute extends TLogRoute
public function processLogs($logs)
{
if(empty($logs) || $this->getApplication()->getMode()==='Performance') return;
- $first = $logs[0][3]; $prev = $first; $total = 0; $delta = 0; $even = true;
+ $first = $logs[0][3];
+ $prev = $first;
+ $even = true;
$response = $this->getApplication()->getResponse();
$response->write($this->renderHeader());
foreach($logs as $log)
{
$timing['total'] = $log[3] - $first;
- $timing['delta'] = $log[3]-$prev;
+ $timing['delta'] = $log[3] - $prev;
$timing['even'] = !($even = !$even);
$prev=$log[3];
$response->write($this->renderMessage($log,$timing));
@@ -600,8 +602,6 @@ class TBrowserLogRoute extends TLogRoute
protected function renderHeader()
{
- $category = is_array($this->getCategories()) ?
- implode(', ',$this->getCategories()) : '';
$string = <<
@@ -648,6 +648,7 @@ EOD;
case TLogger::ALERT: return '#ff00ff';
case TLogger::FATAL: return 'red';
}
+ return '';
}
protected function renderFooter()
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php
index cebedc63..991da05b 100644
--- a/framework/Web/Services/TPageService.php
+++ b/framework/Web/Services/TPageService.php
@@ -417,7 +417,6 @@ class TPageService extends TService
public function run()
{
Prado::trace("Running page service",'System.Web.Services.TPageService');
- $page=null;
$path=$this->getBasePath().'/'.strtr($this->getRequestedPagePath(),'.','/');
if(is_file($path.self::PAGE_FILE_EXT))
{
diff --git a/framework/Web/THttpSession.php b/framework/Web/THttpSession.php
index 1292b548..ad7d272a 100644
--- a/framework/Web/THttpSession.php
+++ b/framework/Web/THttpSession.php
@@ -193,7 +193,7 @@ class THttpSession extends TApplicationComponent implements IteratorAggregate,Ar
else if(ctype_alnum($value))
session_name($value);
else
- throw new TInvalidDataValueException('httpsession_sessionname_invalid',$name);
+ throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value);
}
/**
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index b2b2f830..7c32e6a1 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -583,7 +583,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
}
else if(strpos($str,'