Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '2.1-type-hinting-corrections' into 2.1

  • Loading branch information...
commit 7665f369fac0031fdd14909e1d14ba0cd0df9657 2 parents 677f070 + e958e6c
@markstory markstory authored
Showing with 229 additions and 231 deletions.
  1. +1 −1  lib/Cake/Cache/Engine/XcacheEngine.php
  2. +2 −1  lib/Cake/Console/Command/AclShell.php
  3. +1 −1  lib/Cake/Console/Command/Task/DbConfigTask.php
  4. +3 −3 lib/Cake/Console/Command/Task/ExtractTask.php
  5. +5 −5 lib/Cake/Console/Command/Task/ModelTask.php
  6. +1 −1  lib/Cake/Console/Command/Task/ViewTask.php
  7. +5 −5 lib/Cake/Controller/Component.php
  8. +1 −1  lib/Cake/Controller/Component/Acl/AclInterface.php
  9. +1 −1  lib/Cake/Controller/Component/Acl/DbAcl.php
  10. +1 −1  lib/Cake/Controller/Component/Acl/IniAcl.php
  11. +1 −1  lib/Cake/Controller/Component/Acl/PhpAcl.php
  12. +1 −1  lib/Cake/Controller/Component/Auth/BaseAuthorize.php
  13. +1 −1  lib/Cake/Controller/Component/Auth/ControllerAuthorize.php
  14. +3 −3 lib/Cake/Controller/Component/AuthComponent.php
  15. +1 −1  lib/Cake/Controller/Component/CookieComponent.php
  16. +1 −1  lib/Cake/Controller/Component/EmailComponent.php
  17. +5 −5 lib/Cake/Controller/Component/RequestHandlerComponent.php
  18. +8 −8 lib/Cake/Controller/Component/SecurityComponent.php
  19. +2 −2 lib/Cake/Core/App.php
  20. +2 −2 lib/Cake/Event/CakeEventManager.php
  21. +8 −8 lib/Cake/I18n/L10n.php
  22. +4 −4 lib/Cake/Model/Behavior/AclBehavior.php
  23. +9 −9 lib/Cake/Model/Behavior/ContainableBehavior.php
  24. +14 −14 lib/Cake/Model/Behavior/TranslateBehavior.php
  25. +20 −20 lib/Cake/Model/Behavior/TreeBehavior.php
  26. +1 −1  lib/Cake/Model/CakeSchema.php
  27. +2 −2 lib/Cake/Model/Datasource/Database/Postgres.php
  28. +2 −2 lib/Cake/Model/Datasource/Database/Sqlserver.php
  29. +14 −14 lib/Cake/Model/Datasource/DboSource.php
  30. +1 −1  lib/Cake/Model/Model.php
  31. +13 −13 lib/Cake/Model/ModelBehavior.php
  32. +1 −1  lib/Cake/Network/CakeResponse.php
  33. +1 −1  lib/Cake/Network/Http/HttpSocket.php
  34. +2 −2 lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php
  35. +1 −1  lib/Cake/Test/Case/Console/Command/ApiShellTest.php
  36. +1 −1  lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php
  37. +1 −2  lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php
  38. +1 −1  lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php
  39. +1 −1  lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
  40. +1 −1  lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php
  41. +4 −4 lib/Cake/Test/Case/Controller/ComponentTest.php
  42. +5 −5 lib/Cake/Test/Case/Controller/ControllerTest.php
  43. +3 −3 lib/Cake/Test/Case/Core/AppTest.php
  44. +1 −1  lib/Cake/Test/Case/Error/ExceptionRendererTest.php
  45. +5 −5 lib/Cake/Test/Case/I18n/I18nTest.php
  46. +1 −1  lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
  47. +1 −1  lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php
  48. +16 −16 lib/Cake/Test/Case/Model/BehaviorCollectionTest.php
  49. +2 −2 lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
  50. +1 −1  lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php
  51. +1 −1  lib/Cake/Test/Case/Model/ModelIntegrationTest.php
  52. +2 −2 lib/Cake/Test/Case/Model/ModelValidationTest.php
  53. +8 −8 lib/Cake/Test/Case/Model/models.php
  54. +1 −1  lib/Cake/Test/Case/Routing/DispatcherTest.php
  55. +1 −1  lib/Cake/Test/Case/Utility/FileTest.php
  56. +1 −1  lib/Cake/Test/Case/View/Helper/CacheHelperTest.php
  57. +3 −3 lib/Cake/Test/Fixture/DomainFixture.php
  58. +3 −3 lib/Cake/Test/Fixture/DomainsSiteFixture.php
  59. +3 −3 lib/Cake/Test/Fixture/SiteFixture.php
  60. +1 −1  lib/Cake/Test/test_app/View/Emails/html/default.ctp
  61. +1 −1  lib/Cake/TestSuite/CakeTestLoader.php
  62. +1 −3 lib/Cake/TestSuite/CakeTestSuiteCommand.php
  63. +1 −1  lib/Cake/TestSuite/Coverage/BaseCoverageReport.php
  64. +1 −1  lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php
  65. +1 −1  lib/Cake/Utility/File.php
  66. +1 −1  lib/Cake/Utility/Sanitize.php
  67. +4 −4 lib/Cake/Utility/Set.php
  68. +2 −2 lib/Cake/Utility/String.php
  69. +1 −1  lib/Cake/View/Helper/FormHelper.php
  70. +1 −1  lib/Cake/View/Helper/HtmlHelper.php
  71. +1 −1  lib/Cake/View/Helper/RssHelper.php
  72. +1 −1  lib/Cake/View/JsonView.php
  73. +3 −3 lib/Cake/View/MediaView.php
  74. +2 −2 lib/Cake/View/View.php
  75. +1 −1  lib/Cake/View/XmlView.php
View
2  lib/Cake/Cache/Engine/XcacheEngine.php
@@ -165,7 +165,7 @@ protected function _auth($reverse = false) {
}
if (!empty($this->settings[$setting])) {
$_SERVER[$key] = $this->settings[$setting];
- } else if (!empty($this->settings[$key])) {
+ } elseif (!empty($this->settings[$key])) {
$_SERVER[$key] = $this->settings[$key];
} else {
$_SERVER[$key] = $value;
View
3  lib/Cake/Console/Command/AclShell.php
@@ -17,6 +17,7 @@
*/
App::uses('AppShell', 'Console/Command');
+App::uses('Controller', 'Controller');
App::uses('ComponentCollection', 'Controller');
App::uses('AclComponent', 'Controller/Component');
App::uses('DbAcl', 'Model');
@@ -90,7 +91,7 @@ public function startup() {
if (!in_array($this->command, array('initdb'))) {
$collection = new ComponentCollection();
$this->Acl = new AclComponent($collection);
- $controller = null;
+ $controller = new Controller();
$this->Acl->startup($controller);
}
}
View
2  lib/Cake/Console/Command/Task/DbConfigTask.php
@@ -100,7 +100,7 @@ protected function _interactive() {
if (preg_match('/[^a-z0-9_]/i', $name)) {
$name = '';
$this->out(__d('cake_console', 'The name may only contain unaccented latin characters, numbers or underscores'));
- } else if (preg_match('/^[^a-z_]/i', $name)) {
+ } elseif (preg_match('/^[^a-z_]/i', $name)) {
$name = '';
$this->out(__d('cake_console', 'The name must start with an unaccented latin character or an underscore'));
}
View
6 lib/Cake/Console/Command/Task/ExtractTask.php
@@ -118,7 +118,7 @@ public function execute() {
}
if (isset($this->params['paths'])) {
$this->_paths = explode(',', $this->params['paths']);
- } else if (isset($this->params['plugin'])) {
+ } elseif (isset($this->params['plugin'])) {
$plugin = Inflector::camelize($this->params['plugin']);
if (!CakePlugin::loaded($plugin)) {
CakePlugin::load($plugin);
@@ -159,7 +159,7 @@ public function execute() {
if (isset($this->params['output'])) {
$this->_output = $this->params['output'];
- } else if (isset($this->params['plugin'])) {
+ } elseif (isset($this->params['plugin'])) {
$this->_output = $this->_paths[0] . DS . 'Locale';
} else {
$message = __d('cake_console', "What is the path you would like to output?\n[Q]uit", $this->_paths[0] . DS . 'Locale');
@@ -594,7 +594,7 @@ protected function _getStrings(&$position, $target) {
$position++;
}
$strings[] = $string;
- } else if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
+ } elseif ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
$strings[] = $this->_formatString($this->_tokens[$position][1]);
}
$position++;
View
10 lib/Cake/Console/Command/Task/ModelTask.php
@@ -534,7 +534,7 @@ public function doAssociations($model) {
* @param array $associations Array of in progress associations
* @return array $associations with belongsTo added in.
*/
- public function findBelongsTo($model, $associations) {
+ public function findBelongsTo(Model $model, $associations) {
$fields = $model->schema(true);
foreach ($fields as $fieldName => $field) {
$offset = strpos($fieldName, '_id');
@@ -563,7 +563,7 @@ public function findBelongsTo($model, $associations) {
* @param array $associations Array of in progress associations
* @return array $associations with hasOne and hasMany added in.
*/
- public function findHasOneAndMany($model, $associations) {
+ public function findHasOneAndMany(Model $model, $associations) {
$foreignKey = $this->_modelKey($model->name);
foreach ($this->_tables as $otherTable) {
$tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable);
@@ -606,7 +606,7 @@ public function findHasOneAndMany($model, $associations) {
* @param array $associations Array of in-progress associations
* @return array $associations with hasAndBelongsToMany added in.
*/
- public function findHasAndBelongsToMany($model, $associations) {
+ public function findHasAndBelongsToMany(Model $model, $associations) {
$foreignKey = $this->_modelKey($model->name);
foreach ($this->_tables as $otherTable) {
$tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable);
@@ -646,7 +646,7 @@ public function findHasAndBelongsToMany($model, $associations) {
* @param array $associations Array of associations to be confirmed.
* @return array Array of confirmed associations
*/
- public function confirmAssociations($model, $associations) {
+ public function confirmAssociations(Model $model, $associations) {
foreach ($associations as $type => $settings) {
if (!empty($associations[$type])) {
foreach ($associations[$type] as $i => $assoc) {
@@ -672,7 +672,7 @@ public function confirmAssociations($model, $associations) {
* @param array $associations Array of associations.
* @return array Array of associations.
*/
- public function doMoreAssociations($model, $associations) {
+ public function doMoreAssociations(Model $model, $associations) {
$prompt = __d('cake_console', 'Would you like to define some additional model associations?');
$wannaDoMoreAssoc = $this->in($prompt, array('y', 'n'), 'n');
$possibleKeys = $this->_generatePossibleKeys();
View
2  lib/Cake/Console/Command/Task/ViewTask.php
@@ -448,7 +448,7 @@ public function getOptionParser() {
* @param Model $model
* @return array $associations
*/
- protected function _associations($model) {
+ protected function _associations(Model $model) {
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
$associations = array();
View
10 lib/Cake/Controller/Component.php
@@ -106,7 +106,7 @@ public function __get($name) {
* @return void
* @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::initialize
*/
- public function initialize($controller) { }
+ public function initialize(Controller $controller) { }
/**
* Called after the Controller::beforeFilter() and before the controller action
@@ -115,7 +115,7 @@ public function initialize($controller) { }
* @return void
* @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::startup
*/
- public function startup($controller) { }
+ public function startup(Controller $controller) { }
/**
* Called after the Controller::beforeRender(), after the view class is loaded, and before the
@@ -125,7 +125,7 @@ public function startup($controller) { }
* @return void
* @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRender
*/
- public function beforeRender($controller) { }
+ public function beforeRender(Controller $controller) { }
/**
* Called after Controller::render() and before the output is printed to the browser.
@@ -134,7 +134,7 @@ public function beforeRender($controller) { }
* @return void
* @link @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::shutdown
*/
- public function shutdown($controller) { }
+ public function shutdown(Controller $controller) { }
/**
* Called before Controller::redirect(). Allows you to replace the url that will
@@ -155,6 +155,6 @@ public function shutdown($controller) { }
* @return array|null Either an array or null.
* @link @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRedirect
*/
- public function beforeRedirect($controller, $url, $status = null, $exit = true) {}
+ public function beforeRedirect(Controller $controller, $url, $status = null, $exit = true) {}
}
View
2  lib/Cake/Controller/Component/Acl/AclInterface.php
@@ -65,5 +65,5 @@ public function inherit($aro, $aco, $action = "*");
*
* @param AclComponent $component
*/
- public function initialize($component);
+ public function initialize(Component $component);
}
View
2  lib/Cake/Controller/Component/Acl/DbAcl.php
@@ -52,7 +52,7 @@ public function __construct() {
* @param AclComponent $component
* @return void
*/
- public function initialize($component) {
+ public function initialize(Component $component) {
$component->Aro = $this->Aro;
$component->Aco = $this->Aco;
}
View
2  lib/Cake/Controller/Component/Acl/IniAcl.php
@@ -44,7 +44,7 @@ class IniAcl extends Object implements AclInterface {
* @param AclBase $component
* @return void
*/
- public function initialize($component) {
+ public function initialize(Component $component) {
}
View
2  lib/Cake/Controller/Component/Acl/PhpAcl.php
@@ -65,7 +65,7 @@ public function __construct() {
* @param AclComponent $Component Component instance
* @return void
*/
- public function initialize($Component) {
+ public function initialize(Component $Component) {
if (!empty($Component->settings['adapter'])) {
$this->options = array_merge($this->options, $Component->settings['adapter']);
}
View
2  lib/Cake/Controller/Component/Auth/BaseAuthorize.php
@@ -87,7 +87,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
* @return mixed
* @throws CakeException
*/
- public function controller($controller = null) {
+ public function controller(Controller $controller = null) {
if ($controller) {
if (!$controller instanceof Controller) {
throw new CakeException(__d('cake_dev', '$controller needs to be an instance of Controller'));
View
2  lib/Cake/Controller/Component/Auth/ControllerAuthorize.php
@@ -44,7 +44,7 @@ class ControllerAuthorize extends BaseAuthorize {
* @return mixed
* @throws CakeException
*/
- public function controller($controller = null) {
+ public function controller(Controller $controller = null) {
if ($controller) {
if (!method_exists($controller, 'isAuthorized')) {
throw new CakeException(__d('cake_dev', '$controller does not implement an isAuthorized() method.'));
View
6 lib/Cake/Controller/Component/AuthComponent.php
@@ -246,7 +246,7 @@ class AuthComponent extends Component {
* @param Controller $controller A reference to the instantiating controller object
* @return void
*/
- public function initialize($controller) {
+ public function initialize(Controller $controller) {
$this->request = $controller->request;
$this->response = $controller->response;
$this->_methods = $controller->methods;
@@ -263,7 +263,7 @@ public function initialize($controller) {
* @param Controller $controller A reference to the instantiating controller object
* @return boolean
*/
- public function startup($controller) {
+ public function startup(Controller $controller) {
if ($controller->name == 'CakeError') {
return true;
}
@@ -694,7 +694,7 @@ public static function password($password) {
* @param Controller $controller Instantiating controller
* @return void
*/
- public function shutdown($controller) {
+ public function shutdown(Controller $controller) {
if ($this->loggedIn()) {
$this->Session->delete('Auth.redirect');
}
View
2  lib/Cake/Controller/Component/CookieComponent.php
@@ -187,7 +187,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
* @param Controller $controller
* @return void
*/
- public function startup($controller) {
+ public function startup(Controller $controller) {
$this->_expire($this->time);
if (isset($_COOKIE[$this->name])) {
View
2  lib/Cake/Controller/Component/EmailComponent.php
@@ -270,7 +270,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
* @param Controller $controller Instantiating controller
* @return void
*/
- public function initialize($controller) {
+ public function initialize(Controller $controller) {
if (Configure::read('App.encoding') !== null) {
$this->charset = Configure::read('App.encoding');
}
View
10 lib/Cake/Controller/Component/RequestHandlerComponent.php
@@ -115,7 +115,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
* @return void
* @see Router::parseExtensions()
*/
- public function initialize($controller, $settings = array()) {
+ public function initialize(Controller $controller, $settings = array()) {
if (isset($this->request->params['ext'])) {
$this->ext = $this->request->params['ext'];
}
@@ -173,7 +173,7 @@ protected function _setExtension() {
* @param Controller $controller A reference to the controller
* @return void
*/
- public function startup($controller) {
+ public function startup(Controller $controller) {
$controller->request->params['isAjax'] = $this->request->is('ajax');
$isRecognized = (
!in_array($this->ext, array('html', 'htm')) &&
@@ -224,7 +224,7 @@ public function convertXml($xml) {
* @param boolean $exit
* @return void
*/
- public function beforeRedirect($controller, $url, $status = null, $exit = true) {
+ public function beforeRedirect(Controller $controller, $url, $status = null, $exit = true) {
if (!$this->request->is('ajax')) {
return;
}
@@ -253,7 +253,7 @@ public function beforeRedirect($controller, $url, $status = null, $exit = true)
* @params Controller $controller
* @return boolean false if the render process should be aborted
**/
- public function beforeRender($controller) {
+ public function beforeRender(Controller $controller) {
$shouldCheck = $this->settings['checkHttpCache'];
if ($shouldCheck && $this->response->checkNotModified($this->request)) {
return false;
@@ -566,7 +566,7 @@ public function prefers($type = null) {
* @see RequestHandlerComponent::setContent()
* @see RequestHandlerComponent::respondAs()
*/
- public function renderAs($controller, $type, $options = array()) {
+ public function renderAs(Controller $controller, $type, $options = array()) {
$defaults = array('charset' => 'UTF-8');
if (Configure::read('App.encoding') !== null) {
View
16 lib/Cake/Controller/Component/SecurityComponent.php
@@ -204,7 +204,7 @@ class SecurityComponent extends Component {
* @param Controller $controller Instantiating controller
* @return void
*/
- public function startup($controller) {
+ public function startup(Controller $controller) {
$this->request = $controller->request;
$this->_action = $this->request->params['action'];
$this->_methodsRequired($controller);
@@ -307,7 +307,7 @@ public function requireAuth() {
* @link http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html#handling-blackhole-callbacks
* @throws BadRequestException
*/
- public function blackHole($controller, $error = '') {
+ public function blackHole(Controller $controller, $error = '') {
if ($this->blackHoleCallback == null) {
throw new BadRequestException(__d('cake_dev', 'The request has been black-holed'));
} else {
@@ -335,7 +335,7 @@ protected function _requireMethod($method, $actions = array()) {
* @param Controller $controller Instantiating controller
* @return boolean true if $method is required
*/
- protected function _methodsRequired($controller) {
+ protected function _methodsRequired(Controller $controller) {
foreach (array('Post', 'Get', 'Put', 'Delete') as $method) {
$property = 'require' . $method;
if (is_array($this->$property) && !empty($this->$property)) {
@@ -358,7 +358,7 @@ protected function _methodsRequired($controller) {
* @param Controller $controller Instantiating controller
* @return boolean true if secure connection required
*/
- protected function _secureRequired($controller) {
+ protected function _secureRequired(Controller $controller) {
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
$requireSecure = $this->requireSecure;
@@ -379,7 +379,7 @@ protected function _secureRequired($controller) {
* @param Controller $controller Instantiating controller
* @return boolean true if authentication required
*/
- protected function _authRequired($controller) {
+ protected function _authRequired(Controller $controller) {
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) {
$requireAuth = $this->requireAuth;
@@ -419,7 +419,7 @@ protected function _authRequired($controller) {
* @param Controller $controller Instantiating controller
* @return boolean true if submitted form is valid
*/
- protected function _validatePost($controller) {
+ protected function _validatePost(Controller $controller) {
if (empty($controller->request->data)) {
return true;
}
@@ -544,7 +544,7 @@ public function generateToken(CakeRequest $request) {
* @param Controller $controller A controller to check
* @return boolean Valid csrf token.
*/
- protected function _validateCsrf($controller) {
+ protected function _validateCsrf(Controller $controller) {
$token = $this->Session->read('_Token');
$requestToken = $controller->request->data('_Token.key');
if (isset($token['csrfTokens'][$requestToken]) && $token['csrfTokens'][$requestToken] >= time()) {
@@ -585,7 +585,7 @@ protected function _expireTokens($tokens) {
* @param array $params Parameters to send to method
* @return mixed Controller callback method's response
*/
- protected function _callback($controller, $method, $params = array()) {
+ protected function _callback(Controller $controller, $method, $params = array()) {
if (is_callable(array($controller, $method))) {
return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params);
} else {
View
4 lib/Cake/Core/App.php
@@ -652,7 +652,7 @@ public static function import($type = null, $name = null, $parent = true, $searc
protected static function _loadClass($name, $plugin, $type, $originalType, $parent) {
if ($type == 'Console/Command' && $name == 'Shell') {
$type = 'Console';
- } else if (isset(self::$types[$originalType]['suffix'])) {
+ } elseif (isset(self::$types[$originalType]['suffix'])) {
$suffix = self::$types[$originalType]['suffix'];
$name .= ($suffix == $name) ? '' : $suffix;
}
@@ -691,7 +691,7 @@ protected static function _loadFile($name, $plugin, $search, $file, $return) {
$mapped = self::_mapped($name, $plugin);
if ($mapped) {
$file = $mapped;
- } else if (!empty($search)) {
+ } elseif (!empty($search)) {
foreach ($search as $path) {
$found = false;
if (file_exists($path . $file)) {
View
4 lib/Cake/Event/CakeEventManager.php
@@ -126,7 +126,7 @@ protected function _attachSubscriber(CakeEventListener $subscriber) {
$method = $function;
if (is_array($function) && isset($function['callable'])) {
list($method, $options) = $this->_extractCallable($function, $subscriber);
- } else if (is_array($function) && is_numeric(key($function))) {
+ } elseif (is_array($function) && is_numeric(key($function))) {
foreach ($function as $f) {
list($method, $options) = $this->_extractCallable($f, $subscriber);
$this->attach($method, $eventKey, $options);
@@ -198,7 +198,7 @@ protected function _detachSubscriber(CakeEventListener $subscriber, $eventKey =
$events = $subscriber->implementedEvents();
if (!empty($eventKey) && empty($events[$eventKey])) {
return;
- } else if (!empty($eventKey)) {
+ } elseif (!empty($eventKey)) {
$events = array($eventKey => $events[$eventKey]);
}
foreach ($events as $key => $function) {
View
16 lib/Cake/I18n/L10n.php
@@ -355,9 +355,9 @@ protected function _setLanguage($language = null) {
$langKey = null;
if ($language !== null && isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
$langKey = $this->_l10nMap[$language];
- } else if ($language !== null && isset($this->_l10nCatalog[$language])) {
+ } elseif ($language !== null && isset($this->_l10nCatalog[$language])) {
$langKey = $language;
- } else if (defined('DEFAULT_LANGUAGE')) {
+ } elseif (defined('DEFAULT_LANGUAGE')) {
$langKey = $language = DEFAULT_LANGUAGE;
}
@@ -379,7 +379,7 @@ protected function _setLanguage($language = null) {
if ($this->default) {
if (isset($this->_l10nMap[$this->default]) && isset($this->_l10nCatalog[$this->_l10nMap[$this->default]])) {
$this->languagePath[] = $this->_l10nCatalog[$this->_l10nMap[$this->default]]['localeFallback'];
- } else if (isset($this->_l10nCatalog[$this->default])) {
+ } elseif (isset($this->_l10nCatalog[$this->default])) {
$this->languagePath[] = $this->_l10nCatalog[$this->default]['localeFallback'];
}
}
@@ -405,7 +405,7 @@ protected function _autoLanguage() {
if (isset($this->_l10nCatalog[$langKey])) {
$this->_setLanguage($langKey);
return true;
- } else if (strpos($langKey, '-') !== false) {
+ } elseif (strpos($langKey, '-') !== false) {
$langKey = substr($langKey, 0, 2);
if (isset($this->_l10nCatalog[$langKey])) {
$this->_setLanguage($langKey);
@@ -432,10 +432,10 @@ public function map($mixed = null) {
}
}
return $result;
- } else if (is_string($mixed)) {
+ } elseif (is_string($mixed)) {
if (strlen($mixed) === 2 && in_array($mixed, $this->_l10nMap)) {
return array_search($mixed, $this->_l10nMap);
- } else if (isset($this->_l10nMap[$mixed])) {
+ } elseif (isset($this->_l10nMap[$mixed])) {
return $this->_l10nMap[$mixed];
}
return false;
@@ -459,10 +459,10 @@ public function catalog($language = null) {
}
}
return $result;
- } else if (is_string($language)) {
+ } elseif (is_string($language)) {
if (isset($this->_l10nCatalog[$language])) {
return $this->_l10nCatalog[$language];
- } else if (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
+ } elseif (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
return $this->_l10nCatalog[$this->_l10nMap[$language]];
}
return false;
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
18 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'])) ||
@@ -156,7 +156,7 @@ public function beforeFind($Model, $query) {
}
if (!$reset && empty($instance->__backOriginalAssociation)) {
$instance->__backOriginalAssociation = $backupBindings;
- } else if ($reset) {
+ } elseif ($reset) {
$instance->__backAssociation[$type] = $backupBindings[$type];
}
$instance->{$type}[$assoc] = array_merge($instance->{$type}[$assoc], $model['keep'][$assoc]);
@@ -198,7 +198,7 @@ public function beforeFind($Model, $query) {
foreach ($mandatory[$Model->alias] as $field) {
if ($field == '--primaryKey--') {
$field = $Model->primaryKey;
- } else if (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) {
+ } elseif (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) {
list($modelName, $field) = explode('.', $field);
if ($Model->useDbConfig == $Model->{$modelName}->useDbConfig) {
$field = $modelName . '.' . (
@@ -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,14 +365,14 @@ 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) {
foreach ($bindings as $dependency) {
if ($type == 'hasAndBelongsToMany') {
$fields[$parent][] = '--primaryKey--';
- } else if ($type == 'belongsTo') {
+ } elseif ($type == 'belongsTo') {
$fields[$parent][] = $dependency . '.--primaryKey--';
}
}
View
28 lib/Cake/Model/Behavior/TranslateBehavior.php
@@ -36,14 +36,14 @@ class TranslateBehavior extends ModelBehavior {
*
* @var object
*/
- var $_joinTable;
+ protected $_joinTable;
/**
* Stores the runtime model for generating joins.
*
* @var Model
*/
- var $_runtimeModel;
+ protected $_runtimeModel;
/**
* Callback
@@ -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)) {
@@ -143,7 +143,7 @@ public function beforeFind($model, $query) {
$addFields = array();
if (empty($query['fields'])) {
$addFields = $fields;
- } else if (is_array($query['fields'])) {
+ } elseif (is_array($query['fields'])) {
foreach ($fields as $key => $value) {
$field = (is_numeric($key)) ? $value : $key;
@@ -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/CakeSchema.php
@@ -575,7 +575,7 @@ protected function _values($values) {
foreach ($values as $key => $val) {
if (is_array($val)) {
$vals[] = "'{$key}' => array('" . implode("', '", $val) . "')";
- } else if (!is_numeric($key)) {
+ } elseif (!is_numeric($key)) {
$val = var_export($val, true);
$vals[] = "'{$key}' => {$val}";
}
View
4 lib/Cake/Model/Datasource/Database/Postgres.php
@@ -206,7 +206,7 @@ public function describe($model) {
if ($c->type == 'character varying') {
$length = null;
$type = 'text';
- } else if ($c->type == 'uuid') {
+ } elseif ($c->type == 'uuid') {
$length = 36;
} else {
$length = intval($c->oct_length);
@@ -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
4 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;
}
@@ -689,7 +689,7 @@ public function buildIndex($indexes, $table = null) {
foreach ($indexes as $name => $value) {
if ($name == 'PRIMARY') {
$join[] = 'PRIMARY KEY (' . $this->name($value['column']) . ')';
- } else if (isset($value['unique']) && $value['unique']) {
+ } elseif (isset($value['unique']) && $value['unique']) {
$out = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE";
if (is_array($value['column'])) {
View
28 lib/Cake/Model/Datasource/DboSource.php
@@ -577,9 +577,9 @@ public function query() {
} else {
if (isset($args[1]) && $args[1] === true) {
return $this->fetchAll($args[0], true);
- } else if (isset($args[1]) && !is_array($args[1]) ) {
+ } elseif (isset($args[1]) && !is_array($args[1]) ) {
return $this->fetchAll($args[0], false);
- } else if (isset($args[1]) && is_array($args[1])) {
+ } elseif (isset($args[1]) && is_array($args[1])) {
if (isset($args[2])) {
$cache = $args[2];
} else {
@@ -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;
@@ -1733,7 +1733,7 @@ public function renderStatement($type, $data) {
if (trim($indexes) !== '') {
$columns .= ',';
}
- return "CREATE TABLE {$table} (\n{$columns}{$indexes}){$tableParameters};";
+ return "CREATE TABLE {$table} (\n{$columns}{$indexes}) {$tableParameters};";
case 'alter':
return;
}
@@ -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
2  lib/Cake/Model/Model.php
@@ -793,7 +793,7 @@ public function __isset($name) {
$className = empty($this->__backAssociation[$type][$name]['className']) ?
$name : $this->__backAssociation[$type][$name]['className'];
break;
- } else if ($type == 'hasAndBelongsToMany') {
+ } elseif ($type == 'hasAndBelongsToMany') {
foreach ($this->{$type} as $k => $relation) {
if (empty($relation['with'])) {
continue;
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/Network/CakeResponse.php
@@ -972,7 +972,7 @@ public function etag($tag = null, $weak = false) {
protected function _getUTCDate($time = null) {
if ($time instanceof DateTime) {
$result = clone $time;
- } else if (is_integer($time)) {
+ } elseif (is_integer($time)) {
$result = new DateTime(date('Y-m-d H:i:s', $time));
} else {
$result = new DateTime($time);
View
2  lib/Cake/Network/Http/HttpSocket.php
@@ -403,7 +403,7 @@ public function request($request = array()) {
$this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies);
}
- if($this->request['redirect'] && $this->response->isRedirect()) {
+ if ($this->request['redirect'] && $this->response->isRedirect()) {
$request['uri'] = $this->response->getHeader('Location');
$request['redirect'] = is_int($this->request['redirect']) ? $this->request['redirect'] - 1 : $this->request['redirect'];
$this->response = $this->request($request);
View
4 lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php
@@ -170,7 +170,7 @@ public function testParseServerStringNonLatin() {
* @return void
*/
public function testParseServerStringUnix() {
- $Memcache =& new TestMemcacheEngine();
+ $Memcache = new TestMemcacheEngine();
$result = $Memcache->parseServerString('unix:///path/to/memcached.sock');
$this->assertEquals($result, array('unix:///path/to/memcached.sock', 0));
}
@@ -385,7 +385,7 @@ public function testZeroDuration() {
* @return void
*/
public function testLongDurationEqualToZero() {
- $memcache =& new TestMemcacheEngine();
+ $memcache = new TestMemcacheEngine();
$memcache->settings['compress'] = false;
$mock = $this->getMock('Memcache');
View
2  lib/Cake/Test/Case/Console/Command/ApiShellTest.php
@@ -50,7 +50,7 @@ public function setUp() {
*
* @return void
*/
- public function testMethodNameDetection () {
+ public function testMethodNameDetection() {
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('q'));
$this->Shell->expects($this->at(0))->method('out')->with('Controller');
View
2  lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php
@@ -482,7 +482,7 @@ public function testRevoke() {
* @param bool $treesToo
* @return void
*/
- protected function __debug ($printTreesToo = false) {
+ protected function __debug($printTreesToo = false) {
$this->Acl->Aro->displayField = 'alias';
$this->Acl->Aco->displayField = 'alias';
$aros = $this->Acl->Aro->find('list', array('order' => 'lft'));
View
3  lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php
@@ -41,8 +41,7 @@ public function setUp() {
}
/**
- *
- * @expectedException CakeException
+ * @expectedException PHPUnit_Framework_Error
*/
public function testControllerTypeError() {
$this->auth->controller(new StdClass());
View
2  lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php
@@ -401,7 +401,7 @@ public function testReadingCookieDataOnStartup() {
'version' => '1.2.0.x',
'tag' => 'CakePHP Rocks!'));
- $this->Cookie->startup(null);
+ $this->Cookie->startup(new CookieComponentTestController());
$data = $this->Cookie->read('Encrytped_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!');
View
2  lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
@@ -862,7 +862,7 @@ public function testPaginateMaxLimit() {
* @return void
*/
public function testPaginateOrderVirtualFieldSharedWithRealField() {
- $Controller =& new Controller($this->request);
+ $Controller = new Controller($this->request);
$Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment');
$Controller->constructClasses();
$Controller->PaginatorControllerComment->virtualFields = array(
View
2  lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php
@@ -33,7 +33,7 @@ class TestSecurityComponent extends SecurityComponent {
* @param Controller $controller
* @return boolean
*/
- public function validatePost($controller) {
+ public function validatePost(Controller $controller) {
return $this->_validatePost($controller);
}
}
View
8 lib/Cake/Test/Case/Controller/ComponentTest.php
@@ -92,7 +92,7 @@ class AppleComponent extends Component {
* @param mixed $controller
* @return void
*/
- public function startup($controller) {
+ public function startup(Controller $controller) {
$this->testName = $controller->name;
}
}
@@ -117,7 +117,7 @@ class OrangeComponent extends Component {
* @param mixed $controller
* @return void
*/
- public function initialize($controller) {
+ public function initialize(Controller $controller) {
$this->Controller = $controller;
$this->Banana->testField = 'OrangeField';
}
@@ -128,7 +128,7 @@ public function initialize($controller) {
* @param Controller $controller
* @return string
*/
- public function startup($controller) {
+ public function startup(Controller $controller) {
$controller->foo = 'pass';
}
}
@@ -153,7 +153,7 @@ class BananaComponent extends Component {
* @param Controller $controller
* @return string
*/
- public function startup($controller) {
+ public function startup(Controller $controller) {
$controller->bar = 'fail';
}
}
View
10 lib/Cake/Test/Case/Controller/ControllerTest.php
@@ -328,7 +328,7 @@ public function beforeRedirect() {
*
* @return void
*/
- public function initialize($controller) {
+ public function initialize(Controller $controller) {
}
/**
@@ -336,7 +336,7 @@ public function initialize($controller) {
*
* @return void
*/
- public function startup($controller) {
+ public function startup(Controller $controller) {
}
/**
@@ -344,7 +344,7 @@ public function startup($controller) {
*
* @return void
*/
- public function shutdown($controller) {
+ public function shutdown(Controller $controller) {
}
/**
@@ -352,7 +352,7 @@ public function shutdown($controller) {
*
* @return void
*/
- public function beforeRender($controller) {
+ public function beforeRender(Controller $controller) {
if ($this->viewclass) {
$controller->viewClass = $this->viewclass;
}
@@ -362,7 +362,7 @@ public function beforeRender($controller) {
class Test2Component extends TestComponent {
- public function beforeRender($controller) {
+ public function beforeRender(Controller $controller) {
return false;
}
}
View
6 lib/Cake/Test/Case/Core/AppTest.php
@@ -599,7 +599,7 @@ public function testImportingHelpersFromAlternatePaths() {
*
* @return void
*/
- public function testFileLoading () {
+ public function testFileLoading() {
$file = App::import('File', 'RealFile', false, array(), CAKE . 'Config' . DS . 'config.php');
$this->assertTrue($file);
@@ -629,7 +629,7 @@ public function testFileLoadingWithArray() {
*
* @return void
*/
- public function testFileLoadingReturnValue () {
+ public function testFileLoadingReturnValue() {
$file = App::import('File', 'Name', false, array(), CAKE . 'Config' . DS . 'config.php', true);
$this->assertTrue(!empty($file));
@@ -648,7 +648,7 @@ public function testFileLoadingReturnValue () {
*
* @return void
*/
- public function testLoadingWithSearch () {
+ public function testLoadingWithSearch() {
$file = App::import('File', 'NewName', false, array(CAKE . 'Config' . DS), 'config.php');
$this->assertTrue($file);
View
2  lib/Cake/Test/Case/Error/ExceptionRendererTest.php
@@ -64,7 +64,7 @@ class BlueberryComponent extends Component {
*
* @return void
*/
- public function initialize($controller) {
+ public function initialize(Controller $controller) {
$this->testName = 'BlueberryComponent';
}
}
View
10 lib/Cake/Test/Case/I18n/I18nTest.php
@@ -2314,7 +2314,7 @@ public function testMoRulesFourteen() {
*
* @return void
*/
- public function testSetLanguageWithSession () {
+ public function testSetLanguageWithSession() {
$_SESSION['Config']['language'] = 'po';
$singular = $this->__singular();
$this->assertEquals('Po (translated)', $singular);
@@ -2354,7 +2354,7 @@ public function testSetLanguageWithSession () {
*
* @return void
*/
- public function testNoCoreTranslation () {
+ public function testNoCoreTranslation() {
Configure::write('Config.language', 'po');
$singular = $this->__singular();
$this->assertEquals('Po (translated)', $singular);
@@ -2439,7 +2439,7 @@ public function testPluginTranslation() {
*