Skip to content

Commit

Permalink
Return null instead of false on cache miss.
Browse files Browse the repository at this point in the history
Null better represents "no value found".
  • Loading branch information
ADmad committed Sep 1, 2014
1 parent a9e008f commit f168420
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Utility/Inflector.php
Expand Up @@ -418,7 +418,7 @@ class Inflector {
* @param string $type Inflection type
* @param string $key Original value
* @param string $value Inflected value
* @return string Inflected value, from cache
* @return string|null Inflected value on cache hit or null on cache miss.
*/
protected static function _cache($type, $key, $value = false) {
$key = '_' . $key;
Expand All @@ -428,7 +428,7 @@ protected static function _cache($type, $key, $value = false) {
return $value;
}
if (!isset(static::$_cache[$type][$key])) {

This comment has been minimized.

Copy link
@thaJeztah

thaJeztah Sep 1, 2014

Slightly related, but should this be changed to array_key_exists()? If the stored value is null, then isset($arr[$key]]) === false

return false;
return null;
}
return static::$_cache[$type][$key];
}
Expand Down Expand Up @@ -606,7 +606,7 @@ public static function underscore($camelCasedWord) {
*/
public static function hyphenate($word) {
$result = static::_cache(__FUNCTION__, $word);
if ($result !== false) {
if ($result !== null) {
return $result;
}

Expand Down

0 comments on commit f168420

Please sign in to comment.