Browse Source

harden method signatures

euromark 12 years ago
parent
commit
711ddcaf09

+ 1 - 1
src/Event/EventManager.php

@@ -96,7 +96,7 @@ class EventManager {
  * @throws \InvalidArgumentException When event key is missing or callable is not an
  *   instance of Cake\Event\EventListener.
  */
-	public function attach($callable, $eventKey = null, $options = array()) {
+	public function attach($callable, $eventKey = null, array $options = array()) {
 		if (!$eventKey && !($callable instanceof EventListener)) {
 			throw new \InvalidArgumentException('The eventKey variable is required');
 		}

+ 1 - 1
src/Network/Email/Email.php

@@ -716,7 +716,7 @@ class Email {
  * @param array $include
  * @return array
  */
-	public function getHeaders($include = array()) {
+	public function getHeaders(array $include = array()) {
 		if ($include == array_values($include)) {
 			$include = array_fill_keys($include, true);
 		}

+ 4 - 4
src/Network/Request.php

@@ -402,10 +402,10 @@ class Request implements \ArrayAccess {
  * Recursively walks the FILES array restructuring the data
  * into something sane and useable.
  *
+ * @param array $post The post data having files inserted into
  * @param string $path The dot separated path to insert $data into.
  * @param array $data The data to traverse/insert.
  * @param string $field The terminal field name, which is the top level key in $_FILES.
- * @param array $post The post data having files inserted into
  * @return void
  */
 	protected function _processFileData(&$post, $path, $data, $field) {
@@ -651,8 +651,8 @@ class Request implements \ArrayAccess {
  * @param array $params Array of parameters to merge in
  * @return \Cake\Network\Request The current object, you can chain this method.
  */
-	public function addParams($params) {
-		$this->params = array_merge($this->params, (array)$params);
+	public function addParams(array $params) {
+		$this->params = array_merge($this->params, $params);
 		return $this;
 	}
 
@@ -663,7 +663,7 @@ class Request implements \ArrayAccess {
  * @param array $paths Array of paths to merge in
  * @return \Cake\Network\Request the current object, you can chain this method.
  */
-	public function addPaths($paths) {
+	public function addPaths(array $paths) {
 		foreach (array('webroot', 'here', 'base') as $element) {
 			if (isset($paths[$element])) {
 				$this->{$element} = $paths[$element];

+ 3 - 3
src/Network/Response.php

@@ -351,7 +351,7 @@ class Response {
  *
  * @var array
  */
-	protected $_fileRange = null;
+	protected $_fileRange = [];
 
 /**
  * The charset the response body is encoded with
@@ -1187,7 +1187,7 @@ class Response {
  * If the method is called with an array as argument, it will set the cookie
  * configuration to the cookie container.
  *
- * @param array $options Either null to get all cookies, string for a specific cookie
+ * @param array|null $options Either null to get all cookies, string for a specific cookie
  *  or array to set cookie.
  *
  * ### Options (when setting a configuration)
@@ -1326,7 +1326,7 @@ class Response {
  * @return void
  * @throws \Cake\Error\NotFoundException
  */
-	public function file($path, $options = array()) {
+	public function file($path, array $options = array()) {
 		$options += array(
 			'name' => null,
 			'download' => null

+ 1 - 1
src/Network/Socket.php

@@ -110,7 +110,7 @@ class Socket {
  * @param array $config Socket configuration, which will be merged with the base configuration
  * @see Socket::$_baseConfig
  */
-	public function __construct($config = array()) {
+	public function __construct(array $config = array()) {
 		$this->config($config);
 
 		if (!is_numeric($this->_config['protocol'])) {

+ 2 - 2
src/Routing/Dispatcher.php

@@ -140,7 +140,7 @@ class Dispatcher implements EventListener {
  * @return string|void if `$request['return']` is set then it returns response body, null otherwise
  * @throws \Cake\Error\MissingControllerException When the controller is missing.
  */
-	public function dispatch(Request $request, Response $response, $additionalParams = array()) {
+	public function dispatch(Request $request, Response $response, array $additionalParams = array()) {
 		$beforeEvent = new Event('Dispatcher.beforeDispatch', $this, compact('request', 'response', 'additionalParams'));
 		$this->getEventManager()->dispatch($beforeEvent);
 
@@ -211,7 +211,7 @@ class Dispatcher implements EventListener {
  * @param \Cake\Event\Event $event containing the request, response and additional params
  * @return void
  */
-	public function parseParams($event) {
+	public function parseParams(Event $event) {
 		$request = $event->data['request'];
 		Router::setRequestInfo($request);
 

+ 1 - 1
src/Routing/RequestActionTrait.php

@@ -73,7 +73,7 @@ trait RequestActionTrait {
  * @return mixed Boolean true or false on success/failure, or contents
  *    of rendered action if 'return' is set in $extra.
  */
-	public function requestAction($url, $extra = array()) {
+	public function requestAction($url, array $extra = array()) {
 		if (empty($url)) {
 			return false;
 		}

+ 2 - 2
src/Routing/Route/PluginShortRoute.php

@@ -49,8 +49,8 @@ class PluginShortRoute extends Route {
  *   directory.
  * @return mixed either false or a string URL.
  */
-	public function match($url, $context = array()) {
-		if (isset($url['controller']) && isset($url['plugin']) && $url['plugin'] != $url['controller']) {
+	public function match(array $url, array $context = array()) {
+		if (isset($url['controller']) && isset($url['plugin']) && $url['plugin'] !== $url['controller']) {
 			return false;
 		}
 		$this->defaults['controller'] = $url['controller'];

+ 3 - 3
src/Routing/Route/RedirectRoute.php

@@ -51,10 +51,10 @@ class RedirectRoute extends Route {
  * Constructor
  *
  * @param string $template Template string with parameter placeholders
- * @param array $defaults Array of defaults for the route.
+ * @param array|string $defaults Defaults for the route.
  * @param array $options Array of additional options for the Route
  */
-	public function __construct($template, $defaults = array(), $options = array()) {
+	public function __construct($template, $defaults = [], array $options = []) {
 		parent::__construct($template, $defaults, $options);
 		$this->redirect = (array)$defaults;
 	}
@@ -108,7 +108,7 @@ class RedirectRoute extends Route {
  * @param array $context Array of request context parameters.
  * @return mixed either false or a string url.
  */
-	public function match($url, $context = array()) {
+	public function match(array $url, array $context = array()) {
 		return false;
 	}
 

+ 4 - 4
src/Routing/Route/Route.php

@@ -107,13 +107,13 @@ class Route {
  * - `pass` - Copies the listed parameters into params['pass'].
  *
  * @param string $template Template string with parameter placeholders
- * @param array $defaults Array of defaults for the route.
+ * @param array|string $defaults Defaults for the route.
  * @param array $options Array of additional options for the Route
  */
-	public function __construct($template, $defaults = [], $options = []) {
+	public function __construct($template, $defaults = [], array $options = []) {
 		$this->template = $template;
 		$this->defaults = (array)$defaults;
-		$this->options = (array)$options;
+		$this->options = $options;
 		if (isset($this->options['_name'])) {
 			$this->_name = $this->options['_name'];
 		}
@@ -398,7 +398,7 @@ class Route {
  *   directory.
  * @return mixed Either a string url for the parameters if they match or false.
  */
-	public function match($url, $context = []) {
+	public function match(array $url, array $context = []) {
 		if (!$this->compiled()) {
 			$this->compile();
 		}

+ 2 - 2
src/Validation/Validation.php

@@ -578,7 +578,7 @@ class Validation {
  * @param boolean $caseInsensitive Set to true for case insensitive comparison.
  * @return boolean Success
  */
-	public static function multiple($check, $options = array(), $caseInsensitive = false) {
+	public static function multiple($check, array $options = array(), $caseInsensitive = false) {
 		$defaults = array('in' => null, 'max' => null, 'min' => null);
 		$options = array_merge($defaults, $options);
 
@@ -805,7 +805,7 @@ class Validation {
  * @param boolean $caseInsensitive Set to true for case insensitive comparison.
  * @return boolean Success.
  */
-	public static function inList($check, $list, $caseInsensitive = false) {
+	public static function inList($check, array $list, $caseInsensitive = false) {
 		$strict = !is_numeric($check);
 
 		if ($caseInsensitive) {

+ 2 - 2
src/Validation/ValidationRule.php

@@ -74,7 +74,7 @@ class ValidationRule {
  *
  * @param array $validator [optional] The validator properties
  */
-	public function __construct($validator = array()) {
+	public function __construct(array $validator = array()) {
 		$this->_addValidatorProps($validator);
 	}
 
@@ -105,7 +105,7 @@ class ValidationRule {
  * @throws \InvalidArgumentException when the supplied rule is not a valid
  * callable for the configured scope
  */
-	public function process($value, $providers, array $context = []) {
+	public function process($value, array $providers, array $context = []) {
 		$context += ['data' => [], 'newRecord' => true, 'providers' => $providers];
 
 		if ($this->_skip($context)) {