Browse Source

Replace intval() with int typecasts

Bryan Crowe 11 years ago
parent
commit
1781716065

+ 1 - 1
src/Cache/Engine/ApcEngine.php

@@ -77,7 +77,7 @@ class ApcEngine extends CacheEngine {
 		$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;
 		}

+ 1 - 1
src/Cache/Engine/FileEngine.php

@@ -180,7 +180,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->_config['duration']) < $cachetime)

+ 1 - 1
src/Cache/Engine/WincacheEngine.php

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

+ 1 - 1
src/Cache/Engine/XcacheEngine.php

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

+ 2 - 2
src/Controller/Component/PaginatorComponent.php

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

+ 3 - 3
src/Database/Type/IntegerType.php

@@ -36,7 +36,7 @@ class IntegerType extends \Cake\Database\Type {
 		if ($value === null || $value === '') {
 			return null;
 		}
-		return intval($value);
+		return (int)$value;
 	}
 
 /**
@@ -51,7 +51,7 @@ class IntegerType extends \Cake\Database\Type {
 		if ($value === null) {
 			return null;
 		}
-		return intval($value);
+		return (int)$value;
 	}
 
 /**
@@ -75,7 +75,7 @@ class IntegerType extends \Cake\Database\Type {
 		if ($value === null || $value === '') {
 			return null;
 		}
-		return intval($value);
+		return (int)$value;
 	}
 
 }

+ 1 - 1
src/Shell/Task/PluginTask.php

@@ -296,7 +296,7 @@ class PluginTask extends BakeTask {
 			}
 			$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;
 			}
 		}

+ 2 - 2
src/Utility/Hash.php

@@ -316,8 +316,8 @@ class Hash {
 		$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) {

+ 1 - 1
src/View/Helper/PaginatorHelper.php

@@ -620,7 +620,7 @@ class PaginatorHelper extends Helper {
 		$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']) {

+ 2 - 2
tests/TestCase/Error/DebuggerTest.php

@@ -200,7 +200,7 @@ class DebuggerTest extends TestCase {
 			'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 @@ class DebuggerTest extends TestCase {
 			'<error',
 			'<code', '8', '/code',
 			'<file', 'preg:/[^<]+/', '/file',
-			'<line', '' . (intval(__LINE__) - 7), '/line',
+			'<line', '' . (int)__LINE__ - 7, '/line',
 			'preg:/Undefined variable:\s+foo/',
 			'/error'
 		);