Merge branch 'master' into 2.6

This commit is contained in:
ADmad 2014-09-13 00:37:16 +05:30
commit 3fb252ad2f
34 changed files with 104 additions and 79 deletions

View file

@ -75,7 +75,7 @@ class ApcEngine extends CacheEngine {
*/ */
public function read($key) { public function read($key) {
$time = time(); $time = time();
$cachetime = intval(apc_fetch($key . '_expires')); $cachetime = (int)apc_fetch($key . '_expires');
if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) { if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {
return false; return false;
} }

View file

@ -165,7 +165,7 @@ class FileEngine extends CacheEngine {
$this->_File->rewind(); $this->_File->rewind();
$time = time(); $time = time();
$cachetime = intval($this->_File->current()); $cachetime = (int)$this->_File->current();
if ($cachetime !== false && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) { if ($cachetime !== false && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {
if ($this->settings['lock']) { if ($this->settings['lock']) {

View file

@ -80,7 +80,7 @@ class WincacheEngine extends CacheEngine {
*/ */
public function read($key) { public function read($key) {
$time = time(); $time = time();
$cachetime = intval(wincache_ucache_get($key . '_expires')); $cachetime = (int)wincache_ucache_get($key . '_expires');
if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) { if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) {
return false; return false;
} }

View file

@ -80,7 +80,7 @@ class XcacheEngine extends CacheEngine {
public function read($key) { public function read($key) {
if (xcache_isset($key)) { if (xcache_isset($key)) {
$time = time(); $time = time();
$cachetime = intval(xcache_get($key . '_expires')); $cachetime = (int)xcache_get($key . '_expires');
if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) { if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) {
return false; return false;
} }

View file

@ -579,8 +579,8 @@ class AclShell extends AppShell {
* @return array aro, aco, action * @return array aro, aco, action
*/ */
protected function _getParams() { protected function _getParams() {
$aro = is_numeric($this->args[0]) ? intval($this->args[0]) : $this->args[0]; $aro = is_numeric($this->args[0]) ? (int)$this->args[0] : $this->args[0];
$aco = is_numeric($this->args[1]) ? intval($this->args[1]) : $this->args[1]; $aco = is_numeric($this->args[1]) ? (int)$this->args[1] : $this->args[1];
$aroName = $aro; $aroName = $aro;
$acoName = $aco; $acoName = $aco;

View file

@ -452,14 +452,14 @@ class ControllerTask extends BakeTask {
return $this->_stop(); return $this->_stop();
} }
if (!$enteredController || intval($enteredController) > count($controllers)) { if (!$enteredController || (int)$enteredController > count($controllers)) {
$this->err(__d('cake_console', "The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again.")); $this->err(__d('cake_console', "The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again."));
$enteredController = ''; $enteredController = '';
} }
} }
if (intval($enteredController) > 0 && intval($enteredController) <= count($controllers)) { if ((int)$enteredController > 0 && (int)$enteredController <= count($controllers)) {
$controllerName = $controllers[intval($enteredController) - 1]; $controllerName = $controllers[(int)$enteredController - 1];
} else { } else {
$controllerName = Inflector::camelize($enteredController); $controllerName = Inflector::camelize($enteredController);
} }

View file

@ -430,7 +430,7 @@ class ExtractTask extends AppShell {
if ($mapCount === count($strings)) { if ($mapCount === count($strings)) {
extract(array_combine($map, $strings)); extract(array_combine($map, $strings));
$category = isset($category) ? $category : 6; $category = isset($category) ? $category : 6;
$category = intval($category); $category = (int)$category;
$categoryName = $categories[$category]; $categoryName = $categories[$category];
$domain = isset($domain) ? $domain : 'default'; $domain = isset($domain) ? $domain : 'default';
$details = array( $details = array(

View file

@ -176,7 +176,7 @@ class ModelTask extends BakeTask {
$prompt = __d('cake_console', 'Make a selection from the choices above'); $prompt = __d('cake_console', 'Make a selection from the choices above');
} }
$choice = $this->in($prompt, null, $default); $choice = $this->in($prompt, null, $default);
if (intval($choice) > 0 && intval($choice) <= $max) { if ((int)$choice > 0 && (int)$choice <= $max) {
$valid = true; $valid = true;
} }
} }
@ -728,7 +728,7 @@ class ModelTask extends BakeTask {
while (strtolower($wannaDoMoreAssoc) === 'y') { while (strtolower($wannaDoMoreAssoc) === 'y') {
$assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); $assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
$this->out(__d('cake_console', 'What is the association type?')); $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" . $this->out(__d('cake_console', "For the following options be very careful to match your setup exactly.\n" .
"Any spelling mistakes will cause errors.")); "Any spelling mistakes will cause errors."));
@ -765,7 +765,7 @@ class ModelTask extends BakeTask {
if (!empty($showKeys)) { if (!empty($showKeys)) {
$this->out(__d('cake_console', 'A helpful List of possible keys')); $this->out(__d('cake_console', 'A helpful List of possible keys'));
$foreignKey = $this->inOptions($showKeys, __d('cake_console', 'What is the foreignKey?')); $foreignKey = $this->inOptions($showKeys, __d('cake_console', 'What is the foreignKey?'));
$foreignKey = $showKeys[intval($foreignKey)]; $foreignKey = $showKeys[(int)$foreignKey];
} }
if (!isset($foreignKey)) { if (!isset($foreignKey)) {
$foreignKey = $this->in(__d('cake_console', 'What is the foreignKey? Specify your own.'), null, $suggestedForeignKey); $foreignKey = $this->in(__d('cake_console', 'What is the foreignKey? Specify your own.'), null, $suggestedForeignKey);
@ -985,14 +985,14 @@ class ModelTask extends BakeTask {
return $this->_stop(); return $this->_stop();
} }
if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) { if (!$enteredModel || (int)$enteredModel > count($this->_modelNames)) {
$this->err(__d('cake_console', "The model name you supplied was empty,\n" . $this->err(__d('cake_console', "The model name you supplied was empty,\n" .
"or the number you selected was not an option. Please try again.")); "or the number you selected was not an option. Please try again."));
$enteredModel = ''; $enteredModel = '';
} }
} }
if (intval($enteredModel) > 0 && intval($enteredModel) <= count($this->_modelNames)) { if ((int)$enteredModel > 0 && (int)$enteredModel <= count($this->_modelNames)) {
return $this->_modelNames[intval($enteredModel) - 1]; return $this->_modelNames[(int)$enteredModel - 1];
} }
return $enteredModel; return $enteredModel;

View file

@ -210,7 +210,7 @@ class PluginTask extends AppShell {
} }
$prompt = __d('cake_console', 'Choose a plugin path from the paths above.'); $prompt = __d('cake_console', 'Choose a plugin path from the paths above.');
$choice = $this->in($prompt, null, 1); $choice = $this->in($prompt, null, 1);
if (intval($choice) > 0 && intval($choice) <= $max) { if ((int)$choice > 0 && (int)$choice <= $max) {
$valid = true; $valid = true;
} }
} }

View file

@ -340,6 +340,11 @@ class ProjectTask extends AppShell {
$root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'"; $root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'";
$corePath = $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'"; $corePath = $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'";
$composer = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib';
if (file_exists($composer)) {
$corePath = " ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'";
}
$result = str_replace('__CAKE_PATH__', $corePath, $contents, $count); $result = str_replace('__CAKE_PATH__', $corePath, $contents, $count);
if ($hardCode) { if ($hardCode) {
$result = str_replace('//define(\'CAKE_CORE', 'define(\'CAKE_CORE', $result); $result = str_replace('//define(\'CAKE_CORE', 'define(\'CAKE_CORE', $result);

View file

@ -414,7 +414,7 @@ class CookieComponent extends Component {
$now = new DateTime(); $now = new DateTime();
if (is_int($expires) || is_numeric($expires)) { if (is_int($expires) || is_numeric($expires)) {
return $this->_expires = $now->format('U') + intval($expires); return $this->_expires = $now->format('U') + (int)$expires;
} }
$now->modify($expires); $now->modify($expires);
return $this->_expires = $now->format('U'); return $this->_expires = $now->format('U');

View file

@ -179,7 +179,7 @@ class PaginatorComponent extends Component {
$extra['type'] = $type; $extra['type'] = $type;
} }
if (intval($page) < 1) { if ((int)$page < 1) {
$page = 1; $page = 1;
} }
$page = $options['page'] = (int)$page; $page = $options['page'] = (int)$page;
@ -211,7 +211,7 @@ class PaginatorComponent extends Component {
} }
$count = $object->find('count', array_merge($parameters, $extra)); $count = $object->find('count', array_merge($parameters, $extra));
} }
$pageCount = intval(ceil($count / $limit)); $pageCount = (int)ceil($count / $limit);
$requestedPage = $page; $requestedPage = $page;
$page = max(min($page, $pageCount), 1); $page = max(min($page, $pageCount), 1);

View file

@ -493,7 +493,7 @@ class Mysql extends DboSource {
if ($idx->Index_type === 'FULLTEXT') { if ($idx->Index_type === 'FULLTEXT') {
$index[$idx->Key_name]['type'] = strtolower($idx->Index_type); $index[$idx->Key_name]['type'] = strtolower($idx->Index_type);
} else { } else {
$index[$idx->Key_name]['unique'] = intval($idx->Non_unique == 0); $index[$idx->Key_name]['unique'] = (int)($idx->Non_unique == 0);
} }
} else { } else {
if (!empty($index[$idx->Key_name]['column']) && !is_array($index[$idx->Key_name]['column'])) { if (!empty($index[$idx->Key_name]['column']) && !is_array($index[$idx->Key_name]['column'])) {

View file

@ -219,10 +219,10 @@ class Postgres extends DboSource {
} elseif ($c->type === 'uuid') { } elseif ($c->type === 'uuid') {
$length = 36; $length = 36;
} else { } else {
$length = intval($c->oct_length); $length = (int)$c->oct_length;
} }
} elseif (!empty($c->char_length)) { } elseif (!empty($c->char_length)) {
$length = intval($c->char_length); $length = (int)$c->char_length;
} else { } else {
$length = $this->length($c->type); $length = $this->length($c->type);
} }
@ -726,7 +726,7 @@ class Postgres extends DboSource {
return 36; return 36;
} }
if ($limit) { if ($limit) {
return intval($limit); return (int)$limit;
} }
return null; return null;
} }

View file

@ -509,7 +509,7 @@ class Sqlite extends DboSource {
$key['name'] = 'PRIMARY'; $key['name'] = 'PRIMARY';
} }
$index[$key['name']]['column'] = $keyCol[0]['name']; $index[$key['name']]['column'] = $keyCol[0]['name'];
$index[$key['name']]['unique'] = intval($key['unique'] == 1); $index[$key['name']]['unique'] = (int)$key['unique'] === 1;
} else { } else {
if (!is_array($index[$key['name']]['column'])) { if (!is_array($index[$key['name']]['column'])) {
$col[] = $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)) { 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); preg_match('/OFFSET\s*(\d+)\s*.*?(\d+)\s*ROWS/', $limit, $limitOffset);
$limit = 'TOP ' . intval($limitOffset[2]); $limit = 'TOP ' . (int)$limitOffset[2];
$page = intval($limitOffset[1] / $limitOffset[2]); $page = (int)($limitOffset[1] / $limitOffset[2]);
$offset = intval($limitOffset[2] * $page); $offset = (int)($limitOffset[2] * $page);
$rowCounter = self::ROW_COUNTER; $rowCounter = self::ROW_COUNTER;
$sql = "SELECT {$limit} * FROM ( $sql = "SELECT {$limit} * FROM (

View file

@ -3077,7 +3077,7 @@ class DboSource extends DataSource {
list($col, $limit) = explode('(', $col); list($col, $limit) = explode('(', $col);
} }
if ($limit !== null) { if ($limit !== null) {
return intval($limit); return (int)$limit;
} }
return null; return null;
} }
@ -3118,7 +3118,7 @@ class DboSource extends DataSource {
} }
} }
} }
return intval($length); return (int)$length;
} }
/** /**
@ -3485,10 +3485,10 @@ class DboSource extends DataSource {
if (is_bool($value)) { if (is_bool($value)) {
return 'boolean'; return 'boolean';
} }
if (is_float($value) && floatval($value) === $value) { if (is_float($value) && (float)$value === $value) {
return 'float'; return 'float';
} }
if (is_int($value) && intval($value) === $value) { if (is_int($value) && (int)$value === $value) {
return 'integer'; return 'integer';
} }
if (is_string($value) && strlen($value) > 255) { if (is_string($value) && strlen($value) > 255) {

View file

@ -2162,7 +2162,7 @@ class Model extends Object implements CakeEventListener {
if (isset($keys['old'][$foreignKey]) && $keys['old'][$foreignKey] != $keys[$foreignKey]) { if (isset($keys['old'][$foreignKey]) && $keys['old'][$foreignKey] != $keys[$foreignKey]) {
$conditions[$fkQuoted] = $keys['old'][$foreignKey]; $conditions[$fkQuoted] = $keys['old'][$foreignKey];
$count = intval($this->find('count', compact('conditions', 'recursive'))); $count = (int)$this->find('count', compact('conditions', 'recursive'));
$Model->updateAll( $Model->updateAll(
array($field => $count), array($field => $count),
@ -2176,7 +2176,7 @@ class Model extends Object implements CakeEventListener {
$conditions = array_merge($conditions, (array)$conditions); $conditions = array_merge($conditions, (array)$conditions);
} }
$count = intval($this->find('count', compact('conditions', 'recursive'))); $count = (int)$this->find('count', compact('conditions', 'recursive'));
$Model->updateAll( $Model->updateAll(
array($field => $count), array($field => $count),
@ -3047,7 +3047,7 @@ class Model extends Object implements CakeEventListener {
$query = $this->{'_find' . ucfirst($type)}('before', $query); $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; $query['page'] = 1;
} }
@ -3160,7 +3160,7 @@ class Model extends Object implements CakeEventListener {
return count($results); return count($results);
} }
return intval($results[0][$key]['count']); return (int)$results[0][$key]['count'];
} }
} }

View file

@ -2782,7 +2782,7 @@ class ModelWriteTest extends BaseModelTest {
'user' => 'some user', 'user' => 'some user',
'password' => 'some password' '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; $id = $TestModel->id;
$TestModel->save(array( $TestModel->save(array(

View file

@ -187,7 +187,7 @@ class DebuggerTest extends CakeTestCase {
'error' => array(), 'error' => array(),
'code' => array(), '8', '/code', 'code' => array(), '8', '/code',
'file' => array(), 'preg:/[^<]+/', '/file', 'file' => array(), 'preg:/[^<]+/', '/file',
'line' => array(), '' . (intval(__LINE__) - 7), '/line', 'line' => array(), '' . ((int)__LINE__ - 7), '/line',
'preg:/Undefined variable:\s+foo/', 'preg:/Undefined variable:\s+foo/',
'/error' '/error'
); );
@ -246,7 +246,7 @@ class DebuggerTest extends CakeTestCase {
'<error', '<error',
'<code', '8', '/code', '<code', '8', '/code',
'<file', 'preg:/[^<]+/', '/file', '<file', 'preg:/[^<]+/', '/file',
'<line', '' . (intval(__LINE__) - 7), '/line', '<line', '' . ((int)__LINE__ - 7), '/line',
'preg:/Undefined variable:\s+foo/', 'preg:/Undefined variable:\s+foo/',
'/error' '/error'
); );

View file

@ -976,6 +976,28 @@ class FolderTest extends CakeTestCase {
$Folder->delete(); $Folder->delete();
} }
/**
* Test that SKIP mode skips files too.
*
* @return void
*/
public function testCopyWithSkipFileSkipped() {
$path = TMP . 'folder_test';
$folderOne = $path . DS . 'folder1';
$folderTwo = $path . DS . 'folder2';
new Folder($path, true);
new Folder($folderOne, true);
new Folder($folderTwo, true);
file_put_contents($folderOne . DS . 'fileA.txt', 'Folder One File');
file_put_contents($folderTwo . DS . 'fileA.txt', 'Folder Two File');
$Folder = new Folder($folderOne);
$result = $Folder->copy(array('to' => $folderTwo, 'scheme' => Folder::SKIP));
$this->assertTrue($result);
$this->assertEquals('Folder Two File', file_get_contents($folderTwo . DS . 'fileA.txt'));
}
/** /**
* testCopyWithOverwrite * testCopyWithOverwrite
* *

View file

@ -1377,6 +1377,13 @@ class HashTest extends CakeTestCase {
'pages' => array('name' => array()), 'pages' => array('name' => array()),
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$a = array(
'foo' => array('bar' => 'baz')
);
$result = Hash::insert($a, 'some.0123.path', array('foo' => array('bar' => 'baz')));
$expected = array('foo' => array('bar' => 'baz'));
$this->assertEquals($expected, Hash::get($result, 'some.0123.path'));
} }
/** /**

View file

@ -15,9 +15,6 @@
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Fixture * @package Cake.Test.Fixture
* @since CakePHP(tm) v 1.2.0.5669 * @since CakePHP(tm) v 1.2.0.5669
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
/** /**

View file

@ -15,9 +15,6 @@
* @link http://cakephp.org CakePHP(tm) Project * @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior * @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior
* @since CakePHP(tm) v 1.2.0.5669 * @since CakePHP(tm) v 1.2.0.5669
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */

View file

@ -15,9 +15,6 @@
* @link http://cakephp.org CakePHP(tm) Project * @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior * @package Cake.Test.TestApp.Plugin.TestPlugin.Model.Behavior
* @since CakePHP(tm) v 1.2.0.5669 * @since CakePHP(tm) v 1.2.0.5669
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */

View file

@ -13,9 +13,6 @@
* @link http://cakefoundation.org/projects/info/cakephp CakePHP Project * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project
* @package Cake.Test.TestApp.Plugin.TestPlugin.Model * @package Cake.Test.TestApp.Plugin.TestPlugin.Model
* @since CakePHP v 1.2.0.7726 * @since CakePHP v 1.2.0.7726
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */

View file

@ -13,9 +13,6 @@
* @link http://cakefoundation.org/projects/info/cakephp CakePHP Project * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project
* @package Cake.Test.TestApp.Plugin.TestPlugin.Model * @package Cake.Test.TestApp.Plugin.TestPlugin.Model
* @since CakePHP v 1.2.0.7726 * @since CakePHP v 1.2.0.7726
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */

View file

@ -321,7 +321,7 @@ class CakeTime {
} }
if (is_int($dateString) || is_numeric($dateString)) { if (is_int($dateString) || is_numeric($dateString)) {
$date = intval($dateString); $date = (int)$dateString;
} elseif ( } elseif (
$dateString instanceof DateTime && $dateString instanceof DateTime &&
$dateString->getTimezone()->getName() != date_default_timezone_get() $dateString->getTimezone()->getName() != date_default_timezone_get()
@ -994,12 +994,12 @@ class CakeTime {
$time = self::fromString($dateString); $time = self::fromString($dateString);
} }
return gmmktime( return gmmktime(
intval(date('G', $time)), (int)date('G', $time),
intval(date('i', $time)), (int)date('i', $time),
intval(date('s', $time)), (int)date('s', $time),
intval(date('n', $time)), (int)date('n', $time),
intval(date('j', $time)), (int)date('j', $time),
intval(date('Y', $time)) (int)date('Y', $time)
); );
} }

View file

@ -390,11 +390,11 @@ class Folder {
/** /**
* Change the mode on a directory structure recursively. This includes changing the mode on files as well. * Change the mode on a directory structure recursively. This includes changing the mode on files as well.
* *
* @param string $path The path to chmod * @param string $path The path to chmod.
* @param int $mode octal value 0755 * @param int $mode Octal value, e.g. 0755.
* @param bool $recursive chmod recursively, set to false to only change the current directory. * @param bool $recursive Chmod recursively, set to false to only change the current directory.
* @param array $exceptions array of files, directories to skip * @param array $exceptions Array of files, directories to skip.
* @return bool Returns TRUE on success, FALSE on failure * @return bool Success.
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::chmod * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::chmod
*/ */
public function chmod($path, $mode = false, $recursive = true, $exceptions = array()) { public function chmod($path, $mode = false, $recursive = true, $exceptions = array()) {
@ -650,12 +650,12 @@ class Folder {
* *
* - `to` The directory to copy to. * - `to` The directory to copy to.
* - `from` The directory to copy from, this will cause a cd() to occur, changing the results of pwd(). * - `from` The directory to copy from, this will cause a cd() to occur, changing the results of pwd().
* - `mode` The mode to copy the files/directories with. * - `mode` The mode to copy the files/directories with as integer, e.g. 0775.
* - `skip` Files/directories to skip. * - `skip` Files/directories to skip.
* - `scheme` Folder::MERGE, Folder::OVERWRITE, Folder::SKIP * - `scheme` Folder::MERGE, Folder::OVERWRITE, Folder::SKIP
* *
* @param array|string $options Either an array of options (see above) or a string of the destination directory. * @param array|string $options Either an array of options (see above) or a string of the destination directory.
* @return bool Success * @return bool Success.
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy
*/ */
public function copy($options) { public function copy($options) {
@ -667,7 +667,13 @@ class Folder {
$to = $options; $to = $options;
$options = array(); $options = array();
} }
$options += array('to' => $to, 'from' => $this->path, 'mode' => $this->mode, 'skip' => array(), 'scheme' => Folder::MERGE); $options += array(
'to' => $to,
'from' => $this->path,
'mode' => $this->mode,
'skip' => array(),
'scheme' => Folder::MERGE
);
$fromDir = $options['from']; $fromDir = $options['from'];
$toDir = $options['to']; $toDir = $options['to'];
@ -695,7 +701,7 @@ class Folder {
$to = Folder::addPathElement($toDir, $item); $to = Folder::addPathElement($toDir, $item);
if (($options['scheme'] != Folder::SKIP || !is_dir($to)) && !in_array($item, $exceptions)) { if (($options['scheme'] != Folder::SKIP || !is_dir($to)) && !in_array($item, $exceptions)) {
$from = Folder::addPathElement($fromDir, $item); $from = Folder::addPathElement($fromDir, $item);
if (is_file($from)) { if (is_file($from) && (!is_file($to) || $options['scheme'] != Folder::SKIP)) {
if (copy($from, $to)) { if (copy($from, $to)) {
chmod($to, intval($mode, 8)); chmod($to, intval($mode, 8));
touch($to, filemtime($from)); touch($to, filemtime($from));

View file

@ -300,8 +300,8 @@ class Hash {
$count = count($path); $count = count($path);
$last = $count - 1; $last = $count - 1;
foreach ($path as $i => $key) { foreach ($path as $i => $key) {
if (is_numeric($key) && intval($key) > 0 || $key === '0') { if ((is_numeric($key) && intval($key) > 0 || $key === '0') && strpos($key, '0') !== 0) {
$key = intval($key); $key = (int)$key;
} }
if ($op === 'insert') { if ($op === 'insert') {
if ($i === $last) { if ($i === $last) {

View file

@ -560,7 +560,7 @@ class Set {
} }
foreach ($path as $i => $key) { foreach ($path as $i => $key) {
if (is_numeric($key) && intval($key) > 0 || $key === '0') { if (is_numeric($key) && (int)$key > 0 || $key === '0') {
if (isset($data[$key])) { if (isset($data[$key])) {
$data = $data[$key]; $data = $data[$key];
} else { } else {
@ -657,8 +657,8 @@ class Set {
} }
foreach ($path as $i => $key) { foreach ($path as $i => $key) {
if (is_numeric($key) && intval($key) > 0 || $key === '0') { if (is_numeric($key) && (int)$key > 0 || $key === '0') {
$key = intval($key); $key = (int)$key;
} }
if ($i === count($path) - 1) { if ($i === count($path) - 1) {
return (is_array($data) && array_key_exists($key, $data)); return (is_array($data) && array_key_exists($key, $data));

View file

@ -2894,7 +2894,7 @@ class FormHelper extends AppHelper {
} }
break; break;
case 'year': case 'year':
$current = intval(date('Y')); $current = (int)date('Y');
$min = !isset($options['min']) ? $current - 20 : (int)$options['min']; $min = !isset($options['min']) ? $current - 20 : (int)$options['min'];
$max = !isset($options['max']) ? $current + 20 : (int)$options['max']; $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()) { public function link($title, $url = null, $options = array()) {
if (!isset($options['id'])) { if (!isset($options['id'])) {
$options['id'] = 'link-' . intval(mt_rand()); $options['id'] = 'link-' . (int)mt_rand();
} }
list($options, $htmlOptions) = $this->_getHtmlOptions($options); list($options, $htmlOptions) = $this->_getHtmlOptions($options);
$out = $this->Html->link($title, $url, $htmlOptions); $out = $this->Html->link($title, $url, $htmlOptions);
@ -368,7 +368,7 @@ class JsHelper extends AppHelper {
*/ */
public function submit($caption = null, $options = array()) { public function submit($caption = null, $options = array()) {
if (!isset($options['id'])) { if (!isset($options['id'])) {
$options['id'] = 'submit-' . intval(mt_rand()); $options['id'] = 'submit-' . (int)mt_rand();
} }
$formOptions = array('div'); $formOptions = array('div');
list($options, $htmlOptions) = $this->_getHtmlOptions($options, $formOptions); list($options, $htmlOptions) = $this->_getHtmlOptions($options, $formOptions);

View file

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