From 01b129a42b62fd08cd873f44ded026041b560420 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 11:36:50 -0400 Subject: Fix docblocks A-H --- system/helpers/array_helper.php | 56 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'system/helpers/array_helper.php') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 6f56d9db9..6a7c8e3c7 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -37,19 +37,19 @@ // ------------------------------------------------------------------------ -/** - * Element - * - * Lets you determine whether an array index is set and whether it has a value. - * If the element is empty it returns FALSE (or whatever you specify as the default value.) - * - * @param string - * @param array - * @param mixed - * @return mixed depends on what the array contains - */ if ( ! function_exists('element')) { + /** + * Element + * + * Lets you determine whether an array index is set and whether it has a value. + * If the element is empty it returns FALSE (or whatever you specify as the default value.) + * + * @param string + * @param array + * @param mixed + * @return mixed depends on what the array contains + */ function element($item, $array, $default = FALSE) { return empty($array[$item]) ? $default : $array[$item]; @@ -58,14 +58,14 @@ if ( ! function_exists('element')) // ------------------------------------------------------------------------ -/** - * Random Element - Takes an array as input and returns a random element - * - * @param array - * @return mixed depends on what the array contains - */ if ( ! function_exists('random_element')) { + /** + * Random Element - Takes an array as input and returns a random element + * + * @param array + * @return mixed depends on what the array contains + */ function random_element($array) { return is_array($array) ? $array[array_rand($array)] : $array; @@ -74,19 +74,19 @@ if ( ! function_exists('random_element')) // -------------------------------------------------------------------- -/** - * Elements - * - * Returns only the array items specified. Will return a default value if - * it is not set. - * - * @param array - * @param array - * @param mixed - * @return mixed depends on what the array contains - */ if ( ! function_exists('elements')) { + /** + * Elements + * + * Returns only the array items specified. Will return a default value if + * it is not set. + * + * @param array + * @param array + * @param mixed + * @return mixed depends on what the array contains + */ function elements($items, $array, $default = FALSE) { $return = array(); -- cgit v1.2.3-24-g4f1b From 3c993ba07d0ac4c96e0b584a1f7678d177dee7f6 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sun, 1 Jul 2012 23:46:24 +0200 Subject: If you don't know an answer, just say that you don't know. --- system/helpers/array_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/helpers/array_helper.php') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 6a7c8e3c7..216f12e56 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -50,7 +50,7 @@ if ( ! function_exists('element')) * @param mixed * @return mixed depends on what the array contains */ - function element($item, $array, $default = FALSE) + function element($item, $array, $default = NULL) { return empty($array[$item]) ? $default : $array[$item]; } @@ -87,7 +87,7 @@ if ( ! function_exists('elements')) * @param mixed * @return mixed depends on what the array contains */ - function elements($items, $array, $default = FALSE) + function elements($items, $array, $default = NULL) { $return = array(); -- cgit v1.2.3-24-g4f1b From 0cd553566578dd4c23e1541fc837901bdfefa831 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 2 Jul 2012 15:20:42 +0200 Subject: Update Array Helper documentation default value of the "default value" parameter has changed in element() and elements() methods --- system/helpers/array_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/array_helper.php') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 216f12e56..5d0243951 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -43,7 +43,7 @@ if ( ! function_exists('element')) * Element * * Lets you determine whether an array index is set and whether it has a value. - * If the element is empty it returns FALSE (or whatever you specify as the default value.) + * If the element is empty it returns NULL (or whatever you specify as the default value.) * * @param string * @param array -- cgit v1.2.3-24-g4f1b From 4d1a214836fc16bbecd5afd11060a56bc2859b7d Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 4 Jul 2012 13:45:46 +0200 Subject: Having `"0"` in an array would give you NULL with `elements()`. BAD! The trouble here, is that when we are expecting a valid result, such as `0`, or `false` that the array helper will instead say "I don't know if there is a value" and give you a `null`. --- system/helpers/array_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/array_helper.php') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 5d0243951..0dfc3e1ae 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -52,7 +52,7 @@ if ( ! function_exists('element')) */ function element($item, $array, $default = NULL) { - return empty($array[$item]) ? $default : $array[$item]; + return ! isset($array[$item]) ? $default : $array[$item]; } } -- cgit v1.2.3-24-g4f1b From bf0e38be236812656890223eea3b9f0dc68582c0 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 4 Jul 2012 14:42:29 +0200 Subject: Further update to `element()` to remove more unexpected results. --- system/helpers/array_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/helpers/array_helper.php') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 0dfc3e1ae..5a7f633e8 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -52,7 +52,7 @@ if ( ! function_exists('element')) */ function element($item, $array, $default = NULL) { - return ! isset($array[$item]) ? $default : $array[$item]; + return array_key_exists($array[$item]) ? $array[$item] : $default; } } @@ -95,7 +95,7 @@ if ( ! function_exists('elements')) foreach ($items as $item) { - $return[$item] = isset($array[$item]) ? $array[$item] : $default; + $return[$item] = array_key_exists($array[$item]) ? $array[$item] : $default; } return $return; -- cgit v1.2.3-24-g4f1b From 6801d044d7f7b905e1fdaf21231f8a3fad5b4057 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 4 Jul 2012 14:43:36 +0200 Subject: Ahem. --- system/helpers/array_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/helpers/array_helper.php') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 5a7f633e8..ed2fe3c4a 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -52,7 +52,7 @@ if ( ! function_exists('element')) */ function element($item, $array, $default = NULL) { - return array_key_exists($array[$item]) ? $array[$item] : $default; + return array_key_exists($item, $array) ? $array[$item] : $default; } } @@ -95,7 +95,7 @@ if ( ! function_exists('elements')) foreach ($items as $item) { - $return[$item] = array_key_exists($array[$item]) ? $array[$item] : $default; + $return[$item] = array_key_exists($item, $array) ? $array[$item] : $default; } return $return; -- cgit v1.2.3-24-g4f1b From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 17:33:58 +0200 Subject: Manually apply PR #1594 (fixing phpdoc page-level generation/warnings) Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files. --- system/helpers/array_helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/helpers/array_helper.php') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index ed2fe3c4a..0e66e4b77 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -1,4 +1,4 @@ -