diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 22d0e3fe676..4f3388186a1 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -373,7 +373,7 @@ function delete($var = null) { $_this =& Configure::getInstance(); $name = $_this->__configVarNames($var); - if (count($name) > 1) { + if (isset($name[1])) { unset($_this->{$name[0]}[$name[1]]); } else { unset($_this->{$name[0]}); diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php index d68c61f0399..3501e0b6315 100644 --- a/cake/libs/controller/components/acl.php +++ b/cake/libs/controller/components/acl.php @@ -349,7 +349,7 @@ function allow($aro, $aco, $actions = "*", $value = 1) { } list($save['aro_id'], $save['aco_id']) = array($perms['aro'], $perms['aco']); - if ($perms['link'] != null && count($perms['link']) > 0) { + if ($perms['link'] != null && !empty($perms['link'])) { $save['id'] = $perms['link'][0][$this->Aro->Permission->alias]['id']; } else { unset($save['id']); diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index ce1b114d70a..d391c2472ec 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -737,7 +737,7 @@ function validate() { function validateErrors() { $objects = func_get_args(); - if (!count($objects)) { + if (empty($objects)) { return false; } @@ -747,7 +747,7 @@ function validateErrors() { $errors = array_merge($errors, $this->{$object->alias}->invalidFields()); } - return $this->validationErrors = (count($errors) ? $errors : false); + return $this->validationErrors = (!empty($errors) ? $errors : false); } /** * Instantiates the correct view class, hands it its data, and uses it to render the view output. diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index 42d47916c62..873b8a23cf0 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -403,7 +403,7 @@ function exportVar($var, $recursion = 0) { } } $n = null; - if (count($vars) > 0) { + if (!empty($vars)) { $n = "\n"; } return $out . implode(",", $vars) . "{$n})"; diff --git a/cake/libs/folder.php b/cake/libs/folder.php index a5331f80f51..54856531cb0 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -744,7 +744,7 @@ function realpath($path) { continue; } if ($part === '..') { - if (count($newparts) > 0) { + if (!empty($newparts)) { array_pop($newparts); continue; } else { diff --git a/cake/libs/model/connection_manager.php b/cake/libs/model/connection_manager.php index 57534882273..a0db47226b3 100644 --- a/cake/libs/model/connection_manager.php +++ b/cake/libs/model/connection_manager.php @@ -135,7 +135,7 @@ function sourceList() { function getSourceName(&$source) { $_this =& ConnectionManager::getInstance(); $names = array_keys($_this->_dataSources); - for ($i = 0; $i < count($names); $i++) { + for ($i = 0, $count = count($names); $i < $count; $i++) { if ($_this->_dataSources[$names[$i]] === $source) { return $names[$i]; } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index a48a3c6a2ed..ae8df2cbe1c 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -2039,7 +2039,7 @@ function order($keys, $direction = 'ASC') { $keys = array_filter($keys); } - if (empty($keys) || (is_array($keys) && count($keys) && isset($keys[0]) && empty($keys[0]))) { + if (empty($keys) || (is_array($keys) && isset($keys[0]) && empty($keys[0]))) { return ''; } diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index bfc24f4ba1d..e688f1ea983 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1079,7 +1079,7 @@ function field($name, $conditions = null, $order = null) { return $data[$name[0]][$name[1]]; } } - if (isset($data[0]) && count($data[0]) > 0) { + if (!empty($data[0])) { $name = key($data[0]); return $data[0][$name]; } diff --git a/cake/libs/multibyte.php b/cake/libs/multibyte.php index 724b6592334..1dfcd456bae 100644 --- a/cake/libs/multibyte.php +++ b/cake/libs/multibyte.php @@ -36,7 +36,8 @@ * @param string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. - * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false if $needle is not found. + * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false + * if $needle is not found. */ if (!function_exists('mb_stripos')) { function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { @@ -49,8 +50,9 @@ function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. - * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, + * Default value is false. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack, or false if $needle is not found. */ @@ -65,7 +67,7 @@ function mb_stristr($haystack, $needle, $part = false, $encoding = null) { * @param string $string The string being checked for length. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer The number of characters in string $string having character encoding encoding. - * A multi-byte character is counted as 1. + * A multi-byte character is counted as 1. */ if (!function_exists('mb_strlen')) { function mb_strlen($string, $encoding = null) { @@ -80,7 +82,7 @@ function mb_strlen($string, $encoding = null) { * @param integer $offset The search offset. If it is not specified, 0 is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string. - * If $needle is not found, it returns false. + * If $needle is not found, it returns false. */ if (!function_exists('mb_strpos')) { function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { @@ -93,8 +95,9 @@ function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. - * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, + * Default value is false. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack. or false if $needle is not found. */ @@ -109,8 +112,9 @@ function mb_strrchr($haystack, $needle, $part = false, $encoding = null) { * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. - * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, + * Default value is false. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack. or false if $needle is not found. */ @@ -126,7 +130,8 @@ function mb_strrichr($haystack, $needle, $part = false, $encoding = null) { * @param string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. - * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, or false if $needle is not found. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, + * or false if $needle is not found. */ if (!function_exists('mb_strripos')) { function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { @@ -139,9 +144,10 @@ function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { * @param string $haystack The string being checked, for the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string. - * Negative values will stop searching at an arbitrary point prior to the end of the string. + * Negative values will stop searching at an arbitrary point prior to the end of the string. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. - * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. If $needle is not found, it returns false. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. + * If $needle is not found, it returns false. */ if (!function_exists('mb_strrpos')) { function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { @@ -154,8 +160,9 @@ function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. - * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is FALSE. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, + * Default value is FALSE. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack, or true if $needle is not found. */ @@ -220,12 +227,13 @@ function mb_substr($string, $start, $length = null, $encoding = null) { * * @param string $str The string being encoded * @param string $charset specifies the name of the character set in which str is represented in. - * The default value is determined by the current NLS setting (mbstring.language). - * @param string $transfer_encoding specifies the scheme of MIME encoding. It should be either "B" (Base64) or "Q" (Quoted-Printable). - * Falls back to "B" if not given. - * @param string $linefeed specifies the EOL (end-of-line) marker with which mb_encode_mimeheader() performs line-folding - * (a » RFC term, the act of breaking a line longer than a certain length into multiple lines. - * The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given. + * The default value is determined by the current NLS setting (mbstring.language). + * @param string $transfer_encoding specifies the scheme of MIME encoding. + * It should be either "B" (Base64) or "Q" (Quoted-Printable). Falls back to "B" if not given. + * @param string $linefeed specifies the EOL (end-of-line) marker with which + * mb_encode_mimeheader() performs line-folding + * (a » RFC term, the act of breaking a line longer than a certain length into multiple lines. + * The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given. * @param integer $indent [definition unknown and appears to have no affect] * @return string A converted version of the string represented in ASCII. */ @@ -300,7 +308,7 @@ function utf8($string) { if ($value < 128) { $map[] = $value; } else { - if (count($values) == 0) { + if (empty($values)) { $find = ($value < 224) ? 2 : 3; } $values[] = $value; @@ -350,7 +358,8 @@ function ascii($array) { * @param multi-byte string $haystack The string from which to get the position of the first occurrence of $needle. * @param multi-byte string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. - * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false if $needle is not found. + * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, + * or false if $needle is not found. * @access public * @static */ @@ -368,8 +377,9 @@ function stripos($haystack, $needle, $offset = 0) { * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. - * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, + * Default value is false. * @return int|boolean The portion of $haystack, or false if $needle is not found. * @access public * @static @@ -445,7 +455,7 @@ function strlen($string) { * @param string $needle The position counted from the beginning of haystack. * @param integer $offset The search offset. If it is not specified, 0 is used. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string. - * If $needle is not found, it returns false. + * If $needle is not found, it returns false. * @access public * @static */ @@ -488,8 +498,9 @@ function strpos($haystack, $needle, $offset = 0) { * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. - * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, + * Default value is false. * @return string|boolean The portion of $haystack. or false if $needle is not found. * @access public * @static @@ -548,8 +559,9 @@ function strrchr($haystack, $needle, $part = false) { * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. - * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, + * Default value is false. * @return string|boolean The portion of $haystack. or false if $needle is not found. * @access public * @static @@ -610,7 +622,8 @@ function strrichr($haystack, $needle, $part = false) { * @param string $haystack The string from which to get the position of the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. - * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, or false if $needle is not found. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, + * or false if $needle is not found. * @access public * @static */ @@ -661,8 +674,9 @@ function strripos($haystack, $needle, $offset = 0) { * @param string $haystack The string being checked, for the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string. - * Negative values will stop searching at an arbitrary point prior to the end of the string. - * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. If $needle is not found, it returns false. + * Negative values will stop searching at an arbitrary point prior to the end of the string. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. + * If $needle is not found, it returns false. * @access public * @static */ @@ -711,8 +725,9 @@ function strrpos($haystack, $needle, $offset = 0) { * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack * @param boolean $part Determines which portion of $haystack this function returns. - * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. - * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is FALSE. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, + * Default value is FALSE. * @return string|boolean The portion of $haystack, or true if $needle is not found. * @access public * @static @@ -853,14 +868,14 @@ function strtoupper($string) { if ($length > 1 && count($keys[$key]['lower']) > 1) { $j = 0; - for ($ii = 0; $ii < count($keys[$key]['lower']); $ii++) { + for ($ii = 0, $count = count($keys[$key]['lower']); $ii < $count; $ii++) { $nextChar = $utf8Map[$i + $ii]; if (isset($nextChar) && ($nextChar == $keys[$key]['lower'][$j + $ii])) { $replace++; } } - if ($replace == count($keys[$key]['lower'])) { + if ($replace == $count) { $upperCase[] = $keys[$key]['upper']; $replaced = array_merge($replaced, array_values($keys[$key]['lower'])); $matched = true; @@ -873,14 +888,14 @@ function strtoupper($string) { if (in_array($nextChar, $keys[$ii]['lower'])) { - for ($jj = 0; $jj < count($keys[$ii]['lower']); $jj++) { + for ($jj = 0, $count = count($keys[$ii]['lower']); $jj < $count; $jj++) { $nextChar = $utf8Map[$i + $jj]; if (isset($nextChar) && ($nextChar == $keys[$ii]['lower'][$j + $jj])) { $replace++; } } - if ($replace == count($keys[$ii]['lower'])) { + if ($replace == $count) { $upperCase[] = $keys[$ii]['upper']; $replaced = array_merge($replaced, array_values($keys[$ii]['lower'])); $matched = true; diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index 30d424faf84..8ed84a45558 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -161,7 +161,7 @@ function stripTags() { $params = params(func_get_args()); $str = $params[0]; - for ($i = 1; $i < count($params); $i++) { + for ($i = 1, $count = count($params); $i < $count; $i++) { $str = preg_replace('/<' . $params[$i] . '\b[^>]*>/i', '', $str); $str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str); } diff --git a/cake/libs/set.php b/cake/libs/set.php index 11382e4dc7a..4646387b85c 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -1077,7 +1077,7 @@ function __flatten($results, $key = null) { if (!is_null($key)) { $id = $key; } - if (is_array($r) && count($r)) { + if (is_array($r) && !empty($r)) { $stack = array_merge($stack, Set::__flatten($r, $id)); } else { $stack[] = array('id' => $id, 'value' => $r); diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index b5be53a748e..43b885a3490 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -410,7 +410,7 @@ function style($data, $inline = true) { * @return string */ function getCrumbs($separator = '»', $startText = false) { - if (count($this->_crumbs)) { + if (!empty($this->_crumbs)) { $out = array(); if ($startText) { $out[] = $this->link($startText, '/'); diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 691cd5dbaac..34c0e370a20 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -566,7 +566,7 @@ function &document() { * @access public */ function hasChildren() { - if (is_array($this->children) && count($this->children) > 0) { + if (is_array($this->children) && !empty($this->children)) { return true; } return false; @@ -593,7 +593,7 @@ function toString($options = array(), $depth = 0) { } $d .= '<' . $this->name(); - if (count($this->namespaces) > 0) { + if (!empty($this->namespaces) > 0) { foreach ($this->namespaces as $key => $val) { $val = str_replace('"', '\"', $val); $d .= ' xmlns:' . $key . '="' . $val . '"'; @@ -601,14 +601,14 @@ function toString($options = array(), $depth = 0) { } $parent =& $this->parent(); - if ($parent->name === '#document' && count($parent->namespaces) > 0) { + if ($parent->name === '#document' && !empty($parent->namespaces)) { foreach ($parent->namespaces as $key => $val) { $val = str_replace('"', '\"', $val); $d .= ' xmlns:' . $key . '="' . $val . '"'; } } - if (is_array($this->attributes) && count($this->attributes) > 0) { + if (is_array($this->attributes) && !empty($this->attributes)) { foreach ($this->attributes as $key => $val) { if (is_bool($val) && $val === false) { $val = 0;