mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
parent
6ef4ce4c31
commit
392102b71f
2 changed files with 38 additions and 10 deletions
|
@ -431,14 +431,9 @@ class Set {
|
|||
'key' => $key,
|
||||
'item' => array_keys($context['item']),
|
||||
);
|
||||
} elseif (($key === $token || (ctype_digit($token) && $key == $token) || $token === '.')) {
|
||||
$context['trace'][] = $key;
|
||||
$matches[] = array(
|
||||
'trace' => $context['trace'],
|
||||
'key' => $key,
|
||||
'item' => $context['item'],
|
||||
);
|
||||
} elseif (is_array($context['item']) && array_key_exists($token, $context['item'])) {
|
||||
} elseif (is_array($context['item'])
|
||||
&& array_key_exists($token, $context['item'])
|
||||
&& !(strval($key) === strval($token) && count($tokens) == 1 && $tokens[0] === '.')) {
|
||||
$items = $context['item'][$token];
|
||||
if (!is_array($items)) {
|
||||
$items = array($items);
|
||||
|
@ -477,6 +472,13 @@ class Set {
|
|||
'item' => $item,
|
||||
);
|
||||
}
|
||||
} elseif ($key === $token || (ctype_digit($token) && $key == $token) || $token === '.') {
|
||||
$context['trace'][] = $key;
|
||||
$matches[] = array(
|
||||
'trace' => $context['trace'],
|
||||
'key' => $key,
|
||||
'item' => $context['item'],
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($conditions) {
|
||||
|
|
|
@ -939,7 +939,7 @@ class SetTest extends CakeTestCase {
|
|||
$result = Set::extract('/ParentNode/name', $hasMany);
|
||||
$expected = array('Second');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
||||
$data = array(
|
||||
array(
|
||||
'Category' => array(
|
||||
|
@ -973,6 +973,32 @@ class SetTest extends CakeTestCase {
|
|||
);
|
||||
$result = Set::extract('/Category[id=1]/..', $data);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$data = array(
|
||||
array(
|
||||
'ChildNode' => array('id' => 1),
|
||||
array('name' => 'Item 1')
|
||||
),
|
||||
array(
|
||||
'ChildNode' => array('id' => 2),
|
||||
array('name' => 'Item 2')
|
||||
),
|
||||
);
|
||||
|
||||
$expected = array(
|
||||
'Item 1',
|
||||
'Item 2'
|
||||
);
|
||||
$result = Set::extract('/0/name', $data);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$data = array(
|
||||
array('A1', 'B1'),
|
||||
array('A2', 'B2')
|
||||
);
|
||||
$expected = array('A1', 'A2');
|
||||
$result = Set::extract('/0', $data);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1180,7 +1206,7 @@ class SetTest extends CakeTestCase {
|
|||
$expected = array(1, 2, 3);
|
||||
$r = Set::extract('/User/id', $nonZero);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
|
||||
$expected = array(
|
||||
array('User' => array('id' => 1, 'name' => 'John')),
|
||||
array('User' => array('id' => 2, 'name' => 'Bob')),
|
||||
|
|
Loading…
Reference in a new issue