X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FType.php;h=8dfc7d6295063084a44c53bbf44cdebf0b814150;hb=f2403471b460a122ac834d3c980e8c227b08ac79;hp=54abc84763e947b62494af3c8f3b718c43526f90;hpb=306a8600bda01b8478c6be87c528139817833bad;p=civicrm-core.git diff --git a/CRM/Utils/Type.php b/CRM/Utils/Type.php index 54abc84763..8dfc7d6295 100644 --- a/CRM/Utils/Type.php +++ b/CRM/Utils/Type.php @@ -196,11 +196,18 @@ class CRM_Utils_Type { /** * Helper function to call validate on arrays * + * @param mixed $data + * @param string $type + * + * @return mixed + * + * @throws \CRM_Core_Exception + * * @see validate */ - public static function validateAll($data, $type, $abort = TRUE) { + public static function validateAll($data, $type) { foreach ($data as $key => $value) { - $data[$key] = CRM_Utils_Type::validate($value, $type, $abort); + $data[$key] = CRM_Utils_Type::validate($value, $type); } return $data; } @@ -351,15 +358,13 @@ class CRM_Utils_Type { * If TRUE, the operation will CRM_Core_Error::fatal() on invalid data. * @param string $name * The name of the attribute - * @param bool $isThrowException - * Should an exception be thrown rather than a using a deprecated fatal error. * * @return mixed * The data, escaped if necessary * * @throws \CRM_Core_Exception */ - public static function validate($data, $type, $abort = TRUE, $name = 'One of parameters ', $isThrowException = TRUE) { + public static function validate($data, $type, $abort = TRUE, $name = 'One of parameters ') { $possibleTypes = [ 'Integer', @@ -385,10 +390,7 @@ class CRM_Utils_Type { 'Color', ]; if (!in_array($type, $possibleTypes)) { - if ($isThrowException) { - throw new CRM_Core_Exception(ts('Invalid type, must be one of : ' . implode($possibleTypes))); - } - CRM_Core_Error::fatal(ts('Invalid type, must be one of : ' . implode($possibleTypes))); + throw new CRM_Core_Exception(ts('Invalid type, must be one of : ' . implode($possibleTypes))); } switch ($type) { case 'Integer': @@ -465,10 +467,7 @@ class CRM_Utils_Type { if ($abort) { $data = htmlentities($data); - if ($isThrowException) { - throw new CRM_Core_Exception("$name (value: $data) is not of the type $type"); - } - CRM_Core_Error::fatal("$name (value: $data) is not of the type $type"); + throw new CRM_Core_Exception("$name (value: $data) is not of the type $type"); } return NULL;