Applying optimizations to use of count() from 'jrbasso'

This commit is contained in:
mark_story 2009-11-21 15:14:21 -05:00
parent 71df8dbbba
commit a96c157d94
13 changed files with 69 additions and 54 deletions

View file

@ -373,7 +373,7 @@ class Configure extends Object {
$_this =& Configure::getInstance(); $_this =& Configure::getInstance();
$name = $_this->__configVarNames($var); $name = $_this->__configVarNames($var);
if (count($name) > 1) { if (isset($name[1])) {
unset($_this->{$name[0]}[$name[1]]); unset($_this->{$name[0]}[$name[1]]);
} else { } else {
unset($_this->{$name[0]}); unset($_this->{$name[0]});

View file

@ -349,7 +349,7 @@ class DbAcl extends AclBase {
} }
list($save['aro_id'], $save['aco_id']) = array($perms['aro'], $perms['aco']); 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']; $save['id'] = $perms['link'][0][$this->Aro->Permission->alias]['id'];
} else { } else {
unset($save['id']); unset($save['id']);

View file

@ -737,7 +737,7 @@ class Controller extends Object {
function validateErrors() { function validateErrors() {
$objects = func_get_args(); $objects = func_get_args();
if (!count($objects)) { if (empty($objects)) {
return false; return false;
} }
@ -747,7 +747,7 @@ class Controller extends Object {
$errors = array_merge($errors, $this->{$object->alias}->invalidFields()); $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. * Instantiates the correct view class, hands it its data, and uses it to render the view output.

View file

@ -403,7 +403,7 @@ class Debugger extends Object {
} }
} }
$n = null; $n = null;
if (count($vars) > 0) { if (!empty($vars)) {
$n = "\n"; $n = "\n";
} }
return $out . implode(",", $vars) . "{$n})"; return $out . implode(",", $vars) . "{$n})";

View file

@ -744,7 +744,7 @@ class Folder extends Object {
continue; continue;
} }
if ($part === '..') { if ($part === '..') {
if (count($newparts) > 0) { if (!empty($newparts)) {
array_pop($newparts); array_pop($newparts);
continue; continue;
} else { } else {

View file

@ -135,7 +135,7 @@ class ConnectionManager extends Object {
function getSourceName(&$source) { function getSourceName(&$source) {
$_this =& ConnectionManager::getInstance(); $_this =& ConnectionManager::getInstance();
$names = array_keys($_this->_dataSources); $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) { if ($_this->_dataSources[$names[$i]] === $source) {
return $names[$i]; return $names[$i];
} }

View file

@ -2039,7 +2039,7 @@ class DboSource extends DataSource {
$keys = array_filter($keys); $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 ''; return '';
} }

View file

@ -1079,7 +1079,7 @@ class Model extends Overloadable {
return $data[$name[0]][$name[1]]; return $data[$name[0]][$name[1]];
} }
} }
if (isset($data[0]) && count($data[0]) > 0) { if (!empty($data[0])) {
$name = key($data[0]); $name = key($data[0]);
return $data[0][$name]; return $data[0][$name];
} }

View file

@ -36,7 +36,8 @@ if (function_exists('mb_internal_encoding')) {
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching. * @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. * @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')) { if (!function_exists('mb_stripos')) {
function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) {
@ -49,8 +50,9 @@ if (!function_exists('mb_stripos')) {
* @param string $haystack The string from which to get the first occurrence of $needle. * @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @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 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 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. * @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. * @return string|boolean The portion of $haystack, or false if $needle is not found.
*/ */
@ -65,7 +67,7 @@ if (!function_exists('mb_stristr')) {
* @param string $string The string being checked for length. * @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. * @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. * @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')) { if (!function_exists('mb_strlen')) {
function mb_strlen($string, $encoding = null) { function mb_strlen($string, $encoding = null) {
@ -80,7 +82,7 @@ if (!function_exists('mb_strlen')) {
* @param integer $offset The search offset. If it is not specified, 0 is used. * @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. * @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. * @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')) { if (!function_exists('mb_strpos')) {
function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) {
@ -93,8 +95,9 @@ if (!function_exists('mb_strpos')) {
* @param string $haystack The string from which to get the last occurrence of $needle. * @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @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 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 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. * @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. * @return string|boolean The portion of $haystack. or false if $needle is not found.
*/ */
@ -109,8 +112,9 @@ if (!function_exists('mb_strrchr')) {
* @param string $haystack The string from which to get the last occurrence of $needle. * @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @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 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 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. * @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. * @return string|boolean The portion of $haystack. or false if $needle is not found.
*/ */
@ -126,7 +130,8 @@ if (!function_exists('mb_strrichr')) {
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching. * @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. * @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')) { if (!function_exists('mb_strripos')) {
function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) {
@ -139,9 +144,10 @@ if (!function_exists('mb_strripos')) {
* @param string $haystack The string being checked, for the last occurrence of $needle. * @param string $haystack The string being checked, for the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @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. * @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. * @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')) { if (!function_exists('mb_strrpos')) {
function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) {
@ -154,8 +160,9 @@ if (!function_exists('mb_strrpos')) {
* @param string $haystack The string from which to get the first occurrence of $needle. * @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack * @param string $needle The string to find in $haystack
* @param boolean $part Determines which portion of $haystack this function returns. * @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 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 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. * @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. * @return string|boolean The portion of $haystack, or true if $needle is not found.
*/ */
@ -220,12 +227,13 @@ if (!function_exists('mb_substr')) {
* *
* @param string $str The string being encoded * @param string $str The string being encoded
* @param string $charset specifies the name of the character set in which str is represented in. * @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). * 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). * @param string $transfer_encoding specifies the scheme of MIME encoding.
* Falls back to "B" if not given. * 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 * @param string $linefeed specifies the EOL (end-of-line) marker with which
* (a » RFC term, the act of breaking a line longer than a certain length into multiple lines. * mb_encode_mimeheader() performs line-folding
* The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given. * (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] * @param integer $indent [definition unknown and appears to have no affect]
* @return string A converted version of the string represented in ASCII. * @return string A converted version of the string represented in ASCII.
*/ */
@ -300,7 +308,7 @@ class Multibyte extends Object {
if ($value < 128) { if ($value < 128) {
$map[] = $value; $map[] = $value;
} else { } else {
if (count($values) == 0) { if (empty($values)) {
$find = ($value < 224) ? 2 : 3; $find = ($value < 224) ? 2 : 3;
} }
$values[] = $value; $values[] = $value;
@ -350,7 +358,8 @@ class Multibyte extends Object {
* @param multi-byte string $haystack The string from which to get the position of the first occurrence of $needle. * @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 multi-byte string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching. * @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 * @access public
* @static * @static
*/ */
@ -368,8 +377,9 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the first occurrence of $needle. * @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @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 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 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. * @return int|boolean The portion of $haystack, or false if $needle is not found.
* @access public * @access public
* @static * @static
@ -445,7 +455,7 @@ class Multibyte extends Object {
* @param string $needle The position counted from the beginning of haystack. * @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. * @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. * @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 * @access public
* @static * @static
*/ */
@ -488,8 +498,9 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the last occurrence of $needle. * @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @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 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 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. * @return string|boolean The portion of $haystack. or false if $needle is not found.
* @access public * @access public
* @static * @static
@ -548,8 +559,9 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the last occurrence of $needle. * @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @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 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 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. * @return string|boolean The portion of $haystack. or false if $needle is not found.
* @access public * @access public
* @static * @static
@ -610,7 +622,8 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the position of the last occurrence of $needle. * @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 string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching. * @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 * @access public
* @static * @static
*/ */
@ -661,8 +674,9 @@ class Multibyte extends Object {
* @param string $haystack The string being checked, for the last occurrence of $needle. * @param string $haystack The string being checked, for the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @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. * @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.
* @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.
* @access public * @access public
* @static * @static
*/ */
@ -711,8 +725,9 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the first occurrence of $needle. * @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack * @param string $needle The string to find in $haystack
* @param boolean $part Determines which portion of $haystack this function returns. * @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 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 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. * @return string|boolean The portion of $haystack, or true if $needle is not found.
* @access public * @access public
* @static * @static
@ -853,14 +868,14 @@ class Multibyte extends Object {
if ($length > 1 && count($keys[$key]['lower']) > 1) { if ($length > 1 && count($keys[$key]['lower']) > 1) {
$j = 0; $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]; $nextChar = $utf8Map[$i + $ii];
if (isset($nextChar) && ($nextChar == $keys[$key]['lower'][$j + $ii])) { if (isset($nextChar) && ($nextChar == $keys[$key]['lower'][$j + $ii])) {
$replace++; $replace++;
} }
} }
if ($replace == count($keys[$key]['lower'])) { if ($replace == $count) {
$upperCase[] = $keys[$key]['upper']; $upperCase[] = $keys[$key]['upper'];
$replaced = array_merge($replaced, array_values($keys[$key]['lower'])); $replaced = array_merge($replaced, array_values($keys[$key]['lower']));
$matched = true; $matched = true;
@ -873,14 +888,14 @@ class Multibyte extends Object {
if (in_array($nextChar, $keys[$ii]['lower'])) { 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]; $nextChar = $utf8Map[$i + $jj];
if (isset($nextChar) && ($nextChar == $keys[$ii]['lower'][$j + $jj])) { if (isset($nextChar) && ($nextChar == $keys[$ii]['lower'][$j + $jj])) {
$replace++; $replace++;
} }
} }
if ($replace == count($keys[$ii]['lower'])) { if ($replace == $count) {
$upperCase[] = $keys[$ii]['upper']; $upperCase[] = $keys[$ii]['upper'];
$replaced = array_merge($replaced, array_values($keys[$ii]['lower'])); $replaced = array_merge($replaced, array_values($keys[$ii]['lower']));
$matched = true; $matched = true;

View file

@ -161,7 +161,7 @@ class Sanitize {
$params = params(func_get_args()); $params = params(func_get_args());
$str = $params[0]; $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] . '\b[^>]*>/i', '', $str);
$str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str); $str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str);
} }

View file

@ -1077,7 +1077,7 @@ class Set extends Object {
if (!is_null($key)) { if (!is_null($key)) {
$id = $key; $id = $key;
} }
if (is_array($r) && count($r)) { if (is_array($r) && !empty($r)) {
$stack = array_merge($stack, Set::__flatten($r, $id)); $stack = array_merge($stack, Set::__flatten($r, $id));
} else { } else {
$stack[] = array('id' => $id, 'value' => $r); $stack[] = array('id' => $id, 'value' => $r);

View file

@ -410,7 +410,7 @@ class HtmlHelper extends AppHelper {
* @return string * @return string
*/ */
function getCrumbs($separator = '&raquo;', $startText = false) { function getCrumbs($separator = '&raquo;', $startText = false) {
if (count($this->_crumbs)) { if (!empty($this->_crumbs)) {
$out = array(); $out = array();
if ($startText) { if ($startText) {
$out[] = $this->link($startText, '/'); $out[] = $this->link($startText, '/');

View file

@ -566,7 +566,7 @@ class XmlNode extends Object {
* @access public * @access public
*/ */
function hasChildren() { function hasChildren() {
if (is_array($this->children) && count($this->children) > 0) { if (is_array($this->children) && !empty($this->children)) {
return true; return true;
} }
return false; return false;
@ -593,7 +593,7 @@ class XmlNode extends Object {
} }
$d .= '<' . $this->name(); $d .= '<' . $this->name();
if (count($this->namespaces) > 0) { if (!empty($this->namespaces) > 0) {
foreach ($this->namespaces as $key => $val) { foreach ($this->namespaces as $key => $val) {
$val = str_replace('"', '\"', $val); $val = str_replace('"', '\"', $val);
$d .= ' xmlns:' . $key . '="' . $val . '"'; $d .= ' xmlns:' . $key . '="' . $val . '"';
@ -601,14 +601,14 @@ class XmlNode extends Object {
} }
$parent =& $this->parent(); $parent =& $this->parent();
if ($parent->name === '#document' && count($parent->namespaces) > 0) { if ($parent->name === '#document' && !empty($parent->namespaces)) {
foreach ($parent->namespaces as $key => $val) { foreach ($parent->namespaces as $key => $val) {
$val = str_replace('"', '\"', $val); $val = str_replace('"', '\"', $val);
$d .= ' xmlns:' . $key . '="' . $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) { foreach ($this->attributes as $key => $val) {
if (is_bool($val) && $val === false) { if (is_bool($val) && $val === false) {
$val = 0; $val = 0;