Browse Source

harden method signatures

euromark 12 years ago
parent
commit
0feb766f5d

+ 1 - 1
src/Cache/CacheEngine.php

@@ -63,7 +63,7 @@ abstract class CacheEngine {
  * @param array $config Associative array of parameters for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
-	public function init($config = []) {
+	public function init(array $config = []) {
 		$this->config($config);
 
 		if (!empty($this->_config['groups'])) {

+ 1 - 1
src/Cache/Engine/ApcEngine.php

@@ -41,7 +41,7 @@ class ApcEngine extends CacheEngine {
  * @param array $config array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
-	public function init($config = []) {
+	public function init(array $config = []) {
 		if (!isset($config['prefix'])) {
 			$config['prefix'] = Inflector::slug(APP_DIR) . '_';
 		}

+ 1 - 1
src/Cache/Engine/FileEngine.php

@@ -87,7 +87,7 @@ class FileEngine extends CacheEngine {
  * @param array $config array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
-	public function init($config = []) {
+	public function init(array $config = []) {
 		parent::init($config);
 
 		if (DS === '\\') {

+ 1 - 1
src/Cache/Engine/MemcachedEngine.php

@@ -97,7 +97,7 @@ class MemcachedEngine extends CacheEngine {
  * @return boolean True if the engine has been successfully initialized, false if not
  * @throws \Cake\Error\Exception when you try use authentication without Memcached compiled with SASL support
  */
-	public function init($config = []) {
+	public function init(array $config = []) {
 		if (!class_exists('Memcached')) {
 			return false;
 		}

+ 1 - 1
src/Cache/Engine/RedisEngine.php

@@ -72,7 +72,7 @@ class RedisEngine extends CacheEngine {
  * @param array $config array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
-	public function init($config = []) {
+	public function init(array $config = []) {
 		if (!class_exists('Redis')) {
 			return false;
 		}

+ 1 - 1
src/Cache/Engine/WincacheEngine.php

@@ -44,7 +44,7 @@ class WincacheEngine extends CacheEngine {
  * @param array $config array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
-	public function init($config = []) {
+	public function init(array $config = []) {
 		if (!isset($config['prefix'])) {
 			$config['prefix'] = Inflector::slug(APP_DIR) . '_';
 		}

+ 1 - 1
src/Cache/Engine/XcacheEngine.php

@@ -57,7 +57,7 @@ class XcacheEngine extends CacheEngine {
  * @param array $config array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
-	public function init($config = []) {
+	public function init(array $config = []) {
 		if (php_sapi_name() !== 'cli') {
 			if (!isset($config['prefix'])) {
 				$config['prefix'] = Inflector::slug(APP_DIR) . '_';

+ 1 - 1
src/Controller/Component.php

@@ -102,7 +102,7 @@ class Component extends Object implements EventListener {
  * @param ComponentRegistry $registry A ComponentRegistry this component can use to lazy load its components
  * @param array $config Array of configuration settings.
  */
-	public function __construct(ComponentRegistry $registry, $config = []) {
+	public function __construct(ComponentRegistry $registry, array $config = []) {
 		$this->_registry = $registry;
 
 		$this->config($config);

+ 1 - 1
src/Controller/Component/AclComponent.php

@@ -64,7 +64,7 @@ class AclComponent extends Component {
  * @param array $config
  * @throws \Cake\Error\Exception when Acl.classname could not be loaded.
  */
-	public function __construct(ComponentRegistry $collection, $config = array()) {
+	public function __construct(ComponentRegistry $collection, array $config = array()) {
 		parent::__construct($collection, $config);
 		$classname = $name = Configure::read('Acl.classname');
 		if (!class_exists($classname)) {

+ 1 - 1
src/Controller/Component/Auth/AbstractPasswordHasher.php

@@ -40,7 +40,7 @@ abstract class AbstractPasswordHasher {
  *
  * @param array $config Array of config.
  */
-	public function __construct($config = array()) {
+	public function __construct(array $config = array()) {
 		$this->config($config);
 	}
 

+ 1 - 1
src/Controller/Component/Auth/BaseAuthenticate.php

@@ -186,7 +186,7 @@ abstract class BaseAuthenticate {
  * @param array $user The user about to be logged out.
  * @return void
  */
-	public function logout($user) {
+	public function logout(array $user) {
 	}
 
 /**

+ 3 - 3
src/Controller/Component/Auth/BaseAuthorize.php

@@ -77,7 +77,7 @@ abstract class BaseAuthorize {
  * @param ComponentRegistry $registry The controller for this request.
  * @param array $config An array of config. This class does not use any config.
  */
-	public function __construct(ComponentRegistry $registry, $config = array()) {
+	public function __construct(ComponentRegistry $registry, array $config = array()) {
 		$this->_registry = $registry;
 		$controller = $registry->getController();
 		$this->controller($controller);
@@ -153,7 +153,7 @@ abstract class BaseAuthorize {
  *
  * You can use the custom CRUD operations to create additional generic permissions
  * that behave like CRUD operations. Doing this will require additional columns on the
- * permissions lookup. For example if one wanted an additional search CRUD operation 
+ * permissions lookup. For example if one wanted an additional search CRUD operation
  * one would create and additional column '_search' in the aros_acos table. One could
  * create a custom admin CRUD operation for administration functions similarly if needed.
  *
@@ -161,7 +161,7 @@ abstract class BaseAuthorize {
  * @return mixed Either the current mappings or null when setting.
  * @see AuthComponent::mapActions()
  */
-	public function mapActions($map = array()) {
+	public function mapActions(array $map = array()) {
 		if (empty($map)) {
 			return $this->_config['actionMap'];
 		}

+ 2 - 2
src/Controller/Component/AuthComponent.php

@@ -541,7 +541,7 @@ class AuthComponent extends Component {
  * @see BaseAuthorize::mapActions()
  * @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#mapping-actions-when-using-crudauthorize
  */
-	public function mapActions($map = array()) {
+	public function mapActions(array $map = array()) {
 		if (empty($this->_authorizeObjects)) {
 			$this->constructAuthorize();
 		}
@@ -592,7 +592,7 @@ class AuthComponent extends Component {
 		if (empty($this->_authenticateObjects)) {
 			$this->constructAuthenticate();
 		}
-		$user = $this->user();
+		$user = (array)$this->user();
 		foreach ($this->_authenticateObjects as $auth) {
 			$auth->logout($user);
 		}

+ 1 - 1
src/Controller/Component/CookieComponent.php

@@ -116,7 +116,7 @@ class CookieComponent extends Component {
  * @param ComponentRegistry $collection A ComponentRegistry for this component
  * @param array $config Array of config.
  */
-	public function __construct(ComponentRegistry $collection, $config = array()) {
+	public function __construct(ComponentRegistry $collection, array $config = array()) {
 		parent::__construct($collection, $config);
 
 		if (!$this->_config['key']) {

+ 3 - 3
src/Controller/Component/RequestHandlerComponent.php

@@ -119,7 +119,7 @@ class RequestHandlerComponent extends Component {
  * @param ComponentRegistry $collection ComponentRegistry object.
  * @param array $config Array of config.
  */
-	public function __construct(ComponentRegistry $collection, $config = array()) {
+	public function __construct(ComponentRegistry $collection, array $config = array()) {
 		parent::__construct($collection, $config);
 		$this->addInputType('xml', array(array($this, 'convertXml')));
 
@@ -499,7 +499,7 @@ class RequestHandlerComponent extends Component {
  * @see RequestHandlerComponent::setContent()
  * @see RequestHandlerComponent::respondAs()
  */
-	public function renderAs(Controller $controller, $type, $options = array()) {
+	public function renderAs(Controller $controller, $type, array $options = array()) {
 		$defaults = array('charset' => 'UTF-8');
 
 		if (Configure::read('App.encoding') !== null) {
@@ -561,7 +561,7 @@ class RequestHandlerComponent extends Component {
  *    already been set by this method.
  * @see RequestHandlerComponent::setContent()
  */
-	public function respondAs($type, $options = array()) {
+	public function respondAs($type, array $options = array()) {
 		$defaults = array('index' => null, 'charset' => null, 'attachment' => false);
 		$options = $options + $defaults;
 

+ 1 - 1
src/Controller/Component/SessionComponent.php

@@ -121,7 +121,7 @@ class SessionComponent extends Component {
  * @return void
  * @link http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html#creating-notification-messages
  */
-	public function setFlash($message, $element = 'default', $params = array(), $key = 'flash') {
+	public function setFlash($message, $element = 'default', array $params = array(), $key = 'flash') {
 		Session::write('Message.' . $key, compact('message', 'element', 'params'));
 	}
 

+ 1 - 1
src/Controller/Controller.php

@@ -290,7 +290,7 @@ class Controller extends Object implements EventListener {
  * @param array $config The config for the component.
  * @return \Cake\Controller\Component
  */
-	public function addComponent($name, $config = []) {
+	public function addComponent($name, array $config = []) {
 		list(, $prop) = pluginSplit($name);
 		$this->{$prop} = $this->components()->load($name, $config);
 		return $this->{$prop};

+ 1 - 1
src/Core/Object.php

@@ -53,7 +53,7 @@ class Object {
  * @param array $params Parameter list to use when calling $method
  * @return mixed Returns the result of the method call
  */
-	public function dispatchMethod($method, $params = []) {
+	public function dispatchMethod($method, array $params = []) {
 		switch (count($params)) {
 			case 0:
 				return $this->{$method}();

+ 2 - 2
src/Core/Plugin.php

@@ -111,7 +111,7 @@ class Plugin {
  * @throws \Cake\Error\MissingPluginException if the folder for the plugin to be loaded is not found
  * @return void
  */
-	public static function load($plugin, $config = []) {
+	public static function load($plugin, array $config = []) {
 		if (is_array($plugin)) {
 			foreach ($plugin as $name => $conf) {
 				list($name, $conf) = (is_numeric($name)) ? [$conf, $config] : [$name, $conf];
@@ -176,7 +176,7 @@ class Plugin {
  * @param array $options
  * @return void
  */
-	public static function loadAll($options = []) {
+	public static function loadAll(array $options = []) {
 		$plugins = App::objects('Plugin');
 		foreach ($plugins as $p) {
 			$opts = isset($options[$p]) ? $options[$p] : null;

+ 1 - 1
src/Database/Schema/Table.php

@@ -229,7 +229,7 @@ class Table {
  * @param string $table The table name.
  * @param array $columns The list of columns for the schema.
  */
-	public function __construct($table, $columns = array()) {
+	public function __construct($table, array $columns = array()) {
 		$this->_table = $table;
 		foreach ($columns as $field => $definition) {
 			$this->addColumn($field, $definition);

+ 1 - 1
src/Datasource/ConnectionManager.php

@@ -156,7 +156,7 @@ class ConnectionManager {
  * @return DataSource A reference to the DataSource object, or null if creation failed
  * @deprecated Will be removed in 3.0 stable
  */
-	public static function create($name = '', $config = array()) {
+	public static function create($name = '', array $config = array()) {
 		static::config($name, $config);
 		return static::get($name);
 	}

+ 1 - 1
src/Log/Engine/ConsoleLog.php

@@ -57,7 +57,7 @@ class ConsoleLog extends BaseLog {
  * @param array $config Options for the FileLog, see above.
  * @throws \Cake\Error\Exception
  */
-	public function __construct($config = array()) {
+	public function __construct(array $config = array()) {
 		if (DS === '\\' && !(bool)env('ANSICON')) {
 			$this->_defaultConfig['outputAs'] = ConsoleOutput::PLAIN;
 		} else {

+ 1 - 1
src/ORM/TableRegistry.php

@@ -132,7 +132,7 @@ class TableRegistry {
  * @return \Cake\ORM\Table
  * @throws RuntimeException When you try to configure an alias that already exists.
  */
-	public static function get($alias, $options = []) {
+	public static function get($alias, array $options = []) {
 		$exists = isset(static::$_instances[$alias]);
 		if ($exists && !empty($options)) {
 			throw new RuntimeException(sprintf(

+ 0 - 1
tests/TestCase/Utility/ObjectCollectionTest.php

@@ -34,7 +34,6 @@ class GenericObject {
  */
 	public function __construct(GenericObjectCollection $collection, $settings = array()) {
 		$this->_Collection = $collection;
-		$this->settings = $settings;
 	}
 
 }