X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2FException.php;h=6e968b3071cc5c1e438ba7cc9c5342db5fd36630;hb=5518b80416919e1f0aadcf1e595f83e93f57380e;hp=8c6ca5ba73d26c9e04381065d2416509547692f6;hpb=cdedc5f3d54bf870f80f092af6f9676786fb99db;p=civicrm-core.git diff --git a/api/Exception.php b/api/Exception.php index 8c6ca5ba73..6e968b3071 100644 --- a/api/Exception.php +++ b/api/Exception.php @@ -5,7 +5,7 @@ * * @package CiviCRM_APIv3 * - * @copyright CiviCRM LLC (c) 2004-2017 + * @copyright CiviCRM LLC (c) 2004-2019 */ /** @@ -20,7 +20,7 @@ class API_Exception extends Exception { const UNAUTHORIZED = 'unauthorized'; const NOT_IMPLEMENTED = 'not-found'; - private $extraParams = array(); + private $extraParams = []; /** * Class constructor. @@ -37,7 +37,7 @@ class API_Exception extends Exception { * @param Exception|NULL $previous * A previous exception which caused this new exception. */ - public function __construct($message, $error_code = 0, $extraParams = array(), Exception $previous = NULL) { + public function __construct($message, $error_code = 0, $extraParams = [], Exception $previous = NULL) { // Using int for error code "old way") ? if (is_numeric($error_code)) { $code = $error_code; @@ -46,7 +46,7 @@ class API_Exception extends Exception { $code = 0; } parent::__construct(ts($message), $code, $previous); - $this->extraParams = $extraParams + array('error_code' => $error_code); + $this->extraParams = $extraParams + ['error_code' => $error_code]; } /** @@ -73,13 +73,13 @@ class API_Exception extends Exception { * @return array */ public function getErrorCodes() { - return array( + return [ 2000 => '$params was not an array', 2001 => 'Invalid Value for Date field', 2100 => 'String value is longer than permitted length', self::UNAUTHORIZED => 'Unauthorized', self::NOT_IMPLEMENTED => 'Entity or method is not implemented', - ); + ]; } } @@ -89,7 +89,7 @@ class API_Exception extends Exception { * API_Exception from the api wrapper as the namespace is more generic */ class CiviCRM_API3_Exception extends Exception { - private $extraParams = array(); + private $extraParams = []; /** * Class constructor. @@ -106,9 +106,9 @@ class CiviCRM_API3_Exception extends Exception { * @param Exception|NULL $previous * A previous exception which caused this new exception. */ - public function __construct($message, $error_code, $extraParams = array(), Exception $previous = NULL) { + public function __construct($message, $error_code = 0, $extraParams = [], Exception $previous = NULL) { parent::__construct(ts($message)); - $this->extraParams = $extraParams + array('error_code' => $error_code); + $this->extraParams = $extraParams + ['error_code' => $error_code]; } /**