Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

type hinting models

  • Loading branch information...
commit 45112088a1feef561a1f6965660107cf7f750515 1 parent 22452f6
@dereuromark dereuromark authored markstory committed
View
8 lib/Cake/Model/Behavior/AclBehavior.php
@@ -44,7 +44,7 @@ class AclBehavior extends ModelBehavior {
* @param array $config
* @return void
*/
- public function setup($model, $config = array()) {
+ public function setup(Model $model, $config = array()) {
if (isset($config[0])) {
$config['type'] = $config[0];
unset($config[0]);
@@ -74,7 +74,7 @@ public function setup($model, $config = array()) {
* @return array
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/acl.html#node
*/
- public function node($model, $ref = null, $type = null) {
+ public function node(Model $model, $ref = null, $type = null) {
if (empty($type)) {
$type = $this->_typeMaps[$this->settings[$model->name]['type']];
if (is_array($type)) {
@@ -95,7 +95,7 @@ public function node($model, $ref = null, $type = null) {
* @param boolean $created True if this is a new record
* @return void
*/
- public function afterSave($model, $created) {
+ public function afterSave(Model $model, $created) {
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
if (!is_array($types)) {
$types = array($types);
@@ -125,7 +125,7 @@ public function afterSave($model, $created) {
* @param Model $model
* @return void
*/
- public function afterDelete($model) {
+ public function afterDelete(Model $model) {
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
if (!is_array($types)) {
$types = array($types);
View
12 lib/Cake/Model/Behavior/ContainableBehavior.php
@@ -61,7 +61,7 @@ class ContainableBehavior extends ModelBehavior {
* @param array $settings Settings to override for model.
* @return void
*/
- public function setup($Model, $settings = array()) {
+ public function setup(Model $Model, $settings = array()) {
if (!isset($this->settings[$Model->alias])) {
$this->settings[$Model->alias] = array('recursive' => true, 'notices' => true, 'autoFields' => true);
}
@@ -89,7 +89,7 @@ public function setup($Model, $settings = array()) {
* @param array $query Query parameters as set by cake
* @return array
*/
- public function beforeFind($Model, $query) {
+ public function beforeFind(Model $Model, $query) {
$reset = (isset($query['reset']) ? $query['reset'] : true);
$noContain = (
(isset($this->runtime[$Model->alias]['contain']) && empty($this->runtime[$Model->alias]['contain'])) ||
@@ -225,7 +225,7 @@ public function beforeFind($Model, $query) {
* @return void
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html#using-containable
*/
- public function contain($Model) {
+ public function contain(Model $Model) {
$args = func_get_args();
$contain = call_user_func_array('am', array_slice($args, 1));
$this->runtime[$Model->alias]['contain'] = $contain;
@@ -239,7 +239,7 @@ public function contain($Model) {
* @param Model $Model Model on which to reset bindings
* @return void
*/
- public function resetBindings($Model) {
+ public function resetBindings(Model $Model) {
if (!empty($Model->__backOriginalAssociation)) {
$Model->__backAssociation = $Model->__backOriginalAssociation;
unset($Model->__backOriginalAssociation);
@@ -263,7 +263,7 @@ public function resetBindings($Model) {
* @param boolean $throwErrors Whether non-existent bindings show throw errors
* @return array Containments
*/
- public function containments($Model, $contain, $containments = array(), $throwErrors = null) {
+ public function containments(Model $Model, $contain, $containments = array(), $throwErrors = null) {
$options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery');
$keep = array();
if ($throwErrors === null) {
@@ -365,7 +365,7 @@ public function containments($Model, $contain, $containments = array(), $throwEr
* @param mixed $fields If array, fields to initially load, if false use $Model as primary model
* @return array Fields
*/
- public function fieldDependencies($Model, $map, $fields = array()) {
+ public function fieldDependencies(Model $Model, $map, $fields = array()) {
if ($fields === false) {
foreach ($map as $parent => $children) {
foreach ($children as $type => $bindings) {
View
22 lib/Cake/Model/Behavior/TranslateBehavior.php
@@ -62,7 +62,7 @@ class TranslateBehavior extends ModelBehavior {
* @param array $config Array of configuration information.
* @return mixed
*/
- public function setup($model, $config = array()) {
+ public function setup(Model $model, $config = array()) {
$db = ConnectionManager::getDataSource($model->useDbConfig);
if (!$db->connected) {
trigger_error(
@@ -84,7 +84,7 @@ public function setup($model, $config = array()) {
* @param Model $model Model being detached.
* @return void
*/
- public function cleanup($model) {
+ public function cleanup(Model $model) {
$this->unbindTranslation($model);
unset($this->settings[$model->alias]);
unset($this->runtime[$model->alias]);
@@ -97,7 +97,7 @@ public function cleanup($model) {
* @param array $query Array of Query parameters.
* @return array Modified query
*/
- public function beforeFind($model, $query) {
+ public function beforeFind(Model $model, $query) {
$this->runtime[$model->alias]['virtualFields'] = $model->virtualFields;
$locale = $this->_getLocale($model);
if (empty($locale)) {
@@ -263,7 +263,7 @@ protected function _addJoin(Model $model, $query, $field, $aliasField, $locale,
* @param boolean $primary Did the find originate on $model.
* @return array Modified results
*/
- public function afterFind($model, $results, $primary) {
+ public function afterFind(Model $model, $results, $primary) {
$model->virtualFields = $this->runtime[$model->alias]['virtualFields'];
$this->runtime[$model->alias]['virtualFields'] = $this->runtime[$model->alias]['fields'] = array();
$locale = $this->_getLocale($model);
@@ -309,7 +309,7 @@ public function afterFind($model, $results, $primary) {
* @param Model $model Model invalidFields was called on.
* @return boolean
*/
- public function beforeValidate($model) {
+ public function beforeValidate(Model $model) {
$locale = $this->_getLocale($model);
if (empty($locale)) {
return true;
@@ -343,7 +343,7 @@ public function beforeValidate($model) {
* @param boolean $created Whether or not the save created a record.
* @return void
*/
- public function afterSave($model, $created) {
+ public function afterSave(Model $model, $created) {
if (!isset($this->runtime[$model->alias]['beforeSave'])) {
return true;
}
@@ -386,7 +386,7 @@ public function afterSave($model, $created) {
* @param Model $model Model the callback was run on.
* @return void
*/
- public function afterDelete($model) {
+ public function afterDelete(Model $model) {
$RuntimeModel = $this->translateModel($model);
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
$RuntimeModel->deleteAll($conditions);
@@ -398,7 +398,7 @@ public function afterDelete($model) {
* @param Model $model Model the locale needs to be set/get on.
* @return mixed string or false
*/
- protected function _getLocale($model) {
+ protected function _getLocale(Model $model) {
if (!isset($model->locale) || is_null($model->locale)) {
$I18n = I18n::getInstance();
$I18n->l10n->get(Configure::read('Config.language'));
@@ -417,7 +417,7 @@ protected function _getLocale($model) {
* @param Model $model Model to get a translatemodel for.
* @return Model
*/
- public function translateModel($model) {
+ public function translateModel(Model $model) {
if (!isset($this->runtime[$model->alias]['model'])) {
if (!isset($model->translateModel) || empty($model->translateModel)) {
$className = 'I18nModel';
@@ -447,7 +447,7 @@ public function translateModel($model) {
* @param boolean $reset
* @return boolean
*/
- public function bindTranslation($model, $fields, $reset = true) {
+ public function bindTranslation(Model $model, $fields, $reset = true) {
if (is_string($fields)) {
$fields = array($fields);
}
@@ -525,7 +525,7 @@ public function bindTranslation($model, $fields, $reset = true) {
* unbind all original translations
* @return boolean
*/
- public function unbindTranslation($model, $fields = null) {
+ public function unbindTranslation(Model $model, $fields = null) {
if (empty($fields) && empty($this->settings[$model->alias])) {
return false;
}
View
40 lib/Cake/Model/Behavior/TreeBehavior.php
@@ -54,7 +54,7 @@ class TreeBehavior extends ModelBehavior {
* @param array $config array of configuration settings.
* @return void
*/
- public function setup($Model, $config = array()) {
+ public function setup(Model $Model, $config = array()) {
if (isset($config[0])) {
$config['type'] = $config[0];
unset($config[0]);
@@ -80,7 +80,7 @@ public function setup($Model, $config = array()) {
* @param boolean $created indicates whether the node just saved was created or updated
* @return boolean true on success, false on failure
*/
- public function afterSave($Model, $created) {
+ public function afterSave(Model $Model, $created) {
extract($this->settings[$Model->alias]);
if ($created) {
if ((isset($Model->data[$Model->alias][$parent])) && $Model->data[$Model->alias][$parent]) {
@@ -99,7 +99,7 @@ public function afterSave($Model, $created) {
* @param array $query Query parameters as set by cake
* @return array
*/
- public function beforeFind($Model, $query) {
+ public function beforeFind(Model $Model, $query) {
if ($Model->findQueryType == 'threaded' && !isset($query['parent'])) {
$query['parent'] = $this->settings[$Model->alias]['parent'];
}
@@ -115,7 +115,7 @@ public function beforeFind($Model, $query) {
* @param boolean $cascade
* @return boolean true to continue, false to abort the delete
*/
- public function beforeDelete($Model, $cascade = true) {
+ public function beforeDelete(Model $Model, $cascade = true) {
extract($this->settings[$Model->alias]);
$data = current($Model->find('first', array(
'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
@@ -149,7 +149,7 @@ public function beforeDelete($Model, $cascade = true) {
* @param Model $Model Model instance
* @return boolean true to continue, false to abort the save
*/
- public function beforeSave($Model) {
+ public function beforeSave(Model $Model) {
extract($this->settings[$Model->alias]);
$this->_addToWhitelist($Model, array($left, $right));
@@ -219,7 +219,7 @@ public function beforeSave($Model) {
* @return integer number of child nodes
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::childCount
*/
- public function childCount($Model, $id = null, $direct = false) {
+ public function childCount(Model $Model, $id = null, $direct = false) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@@ -265,7 +265,7 @@ public function childCount($Model, $id = null, $direct = false) {
* @return array Array of child nodes
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::children
*/
- public function children($Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
+ public function children(Model $Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@@ -322,7 +322,7 @@ public function children($Model, $id = null, $direct = false, $fields = null, $o
* @return array An associative array of records, where the id is the key, and the display field is the value
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::generateTreeList
*/
- public function generateTreeList($Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
+ public function generateTreeList(Model $Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
$overrideRecursive = $recursive;
extract($this->settings[$Model->alias]);
if (!is_null($overrideRecursive)) {
@@ -378,7 +378,7 @@ public function generateTreeList($Model, $conditions = null, $keyPath = null, $v
* @return array|boolean Array of data for the parent node
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getParentNode
*/
- public function getParentNode($Model, $id = null, $fields = null, $recursive = null) {
+ public function getParentNode(Model $Model, $id = null, $fields = null, $recursive = null) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@@ -411,7 +411,7 @@ public function getParentNode($Model, $id = null, $fields = null, $recursive = n
* @return array Array of nodes from top most parent to current node
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getPath
*/
- public function getPath($Model, $id = null, $fields = null, $recursive = null) {
+ public function getPath(Model $Model, $id = null, $fields = null, $recursive = null) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@@ -448,7 +448,7 @@ public function getPath($Model, $id = null, $fields = null, $recursive = null) {
* @return boolean true on success, false on failure
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveDown
*/
- public function moveDown($Model, $id = null, $number = 1) {
+ public function moveDown(Model $Model, $id = null, $number = 1) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@@ -506,7 +506,7 @@ public function moveDown($Model, $id = null, $number = 1) {
* @return boolean true on success, false on failure
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveUp
*/
- public function moveUp($Model, $id = null, $number = 1) {
+ public function moveUp(Model $Model, $id = null, $number = 1) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@@ -570,7 +570,7 @@ public function moveUp($Model, $id = null, $number = 1) {
* @return boolean true on success, false on failure
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::recover
*/
- public function recover($Model, $mode = 'parent', $missingParentAction = null) {
+ public function recover(Model $Model, $mode = 'parent', $missingParentAction = null) {
if (is_array($mode)) {
extract (array_merge(array('mode' => 'parent'), $mode));
}
@@ -649,7 +649,7 @@ public function recover($Model, $mode = 'parent', $missingParentAction = null) {
* @return boolean true on success, false on failure
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::reorder
*/
- public function reorder($Model, $options = array()) {
+ public function reorder(Model $Model, $options = array()) {
$options = array_merge(array('id' => null, 'field' => $Model->displayField, 'order' => 'ASC', 'verify' => true), $options);
extract($options);
if ($verify && !$this->verify($Model)) {
@@ -688,7 +688,7 @@ public function reorder($Model, $options = array()) {
* @return boolean true on success, false on failure
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::removeFromTree
*/
- public function removeFromTree($Model, $id = null, $delete = false) {
+ public function removeFromTree(Model $Model, $id = null, $delete = false) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@@ -759,7 +759,7 @@ public function removeFromTree($Model, $id = null, $delete = false) {
* [incorrect left/right index,node id], message)
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::verify
*/
- public function verify($Model) {
+ public function verify(Model $Model) {
extract($this->settings[$Model->alias]);
if (!$Model->find('count', array('conditions' => $scope))) {
return true;
@@ -831,7 +831,7 @@ public function verify($Model) {
* @param boolean $created
* @return boolean true on success, false on failure
*/
- protected function _setParent($Model, $parentId = null, $created = false) {
+ protected function _setParent(Model $Model, $parentId = null, $created = false) {
extract($this->settings[$Model->alias]);
list($node) = array_values($Model->find('first', array(
'conditions' => array($scope, $Model->escapeField() => $Model->id),
@@ -903,7 +903,7 @@ protected function _setParent($Model, $parentId = null, $created = false) {
* @param boolean $created
* @return integer
*/
- protected function _getMax($Model, $scope, $right, $recursive = -1, $created = false) {
+ protected function _getMax(Model $Model, $scope, $right, $recursive = -1, $created = false) {
$db = ConnectionManager::getDataSource($Model->useDbConfig);
if ($created) {
if (is_string($scope)) {
@@ -931,7 +931,7 @@ protected function _getMax($Model, $scope, $right, $recursive = -1, $created = f
* @param integer $recursive
* @return integer
*/
- protected function _getMin($Model, $scope, $left, $recursive = -1) {
+ protected function _getMin(Model $Model, $scope, $left, $recursive = -1) {
$db = ConnectionManager::getDataSource($Model->useDbConfig);
$name = $Model->alias . '.' . $left;
list($edge) = array_values($Model->find('first', array(
@@ -955,7 +955,7 @@ protected function _getMin($Model, $scope, $left, $recursive = -1) {
* @param string $field
* @return void
*/
- protected function _sync($Model, $shift, $dir = '+', $conditions = array(), $created = false, $field = 'both') {
+ protected function _sync(Model $Model, $shift, $dir = '+', $conditions = array(), $created = false, $field = 'both') {
$ModelRecursive = $Model->recursive;
extract($this->settings[$Model->alias]);
$Model->recursive = $recursive;
View
2  lib/Cake/Model/Datasource/Database/Postgres.php
@@ -348,7 +348,7 @@ public function name($data) {
* @param boolean $quote
* @return array
*/
- public function fields($model, $alias = null, $fields = array(), $quote = true) {
+ public function fields(Model $model, $alias = null, $fields = array(), $quote = true) {
if (empty($alias)) {
$alias = $model->alias;
}
View
2  lib/Cake/Model/Datasource/Database/Sqlserver.php
@@ -266,7 +266,7 @@ public function describe($model) {
* @param boolean $quote
* @return array
*/
- public function fields($model, $alias = null, $fields = array(), $quote = true) {
+ public function fields(Model $model, $alias = null, $fields = array(), $quote = true) {
if (empty($alias)) {
$alias = $model->alias;
}
View
22 lib/Cake/Model/Datasource/DboSource.php
@@ -1149,7 +1149,7 @@ protected function _filterResults(&$results, Model $model, $filtered = array())
* @param array $stack
* @return mixed
*/
- public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
+ public function queryAssociation(Model $model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
if (!is_array($resultSet)) {
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
* @param array $ids Array of IDs of associated records
* @return array Association results
*/
- public function fetchAssociated($model, $query, $ids) {
+ public function fetchAssociated(Model $model, $query, $ids) {
$query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query);
if (count($ids) > 1) {
$query = str_replace('= (', 'IN (', $query);
@@ -1435,7 +1435,7 @@ protected function _mergeAssociation(&$data, &$merge, $association, $type, $self
* @param array $resultSet
* @return mixed
*/
- public function generateAssociationQuery($model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
+ public function generateAssociationQuery(Model $model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
$queryData = $this->_scrubQueryData($queryData);
$assocData = $this->_scrubQueryData($assocData);
$modelAlias = $model->alias;
@@ -1812,7 +1812,7 @@ public function update(Model $model, $fields = array(), $values = null, $conditi
* @param boolean $alias Include the model alias in the field name
* @return array Fields and values, quoted and prepared
*/
- protected function _prepareUpdateFields($model, $fields, $quoteValues = true, $alias = false) {
+ protected function _prepareUpdateFields(Model $model, $fields, $quoteValues = true, $alias = false) {
$quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
$updates = array();
@@ -1879,7 +1879,7 @@ public function delete(Model $model, $conditions = null) {
* @param mixed $conditions
* @return array List of record IDs
*/
- protected function _matchRecords($model, $conditions = null) {
+ protected function _matchRecords(Model $model, $conditions = null) {
if ($conditions === true) {
$conditions = $this->conditions(true);
} elseif ($conditions === null) {
@@ -1926,7 +1926,7 @@ protected function _matchRecords($model, $conditions = null) {
* @param Model $model
* @return array
*/
- protected function _getJoins($model) {
+ protected function _getJoins(Model $model) {
$join = array();
$joins = array_merge($model->getAssociated('hasOne'), $model->getAssociated('belongsTo'));
@@ -1955,7 +1955,7 @@ protected function _getJoins($model) {
* @param array $params Function parameters (any values must be quoted manually)
* @return string An SQL calculation function
*/
- public function calculate($model, $func, $params = array()) {
+ public function calculate(Model $model, $func, $params = array()) {
$params = (array)$params;
switch (strtolower($func)) {
@@ -2083,7 +2083,7 @@ public function lastInsertId($source = null) {
* @see DboSource::update()
* @see DboSource::conditions()
*/
- public function defaultConditions($model, $conditions, $useAlias = true) {
+ public function defaultConditions(Model $model, $conditions, $useAlias = true) {
if (!empty($conditions)) {
return $conditions;
}
@@ -2139,7 +2139,7 @@ protected function _scrubQueryData($data) {
* @param mixed $fields virtual fields to be used on query
* @return array
*/
- protected function _constructVirtualFields($model, $alias, $fields) {
+ protected function _constructVirtualFields(Model $model, $alias, $fields) {
$virtual = array();
foreach ($fields as $field) {
$virtualField = $this->name($alias . $this->virtualFieldSeparator . $field);
@@ -2158,7 +2158,7 @@ protected function _constructVirtualFields($model, $alias, $fields) {
* @param boolean $quote If false, returns fields array unquoted
* @return array
*/
- public function fields($model, $alias = null, $fields = array(), $quote = true) {
+ public function fields(Model $model, $alias = null, $fields = array(), $quote = true) {
if (empty($alias)) {
$alias = $model->alias;
}
@@ -2673,7 +2673,7 @@ public function close() {
* @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
* @return boolean True if the table has a matching record, else false
*/
- public function hasAny($Model, $sql) {
+ public function hasAny(Model $Model, $sql) {
$sql = $this->conditions($sql);
$table = $this->fullTableName($Model);
$alias = $this->alias . $this->name($Model->alias);
View
26 lib/Cake/Model/ModelBehavior.php
@@ -32,7 +32,7 @@
* the model instance to be shifted onto the parameter list.
*
* {{{
- * function doSomething($model, $arg1, $arg2) {
+ * function doSomething(Model $model, $arg1, $arg2) {
* //do something
* }
* }}}
@@ -49,7 +49,7 @@
* {{{
* public $mapMethods = array('/do(\w+)/' => 'doSomething');
*
- * function doSomething($model, $method, $arg1, $arg2) {
+ * function doSomething(Model $model, $method, $arg1, $arg2) {
* //do something
* }
* }}}
@@ -92,7 +92,7 @@ class ModelBehavior extends Object {
* @param array $config Configuration settings for $model
* @return void
*/
- public function setup($model, $config = array()) { }
+ public function setup(Model $model, $config = array()) { }
/**
* 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()) { }
* @return void
* @see BehaviorCollection::detach()
*/
- public function cleanup($model) {
+ public function cleanup(Model $model) {
if (isset($this->settings[$model->alias])) {
unset($this->settings[$model->alias]);
}
@@ -118,7 +118,7 @@ public function cleanup($model) {
* @return boolean|array False or null will abort the operation. You can return an array to replace the
* $query that will be eventually run.
*/
- public function beforeFind($model, $query) {
+ public function beforeFind(Model $model, $query) {
return true;
}
@@ -130,7 +130,7 @@ public function beforeFind($model, $query) {
* @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
* @return mixed An array value will replace the value of $results - any other value will be ignored.
*/
- public function afterFind($model, $results, $primary) { }
+ public function afterFind(Model $model, $results, $primary) { }
/**
* beforeValidate is called before a model is validated, you can use this callback to
@@ -140,7 +140,7 @@ public function afterFind($model, $results, $primary) { }
* @param Model $model Model using this behavior
* @return mixed False or null will abort the operation. Any other result will continue.
*/
- public function beforeValidate($model) {
+ public function beforeValidate(Model $model) {
return true;
}
@@ -151,7 +151,7 @@ public function beforeValidate($model) {
* @param Model $model Model using this behavior
* @return mixed False if the operation should abort. Any other result will continue.
*/
- public function beforeSave($model) {
+ public function beforeSave(Model $model) {
return true;
}
@@ -162,7 +162,7 @@ public function beforeSave($model) {
* @param boolean $created True if this save created a new record
* @return boolean
*/
- public function afterSave($model, $created) {
+ public function afterSave(Model $model, $created) {
return true;
}
@@ -174,7 +174,7 @@ public function afterSave($model, $created) {
* @param boolean $cascade If true records that depend on this record will also be deleted
* @return mixed False if the operation should abort. Any other result will continue.
*/
- public function beforeDelete($model, $cascade = true) {
+ public function beforeDelete(Model $model, $cascade = true) {
return true;
}
@@ -184,7 +184,7 @@ public function beforeDelete($model, $cascade = true) {
* @param Model $model Model using this behavior
* @return void
*/
- public function afterDelete($model) { }
+ public function afterDelete(Model $model) { }
/**
* DataSource error callback
@@ -193,7 +193,7 @@ public function afterDelete($model) { }
* @param string $error Error generated in DataSource
* @return void
*/
- public function onError($model, $error) { }
+ public function onError(Model $model, $error) { }
/**
* If $model's whitelist property is non-empty, $field will be added to it.
@@ -205,7 +205,7 @@ public function onError($model, $error) { }
* @param string $field Field to be added to $model's whitelist
* @return void
*/
- protected function _addToWhitelist($model, $field) {
+ protected function _addToWhitelist(Model $model, $field) {
if (is_array($field)) {
foreach ($field as $f) {
$this->_addToWhitelist($model, $f);
View
2  lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
@@ -3644,7 +3644,7 @@ protected function _containments($Model, $contain = array()) {
* @param array $expected
* @return void
*/
- protected function _assertBindings($Model, $expected = array()) {
+ protected function _assertBindings(Model $Model, $expected = array()) {
$expected = array_merge(array(
'belongsTo' => array(),
'hasOne' => array(),
View
32 lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
@@ -43,7 +43,7 @@ class TestBehavior extends ModelBehavior {
* @param array $config
* @return void
*/
- public function setup($model, $config = array()) {
+ public function setup(Model $model, $config = array()) {
parent::setup($model, $config);
if (isset($config['mangle'])) {
$config['mangle'] .= ' mangled';
@@ -58,7 +58,7 @@ public function setup($model, $config = array()) {
* @param mixed $query
* @return void
*/
- public function beforeFind($model, $query) {
+ public function beforeFind(Model $model, $query) {
$settings = $this->settings[$model->alias];
if (!isset($settings['beforeFind']) || $settings['beforeFind'] == 'off') {
return parent::beforeFind($model, $query);
@@ -86,7 +86,7 @@ public function beforeFind($model, $query) {
* @param mixed $primary
* @return void
*/
- public function afterFind($model, $results, $primary) {
+ public function afterFind(Model $model, $results, $primary) {
$settings = $this->settings[$model->alias];
if (!isset($settings['afterFind']) || $settings['afterFind'] == 'off') {
return parent::afterFind($model, $results, $primary);
@@ -113,7 +113,7 @@ public function afterFind($model, $results, $primary) {
* @param mixed $model
* @return void
*/
- public function beforeSave($model) {
+ public function beforeSave(Model $model) {
$settings = $this->settings[$model->alias];
if (!isset($settings['beforeSave']) || $settings['beforeSave'] == 'off') {
return parent::beforeSave($model);
@@ -139,7 +139,7 @@ public function beforeSave($model) {
* @param mixed $created
* @return void
*/
- public function afterSave($model, $created) {
+ public function afterSave(Model $model, $created) {
$settings = $this->settings[$model->alias];
if (!isset($settings['afterSave']) || $settings['afterSave'] == 'off') {
return parent::afterSave($model, $created);
@@ -170,7 +170,7 @@ public function afterSave($model, $created) {
* @param mixed $model
* @return void
*/
- public function beforeValidate($model) {
+ public function beforeValidate(Model $model) {
$settings = $this->settings[$model->alias];
if (!isset($settings['validate']) || $settings['validate'] == 'off') {
return parent::beforeValidate($model);
@@ -201,7 +201,7 @@ public function beforeValidate($model) {
* @param bool $cascade
* @return void
*/
- public function beforeDelete($model, $cascade = true) {
+ public function beforeDelete(Model $model, $cascade = true) {
$settings = $this->settings[$model->alias];
if (!isset($settings['beforeDelete']) || $settings['beforeDelete'] == 'off') {
return parent::beforeDelete($model, $cascade);
@@ -229,7 +229,7 @@ public function beforeDelete($model, $cascade = true) {
* @param mixed $model
* @return void
*/
- public function afterDelete($model) {
+ public function afterDelete(Model $model) {
$settings = $this->settings[$model->alias];
if (!isset($settings['afterDelete']) || $settings['afterDelete'] == 'off') {
return parent::afterDelete($model);
@@ -247,7 +247,7 @@ public function afterDelete($model) {
* @param mixed $model
* @return void
*/
- public function onError($model, $error) {
+ public function onError(Model $model, $error) {
$settings = $this->settings[$model->alias];
if (!isset($settings['onError']) || $settings['onError'] == 'off') {
return parent::onError($model, $error);
@@ -261,7 +261,7 @@ public function onError($model, $error) {
* @param mixed $model
* @return void
*/
- public function beforeTest($model) {
+ public function beforeTest(Model $model) {
if (!isset($model->beforeTestResult)) {
$model->beforeTestResult = array();
}
@@ -330,11 +330,11 @@ public function speakEnglish(Model $model, $method, $query) {
class Test2Behavior extends TestBehavior {
public $mapMethods = array('/mappingRobot(\w+)/' => 'mapped');
- public function resolveMethod($model, $stuff) {
+ public function resolveMethod(Model $model, $stuff) {
}
- public function mapped($model, $method, $query) {
+ public function mapped(Model $model, $method, $query) {
}
}
@@ -353,7 +353,7 @@ class Test3Behavior extends TestBehavior{
* @package Cake.Test.Case.Model
*/
class Test4Behavior extends ModelBehavior{
- public function setup($model, $config = null) {
+ public function setup(Model $model, $config = null) {
$model->bindModel(
array('hasMany' => array('Comment'))
);
@@ -366,7 +366,7 @@ public function setup($model, $config = null) {
* @package Cake.Test.Case.Model
*/
class Test5Behavior extends ModelBehavior{
- public function setup($model, $config = null) {
+ public function setup(Model $model, $config = null) {
$model->bindModel(
array('belongsTo' => array('User'))
);
@@ -379,7 +379,7 @@ public function setup($model, $config = null) {
* @package Cake.Test.Case.Model
*/
class Test6Behavior extends ModelBehavior{
- public function setup($model, $config = null) {
+ public function setup(Model $model, $config = null) {
$model->bindModel(
array('hasAndBelongsToMany' => array('Tag'))
);
@@ -392,7 +392,7 @@ public function setup($model, $config = null) {
* @package Cake.Test.Case.Model
*/
class Test7Behavior extends ModelBehavior{
- public function setup($model, $config = null) {
+ public function setup(Model $model, $config = null) {
$model->bindModel(
array('hasOne' => array('Attachment'))
);
View
4 lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
@@ -1055,7 +1055,7 @@ public function testGenerateAssociationQuerySelfJoin() {
* @param mixed $model
* @return void
*/
- protected function _buildRelatedModels($model) {
+ protected function _buildRelatedModels(Model $model) {
foreach ($model->associations() as $type) {
foreach ($model->{$type} as $assoc => $assocData) {
if (is_string($assocData)) {
@@ -1077,7 +1077,7 @@ protected function _buildRelatedModels($model) {
* @param mixed $binding
* @return void
*/
- protected function &_prepareAssociationQuery($model, &$queryData, $binding) {
+ protected function &_prepareAssociationQuery(Model $model, &$queryData, $binding) {
$type = $binding['type'];
$assoc = $binding['model'];
$assocData = $model->{$type}[$assoc];
Please sign in to comment.
Something went wrong with that request. Please try again.