mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Use (int) cast instead of intval() function for performance reasons and to unify it.
This commit is contained in:
parent
58bf005c09
commit
e77f96d8b7
12 changed files with 25 additions and 25 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,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(
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -203,7 +203,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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');
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3048,7 +3048,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;
|
||||||
}
|
}
|
||||||
|
@ -3089,7 +3089,7 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return intval($length);
|
return (int)$length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3456,10 +3456,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) {
|
||||||
|
|
|
@ -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'
|
||||||
);
|
);
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -290,8 +290,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) && (int)$key > 0 || $key === '0') {
|
||||||
$key = intval($key);
|
$key = (int)$key;
|
||||||
}
|
}
|
||||||
if ($op === 'insert') {
|
if ($op === 'insert') {
|
||||||
if ($i === $last) {
|
if ($i === $last) {
|
||||||
|
|
|
@ -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));
|
||||||
|
|
Loading…
Reference in a new issue