Skip to content

Commit

Permalink
Fixing more strict warnings.
Browse files Browse the repository at this point in the history
Removing & on component callbacks.
Updating incorrect method signatures.
  • Loading branch information
markstory committed Dec 18, 2010
1 parent 24373ae commit de7b324
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 63 deletions.
10 changes: 5 additions & 5 deletions cake/libs/controller/component.php
Expand Up @@ -108,7 +108,7 @@ public function __get($name) {
* @return void
* @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components
*/
public function initialize(&$controller) { }
public function initialize($controller) { }

/**
* Called after the Controller::beforeFilter() and before the controller action
Expand All @@ -117,7 +117,7 @@ public function initialize(&$controller) { }
* @return void
* @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components
*/
public function startup(&$controller) { }
public function startup($controller) { }

/**
* Called after the Controller::beforeRender(), after the view class is loaded, and before the
Expand All @@ -126,15 +126,15 @@ public function startup(&$controller) { }
* @param object $controller Controller with components to beforeRender
* @return void
*/
public function beforeRender(&$controller) { }
public function beforeRender($controller) { }

/**
* Called after Controller::render() and before the output is printed to the browser.
*
* @param object $controller Controller with components to shutdown
* @return void
*/
function shutdown(&$controller) { }
function shutdown($controller) { }

/**
* Called before Controller::redirect(). Allows you to replace the url that will
Expand All @@ -154,6 +154,6 @@ function shutdown(&$controller) { }
* @param bool $exit Will the script exit.
* @return mixed Either an array or null.
*/
public function beforeRedirect(&$controller, $url, $status = null, $exit = true) {}
public function beforeRedirect($controller, $url, $status = null, $exit = true) {}

}
6 changes: 3 additions & 3 deletions cake/libs/controller/components/auth.php
Expand Up @@ -262,7 +262,7 @@ class AuthComponent extends Component {
* @param object $controller A reference to the instantiating controller object
* @return void
*/
public function initialize(Controller $controller, $settings = array()) {
public function initialize($controller) {
$this->request = $controller->request;
$this->params = $this->request;

Expand Down Expand Up @@ -299,7 +299,7 @@ public function initialize(Controller $controller, $settings = array()) {
* @param object $controller A reference to the instantiating controller object
* @return boolean
*/
public function startup(&$controller) {
public function startup($controller) {
$isErrorOrTests = (
strtolower($controller->name) == 'cakeerror' ||
(strtolower($controller->name) == 'tests' && Configure::read('debug') > 0)
Expand Down Expand Up @@ -926,7 +926,7 @@ public function password($password) {
*
* @param object $controller Instantiating controller
*/
public function shutdown(&$controller) {
public function shutdown($controller) {
if ($this->_loggedIn) {
$this->Session->delete('Auth.redirect');
}
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/controller/components/cookie.php
Expand Up @@ -182,7 +182,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
* Start CookieComponent for use in the controller
*
*/
public function startup() {
public function startup($controller) {
$this->_expire($this->time);

if (isset($_COOKIE[$this->name])) {
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/controller/components/email.php
Expand Up @@ -338,7 +338,7 @@ public function __construct(ComponentCollection $collection, $settings = array()
*
* @param object $controller Instantiating controller
*/
public function initialize(&$controller) {
public function initialize($controller) {
if (Configure::read('App.encoding') !== null) {
$this->charset = Configure::read('App.encoding');
}
Expand All @@ -349,7 +349,7 @@ public function initialize(&$controller) {
*
* @param object $controller Instantiating controller
*/
public function startup(&$controller) {}
public function startup($controller) {}

/**
* Send an email using the specified content, template and layout
Expand Down
8 changes: 4 additions & 4 deletions cake/libs/controller/components/request_handler.php
Expand Up @@ -118,7 +118,7 @@ function __construct(ComponentCollection $collection, $settings = array()) {
* @return void
* @see Router::parseExtensions()
*/
public function initialize(&$controller, $settings = array()) {
public function initialize($controller, $settings = array()) {
$this->request = $controller->request;
$this->response = $controller->response;
if (isset($this->request->params['url']['ext'])) {
Expand Down Expand Up @@ -156,7 +156,7 @@ public function initialize(&$controller, $settings = array()) {
* @param object $controller A reference to the controller
* @return void
*/
public function startup(&$controller) {
public function startup($controller) {
$controller->request->params['isAjax'] = $this->request->is('ajax');
$isRecognized = (
!in_array($this->ext, array('html', 'htm')) &&
Expand Down Expand Up @@ -194,7 +194,7 @@ public function startup(&$controller) {
* @param mixed $url A string or array containing the redirect location
* @param mixed HTTP Status for redirect
*/
public function beforeRedirect(&$controller, $url, $status = null) {
public function beforeRedirect($controller, $url, $status = null, $exit = true) {
if (!$this->request->is('ajax')) {
return;
}
Expand Down Expand Up @@ -509,7 +509,7 @@ public function prefers($type = null) {
* @see RequestHandlerComponent::setContent()
* @see RequestHandlerComponent::respondAs()
*/
public function renderAs(&$controller, $type, $options = array()) {
public function renderAs($controller, $type, $options = array()) {
$defaults = array('charset' => 'UTF-8');

if (Configure::read('App.encoding') !== null) {
Expand Down
18 changes: 9 additions & 9 deletions cake/libs/controller/components/security.php
Expand Up @@ -211,7 +211,7 @@ class SecurityComponent extends Component {
* @param object $controller Instantiating controller
* @return void
*/
public function startup(&$controller) {
public function startup($controller) {
$this->request = $controller->request;
$this->_action = strtolower($this->request->params['action']);
$this->_methodsRequired($controller);
Expand Down Expand Up @@ -441,7 +441,7 @@ function generateDigestResponseHash($data) {
* @see SecurityComponent::$blackHoleCallback
* @link http://book.cakephp.org/view/1307/blackHole-object-controller-string-error
*/
function blackHole(&$controller, $error = '') {
function blackHole($controller, $error = '') {
if ($this->blackHoleCallback == null) {
$code = 404;
if ($error == 'login') {
Expand Down Expand Up @@ -474,7 +474,7 @@ protected function _requireMethod($method, $actions = array()) {
* @param object $controller Instantiating controller
* @return bool true if $method is required
*/
protected function _methodsRequired(&$controller) {
protected function _methodsRequired($controller) {
foreach (array('Post', 'Get', 'Put', 'Delete') as $method) {
$property = 'require' . $method;
if (is_array($this->$property) && !empty($this->$property)) {
Expand All @@ -497,7 +497,7 @@ protected function _methodsRequired(&$controller) {
* @param object $controller Instantiating controller
* @return bool true if secure connection required
*/
protected function _secureRequired(&$controller) {
protected function _secureRequired($controller) {
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
$requireSecure = array_map('strtolower', $this->requireSecure);

Expand All @@ -518,7 +518,7 @@ protected function _secureRequired(&$controller) {
* @param object $controller Instantiating controller
* @return bool true if authentication required
*/
protected function _authRequired(&$controller) {
protected function _authRequired($controller) {
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) {
$requireAuth = array_map('strtolower', $this->requireAuth);

Expand Down Expand Up @@ -553,7 +553,7 @@ protected function _authRequired(&$controller) {
* @param object $controller Instantiating controller
* @return bool true if login is required
*/
protected function _loginRequired(&$controller) {
protected function _loginRequired($controller) {
if (is_array($this->requireLogin) && !empty($this->requireLogin)) {
$requireLogin = array_map('strtolower', $this->requireLogin);

Expand Down Expand Up @@ -600,7 +600,7 @@ protected function _loginRequired(&$controller) {
* @param object $controller Instantiating controller
* @return bool true if submitted form is valid
*/
protected function _validatePost(&$controller) {
protected function _validatePost($controller) {
if (empty($controller->request->data)) {
return true;
}
Expand Down Expand Up @@ -672,7 +672,7 @@ protected function _validatePost(&$controller) {
* @param object $controller Instantiating controller
* @return bool Success
*/
protected function _generateToken(&$controller) {
protected function _generateToken($controller) {
if (isset($controller->request->params['requested']) && $controller->request->params['requested'] === 1) {
if ($this->Session->check('_Token')) {
$tokenData = $this->Session->read('_Token');
Expand Down Expand Up @@ -765,7 +765,7 @@ protected function _setLoginDefaults(&$options) {
* @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, $method, $params = array()) {
if (is_callable(array($controller, $method))) {
return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params);
} else {
Expand Down
3 changes: 2 additions & 1 deletion cake/libs/router.php
Expand Up @@ -1217,7 +1217,8 @@ public static function getArgs($args, $options = array()) {
} else {
if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) {
$matches = array_reverse($matches);
$key = array_shift(explode('[', $key));
$parts = explode('[', $key);
$key = array_shift($parts);
$arr = $val;
foreach ($matches as $match) {
if (empty($match[1])) {
Expand Down
10 changes: 5 additions & 5 deletions cake/tests/cases/libs/controller/component.test.php
Expand Up @@ -52,7 +52,7 @@ class ParamTestComponent extends Component {
* @access public
* @return void
*/
function initialize(&$controller, $settings) {
function initialize($controllerz) {
foreach ($settings as $key => $value) {
if (is_numeric($key)) {
$this->{$value} = true;
Expand Down Expand Up @@ -120,7 +120,7 @@ class AppleComponent extends Component {
* @access public
* @return void
*/
function startup(&$controller) {
function startup($controller) {
$this->testName = $controller->name;
}
}
Expand Down Expand Up @@ -148,7 +148,7 @@ class OrangeComponent extends Component {
* @access public
* @return void
*/
function initialize(&$controller) {
function initialize($controller) {
$this->Controller = $controller;
$this->Banana->testField = 'OrangeField';
}
Expand All @@ -159,7 +159,7 @@ function initialize(&$controller) {
* @param Controller $controller
* @return string
*/
public function startup(&$controller) {
public function startup($controller) {
$controller->foo = 'pass';
}
}
Expand All @@ -186,7 +186,7 @@ class BananaComponent extends Component {
* @param Controller $controller
* @return string
*/
public function startup(&$controller) {
public function startup($controller) {
$controller->bar = 'fail';
}
}
Expand Down
5 changes: 3 additions & 2 deletions cake/tests/cases/libs/controller/components/auth.test.php
Expand Up @@ -52,7 +52,7 @@ class TestAuthComponent extends AuthComponent {
* @access public
* @return void
*/
function _stop() {
function _stop($status = 0) {
$this->testStop = true;
}
}
Expand Down Expand Up @@ -498,7 +498,8 @@ function setUp() {
);
$this->Controller->beforeFilter();

ClassRegistry::addObject('view', new View($this->Controller));
$view = new View($this->Controller);
ClassRegistry::addObject('view', $view);

$this->Controller->Session->delete('Auth');
$this->Controller->Session->delete('Message.auth');
Expand Down
Expand Up @@ -383,7 +383,7 @@ function testReadingCookieDataOnStartup() {
'name' => 'CakePHP',
'version' => '1.2.0.x',
'tag' => 'CakePHP Rocks!'));
$this->Cookie->startup();
$this->Cookie->startup(null);

$data = $this->Cookie->read('Encrytped_array');
$expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' =>'CakePHP Rocks!');
Expand Down
3 changes: 2 additions & 1 deletion cake/tests/cases/libs/controller/components/email.test.php
Expand Up @@ -230,7 +230,8 @@ function setUp() {
$this->Controller->Components->init($this->Controller);

$this->Controller->EmailTest->initialize($this->Controller, array());
ClassRegistry::addObject('view', new View($this->Controller));
$view = new View($this->Controller);
ClassRegistry::addObject('view', $view);

App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
Expand Down
Expand Up @@ -113,13 +113,13 @@ function beforeFind($query) {
* @access public
* @return void
*/
function find($type, $options = array()) {
if ($type == 'popular') {
function find($conditions = null, $fields = array(), $order = null, $recursive = null) {
if ($conditions == 'popular') {
$conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1');
$options = Set::merge($options, compact('conditions'));
$options = Set::merge($fields, compact('conditions'));
return parent::find('all', $options);
}
return parent::find($type, $options);
return parent::find($conditions, $fields);
}
}

Expand Down
6 changes: 3 additions & 3 deletions cake/tests/cases/libs/controller/components/security.test.php
Expand Up @@ -34,7 +34,7 @@ class TestSecurityComponent extends SecurityComponent {
* @param Controller $controller
* @return unknown
*/
function validatePost(&$controller) {
function validatePost($controller) {
return $this->_validatePost($controller);
}
}
Expand Down Expand Up @@ -98,8 +98,8 @@ function fail() {
* @access public
* @return void
*/
function redirect($option, $code, $exit) {
return $code;
function redirect($url, $status = null, $exit = true) {
return $status;
}

/**
Expand Down
18 changes: 9 additions & 9 deletions cake/tests/cases/libs/controller/controller.test.php
Expand Up @@ -113,13 +113,13 @@ function beforeFind($query) {
* @access public
* @return void
*/
function find($type, $options = array()) {
if ($type == 'popular') {
function find($conditions = null, $fields = array(), $order = null, $recursive = null) {
if ($conditions == 'popular') {
$conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1');
$options = Set::merge($options, compact('conditions'));
return parent::find('all', $options);
$options = Set::merge($fields, compact('conditions'));
return parent::find('all', $fields);
}
return parent::find($type, $options);
return parent::find($conditions, $fields);
}
}

Expand Down Expand Up @@ -326,7 +326,7 @@ function beforeRedirect() {
* @access public
* @return void
*/
function initialize(&$controller) {
function initialize($controller) {
}

/**
Expand All @@ -335,22 +335,22 @@ function initialize(&$controller) {
* @access public
* @return void
*/
function startup(&$controller) {
function startup($controller) {
}
/**
* shutdown method
*
* @access public
* @return void
*/
function shutdown(&$controller) {
function shutdown($controller) {
}
/**
* beforeRender callback
*
* @return void
*/
function beforeRender(&$controller) {
function beforeRender($controller) {
if ($this->viewclass) {
$controller->view = $this->viewclass;
}
Expand Down

0 comments on commit de7b324

Please sign in to comment.