Skip to content
Permalink
Browse files

Take care of more int casts.

  • Loading branch information...
dereuromark committed Sep 10, 2014
1 parent e77f96d commit 04ef39217f2edb0a4abee6c903146036f3c53a91
@@ -75,7 +75,7 @@ public function write($key, $value, $duration) {
*/
public function read($key) {
$time = time();
$cachetime = intval(apc_fetch($key . '_expires'));
$cachetime = (int)apc_fetch($key . '_expires');
if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {
return false;
}
@@ -165,7 +165,7 @@ public function read($key) {
$this->_File->rewind();
$time = time();
$cachetime = intval($this->_File->current());
$cachetime = (int)$this->_File->current();
if ($cachetime !== false && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {
if ($this->settings['lock']) {
@@ -80,7 +80,7 @@ public function write($key, $value, $duration) {
*/
public function read($key) {
$time = time();
$cachetime = intval(wincache_ucache_get($key . '_expires'));
$cachetime = (int)wincache_ucache_get($key . '_expires');
if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) {
return false;
}
@@ -80,7 +80,7 @@ public function write($key, $value, $duration) {
public function read($key) {
if (xcache_isset($key)) {
$time = time();
$cachetime = intval(xcache_get($key . '_expires'));
$cachetime = (int)xcache_get($key . '_expires');
if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) {
return false;
}
@@ -579,8 +579,8 @@ protected function _getNodeId($class, $identifier) {
* @return array aro, aco, action
*/
protected function _getParams() {
$aro = is_numeric($this->args[0]) ? intval($this->args[0]) : $this->args[0];
$aco = is_numeric($this->args[1]) ? intval($this->args[1]) : $this->args[1];
$aro = is_numeric($this->args[0]) ? (int)$this->args[0] : $this->args[0];
$aco = is_numeric($this->args[1]) ? (int)$this->args[1] : $this->args[1];
$aroName = $aro;
$acoName = $aco;
@@ -728,7 +728,7 @@ public function doMoreAssociations(Model $model, $associations) {
while (strtolower($wannaDoMoreAssoc) === 'y') {
$assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
$this->out(__d('cake_console', 'What is the association type?'));
$assocType = intval($this->inOptions($assocs, __d('cake_console', 'Enter a number')));
$assocType = (int)$this->inOptions($assocs, __d('cake_console', 'Enter a number'));
$this->out(__d('cake_console', "For the following options be very careful to match your setup exactly.\n" .
"Any spelling mistakes will cause errors."));
@@ -211,7 +211,7 @@ public function paginate($object = null, $scope = array(), $whitelist = array())
}
$count = $object->find('count', array_merge($parameters, $extra));
}
$pageCount = intval(ceil($count / $limit));
$pageCount = (int)ceil($count / $limit);
$requestedPage = $page;
$page = max(min($page, $pageCount), 1);
@@ -509,7 +509,7 @@ public function index($model) {
$key['name'] = 'PRIMARY';
}
$index[$key['name']]['column'] = $keyCol[0]['name'];
$index[$key['name']]['unique'] = intval($key['unique'] == 1);
$index[$key['name']]['unique'] = (int)$key['unique'] === 1;
} else {
if (!is_array($index[$key['name']]['column'])) {
$col[] = $index[$key['name']]['column'];
@@ -537,9 +537,9 @@ public function renderStatement($type, $data) {
if (version_compare($this->getVersion(), '11', '<') && preg_match('/FETCH\sFIRST\s+([0-9]+)/i', $limit, $offset)) {
preg_match('/OFFSET\s*(\d+)\s*.*?(\d+)\s*ROWS/', $limit, $limitOffset);
$limit = 'TOP ' . intval($limitOffset[2]);
$page = intval($limitOffset[1] / $limitOffset[2]);
$offset = intval($limitOffset[2] * $page);
$limit = 'TOP ' . (int)$limitOffset[2];
$page = (int)($limitOffset[1] / $limitOffset[2]);
$offset = (int)($limitOffset[2] * $page);
$rowCounter = self::ROW_COUNTER;
$sql = "SELECT {$limit} * FROM (
@@ -2094,7 +2094,7 @@ public function updateCounterCache($keys = array(), $created = false) {
if (isset($keys['old'][$foreignKey]) && $keys['old'][$foreignKey] != $keys[$foreignKey]) {
$conditions[$fkQuoted] = $keys['old'][$foreignKey];
$count = intval($this->find('count', compact('conditions', 'recursive')));
$count = (int)$this->find('count', compact('conditions', 'recursive'));
$Model->updateAll(
array($field => $count),
@@ -2108,7 +2108,7 @@ public function updateCounterCache($keys = array(), $created = false) {
$conditions = array_merge($conditions, (array)$conditions);
}
$count = intval($this->find('count', compact('conditions', 'recursive')));
$count = (int)$this->find('count', compact('conditions', 'recursive'));
$Model->updateAll(
array($field => $count),
@@ -2979,7 +2979,7 @@ public function buildQuery($type = 'first', $query = array()) {
$query = $this->{'_find' . ucfirst($type)}('before', $query);
}
if (!is_numeric($query['page']) || intval($query['page']) < 1) {
if (!is_numeric($query['page']) || (int)$query['page'] < 1) {
$query['page'] = 1;
}
@@ -3092,7 +3092,7 @@ protected function _findCount($state, $query, $results = array()) {
return count($results);
}
return intval($results[0][$key]['count']);
return (int)$results[0][$key]['count'];
}
}
@@ -2528,7 +2528,7 @@ public function testUpdateExisting() {
'user' => 'some user',
'password' => 'some password'
)));
$this->assertTrue(is_int($TestModel->id) || (intval($TestModel->id) === 5));
$this->assertTrue(is_int($TestModel->id) || ((int)$TestModel->id === 5));
$id = $TestModel->id;
$TestModel->save(array(
@@ -994,12 +994,12 @@ public static function gmt($dateString = null) {
$time = self::fromString($dateString);
}
return gmmktime(
intval(date('G', $time)),
intval(date('i', $time)),
intval(date('s', $time)),
intval(date('n', $time)),
intval(date('j', $time)),
intval(date('Y', $time))
(int)date('G', $time),
(int)date('i', $time),
(int)date('s', $time),
(int)date('n', $time),
(int)date('j', $time),
(int)date('Y', $time)
);
}
@@ -2893,7 +2893,7 @@ protected function _generateOptions($name, $options = array()) {
}
break;
case 'year':
$current = intval(date('Y'));
$current = (int)date('Y');
$min = !isset($options['min']) ? $current - 20 : (int)$options['min'];
$max = !isset($options['max']) ? $current + 20 : (int)$options['max'];
@@ -292,7 +292,7 @@ protected function _createVars() {
*/
public function link($title, $url = null, $options = array()) {
if (!isset($options['id'])) {
$options['id'] = 'link-' . intval(mt_rand());
$options['id'] = 'link-' . (int)mt_rand();
}
list($options, $htmlOptions) = $this->_getHtmlOptions($options);
$out = $this->Html->link($title, $url, $htmlOptions);
@@ -368,7 +368,7 @@ public function set($one, $two = null) {
*/
public function submit($caption = null, $options = array()) {
if (!isset($options['id'])) {
$options['id'] = 'submit-' . intval(mt_rand());
$options['id'] = 'submit-' . (int)mt_rand();
}
$formOptions = array('div');
list($options, $htmlOptions) = $this->_getHtmlOptions($options, $formOptions);
@@ -740,7 +740,7 @@ public function numbers($options = array()) {
$out = '';
if ($modulus && $params['pageCount'] > $modulus) {
$half = intval($modulus / 2);
$half = (int)($modulus / 2);
$end = $params['page'] + $half;
if ($end > $params['pageCount']) {

0 comments on commit 04ef392

Please sign in to comment.
You can’t perform that action at this time.