From 586bcb8f28de043b427be957c5c9a119ea245a02 Mon Sep 17 00:00:00 2001 From: the_undefined Date: Tue, 22 Apr 2008 17:18:05 +0000 Subject: [PATCH] Fixed Set::merge warning when calling it from a static function git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6709 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/set.php | 2 +- cake/tests/cases/libs/set.test.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) 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'));