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
This commit is contained in:
the_undefined 2008-04-22 17:18:05 +00:00
parent 5321ce98ec
commit 586bcb8f28
2 changed files with 8 additions and 4 deletions

View file

@ -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') {

View file

@ -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'));