Browse files

`\core\Object::instance()` will return false or null `$name` is null

  • Loading branch information...
1 parent fd4221f commit 561683694948be8ac85db453f49aad305ac6d1fc @gwoo gwoo committed Jun 11, 2010
View
2 libraries/lithium/core/Object.php
@@ -206,7 +206,7 @@ public static function __set_state($data) {
* @return void
*/
protected function _instance($name, array $config = array()) {
- if (is_object($name)) {
+ if (is_object($name) || !$name) {
return $name;
}
if (isset($this->_classes[$name])) {
View
2 libraries/lithium/core/StaticObject.php
@@ -91,7 +91,7 @@ public static function invokeMethod($method, $params = array()) {
* @return void
*/
protected static function _instance($name, array $config = array()) {
- if (is_object($name)) {
+ if (is_object($name) || !$name) {
return $name;
}
if (isset(static::$_classes[$name])) {
View
2 libraries/lithium/test/Report.php
@@ -131,7 +131,7 @@ public function stats() {
'skips' => array()
);
$stats = array_reduce($results, function($stats, $result) use ($defaults) {
- $stats = (array) $stats = $defaults;
+ $stats = (array) $stats + $defaults;
$result = empty($result[0]) ? array($result) : $result;
foreach ($result as $response) {
if (empty($response['result'])) {
View
6 libraries/lithium/tests/cases/core/ObjectTest.php
@@ -198,6 +198,12 @@ public function testInstanceWithObject() {
$result = get_class($object->instance($request));
$this->assertEqual($expected, $result);
}
+
+ public function testInstanceFalse() {
+ $object = new MockInstantiator();
+ $result = $object->instance(false);
+ $this->assertFalse($result);
+ }
}
?>
View
5 libraries/lithium/tests/cases/core/StaticObjectTest.php
@@ -156,6 +156,11 @@ public function testInstanceWithObject() {
$result = get_class(MockStaticInstantiator::instance($request));
$this->assertEqual($expected, $result);
}
+
+ public function testInstanceFalse() {
+ $result = MockStaticInstantiator::instance(false);
+ $this->assertFalse($result);
+ }
}
?>
View
2 libraries/lithium/tests/mocks/action/MockPostsController.php
@@ -66,7 +66,7 @@ public function access($var) {
return $this->{$var};
}
- protected function _stop() {
+ protected function _stop($status = 0 ) {
$this->stopped = true;
}
}

0 comments on commit 5616836

Please sign in to comment.