Mark Scherer 9 年 前
コミット
19eb377178

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

@@ -234,8 +234,8 @@ class CommonComponent extends Component {
 	 * - querystring (especially for 3.x then)
 	 * - passed params
 	 *
-	 * @param mixed $url
-	 * @param int $status
+	 * @param mixed|null $url
+	 * @param int|null $status
 	 * @return \Cake\Network\Response
 	 */
 	public function completeRedirect($url = null, $status = null) {

+ 2 - 1
src/Model/Behavior/BitmaskedBehavior.php

@@ -8,6 +8,7 @@ use Cake\ORM\Behavior;
 use Cake\ORM\Entity;
 use Cake\ORM\Query;
 use Cake\Utility\Inflector;
+use Exception;
 use Tools\Utility\Text;
 
 /**
@@ -67,7 +68,7 @@ class BitmaskedBehavior extends Behavior {
 			$config['bits'] = false;
 		}
 		if (empty($config['bits'])) {
-			throw new \Exception('Bits not found');
+			throw new Exception('Bits not found');
 		}
 		ksort($config['bits'], SORT_NUMERIC);
 

+ 3 - 2
src/Model/Behavior/JsonableBehavior.php

@@ -9,6 +9,7 @@ use Cake\Event\Event;
 use Cake\ORM\Behavior;
 use Cake\ORM\Entity;
 use Cake\ORM\Query;
+use Exception;
 use Tools\Utility\Text;
 
 /**
@@ -78,7 +79,7 @@ class JsonableBehavior extends Behavior {
 	public function initialize(array $config = []) {
 		Type::map('array', 'Tools\Database\Type\ArrayType');
 		if (empty($this->_config['fields'])) {
-			throw new \Exception('Fields are required');
+			throw new Exception('Fields are required');
 		}
 		if (!is_array($this->_config['fields'])) {
 			$this->_config['fields'] = (array)$this->_config['fields'];
@@ -87,7 +88,7 @@ class JsonableBehavior extends Behavior {
 			$this->_config['map'] = (array)$this->_config['map'];
 		}
 		if (!empty($this->_config['map']) && count($this->_config['fields']) !== count($this->_config['map'])) {
-			throw new \Exception('Fields and Map need to be of the same length if map is specified.');
+			throw new Exception('Fields and Map need to be of the same length if map is specified.');
 		}
 		foreach ($this->_config['fields'] as $field) {
 			$this->_table->schema()->columnType($field, 'array');

+ 2 - 1
src/Model/Behavior/NeighborBehavior.php

@@ -5,6 +5,7 @@ namespace Tools\Model\Behavior;
 use Cake\ORM\Behavior;
 use Cake\ORM\Query;
 use Cake\Utility\Hash;
+use InvalidArgumentException;
 
 /**
  * Neighbor Behavior
@@ -25,7 +26,7 @@ class NeighborBehavior extends Behavior {
 
 	public function neighbors($id, array $options = []) {
 		if (empty($id)) {
-			throw new \InvalidArgumentException("The 'id' key is required for find('neighbors')");
+			throw new InvalidArgumentException("The 'id' key is required for find('neighbors')");
 		}
 		$sortField = $this->_table->hasField('created') ? 'created' : $this->_table->primaryKey();
 		$defaults = [

+ 3 - 2
src/Model/Behavior/PasswordableBehavior.php

@@ -9,6 +9,7 @@ use Cake\Event\Event;
 use Cake\ORM\Behavior;
 use Cake\ORM\Entity;
 use Cake\ORM\Table;
+use Exception;
 
 if (!defined('PWD_MIN_LENGTH')) {
 	define('PWD_MIN_LENGTH', 6);
@@ -129,7 +130,7 @@ class PasswordableBehavior extends Behavior {
 		$formFieldCurrent = $this->_config['formFieldCurrent'];
 
 		if ($formField === $this->_config['field']) {
-			throw new \Exception('Invalid setup - the form field must to be different from the model field (' . $this->_config['field'] . ').');
+			throw new Exception('Invalid setup - the form field must to be different from the model field (' . $this->_config['field'] . ').');
 		}
 
 		$rules = $this->_validationRules;
@@ -300,7 +301,7 @@ class PasswordableBehavior extends Behavior {
 			$entity->set($field, $PasswordHasher->hash($entity->get($formField)));
 
 			if (!$entity->get($field)) {
-				throw new \Exception('Empty field');
+				throw new Exception('Empty field');
 			}
 
 			$entity->unsetProperty($formField);

+ 3 - 2
src/Model/Behavior/ResetBehavior.php

@@ -6,6 +6,7 @@ use Cake\Core\Configure;
 use Cake\ORM\Behavior;
 use Cake\ORM\Entity;
 use Cake\ORM\Table;
+use Exception;
 
 /**
  * Allows the model to reset all records as batch command.
@@ -93,7 +94,7 @@ class ResetBehavior extends Behavior {
 		if (!empty($this->_config['fields'])) {
 			foreach ((array)$this->_config['fields'] as $field) {
 				if (!$this->_table->hasField($field)) {
-					throw new \Exception('Table does not have field ' . $field);
+					throw new Exception('Table does not have field ' . $field);
 				}
 			}
 			$defaults['fields'] = array_merge([$this->_table->alias() . '.' . $this->_table->primaryKey()], $this->_config['fields']);
@@ -145,7 +146,7 @@ class ResetBehavior extends Behavior {
 
 				$res = $this->_table->save($record, compact('validate', 'fieldList'));
 				if (!$res) {
-					throw new \Exception(print_r($this->_table->errors(), true));
+					throw new Exception(print_r($this->_table->errors(), true));
 				}
 				$modified++;
 			}

+ 8 - 6
src/Model/Behavior/SluggedBehavior.php

@@ -10,6 +10,8 @@ use Cake\ORM\Entity;
 use Cake\ORM\Query;
 use Cake\ORM\Table;
 use Cake\Utility\Inflector;
+use Exception as PhpException;
+use InvalidArgumentException;
 
 /**
  * SluggedBehavior
@@ -126,11 +128,11 @@ class SluggedBehavior extends Behavior {
 				if (strpos($field, '.')) {
 					list($alias, $field) = explode('.', $field);
 					if (!$this->_table->$alias->hasField($field)) {
-						throw new \Exception('(SluggedBehavior::setup) model ' . $this->_table->$alias->name . ' is missing the field ' . $field .
+						throw new PhpException('(SluggedBehavior::setup) model ' . $this->_table->$alias->name . ' is missing the field ' . $field .
 							' (specified in the setup for model ' . $this->_table->name . ') ');
 					}
 				} elseif (!$this->_table->hasField($field) && !method_exists($this->_table->entityClass(), '_get' . Inflector::classify($field))) {
-					throw new \Exception('(SluggedBehavior::setup) model ' . $this->_table->name . ' is missing the field ' . $field . ' specified in the setup.');
+					throw new PhpException('(SluggedBehavior::setup) model ' . $this->_table->name . ' is missing the field ' . $field . ' specified in the setup.');
 				}
 			}
 		}
@@ -146,7 +148,7 @@ class SluggedBehavior extends Behavior {
 	 */
 	public function findSlugged(Query $query, array $options) {
 		if (empty($options['slug'])) {
-			throw new \InvalidArgumentException("The 'slug' key is required for find('slugged')");
+			throw new InvalidArgumentException("The 'slug' key is required for find('slugged')");
 		}
 
 		return $query->where([$this->_config['field'] => $options['slug']]);
@@ -294,7 +296,7 @@ class SluggedBehavior extends Behavior {
 		}
 		if ($this->_config['unique']) {
 			if (!$entity) {
-				throw new \Exception('Needs an Entity to work on');
+				throw new PhpException('Needs an Entity to work on');
 			}
 			$field = $this->_table->alias() . '.' . $this->_config['field'];
 			$conditions = [$field => $slug];
@@ -335,7 +337,7 @@ class SluggedBehavior extends Behavior {
 	 */
 	public function resetSlugs($params = []) {
 		if (!$this->_table->hasField($this->_config['field'])) {
-			throw new \Exception('Table does not have field ' . $this->_config['field']);
+			throw new PhpException('Table does not have field ' . $this->_config['field']);
 		}
 		$defaults = [
 			'page' => 1,
@@ -361,7 +363,7 @@ class SluggedBehavior extends Behavior {
 					'fieldList' => array_merge([$this->_table->primaryKey(), $this->_config['field']], $this->_config['label'])
 				];
 				if (!$this->_table->save($record, $options)) {
-					throw new \Exception(print_r($this->_table->errors(), true));
+					throw new PhpException(print_r($this->_table->errors(), true));
 				}
 			}
 			$params['page']++;