Use null instead of false for failure.

null is better to indicate that a thing doesn't exist.
This commit is contained in:
mark_story 2016-11-26 10:38:28 -05:00
parent ba9f62a7a0
commit bbb87b3e87
2 changed files with 4 additions and 6 deletions

View file

@ -621,14 +621,13 @@ class Cache {
* Fetch the engine attached to a specific configuration name. * Fetch the engine attached to a specific configuration name.
* *
* @param string $config Optional string configuration name to get an engine for. Defaults to 'default'. * @param string $config Optional string configuration name to get an engine for. Defaults to 'default'.
* @return bool|CacheEngine False if the engine has not been initialized else the engine * @return null|CacheEngine Null if the engine has not been initialized or the engine.
*/ */
public static function engine($config = 'default') { public static function engine($config = 'default') {
if (self::isInitialized($config)) { if (self::isInitialized($config)) {
return self::$_engines[$config]; return self::$_engines[$config];
} }
return false; return null;
} }
} }

View file

@ -593,11 +593,10 @@ class CacheTest extends CakeTestCase {
*/ */
public function testEngineFailure() { public function testEngineFailure() {
$actual = Cache::engine('some_config_that_does_not_exist'); $actual = Cache::engine('some_config_that_does_not_exist');
$this->assertFalse($actual); $this->assertNull($actual);
Configure::write('Cache.disable', true); Configure::write('Cache.disable', true);
$actual = Cache::engine(); $actual = Cache::engine();
$this->assertFalse($actual); $this->assertNull($actual);
} }
} }