diff --git a/cake/libs/set.php b/cake/libs/set.php index 221b27687..cdba29914 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -76,7 +76,7 @@ class Set extends Object { function merge($arr1, $arr2 = null) { $args = func_get_args(); - if (is_a($this, 'set')) { + if (isset($this) && is_a($this, 'set')) { $backtrace = debug_backtrace(); $previousCall = strtolower($backtrace[1]['class'].'::'.$backtrace[1]['function']); if ($previousCall != 'set::merge') { diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index b6f92733d..97cb9f4cc 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -41,8 +41,7 @@ class SetTest extends UnitTestCase { $this->assertIdentical(Set::diff($data, Set::extract($data, '{n}')), array('plugin' => null, 'controller' => '', 'action' => '')); } - function testEnum() - { + function testEnum() { $result = Set::enum(1, 'one, two'); $this->assertIdentical($result, 'two'); $result = Set::enum(2, 'one, two'); @@ -125,7 +124,12 @@ class SetTest extends UnitTestCase { $r = Set::merge('foo', 'bar'); $this->assertIdentical($r, array('foo', 'bar')); - + + if (substr(phpversion(), 0, 1) >= 5) { + $r = eval('class StaticSetCaller{static function merge($a, $b){return Set::merge($a, $b);}} return StaticSetCaller::merge("foo", "bar");'); + $this->assertIdentical($r, array('foo', 'bar')); + } + $r = Set::merge('foo', array('user' => 'bob', 'no-bar'), 'bar'); $this->assertIdentical($r, array('foo', 'user' => 'bob', 'no-bar', 'bar'));