mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
parent
7983b4109b
commit
b781762903
2 changed files with 36 additions and 8 deletions
|
@ -991,6 +991,32 @@ class SetTest extends CakeTestCase {
|
|||
);
|
||||
$result = Set::extract('/Category[id=1]/..', $data);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$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($expected, $result);
|
||||
|
||||
$data = array(
|
||||
array('A1', 'B1'),
|
||||
array('A2', 'B2')
|
||||
);
|
||||
$expected = array('A1', 'A2');
|
||||
$result = Set::extract('/0', $data);
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -400,14 +400,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);
|
||||
|
@ -446,6 +441,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) {
|
||||
|
|
Loading…
Reference in a new issue