Skip to content

Commit

Permalink
Merge pull request #4584 from bcrowe/3.0-int-cast
Browse files Browse the repository at this point in the history
3.0 - Replace intval() with int typecasts
  • Loading branch information
markstory committed Sep 12, 2014
2 parents 46d078f + 083bffa commit ab24722
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Cache/Engine/ApcEngine.php
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Engine/FileEngine.php
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Engine/WincacheEngine.php
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Engine/XcacheEngine.php
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/PaginatorComponent.php
Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Database/Type/IntegerType.php
Expand Up @@ -36,7 +36,7 @@ public function toDatabase($value, Driver $driver) {
if ($value === null || $value === '') {
return null;
}
return intval($value);
return (int)$value;
}

/**
Expand All @@ -51,7 +51,7 @@ public function toPHP($value, Driver $driver) {
if ($value === null) {
return null;
}
return intval($value);
return (int)$value;
}

/**
Expand All @@ -75,7 +75,7 @@ public function marshal($value) {
if ($value === null || $value === '') {
return null;
}
return intval($value);
return (int)$value;
}

}
2 changes: 1 addition & 1 deletion src/Shell/Task/PluginTask.php
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Utility/Hash.php
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/PaginatorHelper.php
Expand Up @@ -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']) {
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Error/DebuggerTest.php
Expand Up @@ -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'
);
Expand Down Expand Up @@ -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'
);
Expand Down

0 comments on commit ab24722

Please sign in to comment.