From 480debb7b6dc958497c8356a47990299ccbdf46d Mon Sep 17 00:00:00 2001 From: swoft-bot Date: Tue, 16 Oct 2018 18:43:27 +0800 Subject: [PATCH] Squashed 'src/framework/' changes from 7ebaf5f..b3a45be MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit b3a45be fix error on trigger event handler (https://github.com/swoft-cloud/swoft-component/pull/196) b1a48cd fix a bug when warnings appear in the high version of swoole (https://github.com/swoft-cloud/swoft-component/pull/195) 9c4da9f 自定义组件支持别名配置 (https://github.com/swoft-cloud/swoft-component/pull/181) bccf7a6 修复restart不能正常使用的BUG (https://github.com/swoft-cloud/swoft-component/pull/180) 97bfe2e 修改连接池配置的timeout字段为float (https://github.com/swoft-cloud/swoft-component/pull/177) 525097b 修改自定义组件只能扫描Aop、Command、Bootstrap三个文件的BUG (https://github.com/swoft-cloud/swoft-component/pull/169) 0b5f320 兼容swoole 4.0.3版本 (https://github.com/swoft-cloud/swoft-component/pull/166) 1d11b56 增加用户自定义组件配置 (https://github.com/swoft-cloud/swoft-component/pull/150) ba1657b Upstream travis ci config (https://github.com/swoft-cloud/swoft-component/pull/160) ffdb60e 修复Json Validator会失效的BUG (https://github.com/swoft-cloud/swoft-component/pull/153) 4d788e9 修复自定义注解无法使用Aop切面编程的BUG (https://github.com/swoft-cloud/swoft-component/pull/139) 405a83e Optimize (https://github.com/swoft-cloud/swoft-component/pull/143) b72e04c 修复执行php bin/swoft stop命令时master进程异常未退出的问题,以及停止失败后,pid文件被删除的问题 (#134) a30bf58 修改`ComposerHelper::getDirByNamespace`匹配有误的BUG (https://github.com/swoft-cloud/swoft-component/pull/137) 43088e6 Update PoolHelper.php (https://github.com/swoft-cloud/swoft-component/pull/131) 82aadc2 Scan bean according to Composer settings (#115) 5e55e72 Add psysh for debug (https://github.com/swoft-cloud/swoft-component/pull/109) 93c3ec7 Parse namespace to dir path according to composer settings (https://github.com/swoft-cloud/swoft-component/pull/103) 2da84a5 fix https://github.com/swoft-cloud/swoft/issues/277 (#96) fc8e1b3 Merge commit 'ab0f47838db6f3739146d53c3b48d3fb11c7675e' 33faf07 fix logWriter (#95) f3075d8 Uniform log path format (https://github.com/swoft-cloud/swoft-component/pull/94) 7003d92 Merge commit '30a1120da2a33a98360ee4da4e4586ad3412b5f2' e8da860 [fixed]eval error with void method (#92) 5cf5896 [fixed] logger->messages init error (#91) 52bbec6 Merge pull request #114 from aprchen/patch-1 847f23b fix spanid c559c93 add coWrite(); use swoft/swoole-ide-helper (#83) 21d268b change fix e88a03f fix index err 620394d Merge commit '1643eb132396c22e6c9be8c90d123a31487455dd' 0d8bb66 add some cosnt, add global func config() REVERT: 7ebaf5f 修复Number验证器最大和最小的template没有生效的问题 (#218) REVERT: ed18988 fix error on trigger event handler (https://github.com/swoft-cloud/swoft-component/pull/196) REVERT: bf188ad fix a bug when warnings appear in the high version of swoole (https://github.com/swoft-cloud/swoft-component/pull/195) REVERT: 4ec3be6 自定义组件支持别名配置 (https://github.com/swoft-cloud/swoft-component/pull/181) REVERT: 609dd83 修复restart不能正常使用的BUG (https://github.com/swoft-cloud/swoft-component/pull/180) REVERT: 0bcd9bc 修改连接池配置的timeout字段为float (https://github.com/swoft-cloud/swoft-component/pull/177) REVERT: 0044361 修改自定义组件只能扫描Aop、Command、Bootstrap三个文件的BUG (https://github.com/swoft-cloud/swoft-component/pull/169) REVERT: 99916fc 兼容swoole 4.0.3版本 (https://github.com/swoft-cloud/swoft-component/pull/166) REVERT: a1d6ace 增加用户自定义组件配置 (https://github.com/swoft-cloud/swoft-component/pull/150) REVERT: d0f7f88 Upstream travis ci config (https://github.com/swoft-cloud/swoft-component/pull/160) REVERT: afb115f 修复Json Validator会失效的BUG (https://github.com/swoft-cloud/swoft-component/pull/153) REVERT: 5fdf6c7 修复自定义注解无法使用Aop切面编程的BUG (https://github.com/swoft-cloud/swoft-component/pull/139) REVERT: 3c147d1 Optimize (https://github.com/swoft-cloud/swoft-component/pull/143) REVERT: c98825b 修复执行php bin/swoft stop命令时master进程异常未退出的问题,以及停止失败后,pid文件被删除的问题 (#134) REVERT: 940f76f 修改`ComposerHelper::getDirByNamespace`匹配有误的BUG (https://github.com/swoft-cloud/swoft-component/pull/137) REVERT: 427dcb6 Update PoolHelper.php (https://github.com/swoft-cloud/swoft-component/pull/131) REVERT: fc38546 Scan bean according to Composer settings (#115) REVERT: 851f3f0 Add psysh for debug (https://github.com/swoft-cloud/swoft-component/pull/109) REVERT: e55fae5 Parse namespace to dir path according to composer settings (https://github.com/swoft-cloud/swoft-component/pull/103) REVERT: 290a2f4 fix https://github.com/swoft-cloud/swoft/issues/277 (#96) REVERT: 0d2dade fix logWriter (#95) REVERT: 1f1af6c Uniform log path format (https://github.com/swoft-cloud/swoft-component/pull/94) REVERT: 148daeb [fixed]eval error with void method (#92) REVERT: a22481a [fixed] logger->messages init error (#91) REVERT: 69975cd add coWrite(); use swoft/swoole-ide-helper (#83) REVERT: 7f66cef change fix REVERT: 410b028 fix index err git-subtree-dir: src/framework git-subtree-split: b3a45be705c9cb53cb357925e228e4f60e6d76d5 --- Helper/ValidatorHelper.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Helper/ValidatorHelper.php b/Helper/ValidatorHelper.php index a5d5c085..d068fe9d 100644 --- a/Helper/ValidatorHelper.php +++ b/Helper/ValidatorHelper.php @@ -4,6 +4,11 @@ use Swoft\Exception\ValidatorException; +/** + * Class ValidatorHelper + * + * @package Swoft\Helper + */ class ValidatorHelper { /** @@ -115,15 +120,15 @@ public static function validateNumber(string $name, $value, $min = null, $max = $value = (int)$value; if ($min !== null && $value < $min) { - $template = empty($template) ? sprintf('Parameter %s is too short (minimum is %d)', $name, $min): $template; + $template = empty($template) ?: $template; - return self::validateError($template, $throws); + return self::validateError(sprintf('Parameter %s is too small (minimum is %d)', $name, $min), $throws); } if ($max !== null && $value > $max) { - $template = empty($template) ? sprintf('Parameter %s is too large (maximum is %d)', $name, $max) : $template; + $template = empty($template) ?: $template; - return self::validateError($template, $throws); + return self::validateError(sprintf('Parameter %s is too big (maximum is %d)', $name, $max), $throws); } return (int)$value; @@ -172,13 +177,13 @@ public static function validateFloat( $value = (float)$value; if ($min !== null && $value < $min) { - $template = empty($template) ? sprintf('Parameter %s is too short (minimum is %d)', $name, $min) : $template; + $template = empty($template) ? sprintf('Parameter %s is too small (minimum is %d)', $name, $min) : $template; return self::validateError($template, $throws); } if ($max !== null && $value > $max) { - $template = empty($template) ? sprintf('Parameter %s is too large (maximum is %d)', $name, $max) : $template; + $template = empty($template) ? sprintf('Parameter %s is too big (maximum is %d)', $name, $max) : $template; return self::validateError($template, $throws); }