diff --git a/cake/libs/set.php b/cake/libs/set.php index de5b6fccf..65680d233 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -429,7 +429,13 @@ class Set extends Object { } $match = false; - if (array_key_exists($token, $context['item'])) { + if ($token == '@*' && is_array($context['item'])) { + $matches[] = array( + 'trace' => am($context['trace'], $key), + 'key' => $key, + 'item' => array_keys($context['item']), + ); + } elseif (is_array($context['item']) && array_key_exists($token, $context['item'])) { $items = $context['item'][$token]; if (!is_array($items) || !isset($items[0])) { $items = array($items); diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 07a4fc4f3..2fe5825f4 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -385,6 +385,10 @@ class SetTest extends UnitTestCase { $r = Set::extract('/User[id>1][id<=3]/id', $a); $this->assertEqual($r, $expected); + $expected = array(array('I'), array('II')); + $r = Set::extract('/a/@*', $c); + $this->assertEqual($r, $expected); + $single = array( 'User' => array( 'id' => 4, @@ -436,6 +440,10 @@ class SetTest extends UnitTestCase { $r = Set::extract('/User[name=/N/i]/id', $tricky); $this->assertEqual($r, $expected); + $expected = array(array('id', 'name'), array('id', 'name'), array('id', 'name'), array('id', 'name')); + $r = Set::extract('/User/@*', $tricky); + $this->assertEqual($r, $expected); + $common = array( array( 'Article' => array(