From f7f3d150ef35c026bf6aee72e78362e263419e1a Mon Sep 17 00:00:00 2001 From: knut <> Date: Wed, 6 Aug 2008 01:34:06 +0000 Subject: fixed #898 --- HISTORY | 2 ++ framework/Caching/TXCache.php | 8 ++++---- framework/Data/Common/TDbCommandBuilder.php | 4 ++-- framework/Data/DataGateway/TDataGatewayCommand.php | 12 ++++++------ framework/I18N/core/DateFormat.php | 4 ++-- framework/I18N/core/MessageCache.php | 6 +++--- framework/I18N/core/MessageSource_MySQL.php | 8 ++++---- framework/I18N/core/MessageSource_SQLite.php | 10 +++++----- framework/I18N/core/MessageSource_XLIFF.php | 4 ++-- framework/Util/TDateTimeStamp.php | 10 +++++----- framework/Util/TSimpleDateFormatter.php | 8 ++++---- 11 files changed, 39 insertions(+), 37 deletions(-) diff --git a/HISTORY b/HISTORY index c0681203..ef94ece5 100644 --- a/HISTORY +++ b/HISTORY @@ -15,7 +15,9 @@ BUG: Ticket#886 - TSimpleDateFormatter: One month offset in time stamp with date BUG: Ticket#897 - TSimpleDateFormatter: If no YearPattern is set it should default to current year (Knut) ENH: Added Prado.Validation.validateControl(id) on client side to validate a specific control (Michael) ENH: Added MessageSource_Database to I18N (uses TDbConnection) (Michael) +ENH: Ticket#890 - Minor optimization: Use $var===null over is_null($var) (Knut) ENH: Ticket#893 - Added page parameter to queryForPagedList() to specify the initial page to load (Michael) +ENH: Ticket#898 - Minor optimization: Use (int) over intval() (Knut) CHG: Ticket#844 - Upgraded TinyMCE to 3.1.0.1 (Christophe) Version 3.1.2 April 21, 2008 diff --git a/framework/Caching/TXCache.php b/framework/Caching/TXCache.php index f3163618..96e50acb 100644 --- a/framework/Caching/TXCache.php +++ b/framework/Caching/TXCache.php @@ -4,7 +4,7 @@ * * @author Wei Zhuo * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id: TXCache.php 1994 2007-06-11 16:02:28Z knut $ * @package System.Caching @@ -54,8 +54,8 @@ class TXCache extends TCache if(!function_exists('xcache_isset')) throw new TConfigurationException('xcache_extension_required'); - $enabled = intval(ini_get('xcache.cacher')) !== 0; - $var_size = intval(ini_get('xcache.var_size')); + $enabled = (int)ini_get('xcache.cacher') !== 0; + $var_size = (int)ini_get('xcache.var_size'); if(!($enabled && $var_size > 0)) throw new TConfigurationException('xcache_extension_not_enabled'); @@ -123,4 +123,4 @@ class TXCache extends TCache } } -?> +?> diff --git a/framework/Data/Common/TDbCommandBuilder.php b/framework/Data/Common/TDbCommandBuilder.php index c4bfeb98..155a62f8 100644 --- a/framework/Data/Common/TDbCommandBuilder.php +++ b/framework/Data/Common/TDbCommandBuilder.php @@ -90,8 +90,8 @@ class TDbCommandBuilder extends TComponent */ public function applyLimitOffset($sql, $limit=-1, $offset=-1) { - $limit = $limit!==null ? intval($limit) : -1; - $offset = $offset!==null ? intval($offset) : -1; + $limit = $limit!==null ? (int)$limit : -1; + $offset = $offset!==null ? (int)$offset : -1; $limitStr = $limit >= 0 ? ' LIMIT '.$limit : ''; $offsetStr = $offset >= 0 ? ' OFFSET '.$offset : ''; return $sql.$limitStr.$offsetStr; diff --git a/framework/Data/DataGateway/TDataGatewayCommand.php b/framework/Data/DataGateway/TDataGatewayCommand.php index 8145ae9d..35e4dcbe 100644 --- a/framework/Data/DataGateway/TDataGatewayCommand.php +++ b/framework/Data/DataGateway/TDataGatewayCommand.php @@ -1,10 +1,10 @@ - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Data.DataGateway @@ -331,7 +331,7 @@ class TDataGatewayCommand extends TComponent public function count($criteria) { if($criteria===null) - return intval($this->getBuilder()->createCountCommand()->queryScalar()); + return (int)$this->getBuilder()->createCountCommand()->queryScalar(); $where = $criteria->getCondition(); $parameters = $criteria->getParameters()->toArray(); $ordering = $criteria->getOrdersBy(); @@ -339,7 +339,7 @@ class TDataGatewayCommand extends TComponent $offset = $criteria->getOffset(); $command = $this->getBuilder()->createCountCommand($where,$parameters,$ordering,$limit,$offset); $this->onCreateCommand($command, $criteria); - return $this->onExecuteCommand($command, intval($command->queryScalar())); + return $this->onExecuteCommand($command, (int)$command->queryScalar()); } /** @@ -536,5 +536,5 @@ class TDataGatewayResultEventParameter extends TEventParameter $this->_result=$value; } } - -?> + +?> diff --git a/framework/I18N/core/DateFormat.php b/framework/I18N/core/DateFormat.php index 173c119f..7724a480 100644 --- a/framework/I18N/core/DateFormat.php +++ b/framework/I18N/core/DateFormat.php @@ -471,7 +471,7 @@ class DateFormat throw new Exception('The pattern for AM/PM marker is "a".'); $hour = $date['hours']; - $ampm = intval($hour/12); + $ampm = (int)($hour/12); return $this->formatInfo->AMPMMarkers[$ampm]; } @@ -649,4 +649,4 @@ class DateFormat } -?> +?> diff --git a/framework/I18N/core/MessageCache.php b/framework/I18N/core/MessageCache.php index 7d15e8c6..d4f58f1d 100644 --- a/framework/I18N/core/MessageCache.php +++ b/framework/I18N/core/MessageCache.php @@ -74,7 +74,7 @@ class MessageCache */ public function setLifeTime($time) { - $this->lifetime = intval($time); + $this->lifetime = (int)$time; } /** @@ -119,7 +119,7 @@ class MessageCache return false; - $lastmodified = intval($lastmodified); + $lastmodified = (int)$lastmodified; if($lastmodified <= 0 || $lastmodified > filemtime($cache)) return false; @@ -168,4 +168,4 @@ class MessageCache } -?> +?> diff --git a/framework/I18N/core/MessageSource_MySQL.php b/framework/I18N/core/MessageSource_MySQL.php index de7bea2b..317d53e2 100644 --- a/framework/I18N/core/MessageSource_MySQL.php +++ b/framework/I18N/core/MessageSource_MySQL.php @@ -186,7 +186,7 @@ class MessageSource_MySQL extends MessageSource "SELECT date_modified FROM catalogue WHERE name = '{$source}'", $this->db); - $result = $rs ? intval(mysql_result($rs,0)) : 0; + $result = $rs ? (int)mysql_result($rs,0) : 0; return $result; } @@ -256,7 +256,7 @@ class MessageSource_MySQL extends MessageSource if(mysql_num_rows($rs) != 1) return false; - $cat_id = intval(mysql_result($rs,0)); + $cat_id = (int)mysql_result($rs,0); //first get the catalogue ID $rs = mysql_query( @@ -264,7 +264,7 @@ class MessageSource_MySQL extends MessageSource FROM trans_unit WHERE cat_id = {$cat_id}", $this->db); - $count = intval(mysql_result($rs,0)); + $count = (int)mysql_result($rs,0); return array($cat_id, $variant, $count); } @@ -415,4 +415,4 @@ class MessageSource_MySQL extends MessageSource } -?> +?> diff --git a/framework/I18N/core/MessageSource_SQLite.php b/framework/I18N/core/MessageSource_SQLite.php index 4448f801..22518bba 100644 --- a/framework/I18N/core/MessageSource_SQLite.php +++ b/framework/I18N/core/MessageSource_SQLite.php @@ -109,7 +109,7 @@ class MessageSource_SQLite extends MessageSource "SELECT date_modified FROM catalogue WHERE name = '{$source}'", $db); - $result = $rs ? intval(sqlite_fetch_single($rs)) : 0; + $result = $rs ? (int)sqlite_fetch_single($rs) : 0; sqlite_close($db); @@ -129,7 +129,7 @@ class MessageSource_SQLite extends MessageSource $rs = sqlite_query( "SELECT COUNT(*) FROM catalogue WHERE name = '{$variant}'", $db); - $result = $rs && intval(sqlite_fetch_single($rs)); + $result = $rs && (int)sqlite_fetch_single($rs); sqlite_close($db); return $result; @@ -181,7 +181,7 @@ class MessageSource_SQLite extends MessageSource if(sqlite_num_rows($rs) != 1) return false; - $cat_id = intval(sqlite_fetch_single($rs)); + $cat_id = (int)sqlite_fetch_single($rs); //first get the catalogue ID $rs = sqlite_query( @@ -189,7 +189,7 @@ class MessageSource_SQLite extends MessageSource FROM trans_unit WHERE cat_id = {$cat_id}", $db); - $count = intval(sqlite_fetch_single($rs)); + $count = (int)sqlite_fetch_single($rs); sqlite_close($db); @@ -351,4 +351,4 @@ class MessageSource_SQLite extends MessageSource } } -?> +?> diff --git a/framework/I18N/core/MessageSource_XLIFF.php b/framework/I18N/core/MessageSource_XLIFF.php index 4a7db93b..f962e9a1 100644 --- a/framework/I18N/core/MessageSource_XLIFF.php +++ b/framework/I18N/core/MessageSource_XLIFF.php @@ -296,7 +296,7 @@ class MessageSource_XLIFF extends MessageSource $lastNodes = $xpath->query('//trans-unit[last()]'); if(($last=$lastNodes->item(0))!==null) - $count = intval($last->getAttribute('id')); + $count = (int)$last->getAttribute('id'); else $count = 0; @@ -520,4 +520,4 @@ EOD; } } -?> +?> diff --git a/framework/Util/TDateTimeStamp.php b/framework/Util/TDateTimeStamp.php index c2fb1327..07466462 100644 --- a/framework/Util/TDateTimeStamp.php +++ b/framework/Util/TDateTimeStamp.php @@ -9,7 +9,7 @@ * * @author Wei Zhuo * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Util @@ -619,9 +619,9 @@ class TDateTimeStamp $min = intval($min); $sec = intval($sec); */ - $mon = intval($mon); - $day = intval($day); - $year = intval($year); + $mon = (int)$mon; + $day = (int)$day; + $year = (int)$year; $year = $this->digitCheck($year); @@ -700,4 +700,4 @@ class TDateTimeStamp } } -?> +?> diff --git a/framework/Util/TSimpleDateFormatter.php b/framework/Util/TSimpleDateFormatter.php index d0ed4496..07a59398 100644 --- a/framework/Util/TSimpleDateFormatter.php +++ b/framework/Util/TSimpleDateFormatter.php @@ -261,19 +261,19 @@ class TSimpleDateFormatter $i_val += strlen($year); if(strlen($year) == 2) { - $iYear = intval($year); + $iYear = (int)$year; if($iYear > 70) $year = $iYear + 1900; else $year = $iYear + 2000; } - $year = intval($year); + $year = (int)$year; } elseif($token=='MM' || $token=='M') { $month=$this->getInteger($value,$i_val, $this->length($token),2); - $iMonth = intval($month); + $iMonth = (int)$month; if($month === null || $iMonth < 1 || $iMonth > 12 ) return null; //throw new TInvalidDataValueException('Invalid month', $value); @@ -284,7 +284,7 @@ class TSimpleDateFormatter { $day = $this->getInteger($value,$i_val, $this->length($token), 2); - $iDay = intval($day); + $iDay = (int)$day; if($day === null || $iDay < 1 || $iDay >31) return null; //throw new TInvalidDataValueException('Invalid day', $value); -- cgit v1.2.3