Browse Source

Avoid use statement for exceptions within same namespace.

ADmad 12 years ago
parent
commit
d670aafef9
3 changed files with 14 additions and 17 deletions
  1. 3 4
      src/Routing/Dispatcher.php
  2. 11 12
      src/Utility/Xml.php
  3. 0 1
      src/View/View.php

+ 3 - 4
src/Routing/Dispatcher.php

@@ -24,13 +24,12 @@ use Cake\Controller\Error\MissingControllerException;
 use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Plugin;
-use Cake\Error;
+use Cake\Error\Exception;
 use Cake\Event\Event;
 use Cake\Event\EventListener;
 use Cake\Event\EventManager;
 use Cake\Network\Request;
 use Cake\Network\Response;
-use Cake\Routing\Error\MissingDispatcherFilterException;
 use Cake\Utility\Inflector;
 use Cake\View\View;
 
@@ -110,7 +109,7 @@ class Dispatcher implements EventListener {
 			if (is_string($filter['callable'])) {
 				$callable = App::classname($filter['callable'], 'Routing/Filter');
 				if (!$callable) {
-					throw new MissingDispatcherFilterException($filter['callable']);
+					throw new Error\MissingDispatcherFilterException($filter['callable']);
 				}
 				$manager->attach(new $callable($settings));
 			} else {
@@ -193,7 +192,7 @@ class Dispatcher implements EventListener {
 
 		$response = $controller->invokeAction();
 		if ($response !== null && !($response instanceof Response)) {
-			throw new Error\Exception('Controller action can only return an instance of Response');
+			throw new Exception('Controller action can only return an instance of Response');
 		}
 
 		if (!$response && $controller->autoRender) {

+ 11 - 12
src/Utility/Xml.php

@@ -19,9 +19,8 @@
 namespace Cake\Utility;
 
 use Cake\Core\Configure;
-use Cake\Network\Error;
+use Cake\Network\Error\SocketException;
 use Cake\Network\Http\Client;
-use Cake\Utility\Error\XmlException;
 use \DOMDocument;
 
 /**
@@ -105,16 +104,16 @@ class Xml {
 				$socket = new Client(['redirect' => 10]);
 				$response = $socket->get($input);
 				if (!$response->isOk()) {
-					throw new XmlException('XML cannot be read.');
+					throw new Error\XmlException('XML cannot be read.');
 				}
 				return static::_loadXml($response->body, $options);
 			} catch (SocketException $e) {
-				throw new XmlException('XML cannot be read.');
+				throw new Error\XmlException('XML cannot be read.');
 			}
 		} elseif (!is_string($input)) {
-			throw new XmlException('Invalid input.');
+			throw new Error\XmlException('Invalid input.');
 		}
-		throw new XmlException('XML cannot be read.');
+		throw new Error\XmlException('XML cannot be read.');
 	}
 
 /**
@@ -146,7 +145,7 @@ class Xml {
 		}
 		libxml_use_internal_errors($internalErrors);
 		if ($xml === null) {
-			throw new XmlException('Xml cannot be read.');
+			throw new Error\XmlException('Xml cannot be read.');
 		}
 		return $xml;
 	}
@@ -191,11 +190,11 @@ class Xml {
  */
 	public static function fromArray(array $input, $options = array()) {
 		if (!is_array($input) || count($input) !== 1) {
-			throw new XmlException('Invalid input.');
+			throw new Error\XmlException('Invalid input.');
 		}
 		$key = key($input);
 		if (is_int($key)) {
-			throw new XmlException('The key of input must be alphanumeric');
+			throw new Error\XmlException('The key of input must be alphanumeric');
 		}
 
 		if (!is_array($options)) {
@@ -272,7 +271,7 @@ class Xml {
 					}
 				} else {
 					if ($key[0] === '@') {
-						throw new XmlException('Invalid array');
+						throw new Error\XmlException('Invalid array');
 					}
 					if (is_numeric(implode('', array_keys($value)))) { // List
 						foreach ($value as $item) {
@@ -285,7 +284,7 @@ class Xml {
 					}
 				}
 			} else {
-				throw new XmlException('Invalid array');
+				throw new Error\XmlException('Invalid array');
 			}
 		}
 	}
@@ -336,7 +335,7 @@ class Xml {
 			$obj = simplexml_import_dom($obj);
 		}
 		if (!($obj instanceof \SimpleXMLElement)) {
-			throw new XmlException('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.');
+			throw new Error\XmlException('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.');
 		}
 		$result = array();
 		$namespaces = array_merge(array('' => ''), $obj->getNamespaces(true));

+ 0 - 1
src/View/View.php

@@ -29,7 +29,6 @@ use Cake\Routing\RequestActionTrait;
 use Cake\Routing\Router;
 use Cake\Utility\Inflector;
 use Cake\Utility\ViewVarsTrait;
-use Cake\View\Error;
 
 /**
  * View, the V in the MVC triad. View interacts with Helpers and view variables passed