Take care of more int casts.

This commit is contained in:
euromark 2014-09-10 16:29:23 +02:00
parent e77f96d8b7
commit 04ef39217f
15 changed files with 27 additions and 27 deletions

View file

@ -75,7 +75,7 @@ class ApcEngine extends CacheEngine {
*/
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;
}

View file

@ -165,7 +165,7 @@ class FileEngine extends CacheEngine {
$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']) {

View file

@ -80,7 +80,7 @@ class WincacheEngine extends CacheEngine {
*/
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;
}

View file

@ -80,7 +80,7 @@ class XcacheEngine extends CacheEngine {
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;
}

View file

@ -579,8 +579,8 @@ class AclShell extends AppShell {
* @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;

View file

@ -728,7 +728,7 @@ class ModelTask extends BakeTask {
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."));

View file

@ -211,7 +211,7 @@ class PaginatorComponent extends Component {
}
$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);

View file

@ -509,7 +509,7 @@ class Sqlite extends DboSource {
$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'];

View file

@ -537,9 +537,9 @@ class Sqlserver extends DboSource {
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 (

View file

@ -2094,7 +2094,7 @@ class Model extends Object implements CakeEventListener {
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 @@ class Model extends Object implements CakeEventListener {
$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 @@ class Model extends Object implements CakeEventListener {
$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 @@ class Model extends Object implements CakeEventListener {
return count($results);
}
return intval($results[0][$key]['count']);
return (int)$results[0][$key]['count'];
}
}

View file

@ -2528,7 +2528,7 @@ class ModelWriteTest extends BaseModelTest {
'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(

View file

@ -994,12 +994,12 @@ class CakeTime {
$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)
);
}

View file

@ -2893,7 +2893,7 @@ class FormHelper extends AppHelper {
}
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'];

View file

@ -292,7 +292,7 @@ class JsHelper extends AppHelper {
*/
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 @@ class JsHelper extends AppHelper {
*/
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);

View file

@ -740,7 +740,7 @@ class PaginatorHelper extends AppHelper {
$out = '';
if ($modulus && $params['pageCount'] > $modulus) {
$half = intval($modulus / 2);
$half = (int)($modulus / 2);
$end = $params['page'] + $half;
if ($end > $params['pageCount']) {