Skip to content
Permalink
Browse files

Return null instead of false on cache miss.

Null better represents "no value found".
  • Loading branch information...
ADmad committed Sep 1, 2014
1 parent a9e008f commit f16842088dd1b10a7f0be0fe933ebb636befa184
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/Utility/Inflector.php
@@ -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;
@@ -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];
}
@@ -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;
}

0 comments on commit f168420

Please sign in to comment.
You can’t perform that action at this time.