Fixing issues in Set::check() with implicit array-to-string casting

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6436 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-02-05 23:08:21 +00:00
parent 28545feec3
commit 1db0c07852
2 changed files with 8 additions and 3 deletions

View file

@ -537,9 +537,9 @@ class Set extends Object {
$key = intval($key);
}
if ($i == count($path) - 1) {
return isset($data[$key]);
return (is_array($data) && array_key_exists($key, $data));
} else {
if (!isset($data[$key])) {
if (!is_array($data) && array_key_exists($key, $data)) {
return false;
}
$data =& $data[$key];

View file

@ -1020,7 +1020,12 @@ class SetTest extends UnitTestCase {
$expected = array('Data' => array('Post' => array('title' => 'Title of this post', 'description' => 'cool')));
$this->assertEqual($result, $expected);
}
function testStrictKeyCheck() {
$set = new Set(array('a' => 'hi'));
$this->assertFalse($set->check('a.b'));
}
function __flatten($results, $key = null) {
$stack = array();
foreach ($results as $k => $r) {