Skip to content
This repository
Browse code

type hinting models

  • Loading branch information...
commit 45112088a1feef561a1f6965660107cf7f750515 1 parent 22452f6
Mark authored February 23, 2012 markstory committed February 25, 2012
8  lib/Cake/Model/Behavior/AclBehavior.php
@@ -44,7 +44,7 @@ class AclBehavior extends ModelBehavior {
44 44
  * @param array $config
45 45
  * @return void
46 46
  */
47  
-	public function setup($model, $config = array()) {
  47
+	public function setup(Model $model, $config = array()) {
48 48
 		if (isset($config[0])) {
49 49
 			$config['type'] = $config[0];
50 50
 			unset($config[0]);
@@ -74,7 +74,7 @@ public function setup($model, $config = array()) {
74 74
  * @return array
75 75
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/acl.html#node
76 76
  */
77  
-	public function node($model, $ref = null, $type = null) {
  77
+	public function node(Model $model, $ref = null, $type = null) {
78 78
 		if (empty($type)) {
79 79
 			$type = $this->_typeMaps[$this->settings[$model->name]['type']];
80 80
 			if (is_array($type)) {
@@ -95,7 +95,7 @@ public function node($model, $ref = null, $type = null) {
95 95
  * @param boolean $created True if this is a new record
96 96
  * @return void
97 97
  */
98  
-	public function afterSave($model, $created) {
  98
+	public function afterSave(Model $model, $created) {
99 99
 		$types = $this->_typeMaps[$this->settings[$model->name]['type']];
100 100
 		if (!is_array($types)) {
101 101
 			$types = array($types);
@@ -125,7 +125,7 @@ public function afterSave($model, $created) {
125 125
  * @param Model $model
126 126
  * @return void
127 127
  */
128  
-	public function afterDelete($model) {
  128
+	public function afterDelete(Model $model) {
129 129
 		$types = $this->_typeMaps[$this->settings[$model->name]['type']];
130 130
 		if (!is_array($types)) {
131 131
 			$types = array($types);
12  lib/Cake/Model/Behavior/ContainableBehavior.php
@@ -61,7 +61,7 @@ class ContainableBehavior extends ModelBehavior {
61 61
  * @param array $settings Settings to override for model.
62 62
  * @return void
63 63
  */
64  
-	public function setup($Model, $settings = array()) {
  64
+	public function setup(Model $Model, $settings = array()) {
65 65
 		if (!isset($this->settings[$Model->alias])) {
66 66
 			$this->settings[$Model->alias] = array('recursive' => true, 'notices' => true, 'autoFields' => true);
67 67
 		}
@@ -89,7 +89,7 @@ public function setup($Model, $settings = array()) {
89 89
  * @param array $query Query parameters as set by cake
90 90
  * @return array
91 91
  */
92  
-	public function beforeFind($Model, $query) {
  92
+	public function beforeFind(Model $Model, $query) {
93 93
 		$reset = (isset($query['reset']) ? $query['reset'] : true);
94 94
 		$noContain = (
95 95
 			(isset($this->runtime[$Model->alias]['contain']) && empty($this->runtime[$Model->alias]['contain'])) ||
@@ -225,7 +225,7 @@ public function beforeFind($Model, $query) {
225 225
  * @return void
226 226
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html#using-containable
227 227
  */
228  
-	public function contain($Model) {
  228
+	public function contain(Model $Model) {
229 229
 		$args = func_get_args();
230 230
 		$contain = call_user_func_array('am', array_slice($args, 1));
231 231
 		$this->runtime[$Model->alias]['contain'] = $contain;
@@ -239,7 +239,7 @@ public function contain($Model) {
239 239
  * @param Model $Model Model on which to reset bindings
240 240
  * @return void
241 241
  */
242  
-	public function resetBindings($Model) {
  242
+	public function resetBindings(Model $Model) {
243 243
 		if (!empty($Model->__backOriginalAssociation)) {
244 244
 			$Model->__backAssociation = $Model->__backOriginalAssociation;
245 245
 			unset($Model->__backOriginalAssociation);
@@ -263,7 +263,7 @@ public function resetBindings($Model) {
263 263
  * @param boolean $throwErrors Whether non-existent bindings show throw errors
264 264
  * @return array Containments
265 265
  */
266  
-	public function containments($Model, $contain, $containments = array(), $throwErrors = null) {
  266
+	public function containments(Model $Model, $contain, $containments = array(), $throwErrors = null) {
267 267
 		$options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery');
268 268
 		$keep = array();
269 269
 		if ($throwErrors === null) {
@@ -365,7 +365,7 @@ public function containments($Model, $contain, $containments = array(), $throwEr
365 365
  * @param mixed $fields If array, fields to initially load, if false use $Model as primary model
366 366
  * @return array Fields
367 367
  */
368  
-	public function fieldDependencies($Model, $map, $fields = array()) {
  368
+	public function fieldDependencies(Model $Model, $map, $fields = array()) {
369 369
 		if ($fields === false) {
370 370
 			foreach ($map as $parent => $children) {
371 371
 				foreach ($children as $type => $bindings) {
22  lib/Cake/Model/Behavior/TranslateBehavior.php
@@ -62,7 +62,7 @@ class TranslateBehavior extends ModelBehavior {
62 62
  * @param array $config Array of configuration information.
63 63
  * @return mixed
64 64
  */
65  
-	public function setup($model, $config = array()) {
  65
+	public function setup(Model $model, $config = array()) {
66 66
 		$db = ConnectionManager::getDataSource($model->useDbConfig);
67 67
 		if (!$db->connected) {
68 68
 			trigger_error(
@@ -84,7 +84,7 @@ public function setup($model, $config = array()) {
84 84
  * @param Model $model Model being detached.
85 85
  * @return void
86 86
  */
87  
-	public function cleanup($model) {
  87
+	public function cleanup(Model $model) {
88 88
 		$this->unbindTranslation($model);
89 89
 		unset($this->settings[$model->alias]);
90 90
 		unset($this->runtime[$model->alias]);
@@ -97,7 +97,7 @@ public function cleanup($model) {
97 97
  * @param array $query Array of Query parameters.
98 98
  * @return array Modified query
99 99
  */
100  
-	public function beforeFind($model, $query) {
  100
+	public function beforeFind(Model $model, $query) {
101 101
 		$this->runtime[$model->alias]['virtualFields'] = $model->virtualFields;
102 102
 		$locale = $this->_getLocale($model);
103 103
 		if (empty($locale)) {
@@ -263,7 +263,7 @@ protected function _addJoin(Model $model, $query, $field, $aliasField, $locale,
263 263
  * @param boolean $primary Did the find originate on $model.
264 264
  * @return array Modified results
265 265
  */
266  
-	public function afterFind($model, $results, $primary) {
  266
+	public function afterFind(Model $model, $results, $primary) {
267 267
 		$model->virtualFields = $this->runtime[$model->alias]['virtualFields'];
268 268
 		$this->runtime[$model->alias]['virtualFields'] = $this->runtime[$model->alias]['fields'] = array();
269 269
 		$locale = $this->_getLocale($model);
@@ -309,7 +309,7 @@ public function afterFind($model, $results, $primary) {
309 309
  * @param Model $model Model invalidFields was called on.
310 310
  * @return boolean
311 311
  */
312  
-	public function beforeValidate($model) {
  312
+	public function beforeValidate(Model $model) {
313 313
 		$locale = $this->_getLocale($model);
314 314
 		if (empty($locale)) {
315 315
 			return true;
@@ -343,7 +343,7 @@ public function beforeValidate($model) {
343 343
  * @param boolean $created Whether or not the save created a record.
344 344
  * @return void
345 345
  */
346  
-	public function afterSave($model, $created) {
  346
+	public function afterSave(Model $model, $created) {
347 347
 		if (!isset($this->runtime[$model->alias]['beforeSave'])) {
348 348
 			return true;
349 349
 		}
@@ -386,7 +386,7 @@ public function afterSave($model, $created) {
386 386
  * @param Model $model Model the callback was run on.
387 387
  * @return void
388 388
  */
389  
-	public function afterDelete($model) {
  389
+	public function afterDelete(Model $model) {
390 390
 		$RuntimeModel = $this->translateModel($model);
391 391
 		$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
392 392
 		$RuntimeModel->deleteAll($conditions);
@@ -398,7 +398,7 @@ public function afterDelete($model) {
398 398
  * @param Model $model Model the locale needs to be set/get on.
399 399
  * @return mixed string or false
400 400
  */
401  
-	protected function _getLocale($model) {
  401
+	protected function _getLocale(Model $model) {
402 402
 		if (!isset($model->locale) || is_null($model->locale)) {
403 403
 			$I18n = I18n::getInstance();
404 404
 			$I18n->l10n->get(Configure::read('Config.language'));
@@ -417,7 +417,7 @@ protected function _getLocale($model) {
417 417
  * @param Model $model Model to get a translatemodel for.
418 418
  * @return Model
419 419
  */
420  
-	public function translateModel($model) {
  420
+	public function translateModel(Model $model) {
421 421
 		if (!isset($this->runtime[$model->alias]['model'])) {
422 422
 			if (!isset($model->translateModel) || empty($model->translateModel)) {
423 423
 				$className = 'I18nModel';
@@ -447,7 +447,7 @@ public function translateModel($model) {
447 447
  * @param boolean $reset
448 448
  * @return boolean
449 449
  */
450  
-	public function bindTranslation($model, $fields, $reset = true) {
  450
+	public function bindTranslation(Model $model, $fields, $reset = true) {
451 451
 		if (is_string($fields)) {
452 452
 			$fields = array($fields);
453 453
 		}
@@ -525,7 +525,7 @@ public function bindTranslation($model, $fields, $reset = true) {
525 525
  *    unbind all original translations
526 526
  * @return boolean
527 527
  */
528  
-	public function unbindTranslation($model, $fields = null) {
  528
+	public function unbindTranslation(Model $model, $fields = null) {
529 529
 		if (empty($fields) && empty($this->settings[$model->alias])) {
530 530
 			return false;
531 531
 		}
40  lib/Cake/Model/Behavior/TreeBehavior.php
@@ -54,7 +54,7 @@ class TreeBehavior extends ModelBehavior {
54 54
  * @param array $config array of configuration settings.
55 55
  * @return void
56 56
  */
57  
-	public function setup($Model, $config = array()) {
  57
+	public function setup(Model $Model, $config = array()) {
58 58
 		if (isset($config[0])) {
59 59
 			$config['type'] = $config[0];
60 60
 			unset($config[0]);
@@ -80,7 +80,7 @@ public function setup($Model, $config = array()) {
80 80
  * @param boolean $created indicates whether the node just saved was created or updated
81 81
  * @return boolean true on success, false on failure
82 82
  */
83  
-	public function afterSave($Model, $created) {
  83
+	public function afterSave(Model $Model, $created) {
84 84
 		extract($this->settings[$Model->alias]);
85 85
 		if ($created) {
86 86
 			if ((isset($Model->data[$Model->alias][$parent])) && $Model->data[$Model->alias][$parent]) {
@@ -99,7 +99,7 @@ public function afterSave($Model, $created) {
99 99
  * @param array $query Query parameters as set by cake
100 100
  * @return array
101 101
  */
102  
-	public function beforeFind($Model, $query) {
  102
+	public function beforeFind(Model $Model, $query) {
103 103
 		if ($Model->findQueryType == 'threaded' && !isset($query['parent'])) {
104 104
 			$query['parent'] = $this->settings[$Model->alias]['parent'];
105 105
 		}
@@ -115,7 +115,7 @@ public function beforeFind($Model, $query) {
115 115
  * @param boolean $cascade
116 116
  * @return boolean true to continue, false to abort the delete
117 117
  */
118  
-	public function beforeDelete($Model, $cascade = true) {
  118
+	public function beforeDelete(Model $Model, $cascade = true) {
119 119
 		extract($this->settings[$Model->alias]);
120 120
 		$data = current($Model->find('first', array(
121 121
 			'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id), 
@@ -149,7 +149,7 @@ public function beforeDelete($Model, $cascade = true) {
149 149
  * @param Model $Model Model instance
150 150
  * @return boolean true to continue, false to abort the save
151 151
  */
152  
-	public function beforeSave($Model) {
  152
+	public function beforeSave(Model $Model) {
153 153
 		extract($this->settings[$Model->alias]);
154 154
 
155 155
 		$this->_addToWhitelist($Model, array($left, $right));
@@ -219,7 +219,7 @@ public function beforeSave($Model) {
219 219
  * @return integer number of child nodes
220 220
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::childCount
221 221
  */
222  
-	public function childCount($Model, $id = null, $direct = false) {
  222
+	public function childCount(Model $Model, $id = null, $direct = false) {
223 223
 		if (is_array($id)) {
224 224
 			extract (array_merge(array('id' => null), $id));
225 225
 		}
@@ -265,7 +265,7 @@ public function childCount($Model, $id = null, $direct = false) {
265 265
  * @return array Array of child nodes
266 266
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::children
267 267
  */
268  
-	public function children($Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
  268
+	public function children(Model $Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
269 269
 		if (is_array($id)) {
270 270
 			extract (array_merge(array('id' => null), $id));
271 271
 		}
@@ -322,7 +322,7 @@ public function children($Model, $id = null, $direct = false, $fields = null, $o
322 322
  * @return array An associative array of records, where the id is the key, and the display field is the value
323 323
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::generateTreeList
324 324
  */
325  
-	public function generateTreeList($Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
  325
+	public function generateTreeList(Model $Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
326 326
 		$overrideRecursive = $recursive;
327 327
 		extract($this->settings[$Model->alias]);
328 328
 		if (!is_null($overrideRecursive)) {
@@ -378,7 +378,7 @@ public function generateTreeList($Model, $conditions = null, $keyPath = null, $v
378 378
  * @return array|boolean Array of data for the parent node
379 379
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getParentNode
380 380
  */
381  
-	public function getParentNode($Model, $id = null, $fields = null, $recursive = null) {
  381
+	public function getParentNode(Model $Model, $id = null, $fields = null, $recursive = null) {
382 382
 		if (is_array($id)) {
383 383
 			extract (array_merge(array('id' => null), $id));
384 384
 		}
@@ -411,7 +411,7 @@ public function getParentNode($Model, $id = null, $fields = null, $recursive = n
411 411
  * @return array Array of nodes from top most parent to current node
412 412
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getPath
413 413
  */
414  
-	public function getPath($Model, $id = null, $fields = null, $recursive = null) {
  414
+	public function getPath(Model $Model, $id = null, $fields = null, $recursive = null) {
415 415
 		if (is_array($id)) {
416 416
 			extract (array_merge(array('id' => null), $id));
417 417
 		}
@@ -448,7 +448,7 @@ public function getPath($Model, $id = null, $fields = null, $recursive = null) {
448 448
  * @return boolean true on success, false on failure
449 449
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveDown
450 450
  */
451  
-	public function moveDown($Model, $id = null, $number = 1) {
  451
+	public function moveDown(Model $Model, $id = null, $number = 1) {
452 452
 		if (is_array($id)) {
453 453
 			extract (array_merge(array('id' => null), $id));
454 454
 		}
@@ -506,7 +506,7 @@ public function moveDown($Model, $id = null, $number = 1) {
506 506
  * @return boolean true on success, false on failure
507 507
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveUp
508 508
  */
509  
-	public function moveUp($Model, $id = null, $number = 1) {
  509
+	public function moveUp(Model $Model, $id = null, $number = 1) {
510 510
 		if (is_array($id)) {
511 511
 			extract (array_merge(array('id' => null), $id));
512 512
 		}
@@ -570,7 +570,7 @@ public function moveUp($Model, $id = null, $number = 1) {
570 570
  * @return boolean true on success, false on failure
571 571
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::recover
572 572
  */
573  
-	public function recover($Model, $mode = 'parent', $missingParentAction = null) {
  573
+	public function recover(Model $Model, $mode = 'parent', $missingParentAction = null) {
574 574
 		if (is_array($mode)) {
575 575
 			extract (array_merge(array('mode' => 'parent'), $mode));
576 576
 		}
@@ -649,7 +649,7 @@ public function recover($Model, $mode = 'parent', $missingParentAction = null) {
649 649
  * @return boolean true on success, false on failure
650 650
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::reorder
651 651
  */
652  
-	public function reorder($Model, $options = array()) {
  652
+	public function reorder(Model $Model, $options = array()) {
653 653
 		$options = array_merge(array('id' => null, 'field' => $Model->displayField, 'order' => 'ASC', 'verify' => true), $options);
654 654
 		extract($options);
655 655
 		if ($verify && !$this->verify($Model)) {
@@ -688,7 +688,7 @@ public function reorder($Model, $options = array()) {
688 688
  * @return boolean true on success, false on failure
689 689
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::removeFromTree
690 690
  */
691  
-	public function removeFromTree($Model, $id = null, $delete = false) {
  691
+	public function removeFromTree(Model $Model, $id = null, $delete = false) {
692 692
 		if (is_array($id)) {
693 693
 			extract (array_merge(array('id' => null), $id));
694 694
 		}
@@ -759,7 +759,7 @@ public function removeFromTree($Model, $id = null, $delete = false) {
759 759
  *  [incorrect left/right index,node id], message)
760 760
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::verify
761 761
  */
762  
-	public function verify($Model) {
  762
+	public function verify(Model $Model) {
763 763
 		extract($this->settings[$Model->alias]);
764 764
 		if (!$Model->find('count', array('conditions' => $scope))) {
765 765
 			return true;
@@ -831,7 +831,7 @@ public function verify($Model) {
831 831
  * @param boolean $created
832 832
  * @return boolean true on success, false on failure
833 833
  */
834  
-	protected function _setParent($Model, $parentId = null, $created = false) {
  834
+	protected function _setParent(Model $Model, $parentId = null, $created = false) {
835 835
 		extract($this->settings[$Model->alias]);
836 836
 		list($node) = array_values($Model->find('first', array(
837 837
 			'conditions' => array($scope, $Model->escapeField() => $Model->id),
@@ -903,7 +903,7 @@ protected function _setParent($Model, $parentId = null, $created = false) {
903 903
  * @param boolean $created
904 904
  * @return integer
905 905
  */
906  
-	protected function _getMax($Model, $scope, $right, $recursive = -1, $created = false) {
  906
+	protected function _getMax(Model $Model, $scope, $right, $recursive = -1, $created = false) {
907 907
 		$db = ConnectionManager::getDataSource($Model->useDbConfig);
908 908
 		if ($created) {
909 909
 			if (is_string($scope)) {
@@ -931,7 +931,7 @@ protected function _getMax($Model, $scope, $right, $recursive = -1, $created = f
931 931
  * @param integer $recursive
932 932
  * @return integer
933 933
  */
934  
-	protected function _getMin($Model, $scope, $left, $recursive = -1) {
  934
+	protected function _getMin(Model $Model, $scope, $left, $recursive = -1) {
935 935
 		$db = ConnectionManager::getDataSource($Model->useDbConfig);
936 936
 		$name = $Model->alias . '.' . $left;
937 937
 		list($edge) = array_values($Model->find('first', array(
@@ -955,7 +955,7 @@ protected function _getMin($Model, $scope, $left, $recursive = -1) {
955 955
  * @param string $field
956 956
  * @return void
957 957
  */
958  
-	protected function _sync($Model, $shift, $dir = '+', $conditions = array(), $created = false, $field = 'both') {
  958
+	protected function _sync(Model $Model, $shift, $dir = '+', $conditions = array(), $created = false, $field = 'both') {
959 959
 		$ModelRecursive = $Model->recursive;
960 960
 		extract($this->settings[$Model->alias]);
961 961
 		$Model->recursive = $recursive;
2  lib/Cake/Model/Datasource/Database/Postgres.php
@@ -348,7 +348,7 @@ public function name($data) {
348 348
  * @param boolean $quote
349 349
  * @return array
350 350
  */
351  
-	public function fields($model, $alias = null, $fields = array(), $quote = true) {
  351
+	public function fields(Model $model, $alias = null, $fields = array(), $quote = true) {
352 352
 		if (empty($alias)) {
353 353
 			$alias = $model->alias;
354 354
 		}
2  lib/Cake/Model/Datasource/Database/Sqlserver.php
@@ -266,7 +266,7 @@ public function describe($model) {
266 266
  * @param boolean $quote
267 267
  * @return array
268 268
  */
269  
-	public function fields($model, $alias = null, $fields = array(), $quote = true) {
  269
+	public function fields(Model $model, $alias = null, $fields = array(), $quote = true) {
270 270
 		if (empty($alias)) {
271 271
 			$alias = $model->alias;
272 272
 		}
22  lib/Cake/Model/Datasource/DboSource.php
@@ -1149,7 +1149,7 @@ protected function _filterResults(&$results, Model $model, $filtered = array())
1149 1149
  * @param array $stack
1150 1150
  * @return mixed
1151 1151
  */
1152  
-	public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
  1152
+	public function queryAssociation(Model $model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
1153 1153
 		if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
1154 1154
 			if (!is_array($resultSet)) {
1155 1155
 				throw new CakeException(__d('cake_dev', 'Error in Model %s', get_class($model)));
@@ -1291,7 +1291,7 @@ public function queryAssociation($model, &$linkModel, $type, $association, $asso
1291 1291
  * @param array $ids Array of IDs of associated records
1292 1292
  * @return array Association results
1293 1293
  */
1294  
-	public function fetchAssociated($model, $query, $ids) {
  1294
+	public function fetchAssociated(Model $model, $query, $ids) {
1295 1295
 		$query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query);
1296 1296
 		if (count($ids) > 1) {
1297 1297
 			$query = str_replace('= (', 'IN (', $query);
@@ -1435,7 +1435,7 @@ protected function _mergeAssociation(&$data, &$merge, $association, $type, $self
1435 1435
  * @param array $resultSet
1436 1436
  * @return mixed
1437 1437
  */
1438  
-	public function generateAssociationQuery($model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
  1438
+	public function generateAssociationQuery(Model $model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
1439 1439
 		$queryData = $this->_scrubQueryData($queryData);
1440 1440
 		$assocData = $this->_scrubQueryData($assocData);
1441 1441
 		$modelAlias = $model->alias;
@@ -1812,7 +1812,7 @@ public function update(Model $model, $fields = array(), $values = null, $conditi
1812 1812
  * @param boolean $alias Include the model alias in the field name
1813 1813
  * @return array Fields and values, quoted and prepared
1814 1814
  */
1815  
-	protected function _prepareUpdateFields($model, $fields, $quoteValues = true, $alias = false) {
  1815
+	protected function _prepareUpdateFields(Model $model, $fields, $quoteValues = true, $alias = false) {
1816 1816
 		$quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
1817 1817
 
1818 1818
 		$updates = array();
@@ -1879,7 +1879,7 @@ public function delete(Model $model, $conditions = null) {
1879 1879
  * @param mixed $conditions
1880 1880
  * @return array List of record IDs
1881 1881
  */
1882  
-	protected function _matchRecords($model, $conditions = null) {
  1882
+	protected function _matchRecords(Model $model, $conditions = null) {
1883 1883
 		if ($conditions === true) {
1884 1884
 			$conditions = $this->conditions(true);
1885 1885
 		} elseif ($conditions === null) {
@@ -1926,7 +1926,7 @@ protected function _matchRecords($model, $conditions = null) {
1926 1926
  * @param Model $model
1927 1927
  * @return array
1928 1928
  */
1929  
-	protected function _getJoins($model) {
  1929
+	protected function _getJoins(Model $model) {
1930 1930
 		$join = array();
1931 1931
 		$joins = array_merge($model->getAssociated('hasOne'), $model->getAssociated('belongsTo'));
1932 1932
 
@@ -1955,7 +1955,7 @@ protected function _getJoins($model) {
1955 1955
  * @param array $params Function parameters (any values must be quoted manually)
1956 1956
  * @return string An SQL calculation function
1957 1957
  */
1958  
-	public function calculate($model, $func, $params = array()) {
  1958
+	public function calculate(Model $model, $func, $params = array()) {
1959 1959
 		$params = (array)$params;
1960 1960
 
1961 1961
 		switch (strtolower($func)) {
@@ -2083,7 +2083,7 @@ public function lastInsertId($source = null) {
2083 2083
  * @see DboSource::update()
2084 2084
  * @see DboSource::conditions()
2085 2085
  */
2086  
-	public function defaultConditions($model, $conditions, $useAlias = true) {
  2086
+	public function defaultConditions(Model $model, $conditions, $useAlias = true) {
2087 2087
 		if (!empty($conditions)) {
2088 2088
 			return $conditions;
2089 2089
 		}
@@ -2139,7 +2139,7 @@ protected function _scrubQueryData($data) {
2139 2139
  * @param mixed $fields virtual fields to be used on query
2140 2140
  * @return array
2141 2141
  */
2142  
-	protected function _constructVirtualFields($model, $alias, $fields) {
  2142
+	protected function _constructVirtualFields(Model $model, $alias, $fields) {
2143 2143
 		$virtual = array();
2144 2144
 		foreach ($fields as $field) {
2145 2145
 			$virtualField = $this->name($alias . $this->virtualFieldSeparator . $field);
@@ -2158,7 +2158,7 @@ protected function _constructVirtualFields($model, $alias, $fields) {
2158 2158
  * @param boolean $quote If false, returns fields array unquoted
2159 2159
  * @return array
2160 2160
  */
2161  
-	public function fields($model, $alias = null, $fields = array(), $quote = true) {
  2161
+	public function fields(Model $model, $alias = null, $fields = array(), $quote = true) {
2162 2162
 		if (empty($alias)) {
2163 2163
 			$alias = $model->alias;
2164 2164
 		}
@@ -2673,7 +2673,7 @@ public function close() {
2673 2673
  * @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
2674 2674
  * @return boolean True if the table has a matching record, else false
2675 2675
  */
2676  
-	public function hasAny($Model, $sql) {
  2676
+	public function hasAny(Model $Model, $sql) {
2677 2677
 		$sql = $this->conditions($sql);
2678 2678
 		$table = $this->fullTableName($Model);
2679 2679
 		$alias = $this->alias . $this->name($Model->alias);
26  lib/Cake/Model/ModelBehavior.php
@@ -32,7 +32,7 @@
32 32
  * the model instance to be shifted onto the parameter list.
33 33
  *
34 34
  * {{{
35  
- * function doSomething($model, $arg1, $arg2) {
  35
+ * function doSomething(Model $model, $arg1, $arg2) {
36 36
  *		//do something
37 37
  * }
38 38
  * }}}
@@ -49,7 +49,7 @@
49 49
  * {{{
50 50
  * public $mapMethods = array('/do(\w+)/' => 'doSomething');
51 51
  *
52  
- * function doSomething($model, $method, $arg1, $arg2) {
  52
+ * function doSomething(Model $model, $method, $arg1, $arg2) {
53 53
  *		//do something
54 54
  * }
55 55
  * }}}
@@ -92,7 +92,7 @@ class ModelBehavior extends Object {
92 92
  * @param array $config Configuration settings for $model
93 93
  * @return void
94 94
  */
95  
-	public function setup($model, $config = array()) { }
  95
+	public function setup(Model $model, $config = array()) { }
96 96
 
97 97
 /**
98 98
  * Clean up any initialization this behavior has done on a model.  Called when a behavior is dynamically
@@ -102,7 +102,7 @@ public function setup($model, $config = array()) { }
102 102
  * @return void
103 103
  * @see BehaviorCollection::detach()
104 104
  */
105  
-	public function cleanup($model) {
  105
+	public function cleanup(Model $model) {
106 106
 		if (isset($this->settings[$model->alias])) {
107 107
 			unset($this->settings[$model->alias]);
108 108
 		}
@@ -118,7 +118,7 @@ public function cleanup($model) {
118 118
  * @return boolean|array False or null will abort the operation. You can return an array to replace the
119 119
  *   $query that will be eventually run.
120 120
  */
121  
-	public function beforeFind($model, $query) {
  121
+	public function beforeFind(Model $model, $query) {
122 122
 		return true;
123 123
 	}
124 124
 
@@ -130,7 +130,7 @@ public function beforeFind($model, $query) {
130 130
  * @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
131 131
  * @return mixed An array value will replace the value of $results - any other value will be ignored.
132 132
  */
133  
-	public function afterFind($model, $results, $primary) { }
  133
+	public function afterFind(Model $model, $results, $primary) { }
134 134
 
135 135
 /**
136 136
  * beforeValidate is called before a model is validated, you can use this callback to
@@ -140,7 +140,7 @@ public function afterFind($model, $results, $primary) { }
140 140
  * @param Model $model Model using this behavior
141 141
  * @return mixed False or null will abort the operation. Any other result will continue.
142 142
  */
143  
-	public function beforeValidate($model) {
  143
+	public function beforeValidate(Model $model) {
144 144
 		return true;
145 145
 	}
146 146
 
@@ -151,7 +151,7 @@ public function beforeValidate($model) {
151 151
  * @param Model $model Model using this behavior
152 152
  * @return mixed False if the operation should abort. Any other result will continue.
153 153
  */
154  
-	public function beforeSave($model) {
  154
+	public function beforeSave(Model $model) {
155 155
 		return true;
156 156
 	}
157 157
 
@@ -162,7 +162,7 @@ public function beforeSave($model) {
162 162
  * @param boolean $created True if this save created a new record
163 163
  * @return boolean
164 164
  */
165  
-	public function afterSave($model, $created) {
  165
+	public function afterSave(Model $model, $created) {
166 166
 		return true;
167 167
 	}
168 168
 
@@ -174,7 +174,7 @@ public function afterSave($model, $created) {
174 174
  * @param boolean $cascade If true records that depend on this record will also be deleted
175 175
  * @return mixed False if the operation should abort. Any other result will continue.
176 176
  */
177  
-	public function beforeDelete($model, $cascade = true) {
  177
+	public function beforeDelete(Model $model, $cascade = true) {
178 178
 		return true;
179 179
 	}
180 180
 
@@ -184,7 +184,7 @@ public function beforeDelete($model, $cascade = true) {
184 184
  * @param Model $model Model using this behavior
185 185
  * @return void
186 186
  */
187  
-	public function afterDelete($model) { }
  187
+	public function afterDelete(Model $model) { }
188 188
 
189 189
 /**
190 190
  * DataSource error callback
@@ -193,7 +193,7 @@ public function afterDelete($model) { }
193 193
  * @param string $error Error generated in DataSource
194 194
  * @return void
195 195
  */
196  
-	public function onError($model, $error) { }
  196
+	public function onError(Model $model, $error) { }
197 197
 
198 198
 /**
199 199
  * If $model's whitelist property is non-empty, $field will be added to it.
@@ -205,7 +205,7 @@ public function onError($model, $error) { }
205 205
  * @param string $field Field to be added to $model's whitelist
206 206
  * @return void
207 207
  */
208  
-	protected function _addToWhitelist($model, $field) {
  208
+	protected function _addToWhitelist(Model $model, $field) {
209 209
 		if (is_array($field)) {
210 210
 			foreach ($field as $f) {
211 211
 				$this->_addToWhitelist($model, $f);
2  lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
@@ -3644,7 +3644,7 @@ protected function _containments($Model, $contain = array()) {
3644 3644
  * @param array $expected
3645 3645
  * @return void
3646 3646
  */
3647  
-	protected function _assertBindings($Model, $expected = array()) {
  3647
+	protected function _assertBindings(Model $Model, $expected = array()) {
3648 3648
 		$expected = array_merge(array(
3649 3649
 			'belongsTo' => array(),
3650 3650
 			'hasOne' => array(),
32  lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
@@ -43,7 +43,7 @@ class TestBehavior extends ModelBehavior {
43 43
  * @param array $config
44 44
  * @return void
45 45
  */
46  
-	public function setup($model, $config = array()) {
  46
+	public function setup(Model $model, $config = array()) {
47 47
 		parent::setup($model, $config);
48 48
 		if (isset($config['mangle'])) {
49 49
 			$config['mangle'] .= ' mangled';
@@ -58,7 +58,7 @@ public function setup($model, $config = array()) {
58 58
  * @param mixed $query
59 59
  * @return void
60 60
  */
61  
-	public function beforeFind($model, $query) {
  61
+	public function beforeFind(Model $model, $query) {
62 62
 		$settings = $this->settings[$model->alias];
63 63
 		if (!isset($settings['beforeFind']) || $settings['beforeFind'] == 'off') {
64 64
 			return parent::beforeFind($model, $query);
@@ -86,7 +86,7 @@ public function beforeFind($model, $query) {
86 86
  * @param mixed $primary
87 87
  * @return void
88 88
  */
89  
-	public function afterFind($model, $results, $primary) {
  89
+	public function afterFind(Model $model, $results, $primary) {
90 90
 		$settings = $this->settings[$model->alias];
91 91
 		if (!isset($settings['afterFind']) || $settings['afterFind'] == 'off') {
92 92
 			return parent::afterFind($model, $results, $primary);
@@ -113,7 +113,7 @@ public function afterFind($model, $results, $primary) {
113 113
  * @param mixed $model
114 114
  * @return void
115 115
  */
116  
-	public function beforeSave($model) {
  116
+	public function beforeSave(Model $model) {
117 117
 		$settings = $this->settings[$model->alias];
118 118
 		if (!isset($settings['beforeSave']) || $settings['beforeSave'] == 'off') {
119 119
 			return parent::beforeSave($model);
@@ -139,7 +139,7 @@ public function beforeSave($model) {
139 139
  * @param mixed $created
140 140
  * @return void
141 141
  */
142  
-	public function afterSave($model, $created) {
  142
+	public function afterSave(Model $model, $created) {
143 143
 		$settings = $this->settings[$model->alias];
144 144
 		if (!isset($settings['afterSave']) || $settings['afterSave'] == 'off') {
145 145
 			return parent::afterSave($model, $created);
@@ -170,7 +170,7 @@ public function afterSave($model, $created) {
170 170
  * @param mixed $model
171 171
  * @return void
172 172
  */
173  
-	public function beforeValidate($model) {
  173
+	public function beforeValidate(Model $model) {
174 174
 		$settings = $this->settings[$model->alias];
175 175
 		if (!isset($settings['validate']) || $settings['validate'] == 'off') {
176 176
 			return parent::beforeValidate($model);
@@ -201,7 +201,7 @@ public function beforeValidate($model) {
201 201
  * @param bool $cascade
202 202
  * @return void
203 203
  */
204  
-	public function beforeDelete($model, $cascade = true) {
  204
+	public function beforeDelete(Model $model, $cascade = true) {
205 205
 		$settings = $this->settings[$model->alias];
206 206
 		if (!isset($settings['beforeDelete']) || $settings['beforeDelete'] == 'off') {
207 207
 			return parent::beforeDelete($model, $cascade);
@@ -229,7 +229,7 @@ public function beforeDelete($model, $cascade = true) {
229 229
  * @param mixed $model
230 230
  * @return void
231 231
  */
232  
-	public function afterDelete($model) {
  232
+	public function afterDelete(Model $model) {
233 233
 		$settings = $this->settings[$model->alias];
234 234
 		if (!isset($settings['afterDelete']) || $settings['afterDelete'] == 'off') {
235 235
 			return parent::afterDelete($model);
@@ -247,7 +247,7 @@ public function afterDelete($model) {
247 247
  * @param mixed $model
248 248
  * @return void
249 249
  */
250  
-	public function onError($model, $error) {
  250
+	public function onError(Model $model, $error) {
251 251
 		$settings = $this->settings[$model->alias];
252 252
 		if (!isset($settings['onError']) || $settings['onError'] == 'off') {
253 253
 			return parent::onError($model, $error);
@@ -261,7 +261,7 @@ public function onError($model, $error) {
261 261
  * @param mixed $model
262 262
  * @return void
263 263
  */
264  
-	public function beforeTest($model) {
  264
+	public function beforeTest(Model $model) {
265 265
 		if (!isset($model->beforeTestResult)) {
266 266
 			$model->beforeTestResult = array();
267 267
 		}
@@ -330,11 +330,11 @@ public function speakEnglish(Model $model, $method, $query) {
330 330
 class Test2Behavior extends TestBehavior {
331 331
 	public $mapMethods = array('/mappingRobot(\w+)/' => 'mapped');
332 332
 
333  
-	public function resolveMethod($model, $stuff) {
  333
+	public function resolveMethod(Model $model, $stuff) {
334 334
 
335 335
 	}
336 336
 
337  
-	public function mapped($model, $method, $query) {
  337
+	public function mapped(Model $model, $method, $query) {
338 338
 
339 339
 	}
340 340
 }
@@ -353,7 +353,7 @@ class Test3Behavior extends TestBehavior{
353 353
  * @package       Cake.Test.Case.Model
354 354
  */
355 355
 class Test4Behavior extends ModelBehavior{
356  
-	public function setup($model, $config = null) {
  356
+	public function setup(Model $model, $config = null) {
357 357
 		$model->bindModel(
358 358
 			array('hasMany' => array('Comment'))
359 359
 		);
@@ -366,7 +366,7 @@ public function setup($model, $config = null) {
366 366
  * @package       Cake.Test.Case.Model
367 367
  */
368 368
 class Test5Behavior extends ModelBehavior{
369  
-	public function setup($model, $config = null) {
  369
+	public function setup(Model $model, $config = null) {
370 370
 		$model->bindModel(
371 371
 			array('belongsTo' => array('User'))
372 372
 		);
@@ -379,7 +379,7 @@ public function setup($model, $config = null) {
379 379
  * @package       Cake.Test.Case.Model
380 380
  */
381 381
 class Test6Behavior extends ModelBehavior{
382  
-	public function setup($model, $config = null) {
  382
+	public function setup(Model $model, $config = null) {
383 383
 		$model->bindModel(
384 384
 			array('hasAndBelongsToMany' => array('Tag'))
385 385
 		);
@@ -392,7 +392,7 @@ public function setup($model, $config = null) {
392 392
  * @package       Cake.Test.Case.Model
393 393
  */
394 394
 class Test7Behavior extends ModelBehavior{
395  
-	public function setup($model, $config = null) {
  395
+	public function setup(Model $model, $config = null) {
396 396
 		$model->bindModel(
397 397
 			array('hasOne' => array('Attachment'))
398 398
 		);
4  lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
@@ -1055,7 +1055,7 @@ public function testGenerateAssociationQuerySelfJoin() {
1055 1055
  * @param mixed $model
1056 1056
  * @return void
1057 1057
  */
1058  
-	protected function _buildRelatedModels($model) {
  1058
+	protected function _buildRelatedModels(Model $model) {
1059 1059
 		foreach ($model->associations() as $type) {
1060 1060
 			foreach ($model->{$type} as $assoc => $assocData) {
1061 1061
 				if (is_string($assocData)) {
@@ -1077,7 +1077,7 @@ protected function _buildRelatedModels($model) {
1077 1077
  * @param mixed $binding
1078 1078
  * @return void
1079 1079
  */
1080  
-	protected function &_prepareAssociationQuery($model, &$queryData, $binding) {
  1080
+	protected function &_prepareAssociationQuery(Model $model, &$queryData, $binding) {
1081 1081
 		$type = $binding['type'];
1082 1082
 		$assoc = $binding['model'];
1083 1083
 		$assocData = $model->{$type}[$assoc];

0 notes on commit 4511208

Please sign in to comment.
Something went wrong with that request. Please try again.