Skip to content
Permalink
Browse files

Replace intval() with int typecasts

  • Loading branch information...
bcrowe committed Sep 11, 2014
1 parent 46d078f commit 1781716065d669553018db670e8d75ed20847ead
@@ -77,7 +77,7 @@ public function read($key) {
$key = $this->_key($key);
$time = time();
$cachetime = intval(apc_fetch($key . '_expires'));
$cachetime = (int)apc_fetch($key . '_expires');
if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->_config['duration']) < $cachetime)) {
return false;
}
@@ -180,7 +180,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->_config['duration']) < $cachetime)
@@ -80,7 +80,7 @@ public function read($key) {
$key = $this->_key($key);
$time = time();
$cachetime = intval(wincache_ucache_get($key . '_expires'));
$cachetime = (int)wincache_ucache_get($key . '_expires');
if ($cachetime < $time || ($time + $this->_config['duration']) < $cachetime) {
return false;
}
@@ -94,7 +94,7 @@ 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->_config['duration']) < $cachetime) {
return false;
}
@@ -154,7 +154,7 @@ public function paginate($object, array $settings = []) {
$options = $this->checkLimit($options);
$options += ['page' => 1];
$options['page'] = intval($options['page']) < 1 ? 1 : (int)$options['page'];
$options['page'] = (int)$options['page'] < 1 ? 1 : (int)$options['page'];
list($finder, $options) = $this->_extractFinder($options);
if (empty($query)) {
@@ -171,7 +171,7 @@ public function paginate($object, array $settings = []) {
$page = $options['page'];
$limit = $options['limit'];
$pageCount = intval(ceil($count / $limit));
$pageCount = (int)ceil($count / $limit);
$requestedPage = $page;
$page = max(min($page, $pageCount), 1);
$request = $this->_registry->getController()->request;
@@ -36,7 +36,7 @@ public function toDatabase($value, Driver $driver) {
if ($value === null || $value === '') {
return null;
}
return intval($value);
return (int)$value;
}
/**
@@ -51,7 +51,7 @@ public function toPHP($value, Driver $driver) {
if ($value === null) {
return null;
}
return intval($value);
return (int)$value;
}
/**
@@ -75,7 +75,7 @@ public function marshal($value) {
if ($value === null || $value === '') {
return null;
}
return intval($value);
return (int)$value;
}
}
@@ -296,7 +296,7 @@ public function findPath(array $pathOptions) {
}
$prompt = 'Choose a plugin path from the paths above.';
$choice = $this->in($prompt, null, 1);
if (intval($choice) > 0 && intval($choice) <= $max) {
if ((int)$choice > 0 && (int)$choice <= $max) {
$valid = true;
}
}
@@ -316,8 +316,8 @@ protected static function _simpleOp($op, $data, $path, $values = null) {
$count = count($path);
$last = $count - 1;
foreach ($path as $i => $key) {
if (is_numeric($key) && intval($key) > 0 || $key === '0') {
$key = intval($key);
if (is_numeric($key) && (int)$key > 0 || $key === '0') {
$key = (int)$key;
}
if ($op === 'insert') {
if ($i === $last) {
@@ -620,7 +620,7 @@ public function numbers(array $options = array()) {
$ellipsis = $templater->format('ellipsis', []);
if ($options['modulus'] && $params['pageCount'] > $options['modulus']) {
$half = intval($options['modulus'] / 2);
$half = (int)$options['modulus'] / 2;
$end = $params['page'] + $half;
if ($end > $params['pageCount']) {
@@ -200,7 +200,7 @@ public function testChangeOutputFormats() {
'error' => array(),
'code' => array(), '8', '/code',
'file' => array(), 'preg:/[^<]+/', '/file',
'line' => array(), '' . (intval(__LINE__) - 7), '/line',
'line' => array(), '' . (int)__LINE__ - 7, '/line',
'preg:/Undefined variable:\s+foo/',
'/error'
);
@@ -259,7 +259,7 @@ public function testAddFormat() {
'<error',
'<code', '8', '/code',
'<file', 'preg:/[^<]+/', '/file',
'<line', '' . (intval(__LINE__) - 7), '/line',
'<line', '' . (int)__LINE__ - 7, '/line',
'preg:/Undefined variable:\s+foo/',
'/error'
);

0 comments on commit 1781716

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