Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switch usage to Hash where possible.

  • Loading branch information...
commit 19e0d8d946eaa544652fd46a04b872c9637c1634 1 parent 29048b3
Mark Story markstory authored
Showing with 148 additions and 141 deletions.
  1. +1 −1  lib/Cake/Configure/IniReader.php
  2. +3 −1 lib/Cake/Console/Command/AclShell.php
  3. +1 −1  lib/Cake/Console/Command/ConsoleShell.php
  4. +2 −1  lib/Cake/Console/Command/Task/ExtractTask.php
  5. +1 −0  lib/Cake/Controller/Component/Acl/DbAcl.php
  6. +2 −2 lib/Cake/Controller/Component/Acl/IniAcl.php
  7. +1 −1  lib/Cake/Controller/Component/Acl/PhpAcl.php
  8. +2 −2 lib/Cake/Controller/Component/Auth/BaseAuthenticate.php
  9. +2 −1  lib/Cake/Controller/Component/Auth/BaseAuthorize.php
  10. +3 −3 lib/Cake/Controller/Component/AuthComponent.php
  11. +4 −3 lib/Cake/Controller/Component/CookieComponent.php
  12. +2 −1  lib/Cake/Controller/Component/PaginatorComponent.php
  13. +2 −1  lib/Cake/Controller/Component/SecurityComponent.php
  14. +4 −4 lib/Cake/Core/Object.php
  15. +2 −1  lib/Cake/Model/Behavior/AclBehavior.php
  16. +1 −1  lib/Cake/Model/Behavior/ContainableBehavior.php
  17. +3 −3 lib/Cake/Model/Behavior/TreeBehavior.php
  18. +2 −2 lib/Cake/Model/Datasource/CakeSession.php
  19. +1 −1  lib/Cake/Model/Datasource/Database/Postgres.php
  20. +4 −4 lib/Cake/Model/Datasource/DboSource.php
  21. +8 −8 lib/Cake/Model/Model.php
  22. +5 −5 lib/Cake/Network/CakeRequest.php
  23. +1 −1  lib/Cake/Network/Email/CakeEmail.php
  24. +8 −8 lib/Cake/Network/Http/HttpSocket.php
  25. +1 −1  lib/Cake/Routing/Route/CakeRoute.php
  26. +2 −2 lib/Cake/Routing/Router.php
  27. +1 −1  lib/Cake/Test/Case/Console/ShellTest.php
  28. +19 −19 lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
  29. +3 −3 lib/Cake/Test/Case/Controller/ControllerTest.php
  30. +13 −15 lib/Cake/Test/Case/Model/AclNodeTest.php
  31. +2 −2 lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
  32. +6 −6 lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
  33. +9 −9 lib/Cake/Test/Case/Model/ModelReadTest.php
  34. +10 −10 lib/Cake/Test/Case/Model/ModelWriteTest.php
  35. +2 −2 lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
  36. +1 −1  lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  37. +1 −1  lib/Cake/Utility/Debugger.php
  38. +5 −5 lib/Cake/Utility/Hash.php
  39. +2 −2 lib/Cake/View/Helper.php
  40. +3 −3 lib/Cake/View/Helper/FormHelper.php
  41. +1 −1  lib/Cake/View/Helper/NumberHelper.php
  42. +1 −1  lib/Cake/View/Helper/TextHelper.php
  43. +1 −1  lib/Cake/View/Helper/TimeHelper.php
2  lib/Cake/Configure/IniReader.php
View
@@ -127,7 +127,7 @@ protected function _parseNestedValues($values) {
$value = false;
}
if (strpos($key, '.') !== false) {
- $values = Set::insert($values, $key, $value);
+ $values = Hash::insert($values, $key, $value);
} else {
$values[$key] = $value;
}
4 lib/Cake/Console/Command/AclShell.php
View
@@ -21,6 +21,7 @@
App::uses('ComponentCollection', 'Controller');
App::uses('AclComponent', 'Controller/Component');
App::uses('DbAcl', 'Model');
+App::uses('Hash', 'Utility');
/**
* Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode
@@ -558,8 +559,9 @@ protected function _getNodeId($class, $identifier) {
$identifier = var_export($identifier, true);
}
$this->error(__d('cake_console', 'Could not find node using reference "%s"', $identifier));
+ return;
}
- return Set::extract($node, "0.{$class}.id");
+ return Hash::get($node, "0.{$class}.id");
}
/**
2  lib/Cake/Console/Command/ConsoleShell.php
View
@@ -300,7 +300,7 @@ public function main($command = null) {
break;
case (preg_match("/^routes\s+show/i", $command, $tmp) == true):
$router = Router::getInstance();
- $this->out(implode("\n", Set::extract($router->routes, '{n}.0')));
+ $this->out(implode("\n", Hash::extract($router->routes, '{n}.0')));
break;
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
if ($url = eval('return array' . $tmp[1] . ';')) {
3  lib/Cake/Console/Command/Task/ExtractTask.php
View
@@ -19,6 +19,7 @@
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
+App::uses('Hash', 'Utility');
/**
* Language string extractor
@@ -431,7 +432,7 @@ protected function _processValidationRules($field, $rules, $file, $domain) {
return;
}
- $dims = Set::countDim($rules);
+ $dims = Hash::dimensions($rules);
if ($dims == 1 || ($dims == 2 && isset($rules['message']))) {
$rules = array($rules);
}
1  lib/Cake/Controller/Component/Acl/DbAcl.php
View
@@ -13,6 +13,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AclInterface', 'Controller/Component/Acl');
+App::uses('Hash', 'Utility');
/**
* DbAcl implements an ACL control system in the database. ARO's and ACO's are
4 lib/Cake/Controller/Component/Acl/IniAcl.php
View
@@ -30,7 +30,7 @@ class IniAcl extends Object implements AclInterface {
public $config = null;
/**
- * The Set::classicExtract() path to the user/aro identifier in the
+ * The Hash::extract() path to the user/aro identifier in the
* acl.ini file. This path will be used to extract the string
* representation of a user used in the ini file.
*
@@ -97,7 +97,7 @@ public function check($aro, $aco, $action = null) {
$aclConfig = $this->config;
if (is_array($aro)) {
- $aro = Set::classicExtract($aro, $this->userPath);
+ $aro = Hash::get($aro, $this->userPath);
}
if (isset($aclConfig[$aro]['deny'])) {
2  lib/Cake/Controller/Component/Acl/PhpAcl.php
View
@@ -494,7 +494,7 @@ public function addRole(array $aro) {
// detect cycles
$roles = $this->roles($dependency);
- if (in_array($role, Set::flatten($roles))) {
+ if (in_array($role, Hash::flatten($roles))) {
$path = '';
foreach ($roles as $roleDependencies) {
4 lib/Cake/Controller/Component/Auth/BaseAuthenticate.php
View
@@ -12,8 +12,8 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-
App::uses('Security', 'Utility');
+App::uses('Hash', 'Utility');
/**
* Base Authentication class with common methods and properties.
@@ -58,7 +58,7 @@
*/
public function __construct(ComponentCollection $collection, $settings) {
$this->_Collection = $collection;
- $this->settings = Set::merge($this->settings, $settings);
+ $this->settings = Hash::merge($this->settings, $settings);
}
/**
3  lib/Cake/Controller/Component/Auth/BaseAuthorize.php
View
@@ -12,6 +12,7 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+App::uses('Hash', 'Utility');
/**
* Abstract base authorization adapter for AuthComponent.
@@ -69,7 +70,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
$this->_Collection = $collection;
$controller = $collection->getController();
$this->controller($controller);
- $this->settings = Set::merge($this->settings, $settings);
+ $this->settings = Hash::merge($this->settings, $settings);
}
/**
6 lib/Cake/Controller/Component/AuthComponent.php
View
@@ -19,11 +19,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-
App::uses('Component', 'Controller');
App::uses('Router', 'Routing');
App::uses('Security', 'Utility');
App::uses('Debugger', 'Utility');
+App::uses('Hash', 'Utility');
App::uses('CakeSession', 'Model/Datasource');
App::uses('BaseAuthorize', 'Controller/Component/Auth');
App::uses('BaseAuthenticate', 'Controller/Component/Auth');
@@ -394,7 +394,7 @@ public function constructAuthorize() {
return;
}
$this->_authorizeObjects = array();
- $config = Set::normalize($this->authorize);
+ $config = Hash::normalize((array)$this->authorize);
$global = array();
if (isset($config[AuthComponent::ALL])) {
$global = $config[AuthComponent::ALL];
@@ -652,7 +652,7 @@ public function constructAuthenticate() {
return;
}
$this->_authenticateObjects = array();
- $config = Set::normalize($this->authenticate);
+ $config = Hash::normalize((array)$this->authenticate);
$global = array();
if (isset($config[AuthComponent::ALL])) {
$global = $config[AuthComponent::ALL];
7 lib/Cake/Controller/Component/CookieComponent.php
View
@@ -19,6 +19,7 @@
App::uses('Component', 'Controller');
App::uses('Security', 'Utility');
+App::uses('Hash', 'Utility');
/**
* Cookie Component.
@@ -239,7 +240,7 @@ public function write($key, $value = null, $encrypt = true, $expires = null) {
if (!isset($this->_values[$this->name][$names[0]])) {
$this->_values[$this->name][$names[0]] = array();
}
- $this->_values[$this->name][$names[0]] = Set::insert($this->_values[$this->name][$names[0]], $names[1], $value);
+ $this->_values[$this->name][$names[0]] = Hash::insert($this->_values[$this->name][$names[0]], $names[1], $value);
$this->_write('[' . implode('][', $names) . ']', $value);
}
}
@@ -276,7 +277,7 @@ public function read($key = null) {
}
if (!empty($names[1])) {
- return Set::extract($this->_values[$this->name][$key], $names[1]);
+ return Hash::get($this->_values[$this->name][$key], $names[1]);
}
return $this->_values[$this->name][$key];
}
@@ -310,7 +311,7 @@ public function delete($key) {
}
$names = explode('.', $key, 2);
if (isset($this->_values[$this->name][$names[0]])) {
- $this->_values[$this->name][$names[0]] = Set::remove($this->_values[$this->name][$names[0]], $names[1]);
+ $this->_values[$this->name][$names[0]] = Hash::remove($this->_values[$this->name][$names[0]], $names[1]);
}
$this->_delete('[' . implode('][', $names) . ']');
}
3  lib/Cake/Controller/Component/PaginatorComponent.php
View
@@ -16,6 +16,7 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+App::uses('Hash', 'Utility');
/**
* This component is used to handle automatic model data pagination. The primary way to use this
@@ -194,7 +195,7 @@ public function paginate($object = null, $scope = array(), $whitelist = array())
'pageCount' => $pageCount,
'order' => $order,
'limit' => $limit,
- 'options' => Set::diff($options, $defaults),
+ 'options' => Hash::diff($options, $defaults),
'paramType' => $options['paramType']
);
if (!isset($this->Controller->request['paging'])) {
3  lib/Cake/Controller/Component/SecurityComponent.php
View
@@ -19,6 +19,7 @@
App::uses('Component', 'Controller');
App::uses('String', 'Utility');
+App::uses('Hash', 'Utility');
App::uses('Security', 'Utility');
/**
@@ -443,7 +444,7 @@ protected function _validatePost(Controller $controller) {
$unlocked = explode('|', $unlocked);
$lockedFields = array();
- $fields = Set::flatten($check);
+ $fields = Hash::flatten($check);
$fieldList = array_keys($fields);
$multi = array();
8 lib/Cake/Core/Object.php
View
@@ -181,7 +181,7 @@ protected function _set($properties = array()) {
*
* @param array $properties The name of the properties to merge.
* @param string $class The class to merge the property with.
- * @param boolean $normalize Set to true to run the properties through Set::normalize() before merging.
+ * @param boolean $normalize Set to true to run the properties through Hash::normalize() before merging.
* @return void
*/
protected function _mergeVars($properties, $class, $normalize = true) {
@@ -194,10 +194,10 @@ protected function _mergeVars($properties, $class, $normalize = true) {
$this->{$var} != $classProperties[$var]
) {
if ($normalize) {
- $classProperties[$var] = Set::normalize($classProperties[$var]);
- $this->{$var} = Set::normalize($this->{$var});
+ $classProperties[$var] = Hash::normalize($classProperties[$var]);
+ $this->{$var} = Hash::normalize($this->{$var});
}
- $this->{$var} = Set::merge($classProperties[$var], $this->{$var});
+ $this->{$var} = Hash::merge($classProperties[$var], $this->{$var});
}
}
}
3  lib/Cake/Model/Behavior/AclBehavior.php
View
@@ -19,6 +19,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AclNode', 'Model');
+App::uses('Hash', 'Utility');
/**
* ACL behavior
@@ -131,7 +132,7 @@ public function afterDelete(Model $model) {
$types = array($types);
}
foreach ($types as $type) {
- $node = Set::extract($this->node($model, null, $type), "0.{$type}.id");
+ $node = Hash::extract($this->node($model, null, $type), "0.{$type}.id");
if (!empty($node)) {
$model->{$type}->delete($node);
}
2  lib/Cake/Model/Behavior/ContainableBehavior.php
View
@@ -321,7 +321,7 @@ public function containments(Model $Model, $contain, $containments = array(), $t
$key = $option;
$optionKey = true;
if (!empty($newChildren)) {
- $children = Set::merge($children, $newChildren);
+ $children = Hash::merge($children, $newChildren);
}
}
if ($optionKey && isset($children[$key])) {
6 lib/Cake/Model/Behavior/TreeBehavior.php
View
@@ -363,10 +363,10 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu
}
if ($valuePath == null) {
- $valuePath = array('{0}{1}', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField);
+ $valuePath = array('%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField);
} elseif (is_string($valuePath)) {
- $valuePath = array('{0}{1}', '{n}.tree_prefix', $valuePath);
+ $valuePath = array('%s%s', '{n}.tree_prefix', $valuePath);
} else {
$valuePath[0] = '{' . (count($valuePath) - 1) . '}' . $valuePath[0];
@@ -386,7 +386,7 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu
if (empty($results)) {
return array();
}
- return Set::combine($results, $keyPath, $valuePath);
+ return Hash::combine($results, $keyPath, $valuePath);
}
/**
4 lib/Cake/Model/Datasource/CakeSession.php
View
@@ -245,7 +245,7 @@ public static function id($id = null) {
*/
public static function delete($name) {
if (self::check($name)) {
- self::_overwrite($_SESSION, Set::remove($_SESSION, $name));
+ self::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
return (self::check($name) == false);
}
self::_setError(2, __d('cake_dev', "%s doesn't exist", $name));
@@ -452,7 +452,7 @@ protected static function _configureSession() {
if (isset($sessionConfig['defaults'])) {
$defaults = self::_defaultConfig($sessionConfig['defaults']);
if ($defaults) {
- $sessionConfig = Set::merge($defaults, $sessionConfig);
+ $sessionConfig = Hash::merge($defaults, $sessionConfig);
}
}
if (!isset($sessionConfig['ini']['session.cookie_secure']) && env('HTTPS')) {
2  lib/Cake/Model/Datasource/Database/Postgres.php
View
@@ -421,7 +421,7 @@ protected function _quoteFunctionField($match) {
$match[1] = $this->name($match[1]);
} elseif (!$constant) {
$parts = explode('.', $match[1]);
- if (!Set::numeric($parts)) {
+ if (!Hash::numeric($parts)) {
$match[1] = $this->name($match[1]);
}
}
8 lib/Cake/Model/Datasource/DboSource.php
View
@@ -1409,7 +1409,7 @@ protected function _mergeAssociation(&$data, &$merge, $association, $type, $self
if ($mergeKeys[0] === $dataKeys[0] || $mergeKeys === $dataKeys) {
$data[$association][$association] = $merge[0][$association];
} else {
- $diff = Set::diff($dataAssocTmp, $mergeAssocTmp);
+ $diff = Hash::diff($dataAssocTmp, $mergeAssocTmp);
$data[$association] = array_merge($merge[0][$association], $diff);
}
} elseif ($selfJoin && array_key_exists($association, $merge[0])) {
@@ -1934,7 +1934,7 @@ protected function _matchRecords(Model $model, $conditions = null) {
return false;
}
$conditions = $this->conditions(array(
- $model->primaryKey => Set::extract($idList, "{n}.{$model->alias}.{$model->primaryKey}")
+ $model->primaryKey => Hash::extract($idList, "{n}.{$model->alias}.{$model->primaryKey}")
));
}
return $conditions;
@@ -2256,7 +2256,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote =
} else {
if (strpos($fields[$i], ',') === false) {
$build = explode('.', $fields[$i]);
- if (!Set::numeric($build)) {
+ if (!Hash::numeric($build)) {
$fields[$i] = $this->name(implode('.', $build));
}
}
@@ -2268,7 +2268,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote =
$field[1] = $this->name($alias . '.' . $field[1]);
} else {
$field[0] = explode('.', $field[1]);
- if (!Set::numeric($field[0])) {
+ if (!Hash::numeric($field[0])) {
$field[0] = implode('.', array_map(array(&$this, 'name'), $field[0]));
$fields[$i] = preg_replace('/\(' . $field[1] . '\)/', '(' . $field[0] . ')', $fields[$i], 1);
}
16 lib/Cake/Model/Model.php
View
@@ -1728,7 +1728,7 @@ public function save($data = null, $validate = true, $fieldList = array()) {
$this->getEventManager()->dispatch($event);
}
if (!empty($this->data)) {
- $success = Set::merge($success, $this->data);
+ $success = Hash::merge($success, $this->data);
}
$this->data = false;
$this->_clearCache();
@@ -1819,7 +1819,7 @@ protected function _saveMulti($joined, $id, $db) {
'fields' => $associationForeignKey,
));
- $oldLinks = Set::extract($links, "{n}.{$associationForeignKey}");
+ $oldLinks = Hash::extract($links, "{n}.{$associationForeignKey}");
if (!empty($oldLinks)) {
if ($keepExisting && !empty($newJoins)) {
$conditions[$associationForeignKey] = array_diff($oldLinks, $newJoins);
@@ -1993,7 +1993,7 @@ protected function _prepareUpdateFields($data) {
*/
public function saveAll($data = null, $options = array()) {
$options = array_merge(array('validate' => 'first'), $options);
- if (Set::numeric(array_keys($data))) {
+ if (Hash::numeric(array_keys($data))) {
if ($options['validate'] === 'only') {
return $this->validateMany($data, $options);
}
@@ -2514,7 +2514,7 @@ public function deleteAll($conditions, $cascade = true, $callbacks = false) {
return false;
}
- $ids = Set::extract($ids, "{n}.{$this->alias}.{$this->primaryKey}");
+ $ids = Hash::extract($ids, "{n}.{$this->alias}.{$this->primaryKey}");
if (empty($ids)) {
return true;
}
@@ -2837,7 +2837,7 @@ protected function _findList($state, $query, $results = array()) {
return array();
}
$lst = $query['list'];
- return Set::combine($results, $lst['keyPath'], $lst['valuePath'], $lst['groupPath']);
+ return Hash::combine($results, $lst['keyPath'], $lst['valuePath'], $lst['groupPath']);
}
}
@@ -2915,9 +2915,9 @@ protected function _findThreaded($state, $query, $results = array()) {
if (isset($query['parent'])) {
$parent = $query['parent'];
}
- return Set::nest($results, array(
- 'idPath' => '/' . $this->alias . '/' . $this->primaryKey,
- 'parentPath' => '/' . $this->alias . '/' . $parent
+ return Hash::nest($results, array(
+ 'idPath' => '{n}.' . $this->alias . '.' . $this->primaryKey,
+ 'parentPath' => '{n}.' . $this->alias . '.' . $parent
));
}
}
10 lib/Cake/Network/CakeRequest.php
View
@@ -153,7 +153,7 @@ public function __construct($url = null, $parseEnvironment = true) {
* into a single array. Variables prefixed with `data` will overwrite those without.
*
* If you have mixed POST values be careful not to make any top level keys numeric
- * containing arrays. Set::merge() is used to merge data, and it has possibly
+ * containing arrays. Hash::merge() is used to merge data, and it has possibly
* unexpected behavior in this situation.
*
* @return void
@@ -181,7 +181,7 @@ protected function _processPost() {
$this->data = $data;
} else {
unset($this->data['data']);
- $this->data = Set::merge($this->data, $data);
+ $this->data = Hash::merge($this->data, $data);
}
}
}
@@ -519,7 +519,7 @@ public function is($type) {
public function addDetector($name, $options) {
$name = strtolower($name);
if (isset($this->_detectors[$name]) && isset($options['options'])) {
- $options = Set::merge($this->_detectors[$name], $options);
+ $options = Hash::merge($this->_detectors[$name], $options);
}
$this->_detectors[$name] = $options;
}
@@ -748,10 +748,10 @@ public static function acceptLanguage($language = null) {
public function data($name) {
$args = func_get_args();
if (count($args) == 2) {
- $this->data = Set::insert($this->data, $name, $args[1]);
+ $this->data = Hash::insert($this->data, $name, $args[1]);
return $this;
}
- return Set::classicExtract($this->data, $name);
+ return Hash::get($this->data, $name);
}
/**
2  lib/Cake/Network/Email/CakeEmail.php
View
@@ -1363,7 +1363,7 @@ protected function _render($content) {
$msg = array();
- $contentIds = array_filter((array)Set::classicExtract($this->_attachments, '{s}.contentId'));
+ $contentIds = array_filter((array)Hash::extract($this->_attachments, '{s}.contentId'));
$hasInlineAttachments = count($contentIds) > 0;
$hasAttachments = !empty($this->_attachments);
$hasMultipleTypes = count($rendered) > 1;
16 lib/Cake/Network/Http/HttpSocket.php
View
@@ -153,7 +153,7 @@ public function __construct($config = array()) {
$this->_configUri($config['request']['uri']);
unset($config['request']['uri']);
}
- $this->config = Set::merge($this->config, $config);
+ $this->config = Hash::merge($this->config, $config);
}
parent::__construct($this->config);
}
@@ -271,7 +271,7 @@ public function request($request = array()) {
}
$request['uri'] = $this->url($request['uri']);
$request['uri'] = $this->_parseUri($request['uri'], true);
- $this->request = Set::merge($this->request, array_diff_key($this->config['request'], array('cookies' => true)), $request);
+ $this->request = Hash::merge($this->request, array_diff_key($this->config['request'], array('cookies' => true)), $request);
$this->_configUri($this->request['uri']);
@@ -446,7 +446,7 @@ public function get($uri = null, $query = array(), $request = array()) {
$uri = $this->_buildUri($uri);
}
- $request = Set::merge(array('method' => 'GET', 'uri' => $uri), $request);
+ $request = Hash::merge(array('method' => 'GET', 'uri' => $uri), $request);
return $this->request($request);
}
@@ -468,7 +468,7 @@ public function get($uri = null, $query = array(), $request = array()) {
* @return mixed Result of request, either false on failure or the response to the request.
*/
public function post($uri = null, $data = array(), $request = array()) {
- $request = Set::merge(array('method' => 'POST', 'uri' => $uri, 'body' => $data), $request);
+ $request = Hash::merge(array('method' => 'POST', 'uri' => $uri, 'body' => $data), $request);
return $this->request($request);
}
@@ -481,7 +481,7 @@ public function post($uri = null, $data = array(), $request = array()) {
* @return mixed Result of request
*/
public function put($uri = null, $data = array(), $request = array()) {
- $request = Set::merge(array('method' => 'PUT', 'uri' => $uri, 'body' => $data), $request);
+ $request = Hash::merge(array('method' => 'PUT', 'uri' => $uri, 'body' => $data), $request);
return $this->request($request);
}
@@ -494,7 +494,7 @@ public function put($uri = null, $data = array(), $request = array()) {
* @return mixed Result of request
*/
public function delete($uri = null, $data = array(), $request = array()) {
- $request = Set::merge(array('method' => 'DELETE', 'uri' => $uri, 'body' => $data), $request);
+ $request = Hash::merge(array('method' => 'DELETE', 'uri' => $uri, 'body' => $data), $request);
return $this->request($request);
}
@@ -639,8 +639,8 @@ protected function _configUri($uri = null) {
'uri' => array_intersect_key($uri, $this->config['request']['uri'])
)
);
- $this->config = Set::merge($this->config, $config);
- $this->config = Set::merge($this->config, array_intersect_key($this->config['request']['uri'], $this->config));
+ $this->config = Hash::merge($this->config, $config);
+ $this->config = Hash::merge($this->config, array_intersect_key($this->config['request']['uri'], $this->config));
return true;
}
2  lib/Cake/Routing/Route/CakeRoute.php
View
@@ -494,7 +494,7 @@ protected function _writeUrl($params) {
$named = array();
foreach ($params['named'] as $key => $value) {
if (is_array($value)) {
- $flat = Set::flatten($value, '][');
+ $flat = Hash::flatten($value, '][');
foreach ($flat as $namedKey => $namedValue) {
$named[] = $key . "[$namedKey]" . $separator . rawurlencode($namedValue);
}
4 lib/Cake/Routing/Router.php
View
@@ -890,7 +890,7 @@ protected static function _handleNoRoute($url) {
}
}
- list($args, $named) = array(Set::filter($args, true), Set::filter($named, true));
+ list($args, $named) = array(Hash::filter($args), Hash::filter($named));
foreach (self::$_prefixes as $prefix) {
if (!empty($url[$prefix])) {
$url['action'] = str_replace($prefix . '_', '', $url['action']);
@@ -923,7 +923,7 @@ protected static function _handleNoRoute($url) {
if (!empty($named)) {
foreach ($named as $name => $value) {
if (is_array($value)) {
- $flattend = Set::flatten($value, '][');
+ $flattend = Hash::flatten($value, '][');
foreach ($flattend as $namedKey => $namedValue) {
$output .= '/' . $name . "[$namedKey]" . self::$_namedConfig['separator'] . rawurlencode($namedValue);
}
2  lib/Cake/Test/Case/Console/ShellTest.php
View
@@ -161,7 +161,7 @@ public function testMergeVars() {
$this->assertEquals($expected, $this->Shell->tasks);
$expected = array('Fixture' => null, 'DbConfig' => array('one', 'two'));
- $this->assertEquals($expected, Set::normalize($this->Shell->tasks), 'Normalized results are wrong.');
+ $this->assertEquals($expected, Hash::normalize($this->Shell->tasks), 'Normalized results are wrong.');
$this->assertEquals(array('Comment', 'Posts'), $this->Shell->uses, 'Merged models are wrong.');
}
38 lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
View
@@ -108,7 +108,7 @@ public function beforeFind($query) {
public function find($conditions = null, $fields = array(), $order = null, $recursive = null) {
if ($conditions == 'popular') {
$conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1');
- $options = Set::merge($fields, compact('conditions'));
+ $options = Hash::merge($fields, compact('conditions'));
return parent::find('all', $options);
}
return parent::find($conditions, $fields);
@@ -352,47 +352,47 @@ public function testPaginate() {
$Controller->request->query = array();
$Controller->constructClasses();
- $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
+ $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(array(1, 2, 3), $results);
- $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id');
+ $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id');
$this->assertEquals(array(1, 2, 3, 4, 5, 6), $results);
$Controller->modelClass = null;
$Controller->uses[0] = 'Plugin.PaginatorControllerPost';
- $results = Set::extract($Controller->Paginator->paginate(), '{n}.PaginatorControllerPost.id');
+ $results = Hash::extract($Controller->Paginator->paginate(), '{n}.PaginatorControllerPost.id');
$this->assertEquals(array(1, 2, 3), $results);
$Controller->request->params['named'] = array('page' => '-1');
- $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
+ $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(1, 2, 3), $results);
$Controller->request->params['named'] = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'asc');
- $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
+ $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(1, 2, 3), $results);
$Controller->request->params['named'] = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'desc');
- $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
+ $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(3, 2, 1), $results);
$Controller->request->params['named'] = array('sort' => 'id', 'direction' => 'desc');
- $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
+ $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(3, 2, 1), $results);
$Controller->request->params['named'] = array('sort' => 'NotExisting.field', 'direction' => 'desc');
- $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
+ $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page'], 'Invalid field in query %s');
$this->assertEquals(array(1, 2, 3), $results);
$Controller->request->params['named'] = array(
'sort' => 'PaginatorControllerPost.author_id', 'direction' => 'allYourBase'
);
- $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
+ $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(array('PaginatorControllerPost.author_id' => 'asc'), $Controller->PaginatorControllerPost->lastQueries[1]['order'][0]);
$this->assertEquals(array(1, 3, 2), $results);
@@ -469,7 +469,7 @@ public function testPaginateExtraParams() {
$Controller->request->params['named'] = array('page' => '-1', 'contain' => array('PaginatorControllerComment'));
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
- $this->assertEquals(array(1, 2, 3), Set::extract($result, '{n}.PaginatorControllerPost.id'));
+ $this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id'));
$this->assertTrue(!isset($Controller->PaginatorControllerPost->lastQueries[1]['contain']));
$Controller->request->params['named'] = array('page' => '-1');
@@ -482,7 +482,7 @@ public function testPaginateExtraParams() {
);
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
- $this->assertEquals(array(1, 2, 3), Set::extract($result, '{n}.PaginatorControllerPost.id'));
+ $this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id'));
$this->assertTrue(isset($Controller->PaginatorControllerPost->lastQueries[1]['contain']));
$Controller->Paginator->settings = array(
@@ -491,7 +491,7 @@ public function testPaginateExtraParams() {
),
);
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
- $this->assertEquals(array(2, 3), Set::extract($result, '{n}.PaginatorControllerPost.id'));
+ $this->assertEquals(array(2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id'));
$this->assertEquals(array('PaginatorControllerPost.id > ' => '1'), $Controller->PaginatorControllerPost->lastQueries[1]['conditions']);
$Controller->request->params['named'] = array('limit' => 12);
@@ -566,7 +566,7 @@ public function testPaginateSpecialType() {
);
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
- $this->assertEquals(array(2, 3), Set::extract($result, '{n}.PaginatorControllerPost.id'));
+ $this->assertEquals(array(2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id'));
$this->assertEquals(
$Controller->PaginatorControllerPost->lastQueries[1]['conditions'],
array('PaginatorControllerPost.id > ' => '1')
@@ -589,7 +589,7 @@ public function testDefaultPaginateParams() {
'maxLimit' => 10,
'paramType' => 'named'
);
- $results = Set::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
+ $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals('PaginatorControllerPost.id DESC', $Controller->params['paging']['PaginatorControllerPost']['order']);
$this->assertEquals(array(3, 2, 1), $results);
}
@@ -615,7 +615,7 @@ public function testPaginateOrderVirtualField() {
'paramType' => 'named'
);
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
- $this->assertEquals(array(4, 3, 2), Set::extract($result, '{n}.PaginatorControllerPost.offset_test'));
+ $this->assertEquals(array(4, 3, 2), Hash::extract($result, '{n}.PaginatorControllerPost.offset_test'));
$Controller->request->params['named'] = array('sort' => 'offset_test', 'direction' => 'asc');
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
@@ -639,11 +639,11 @@ public function testPaginateOrderVirtualFieldJoinedModel() {
'paramType' => 'named'
);
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
- $this->assertEquals(array(4, 2, 2), Set::extract($result, '{n}.PaginatorAuthor.joined_offset'));
+ $this->assertEquals(array(4, 2, 2), Hash::extract($result, '{n}.PaginatorAuthor.joined_offset'));
$Controller->request->params['named'] = array('sort' => 'PaginatorAuthor.joined_offset', 'direction' => 'asc');
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
- $this->assertEquals(array(2, 2, 4), Set::extract($result, '{n}.PaginatorAuthor.joined_offset'));
+ $this->assertEquals(array(2, 2, 4), Hash::extract($result, '{n}.PaginatorAuthor.joined_offset'));
}
/**
@@ -968,7 +968,7 @@ public function testPaginateOrderVirtualFieldSharedWithRealField() {
);
$Controller->passedArgs = array('sort' => 'PaginatorControllerPost.title', 'dir' => 'asc');
$result = $Controller->paginate('PaginatorControllerComment');
- $this->assertEquals(array(1, 2, 3, 4, 5, 6), Set::extract($result, '{n}.PaginatorControllerComment.id'));
+ $this->assertEquals(array(1, 2, 3, 4, 5, 6), Hash::extract($result, '{n}.PaginatorControllerComment.id'));
}
/**
6 lib/Cake/Test/Case/Controller/ControllerTest.php
View
@@ -104,7 +104,7 @@ public function beforeFind($query) {
public function find($type = 'first', $options = array()) {
if ($type == 'popular') {
$conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1');
- $options = Set::merge($options, compact('conditions'));
+ $options = Hash::merge($options, compact('conditions'));
return parent::find('all', $options);
}
return parent::find($type, $options);
@@ -898,7 +898,7 @@ public function testMergeVars() {
$this->assertEquals(0, count(array_diff_key($TestController->helpers, array_flip($helpers))));
$this->assertEquals(0, count(array_diff($TestController->uses, $uses)));
- $this->assertEquals(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0);
+ $this->assertEquals(count(array_diff_assoc(Hash::normalize($TestController->components), Hash::normalize($components))), 0);
$expected = array('ControllerComment', 'ControllerAlias', 'ControllerPost');
$this->assertEquals($expected, $TestController->uses, '$uses was merged incorrectly, ControllerTestAppController models should be last.');
@@ -1275,7 +1275,7 @@ public function testPaginateBackwardsCompatibility() {
$expected = array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named');
$this->assertEquals($expected, $Controller->paginate);
- $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id');
+ $results = Hash::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id');
$this->assertEquals(array(1, 2, 3), $results);
$Controller->passedArgs = array();
28 lib/Cake/Test/Case/Model/AclNodeTest.php
View
@@ -254,35 +254,33 @@ public function setUp() {
*/
public function testNode() {
$Aco = new DbAcoTest();
- $result = Set::extract($Aco->node('Controller1'), '{n}.DbAcoTest.id');
+ $result = Hash::extract($Aco->node('Controller1'), '{n}.DbAcoTest.id');
$expected = array(2, 1);
$this->assertEquals($expected, $result);
- $result = Set::extract($Aco->node('Controller1/action1'), '{n}.DbAcoTest.id');
+ $result = Hash::extract($Aco->node('Controller1/action1'), '{n}.DbAcoTest.id');
$expected = array(3, 2, 1);
$this->assertEquals($expected, $result);
- $result = Set::extract($Aco->node('Controller2/action1'), '{n}.DbAcoTest.id');
+ $result = Hash::extract($Aco->node('Controller2/action1'), '{n}.DbAcoTest.id');
$expected = array(7, 6, 1);
$this->assertEquals($expected, $result);
- $result = Set::extract($Aco->node('Controller1/action2'), '{n}.DbAcoTest.id');
+ $result = Hash::extract($Aco->node('Controller1/action2'), '{n}.DbAcoTest.id');
$expected = array(5, 2, 1);
$this->assertEquals($expected, $result);
- $result = Set::extract($Aco->node('Controller1/action1/record1'), '{n}.DbAcoTest.id');
+ $result = Hash::extract($Aco->node('Controller1/action1/record1'), '{n}.DbAcoTest.id');
$expected = array(4, 3, 2, 1);
$this->assertEquals($expected, $result);
- $result = Set::extract($Aco->node('Controller2/action1/record1'), '{n}.DbAcoTest.id');
+ $result = Hash::extract($Aco->node('Controller2/action1/record1'), '{n}.DbAcoTest.id');
$expected = array(8, 7, 6, 1);
$this->assertEquals($expected, $result);
- $result = Set::extract($Aco->node('Controller2/action3'), '{n}.DbAcoTest.id');
- $this->assertNull($result);
+ $this->assertFalse($Aco->node('Controller2/action3'));
- $result = Set::extract($Aco->node('Controller2/action3/record5'), '{n}.DbAcoTest.id');
- $this->assertNull($result);
+ $this->assertFalse($Aco->node('Controller2/action3/record5'));
$result = $Aco->node('');
$this->assertEquals(null, $result);
@@ -307,12 +305,12 @@ public function testNodeWithDuplicatePathSegments() {
public function testNodeArrayFind() {
$Aro = new DbAroTest();
Configure::write('DbAclbindMode', 'string');
- $result = Set::extract($Aro->node(array('DbAroUserTest' => array('id' => '1', 'foreign_key' => '1'))), '{n}.DbAroTest.id');
+ $result = Hash::extract($Aro->node(array('DbAroUserTest' => array('id' => '1', 'foreign_key' => '1'))), '{n}.DbAroTest.id');
$expected = array(3, 2, 1);
$this->assertEquals($expected, $result);
Configure::write('DbAclbindMode', 'array');
- $result = Set::extract($Aro->node(array('DbAroUserTest' => array('id' => 4, 'foreign_key' => 2))), '{n}.DbAroTest.id');
+ $result = Hash::extract($Aro->node(array('DbAroUserTest' => array('id' => 4, 'foreign_key' => 2))), '{n}.DbAroTest.id');
$expected = array(4);
$this->assertEquals($expected, $result);
}
@@ -326,12 +324,12 @@ public function testNodeObjectFind() {
$Aro = new DbAroTest();
$Model = new DbAroUserTest();
$Model->id = 1;
- $result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id');
+ $result = Hash::extract($Aro->node($Model), '{n}.DbAroTest.id');
$expected = array(3, 2, 1);
$this->assertEquals($expected, $result);
$Model->id = 2;
- $result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id');
+ $result = Hash::extract($Aro->node($Model), '{n}.DbAroTest.id');
$expected = array(4, 2, 1);
$this->assertEquals($expected, $result);
}
@@ -379,7 +377,7 @@ public function testNodeActionAuthorize() {
$this->assertEquals($expected, $result);
$node = $Aro->node(array('TestPlugin.TestPluginAuthUser' => array('id' => 1, 'user' => 'mariano')));
- $result = Set::extract($node, '0.DbAroTest.id');
+ $result = Hash::get($node, '0.DbAroTest.id');
$expected = $Aro->id;
$this->assertEquals($expected, $result);
CakePlugin::unload('TestPlugin');
4 lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
View
@@ -631,8 +631,8 @@ public function testMixedCreateUpdateWithArrayLocale() {
$translations = array('title' => 'Title', 'content' => 'Content');
$TestModel->bindTranslation($translations, false);
$result = $TestModel->read(null, 1);
- $result['Title'] = Set::sort($result['Title'], '{n}.id', 'asc');
- $result['Content'] = Set::sort($result['Content'], '{n}.id', 'asc');
+ $result['Title'] = Hash::sort($result['Title'], '{n}.id', 'asc');
+ $result['Content'] = Hash::sort($result['Content'], '{n}.id', 'asc');
$expected = array(
'TranslatedItem' => array('id' => 1, 'slug' => 'first_translated', 'locale' => 'cze', 'title' => 'Titulek #1', 'content' => 'Upraveny obsah #1'),
'Title' => array(
12 lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
View
@@ -102,7 +102,7 @@ public function afterFind(Model $model, $results, $primary) {
return null;
break;
case 'modify':
- return Set::extract($results, "{n}.{$model->alias}");
+ return Hash::extract($results, "{n}.{$model->alias}");
break;
}
}
@@ -839,7 +839,7 @@ public function testBehaviorSaveCallbacks() {
$this->assertSame($expected, $result);
$Sample->Behaviors->attach('Test', array('beforeSave' => 'modify'));
- $expected = Set::insert($record, 'Sample.name', 'sample99 modified before');
+ $expected = Hash::insert($record, 'Sample.name', 'sample99 modified before');
$Sample->create();
$result = $Sample->save($record);
$expected['Sample']['id'] = $Sample->id;
@@ -849,14 +849,14 @@ public function testBehaviorSaveCallbacks() {
$this->assertSame($record, $Sample->save($record));
$Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'on'));
- $expected = Set::merge($record, array('Sample' => array('aftersave' => 'modified after on create')));
+ $expected = Hash::merge($record, array('Sample' => array('aftersave' => 'modified after on create')));
$Sample->create();
$result = $Sample->save($record);
$expected['Sample']['id'] = $Sample->id;
$this->assertEquals($expected, $result);
$Sample->Behaviors->attach('Test', array('beforeSave' => 'modify', 'afterSave' => 'modify'));
- $expected = Set::merge($record, array('Sample' => array('name' => 'sample99 modified before modified after on create')));
+ $expected = Hash::merge($record, array('Sample' => array('name' => 'sample99 modified before modified after on create')));
$Sample->create();
$result = $Sample->save($record);
$expected['Sample']['id'] = $Sample->id;
@@ -881,12 +881,12 @@ public function testBehaviorSaveCallbacks() {
$record2 = $Sample->read(null, 1);
$Sample->Behaviors->attach('Test', array('afterSave' => 'on'));
- $expected = Set::merge($record2, array('Sample' => array('aftersave' => 'modified after')));
+ $expected = Hash::merge($record2, array('Sample' => array('aftersave' => 'modified after')));
$Sample->create();
$this->assertSame($expected, $Sample->save($record2));
$Sample->Behaviors->attach('Test', array('afterSave' => 'modify'));
- $expected = Set::merge($record2, array('Sample' => array('name' => 'sample1 modified after')));
+ $expected = Hash::merge($record2, array('Sample' => array('name' => 'sample1 modified after')));
$Sample->create();
$this->assertSame($expected, $Sample->save($record2));
}
18 lib/Cake/Test/Case/Model/ModelReadTest.php
View
@@ -3015,7 +3015,7 @@ public function testFindThreadedNoParent() {
$this->loadFixtures('Apple', 'Sample');
$Apple = new Apple();
$result = $Apple->find('threaded');
- $result = Set::extract($result, '{n}.children');
+ $result = Hash::extract($result, '{n}.children');
$expected = array(array(), array(), array(), array(), array(), array(), array());
$this->assertEquals($expected, $result);
}
@@ -3030,7 +3030,7 @@ public function testFindThreaded() {
$Model = new Person();
$Model->recursive = -1;
$result = $Model->find('threaded');
- $result = Set::extract($result, '{n}.children');
+ $result = Hash::extract($result, '{n}.children');
$expected = array(array(), array(), array(), array(), array(), array(), array());
$this->assertEquals($expected, $result);
@@ -6479,7 +6479,7 @@ public function testGenerateFindList() {
$this->assertEquals($expected, $result);
}
- $result = Set::combine(
+ $result = Hash::combine(
$TestModel->find('all', array(
'order' => 'Article.title ASC',
'fields' => array('id', 'title')
@@ -6493,7 +6493,7 @@ public function testGenerateFindList() {
);
$this->assertEquals($expected, $result);
- $result = Set::combine(
+ $result = Hash::combine(
$TestModel->find('all', array(
'order' => 'Article.title ASC'
)),
@@ -6530,7 +6530,7 @@ public function testGenerateFindList() {
$this->assertEquals($expected, $result);
- $result = Set::combine(
+ $result = Hash::combine(
$TestModel->find('all', array(
'order' => 'Article.title ASC'
)),
@@ -6569,7 +6569,7 @@ public function testGenerateFindList() {
$this->assertEquals($expected, $result);
- $result = Set::combine(
+ $result = Hash::combine(
$TestModel->find('all', array(
'order' => 'Article.title ASC',
'fields' => array('id', 'title', 'user_id')
@@ -7689,17 +7689,17 @@ public function testVirtualFieldsOrder() {
$Post->Author->virtualFields = array('joined' => 'Post.id * Author.id');
$result = $Post->find('all');
- $result = Set::extract('{n}.Author.joined', $result);
+ $result = Hash::extract($result, '{n}.Author.joined');
$expected = array(1, 6, 3);
$this->assertEquals($expected, $result);
$result = $Post->find('all', array('order' => array('Author.joined' => 'ASC')));
- $result = Set::extract('{n}.Author.joined', $result);
+ $result = Hash::extract($result, '{n}.Author.joined');
$expected = array(1, 3, 6);
$this->assertEquals($expected, $result);
$result = $Post->find('all', array('order' => array('Author.joined' => 'DESC')));
- $result = Set::extract('{n}.Author.joined', $result);
+ $result = Hash::extract($result, '{n}.Author.joined');
$expected = array(6, 3, 1);
$this->assertEquals($expected, $result);
}
20 lib/Cake/Test/Case/Model/ModelWriteTest.php
View
@@ -411,7 +411,7 @@ public function testCounterCacheWithSelfJoin() {
$Category = new CategoryThread();
$Category->belongsTo['ParentCategory']['counterCache'] = 'child_count';
$Category->updateCounterCache(array('parent_id' => 5));
- $result = Set::extract($Category->find('all', array('conditions' => array('CategoryThread.id' => 5))), '{n}.CategoryThread.child_count');
+ $result = Hash::extract($Category->find('all', array('conditions' => array('CategoryThread.id' => 5))), '{n}.CategoryThread.child_count');
$expected = array(1);
$this->assertEquals($expected, $result);
}
@@ -1680,7 +1680,7 @@ public function testSaveHabtmNoPrimaryData() {
$TestModel->id = 2;
$TestModel->save($data);
$result = $TestModel->findById(2);
- $result['Item'] = Set::sort($result['Item'], '{n}.id', 'asc');
+ $result['Item'] = Hash::sort($result['Item'], '{n}.id', 'asc');
$expected = array(
'Portfolio' => array(
'id' => 2,
@@ -2400,12 +2400,12 @@ public function testUpdateSavingBlankValues() {
public function testUpdateMultiple() {
$this->loadFixtures('Comment', 'Article', 'User', 'CategoryThread');
$TestModel = new Comment();
- $result = Set::extract($TestModel->find('all'), '{n}.Comment.user_id');
+ $result = Hash::extract($TestModel->find('all'), '{n}.Comment.user_id');
$expected = array('2', '4', '1', '1', '1', '2');
$this->assertEquals($expected, $result);
$TestModel->updateAll(array('Comment.user_id' => 5), array('Comment.user_id' => 2));
- $result = Set::combine($TestModel->find('all'), '{n}.Comment.id', '{n}.Comment.user_id');
+ $result = Hash::combine($TestModel->find('all'), '{n}.Comment.id', '{n}.Comment.user_id');
$expected = array(1 => 5, 2 => 4, 3 => 1, 4 => 1, 5 => 1, 6 => 5);
$this->assertEquals($expected, $result);
@@ -2414,7 +2414,7 @@ public function testUpdateMultiple() {
array('Comment.user_id' => 5)
);
$this->assertFalse(empty($result));
- $result = Set::extract(
+ $result = Hash::extract(
$TestModel->find('all', array(
'conditions' => array(
'Comment.user_id' => 5
@@ -3075,7 +3075,7 @@ public function testSaveAllDeepAssociated() {
'First new comment',
'Second new comment'
);
- $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
$this->assertEquals($expected, $result);
$result = $TestModel->Comment->User->field('id', array('user' => 'newuser', 'password' => 'newuserpass'));
@@ -3098,7 +3098,7 @@ public function testSaveAllDeepAssociated() {
'Third new comment',
'Fourth new comment'
);
- $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
$this->assertEquals($expected, $result);
$result = $TestModel->Comment->Attachment->field('id', array('attachment' => 'deepsaved'));
@@ -3850,7 +3850,7 @@ public function testSaveAllHasMany() {
'First new comment',
'Second new comment'
);
- $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
$this->assertEquals($expected, $result);
$result = $TestModel->saveAll(
@@ -3874,7 +3874,7 @@ public function testSaveAllHasMany() {
'Second new comment',
'Third new comment'
);
- $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
$this->assertEquals($expected, $result);
$TestModel->beforeSaveReturn = false;
@@ -3899,7 +3899,7 @@ public function testSaveAllHasMany() {
'Second new comment',
'Third new comment'
);
- $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
$this->assertEquals($expected, $result);
}
4 lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
View
@@ -531,13 +531,13 @@ public function testRequest() {
foreach ($tests as $i => $test) {
if (strpos($i, 'reset') === 0) {
foreach ($test as $path => $val) {
- $expectation = Set::insert($expectation, $path, $val);
+ $expectation = Hash::insert($expectation, $path, $val);
}
continue;
}
if (isset($test['expectation'])) {
- $expectation = Set::merge($expectation, $test['expectation']);
+ $expectation = Hash::merge($expectation, $test['expectation']);
}
$this->Socket->request($test['request']);
2  lib/Cake/Test/Case/View/Helper/FormHelperTest.php
View
@@ -6860,7 +6860,7 @@ public function testFormInputRequiredDetection() {
$result = $this->Form->input('Contact.non_existing');
$expected = array(
- 'div' => array('class' => 'input text required'),
+ 'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactNonExisting'),
'Non Existing',
'/label',
2  lib/Cake/Utility/Debugger.php
View
@@ -288,7 +288,7 @@ public static function trace($options = array()) {
'scope' => null,
'exclude' => array('call_user_func_array', 'trigger_error')
);
- $options = Set::merge($defaults, $options);
+ $options = Hash::merge($defaults, $options);
$backtrace = debug_backtrace();
$count = count($backtrace);
10 lib/Cake/Utility/Hash.php
View
@@ -317,7 +317,7 @@ public static function remove(array $data, $path) {
/**
* Creates an associative array using `$keyPath` as the path to build its keys, and optionally
* `$valuePath` as path to get the values. If `$valuePath` is not specified, all values will be initialized
- * to null (useful for Set::merge). You can optionally group the values by what is obtained when
+ * to null (useful for Hash::merge). You can optionally group the values by what is obtained when
* following the path specified in `$groupPath`.
*
* @param array $data Array from where to extract keys and values
@@ -383,7 +383,7 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP
* Usage:
*
* {{{
- * $result = Set::format($users, array('{n}.User.id', '{n}.User.name'), '%s : %s');
+ * $result = Hash::format($users, array('{n}.User.id', '{n}.User.name'), '%s : %s');
* }}}
*
* The `$format` string can use any format options that `vsprintf()` and `sprintf()` do.
@@ -405,7 +405,7 @@ public static function format(array $data, array $paths, $format) {
}
for ($i = 0; $i < $count; $i++) {
- $extracted[] = Set::extract($data, $paths[$i]);
+ $extracted[] = self::extract($data, $paths[$i]);
}
$out = array();
$data = $extracted;
@@ -639,7 +639,7 @@ public static function maxDimensions(array $data) {
$depth = array();
if (is_array($data) && reset($data) !== false) {
foreach ($data as $value) {
- $depth[] = Hash::dimensions((array)$value) + 1;
+ $depth[] = self::dimensions((array)$value) + 1;
}
}
return max($depth);
@@ -830,7 +830,7 @@ public static function normalize(array $data, $assoc = true) {
* @param mixed $data The data to nest.
* @param array $options Options are:
* @return array of results, nested
- * @see Set::extract()
+ * @see Hash::extract()
*/
public static function nest(array $data, $options = array()) {
if (!$data) {
4 lib/Cake/View/Helper.php
View
@@ -471,7 +471,7 @@ public function setEntity($entity, $setScope = false) {
if ($setScope === true) {
$this->_modelScope = $entity;
}
- $parts = array_values(Set::filter(explode('.', $entity), true));
+ $parts = array_values(Hash::filter(explode('.', $entity)));
if (empty($parts)) {
return;
}
@@ -673,7 +673,7 @@ public function value($options = array(), $field = null, $key = 'value') {
$entity = $this->entity();
if (!empty($data) && !empty($entity)) {
- $result = Set::extract(implode('.', $entity), $data);
+ $result = Hash::get($data, implode('.', $entity));
}
$habtmKey = $this->field();
6 lib/Cake/View/Helper/FormHelper.php
View
@@ -243,7 +243,7 @@ protected function _isRequiredField($validateProperties) {
return true;
} elseif (is_array($validateProperties)) {
- $dims = Set::countDim($validateProperties);
+ $dims = Hash::dimensions($validateProperties);
if ($dims == 1 || ($dims == 2 && isset($validateProperties['rule']))) {
$validateProperties = array($validateProperties);
}
@@ -312,7 +312,7 @@ public function tagIsInvalid() {
if (empty($errors)) {
return false;
}
- $errors = Set::classicExtract($errors, join('.', $entity));
+ $errors = Hash::get($errors, join('.', $entity));
return $errors === null ? false : $errors;
}
@@ -623,7 +623,7 @@ protected function _secure($lock, $field = null, $value = null) {
if (!$field) {
$field = $this->entity();
} elseif (is_string($field)) {
- $field = Set::filter(explode('.', $field), true);
+ $field = Hash::filter(explode('.', $field));
}
foreach ($this->_unlockedFields as $unlockField) {
2  lib/Cake/View/Helper/NumberHelper.php
View
@@ -53,7 +53,7 @@ class NumberHelper extends AppHelper {
* @throws CakeException When the engine class could not be found.
*/
public function __construct(View $View, $settings = array()) {
- $settings = Set::merge(array('engine' => 'CakeNumber'), $settings);
+ $settings = Hash::merge(array('engine' => 'CakeNumber'), $settings);
parent::__construct($View, $settings);
list($plugin, $engineClass) = pluginSplit($settings['engine'], true);
App::uses($engineClass, $plugin . 'Utility');
2  lib/Cake/View/Helper/TextHelper.php
View
@@ -66,7 +66,7 @@ class TextHelper extends AppHelper {
* @throws CakeException when the engine class could not be found.
*/
public function __construct(View $View, $settings = array()) {
- $settings = Set::merge(array('engine' => 'String'), $settings);
+ $settings = Hash::merge(array('engine' => 'String'), $settings);
parent::__construct($View, $settings);
list($plugin, $engineClass) = pluginSplit($settings['engine'], true);
App::uses($engineClass, $plugin . 'Utility');
2  lib/Cake/View/Helper/TimeHelper.php
View
@@ -50,7 +50,7 @@ class TimeHelper extends AppHelper {
* @throws CakeException When the engine class could not be found.
*/
public function __construct(View $View, $settings = array()) {
- $settings = Set::merge(array('engine' => 'CakeTime'), $settings);
+ $settings = Hash::merge(array('engine' => 'CakeTime'), $settings);
parent::__construct($View, $settings);
list($plugin, $engineClass) = pluginSplit($settings['engine'], true);
App::uses($engineClass, $plugin . 'Utility');
Please sign in to comment.
Something went wrong with that request. Please try again.