[更新]ComposerUpdate

This commit is contained in:
Anyon 2019-02-14 14:42:19 +08:00
parent 4ef806989d
commit 4e3dab96c5
22 changed files with 287 additions and 346 deletions

View File

@ -2,13 +2,14 @@
"type": "project",
"name": "zoujingli/thinkadmin",
"license": "MIT",
"keywords": ["thinkphp", "thinkadmin"],
"homepage": "http://demo.thinkadmin.top",
"description": "ThinkAdmin Developer CMF",
"authors": [{"name": "Anyon", "email": "zoujingli@qq.com"}],
"extra": {"think-path": "thinkphp"},
"config": {"preferred-install": "dist"},
"autoload": {"psr-4": {"app\\": "application"}},
"authors": [
{
"name": "Anyon",
"email": "zoujingli@qq.com"
}
],
"require": {
"php": ">=5.6.0",
"qiniu/php-sdk": "^7.2",

View File

@ -533,7 +533,7 @@ if (!function_exists('response')) {
* @param string $type
* @return Response
*/
function response($data = [], $code = 200, $header = [], $type = 'html')
function response($data = '', $code = 200, $header = [], $type = 'html')
{
return Response::create($data, $type, $code, $header);
}

View File

@ -20,7 +20,7 @@ use think\route\Dispatch;
*/
class App extends Container
{
const VERSION = '5.1.33 LTS';
const VERSION = '5.1.34 LTS';
/**
* 当前模块路径

View File

@ -300,7 +300,7 @@ class File extends SplFileObject
*/
public function checkSize($size)
{
if ($this->getSize() > $size) {
if ($this->getSize() > (int) $size) {
$this->error = 'filesize not match';
return false;
}

View File

@ -1529,7 +1529,7 @@ class Request
*/
public function has($name, $type = 'param', $checkEmpty = false)
{
if (!in_array($type, ['param', 'get', 'post', 'request', 'put', 'file', 'session', 'cookie', 'env', 'header', 'route'])) {
if (!in_array($type, ['param', 'get', 'post', 'request', 'put', 'patch', 'file', 'session', 'cookie', 'env', 'header', 'route'])) {
return false;
}

View File

@ -408,7 +408,7 @@ class Route
$result = $this->bind[$domain];
} elseif (isset($name) && isset($this->bind[$name])) {
$result = $this->bind[$name];
} elseif (isset($this->bind['*'])) {
} elseif (!empty($subDomain) && isset($this->bind['*'])) {
$result = $this->bind['*'];
} else {
$result = null;

View File

@ -567,10 +567,11 @@ class Validate
} elseif (true !== $result) {
// 返回自定义错误信息
if (is_string($result) && false !== strpos($result, ':')) {
$result = str_replace(
[':attribute', ':rule'],
[$title, (string) $rule],
$result);
$result = str_replace(':attribute', $title, $result);
if (strpos($result, ':rule') && is_scalar($rule)) {
$msg = str_replace(':rule', (string) $rule, $result);
}
}
return $result;
@ -1012,6 +1013,8 @@ class Validate
$map[] = [$key, '=', $data[$key]];
}
}
} elseif (strpos($key, '=')) {
parse_str($key, $map);
} elseif (isset($data[$field])) {
$map[] = [$key, '=', $data[$field]];
} else {
@ -1469,13 +1472,17 @@ class Validate
$msg = $title . $lang->get('not conform to the rules');
}
if (is_string($msg) && 0 === strpos($msg, '{%')) {
if (!is_string($msg)) {
return $msg;
}
if (0 === strpos($msg, '{%')) {
$msg = $lang->get(substr($msg, 2, -1));
} elseif ($lang->has($msg)) {
$msg = $lang->get($msg);
}
if (is_string($msg) && is_scalar($rule) && false !== strpos($msg, ':')) {
if (is_scalar($rule) && false !== strpos($msg, ':')) {
// 变量替换
if (is_string($rule) && strpos($rule, ',')) {
$array = array_pad(explode(',', $rule), 3, '');
@ -1483,9 +1490,12 @@ class Validate
$array = array_pad([], 3, '');
}
$msg = str_replace(
[':attribute', ':rule', ':1', ':2', ':3'],
[$title, (string) $rule, $array[0], $array[1], $array[2]],
[':attribute', ':1', ':2', ':3'],
[$title, $array[0], $array[1], $array[2]],
$msg);
if (strpos($msg, ':rule')) {
$msg = str_replace(':rule', (string) $rule, $msg);
}
}
return $msg;

View File

@ -647,6 +647,8 @@ abstract class Builder
// IN 查询
if ($value instanceof \Closure) {
$value = $this->parseClosure($query, $value, false);
} elseif ($value instanceof Expression) {
$value = $value->getValue();
} else {
$value = array_unique(is_array($value) ? $value : explode(',', $value));

View File

@ -611,9 +611,9 @@ class Query
/**
* 聚合查询
* @access public
* @param string $aggregate 聚合方法
* @param string $field 字段名
* @param bool $force 强制转为数字类型
* @param string $aggregate 聚合方法
* @param string|Expression $field 字段名
* @param bool $force 强制转为数字类型
* @return mixed
*/
public function aggregate($aggregate, $field, $force = false)
@ -634,7 +634,7 @@ class Query
/**
* COUNT查询
* @access public
* @param string $field 字段名
* @param string|Expression $field 字段名
* @return float|string
*/
public function count($field = '*')
@ -664,7 +664,7 @@ class Query
/**
* SUM查询
* @access public
* @param string $field 字段名
* @param string|Expression $field 字段名
* @return float
*/
public function sum($field)
@ -675,8 +675,8 @@ class Query
/**
* MIN查询
* @access public
* @param string $field 字段名
* @param bool $force 强制转为数字类型
* @param string|Expression $field 字段名
* @param bool $force 强制转为数字类型
* @return mixed
*/
public function min($field, $force = true)
@ -687,8 +687,8 @@ class Query
/**
* MAX查询
* @access public
* @param string $field 字段名
* @param bool $force 强制转为数字类型
* @param string|Expression $field 字段名
* @param bool $force 强制转为数字类型
* @return mixed
*/
public function max($field, $force = true)
@ -699,7 +699,7 @@ class Query
/**
* AVG查询
* @access public
* @param string $field 字段名
* @param string|Expression $field 字段名
* @return float
*/
public function avg($field)
@ -1582,7 +1582,7 @@ class Query
// 字段相等查询
$where = [$field, '=', $op];
}
} elseif (in_array(strtoupper($op), ['REGEXP', 'NOT REGEXP', 'EXISTS', 'NOT EXISTS', 'NOTEXISTS'], true)) {
} elseif (in_array(strtoupper($op), ['EXISTS', 'NOT EXISTS', 'NOTEXISTS'], true)) {
$where = [$field, $op, is_string($condition) ? $this->raw($condition) : $condition];
} else {
$where = $field ? [$field, $op, $condition, isset($param[2]) ? $param[2] : null] : null;

View File

@ -94,13 +94,17 @@ class Mysql extends Builder
* @param Query $query 查询对象
* @param string $key
* @param string $exp
* @param Expression $value
* @param mixed $value
* @param string $field
* @return string
*/
protected function parseRegexp(Query $query, $key, $exp, Expression $value, $field)
protected function parseRegexp(Query $query, $key, $exp, $value, $field)
{
return $key . ' ' . $exp . ' ' . $value->getValue();
if ($value instanceof Expression) {
$value = $value->getValue();
}
return $key . ' ' . $exp . ' ' . $value;
}
/**
@ -145,7 +149,7 @@ class Mysql extends Builder
throw new Exception('not support data:' . $key);
}
if ('*' != $key && ($strict || !preg_match('/[,\'\"\*\(\)`.\s]/', $key))) {
if ('*' != $key && !preg_match('/[,\'\"\*\(\)`.\s]/', $key)) {
$key = '`' . $key . '`';
}

View File

@ -114,7 +114,7 @@ class Sqlsrv extends Builder
throw new Exception('not support data:' . $key);
}
if ('*' != $key && ($strict || !preg_match('/[,\'\"\*\(\)\[.\s]/', $key))) {
if ('*' != $key && !preg_match('/[,\'\"\*\(\)\[.\s]/', $key)) {
$key = '[' . $key . ']';
}

View File

@ -12,6 +12,7 @@
namespace think\model\concern;
use InvalidArgumentException;
use think\db\Expression;
use think\Exception;
use think\Loader;
use think\model\Relation;
@ -407,6 +408,10 @@ trait Attribute
return;
}
if ($value instanceof Expression) {
return $value;
}
if (is_array($type)) {
list($type, $param) = $type;
} elseif (strpos($type, ':')) {

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit3453515942e444a26be0d4b35ca72189::getLoader();
return ComposerAutoloaderInit53186b8f9ced5efc2d0ef0e9b2b040f3::getLoader();

View File

@ -176,42 +176,6 @@ return array(
'WePay\\Refund' => $vendorDir . '/zoujingli/wechat-developer/WePay/Refund.php',
'WePay\\Transfers' => $vendorDir . '/zoujingli/wechat-developer/WePay/Transfers.php',
'WePay\\TransfersBank' => $vendorDir . '/zoujingli/wechat-developer/WePay/TransfersBank.php',
'app\\admin\\controller\\Auth' => $baseDir . '/application/admin/controller/Auth.php',
'app\\admin\\controller\\Config' => $baseDir . '/application/admin/controller/Config.php',
'app\\admin\\controller\\Index' => $baseDir . '/application/admin/controller/Index.php',
'app\\admin\\controller\\Log' => $baseDir . '/application/admin/controller/Log.php',
'app\\admin\\controller\\Login' => $baseDir . '/application/admin/controller/Login.php',
'app\\admin\\controller\\Menu' => $baseDir . '/application/admin/controller/Menu.php',
'app\\admin\\controller\\Node' => $baseDir . '/application/admin/controller/Node.php',
'app\\admin\\controller\\Plugs' => $baseDir . '/application/admin/controller/Plugs.php',
'app\\admin\\controller\\User' => $baseDir . '/application/admin/controller/User.php',
'app\\admin\\middleware\\Auth' => $baseDir . '/application/admin/middleware/Auth.php',
'app\\index\\controller\\Index' => $baseDir . '/application/index/controller/Index.php',
'app\\store\\controller\\Express' => $baseDir . '/application/store/controller/Express.php',
'app\\store\\controller\\Goods' => $baseDir . '/application/store/controller/Goods.php',
'app\\store\\controller\\GoodsBrand' => $baseDir . '/application/store/controller/GoodsBrand.php',
'app\\store\\controller\\GoodsCate' => $baseDir . '/application/store/controller/GoodsCate.php',
'app\\store\\controller\\GoodsSpec' => $baseDir . '/application/store/controller/GoodsSpec.php',
'app\\store\\controller\\Order' => $baseDir . '/application/store/controller/Order.php',
'app\\store\\controller\\wechat\\Demo' => $baseDir . '/application/store/controller/wechat/Demo.php',
'app\\store\\controller\\wechat\\Index' => $baseDir . '/application/store/controller/wechat/Index.php',
'app\\store\\service\\GoodsService' => $baseDir . '/application/store/service/GoodsService.php',
'app\\store\\service\\MemberService' => $baseDir . '/application/store/service/MemberService.php',
'app\\store\\service\\OrderService' => $baseDir . '/application/store/service/OrderService.php',
'app\\wechat\\controller\\Config' => $baseDir . '/application/wechat/controller/Config.php',
'app\\wechat\\controller\\Fans' => $baseDir . '/application/wechat/controller/Fans.php',
'app\\wechat\\controller\\FansBlock' => $baseDir . '/application/wechat/controller/FansBlock.php',
'app\\wechat\\controller\\Keys' => $baseDir . '/application/wechat/controller/Keys.php',
'app\\wechat\\controller\\Menu' => $baseDir . '/application/wechat/controller/Menu.php',
'app\\wechat\\controller\\News' => $baseDir . '/application/wechat/controller/News.php',
'app\\wechat\\controller\\Review' => $baseDir . '/application/wechat/controller/Review.php',
'app\\wechat\\controller\\Tags' => $baseDir . '/application/wechat/controller/Tags.php',
'app\\wechat\\controller\\api\\Js' => $baseDir . '/application/wechat/controller/api/Js.php',
'app\\wechat\\controller\\api\\Push' => $baseDir . '/application/wechat/controller/api/Push.php',
'app\\wechat\\controller\\api\\Tools' => $baseDir . '/application/wechat/controller/api/Tools.php',
'app\\wechat\\service\\FansService' => $baseDir . '/application/wechat/service/FansService.php',
'app\\wechat\\service\\MediaService' => $baseDir . '/application/wechat/service/MediaService.php',
'app\\wechat\\service\\TagsService' => $baseDir . '/application/wechat/service/TagsService.php',
'think\\captcha\\Captcha' => $vendorDir . '/topthink/think-captcha/src/Captcha.php',
'think\\captcha\\CaptchaController' => $vendorDir . '/topthink/think-captcha/src/CaptchaController.php',
'think\\composer\\Plugin' => $vendorDir . '/topthink/think-installer/src/Plugin.php',

View File

@ -8,7 +8,6 @@ $baseDir = dirname($vendorDir);
return array(
'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'),
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
'app\\' => array($baseDir . '/application'),
'WePay\\' => array($vendorDir . '/zoujingli/wechat-developer/WePay'),
'WeOpen\\' => array($vendorDir . '/zoujingli/weopen-developer/WeOpen'),
'WeMini\\' => array($vendorDir . '/zoujingli/wechat-developer/WeMini', $vendorDir . '/zoujingli/weopen-developer/WeMini'),

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit3453515942e444a26be0d4b35ca72189
class ComposerAutoloaderInit53186b8f9ced5efc2d0ef0e9b2b040f3
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInit3453515942e444a26be0d4b35ca72189
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit3453515942e444a26be0d4b35ca72189', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit53186b8f9ced5efc2d0ef0e9b2b040f3', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit3453515942e444a26be0d4b35ca72189', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit53186b8f9ced5efc2d0ef0e9b2b040f3', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit3453515942e444a26be0d4b35ca72189::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit53186b8f9ced5efc2d0ef0e9b2b040f3::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInit3453515942e444a26be0d4b35ca72189
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit3453515942e444a26be0d4b35ca72189::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit53186b8f9ced5efc2d0ef0e9b2b040f3::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire3453515942e444a26be0d4b35ca72189($fileIdentifier, $file);
composerRequire53186b8f9ced5efc2d0ef0e9b2b040f3($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire3453515942e444a26be0d4b35ca72189($fileIdentifier, $file)
function composerRequire53186b8f9ced5efc2d0ef0e9b2b040f3($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit3453515942e444a26be0d4b35ca72189
class ComposerStaticInit53186b8f9ced5efc2d0ef0e9b2b040f3
{
public static $files = array (
'841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php',
@ -17,10 +17,6 @@ class ComposerStaticInit3453515942e444a26be0d4b35ca72189
'think\\composer\\' => 15,
'think\\captcha\\' => 14,
),
'a' =>
array (
'app\\' => 4,
),
'W' =>
array (
'WePay\\' => 6,
@ -59,10 +55,6 @@ class ComposerStaticInit3453515942e444a26be0d4b35ca72189
array (
0 => __DIR__ . '/..' . '/topthink/think-captcha/src',
),
'app\\' =>
array (
0 => __DIR__ . '/../..' . '/application',
),
'WePay\\' =>
array (
0 => __DIR__ . '/..' . '/zoujingli/wechat-developer/WePay',
@ -274,42 +266,6 @@ class ComposerStaticInit3453515942e444a26be0d4b35ca72189
'WePay\\Refund' => __DIR__ . '/..' . '/zoujingli/wechat-developer/WePay/Refund.php',
'WePay\\Transfers' => __DIR__ . '/..' . '/zoujingli/wechat-developer/WePay/Transfers.php',
'WePay\\TransfersBank' => __DIR__ . '/..' . '/zoujingli/wechat-developer/WePay/TransfersBank.php',
'app\\admin\\controller\\Auth' => __DIR__ . '/../..' . '/application/admin/controller/Auth.php',
'app\\admin\\controller\\Config' => __DIR__ . '/../..' . '/application/admin/controller/Config.php',
'app\\admin\\controller\\Index' => __DIR__ . '/../..' . '/application/admin/controller/Index.php',
'app\\admin\\controller\\Log' => __DIR__ . '/../..' . '/application/admin/controller/Log.php',
'app\\admin\\controller\\Login' => __DIR__ . '/../..' . '/application/admin/controller/Login.php',
'app\\admin\\controller\\Menu' => __DIR__ . '/../..' . '/application/admin/controller/Menu.php',
'app\\admin\\controller\\Node' => __DIR__ . '/../..' . '/application/admin/controller/Node.php',
'app\\admin\\controller\\Plugs' => __DIR__ . '/../..' . '/application/admin/controller/Plugs.php',
'app\\admin\\controller\\User' => __DIR__ . '/../..' . '/application/admin/controller/User.php',
'app\\admin\\middleware\\Auth' => __DIR__ . '/../..' . '/application/admin/middleware/Auth.php',
'app\\index\\controller\\Index' => __DIR__ . '/../..' . '/application/index/controller/Index.php',
'app\\store\\controller\\Express' => __DIR__ . '/../..' . '/application/store/controller/Express.php',
'app\\store\\controller\\Goods' => __DIR__ . '/../..' . '/application/store/controller/Goods.php',
'app\\store\\controller\\GoodsBrand' => __DIR__ . '/../..' . '/application/store/controller/GoodsBrand.php',
'app\\store\\controller\\GoodsCate' => __DIR__ . '/../..' . '/application/store/controller/GoodsCate.php',
'app\\store\\controller\\GoodsSpec' => __DIR__ . '/../..' . '/application/store/controller/GoodsSpec.php',
'app\\store\\controller\\Order' => __DIR__ . '/../..' . '/application/store/controller/Order.php',
'app\\store\\controller\\wechat\\Demo' => __DIR__ . '/../..' . '/application/store/controller/wechat/Demo.php',
'app\\store\\controller\\wechat\\Index' => __DIR__ . '/../..' . '/application/store/controller/wechat/Index.php',
'app\\store\\service\\GoodsService' => __DIR__ . '/../..' . '/application/store/service/GoodsService.php',
'app\\store\\service\\MemberService' => __DIR__ . '/../..' . '/application/store/service/MemberService.php',
'app\\store\\service\\OrderService' => __DIR__ . '/../..' . '/application/store/service/OrderService.php',
'app\\wechat\\controller\\Config' => __DIR__ . '/../..' . '/application/wechat/controller/Config.php',
'app\\wechat\\controller\\Fans' => __DIR__ . '/../..' . '/application/wechat/controller/Fans.php',
'app\\wechat\\controller\\FansBlock' => __DIR__ . '/../..' . '/application/wechat/controller/FansBlock.php',
'app\\wechat\\controller\\Keys' => __DIR__ . '/../..' . '/application/wechat/controller/Keys.php',
'app\\wechat\\controller\\Menu' => __DIR__ . '/../..' . '/application/wechat/controller/Menu.php',
'app\\wechat\\controller\\News' => __DIR__ . '/../..' . '/application/wechat/controller/News.php',
'app\\wechat\\controller\\Review' => __DIR__ . '/../..' . '/application/wechat/controller/Review.php',
'app\\wechat\\controller\\Tags' => __DIR__ . '/../..' . '/application/wechat/controller/Tags.php',
'app\\wechat\\controller\\api\\Js' => __DIR__ . '/../..' . '/application/wechat/controller/api/Js.php',
'app\\wechat\\controller\\api\\Push' => __DIR__ . '/../..' . '/application/wechat/controller/api/Push.php',
'app\\wechat\\controller\\api\\Tools' => __DIR__ . '/../..' . '/application/wechat/controller/api/Tools.php',
'app\\wechat\\service\\FansService' => __DIR__ . '/../..' . '/application/wechat/service/FansService.php',
'app\\wechat\\service\\MediaService' => __DIR__ . '/../..' . '/application/wechat/service/MediaService.php',
'app\\wechat\\service\\TagsService' => __DIR__ . '/../..' . '/application/wechat/service/TagsService.php',
'think\\captcha\\Captcha' => __DIR__ . '/..' . '/topthink/think-captcha/src/Captcha.php',
'think\\captcha\\CaptchaController' => __DIR__ . '/..' . '/topthink/think-captcha/src/CaptchaController.php',
'think\\composer\\Plugin' => __DIR__ . '/..' . '/topthink/think-installer/src/Plugin.php',
@ -321,9 +277,9 @@ class ComposerStaticInit3453515942e444a26be0d4b35ca72189
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit3453515942e444a26be0d4b35ca72189::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit3453515942e444a26be0d4b35ca72189::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit3453515942e444a26be0d4b35ca72189::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit53186b8f9ced5efc2d0ef0e9b2b040f3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit53186b8f9ced5efc2d0ef0e9b2b040f3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit53186b8f9ced5efc2d0ef0e9b2b040f3::$classMap;
}, null, ClassLoader::class);
}

View File

@ -177,17 +177,17 @@
},
{
"name": "symfony/options-resolver",
"version": "v3.4.21",
"version_normalized": "3.4.21.0",
"version": "v3.4.22",
"version_normalized": "3.4.22.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "8a10e36ffd04c0c551051594952304d34ecece71"
"reference": "0f1cbaee6b356e72c0e025f9a4e9d76a25bf4793"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/8a10e36ffd04c0c551051594952304d34ecece71",
"reference": "8a10e36ffd04c0c551051594952304d34ecece71",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/0f1cbaee6b356e72c0e025f9a4e9d76a25bf4793",
"reference": "0f1cbaee6b356e72c0e025f9a4e9d76a25bf4793",
"shasum": "",
"mirrors": [
{
@ -199,7 +199,7 @@
"require": {
"php": "^5.5.9|>=7.0.8"
},
"time": "2019-01-01T13:45:19+00:00",
"time": "2019-01-16T09:39:14+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -239,17 +239,17 @@
},
{
"name": "topthink/framework",
"version": "v5.1.33",
"version_normalized": "5.1.33.0",
"version": "v5.1.34",
"version_normalized": "5.1.34.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "477e1cef91290a36398ecbcdffcec7268d80f0dd"
"reference": "7c8cd1ea2bd4683a6ef46af415334260c6e2cc15"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/477e1cef91290a36398ecbcdffcec7268d80f0dd",
"reference": "477e1cef91290a36398ecbcdffcec7268d80f0dd",
"url": "https://api.github.com/repos/top-think/framework/zipball/7c8cd1ea2bd4683a6ef46af415334260c6e2cc15",
"reference": "7c8cd1ea2bd4683a6ef46af415334260c6e2cc15",
"shasum": "",
"mirrors": [
{
@ -271,7 +271,7 @@
"sebastian/phpcpd": "2.*",
"squizlabs/php_codesniffer": "2.*"
},
"time": "2019-01-16T06:10:52+00:00",
"time": "2019-01-30T06:38:38+00:00",
"type": "think-framework",
"installation-source": "dist",
"notification-url": "https://packagist.org/downloads/",
@ -394,17 +394,17 @@
},
{
"name": "zoujingli/ip2region",
"version": "v1.0.4",
"version_normalized": "1.0.4.0",
"version": "v1.0.5",
"version_normalized": "1.0.5.0",
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ip2region.git",
"reference": "0a55d6c1ab6b4cbaa204824557aa950aaaefda0e"
"reference": "944dc687304133027c4586a35ff78b57e56dd659"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ip2region/zipball/0a55d6c1ab6b4cbaa204824557aa950aaaefda0e",
"reference": "0a55d6c1ab6b4cbaa204824557aa950aaaefda0e",
"url": "https://api.github.com/repos/zoujingli/ip2region/zipball/944dc687304133027c4586a35ff78b57e56dd659",
"reference": "944dc687304133027c4586a35ff78b57e56dd659",
"shasum": "",
"mirrors": [
{
@ -416,7 +416,7 @@
"require": {
"php": ">=5.3"
},
"time": "2018-06-01T02:21:05+00:00",
"time": "2019-01-23T06:23:53+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {

View File

@ -29,51 +29,51 @@ class OptionsResolver implements Options
/**
* The names of all defined options.
*/
private $defined = array();
private $defined = [];
/**
* The default option values.
*/
private $defaults = array();
private $defaults = [];
/**
* The names of required options.
*/
private $required = array();
private $required = [];
/**
* The resolved option values.
*/
private $resolved = array();
private $resolved = [];
/**
* A list of normalizer closures.
*
* @var \Closure[]
*/
private $normalizers = array();
private $normalizers = [];
/**
* A list of accepted values for each option.
*/
private $allowedValues = array();
private $allowedValues = [];
/**
* A list of accepted types for each option.
*/
private $allowedTypes = array();
private $allowedTypes = [];
/**
* A list of closures for evaluating lazy options.
*/
private $lazy = array();
private $lazy = [];
/**
* A list of lazy options whose closure is currently being called.
*
* This list helps detecting circular dependencies between lazy options.
*/
private $calling = array();
private $calling = [];
/**
* Whether the instance is locked for reading.
@ -85,11 +85,11 @@ class OptionsResolver implements Options
*/
private $locked = false;
private static $typeAliases = array(
private static $typeAliases = [
'boolean' => 'bool',
'integer' => 'int',
'double' => 'float',
);
];
/**
* Sets the default value of a given option.
@ -154,7 +154,7 @@ class OptionsResolver implements Options
// Ignore previous lazy options if the closure has no second parameter
if (!isset($this->lazy[$option]) || !isset($params[1])) {
$this->lazy[$option] = array();
$this->lazy[$option] = [];
}
// Store closure for later evaluation
@ -423,7 +423,7 @@ class OptionsResolver implements Options
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
}
$this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : array($allowedValues);
$this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : [$allowedValues];
// Make sure the option is processed
unset($this->resolved[$option]);
@ -465,7 +465,7 @@ class OptionsResolver implements Options
}
if (!\is_array($allowedValues)) {
$allowedValues = array($allowedValues);
$allowedValues = [$allowedValues];
}
if (!isset($this->allowedValues[$option])) {
@ -590,14 +590,14 @@ class OptionsResolver implements Options
throw new AccessException('Options cannot be cleared from a lazy option or normalizer.');
}
$this->defined = array();
$this->defaults = array();
$this->required = array();
$this->resolved = array();
$this->lazy = array();
$this->normalizers = array();
$this->allowedTypes = array();
$this->allowedValues = array();
$this->defined = [];
$this->defaults = [];
$this->required = [];
$this->resolved = [];
$this->lazy = [];
$this->normalizers = [];
$this->allowedTypes = [];
$this->allowedValues = [];
return $this;
}
@ -626,7 +626,7 @@ class OptionsResolver implements Options
* @throws NoSuchOptionException If a lazy option reads an unavailable option
* @throws AccessException If called from a lazy option or normalizer
*/
public function resolve(array $options = array())
public function resolve(array $options = [])
{
if ($this->locked) {
throw new AccessException('Options cannot be resolved from a lazy option or normalizer.');
@ -735,7 +735,7 @@ class OptionsResolver implements Options
// Validate the type of the resolved option
if (isset($this->allowedTypes[$option])) {
$valid = false;
$invalidTypes = array();
$invalidTypes = [];
foreach ($this->allowedTypes[$option] as $type) {
$type = isset(self::$typeAliases[$type]) ? self::$typeAliases[$type] : $type;
@ -759,7 +759,7 @@ class OptionsResolver implements Options
// Validate the value of the resolved option
if (isset($this->allowedValues[$option])) {
$success = false;
$printableAllowedValues = array();
$printableAllowedValues = [];
foreach ($this->allowedValues[$option] as $allowedValue) {
if ($allowedValue instanceof \Closure) {
@ -981,7 +981,7 @@ class OptionsResolver implements Options
}
if (\is_array($value)) {
$subTypes = array();
$subTypes = [];
foreach ($value as $val) {
$subTypes[$this->formatTypeOf($val, null)] = true;
}

View File

@ -64,7 +64,7 @@ class OptionsResolverIntrospectorTest extends TestCase
public function testGetLazyClosures()
{
$resolver = new OptionsResolver();
$closures = array();
$closures = [];
$resolver->setDefault($option = 'foo', $closures[] = function (Options $options) {});
$debug = new OptionsResolverIntrospector($resolver);
@ -100,7 +100,7 @@ class OptionsResolverIntrospectorTest extends TestCase
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$resolver->setAllowedTypes($option = 'foo', $allowedTypes = array('string', 'bool'));
$resolver->setAllowedTypes($option = 'foo', $allowedTypes = ['string', 'bool']);
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame($allowedTypes, $debug->getAllowedTypes($option));
@ -135,7 +135,7 @@ class OptionsResolverIntrospectorTest extends TestCase
{
$resolver = new OptionsResolver();
$resolver->setDefined($option = 'foo');
$resolver->setAllowedValues($option = 'foo', $allowedValues = array('bar', 'baz'));
$resolver->setAllowedValues($option = 'foo', $allowedValues = ['bar', 'baz']);
$debug = new OptionsResolverIntrospector($resolver);
$this->assertSame($allowedValues, $debug->getAllowedValues($option));

View File

@ -38,7 +38,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('z', '1');
$this->resolver->setDefault('a', '2');
$this->resolver->resolve(array('foo' => 'bar'));
$this->resolver->resolve(['foo' => 'bar']);
}
/**
@ -50,7 +50,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('z', '1');
$this->resolver->setDefault('a', '2');
$this->resolver->resolve(array('ping' => 'pong', 'foo' => 'bar', 'baz' => 'bam'));
$this->resolver->resolve(['ping' => 'pong', 'foo' => 'bar', 'baz' => 'bam']);
}
/**
@ -59,7 +59,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsFromLazyOption()
{
$this->resolver->setDefault('foo', function (Options $options) {
$options->resolve(array());
$options->resolve([]);
});
$this->resolver->resolve();
@ -75,10 +75,10 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('one', '1');
$this->resolver->setDefault('two', '20');
$this->assertEquals(array(
$this->assertEquals([
'one' => '1',
'two' => '20',
), $this->resolver->resolve());
], $this->resolver->resolve());
}
/**
@ -118,7 +118,7 @@ class OptionsResolverTest extends TestCase
return 'lazy';
});
$this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'lazy'], $this->resolver->resolve());
}
public function testClosureWithoutTypeHintNotInvoked()
@ -129,7 +129,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('foo', $closure);
$this->assertSame(array('foo' => $closure), $this->resolver->resolve());
$this->assertSame(['foo' => $closure], $this->resolver->resolve());
}
public function testClosureWithoutParametersNotInvoked()
@ -140,7 +140,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('foo', $closure);
$this->assertSame(array('foo' => $closure), $this->resolver->resolve());
$this->assertSame(['foo' => $closure], $this->resolver->resolve());
}
public function testAccessPreviousDefaultValue()
@ -155,7 +155,7 @@ class OptionsResolverTest extends TestCase
return 'lazy';
});
$this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'lazy'], $this->resolver->resolve());
}
public function testAccessPreviousLazyDefaultValue()
@ -172,7 +172,7 @@ class OptionsResolverTest extends TestCase
return 'lazy';
});
$this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'lazy'], $this->resolver->resolve());
}
public function testPreviousValueIsNotEvaluatedIfNoSecondArgument()
@ -187,7 +187,7 @@ class OptionsResolverTest extends TestCase
return 'lazy';
});
$this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'lazy'], $this->resolver->resolve());
}
public function testOverwrittenLazyOptionNotEvaluated()
@ -198,7 +198,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('foo', 'bar');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
public function testInvokeEachLazyOptionOnlyOnce()
@ -259,7 +259,7 @@ class OptionsResolverTest extends TestCase
{
$this->resolver->setRequired('foo');
$this->assertNotEmpty($this->resolver->resolve(array('foo' => 'bar')));
$this->assertNotEmpty($this->resolver->resolve(['foo' => 'bar']));
}
public function testIsRequired()
@ -307,11 +307,11 @@ class OptionsResolverTest extends TestCase
public function testGetRequiredOptions()
{
$this->resolver->setRequired(array('foo', 'bar'));
$this->resolver->setRequired(['foo', 'bar']);
$this->resolver->setDefault('bam', 'baz');
$this->resolver->setDefault('foo', 'boo');
$this->assertSame(array('foo', 'bar'), $this->resolver->getRequiredOptions());
$this->assertSame(['foo', 'bar'], $this->resolver->getRequiredOptions());
}
public function testIsMissingIfNotSet()
@ -346,11 +346,11 @@ class OptionsResolverTest extends TestCase
public function testGetMissingOptions()
{
$this->resolver->setRequired(array('foo', 'bar'));
$this->resolver->setRequired(['foo', 'bar']);
$this->resolver->setDefault('bam', 'baz');
$this->resolver->setDefault('foo', 'boo');
$this->assertSame(array('bar'), $this->resolver->getMissingOptions());
$this->assertSame(['bar'], $this->resolver->getMissingOptions());
}
/**
@ -369,7 +369,7 @@ class OptionsResolverTest extends TestCase
{
$this->resolver->setDefined('foo');
$this->assertSame(array(), $this->resolver->resolve());
$this->assertSame([], $this->resolver->resolve());
}
public function testDefinedOptionsIncludedIfDefaultSetBefore()
@ -377,7 +377,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('foo', 'bar');
$this->resolver->setDefined('foo');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
public function testDefinedOptionsIncludedIfDefaultSetAfter()
@ -385,14 +385,14 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefined('foo');
$this->resolver->setDefault('foo', 'bar');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
public function testDefinedOptionsIncludedIfPassedToResolve()
{
$this->resolver->setDefined('foo');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve(array('foo' => 'bar')));
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve(['foo' => 'bar']));
}
public function testIsDefined()
@ -425,11 +425,11 @@ class OptionsResolverTest extends TestCase
public function testGetDefinedOptions()
{
$this->resolver->setDefined(array('foo', 'bar'));
$this->resolver->setDefined(['foo', 'bar']);
$this->resolver->setDefault('baz', 'bam');
$this->resolver->setRequired('boo');
$this->assertSame(array('foo', 'bar', 'baz', 'boo'), $this->resolver->getDefinedOptions());
$this->assertSame(['foo', 'bar', 'baz', 'boo'], $this->resolver->getDefinedOptions());
}
public function testRemovedOptionsAreNotDefined()
@ -462,9 +462,9 @@ class OptionsResolverTest extends TestCase
{
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[]');
$options = $this->resolver->resolve(array('foo' => array('bar', 'baz')));
$options = $this->resolver->resolve(['foo' => ['bar', 'baz']]);
$this->assertSame(array('foo' => array('bar', 'baz')), $options);
$this->assertSame(['foo' => ['bar', 'baz']], $options);
}
/**
@ -490,7 +490,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[]');
$this->resolver->resolve(array('foo' => array(new \DateTime())));
$this->resolver->resolve(['foo' => [new \DateTime()]]);
}
/**
@ -502,7 +502,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[]');
$this->resolver->resolve(array('foo' => 'bar'));
$this->resolver->resolve(['foo' => 'bar']);
}
/**
@ -515,11 +515,11 @@ class OptionsResolverTest extends TestCase
$this->resolver->setAllowedTypes('foo', 'int[]');
$values = range(1, 5);
$values[] = new \stdClass();
$values[] = array();
$values[] = [];
$values[] = new \DateTime();
$values[] = 123;
$this->resolver->resolve(array('foo' => $values));
$this->resolver->resolve(['foo' => $values]);
}
/**
@ -532,11 +532,11 @@ class OptionsResolverTest extends TestCase
$this->resolver->setAllowedTypes('foo', 'int[][]');
$this->resolver->resolve(
array(
'foo' => array(
array(1.2),
),
)
[
'foo' => [
[1.2],
],
]
);
}
@ -555,21 +555,21 @@ class OptionsResolverTest extends TestCase
$this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', $exceptionMessage);
}
$this->resolver->resolve(array('option' => $actualType));
$this->resolver->resolve(['option' => $actualType]);
}
public function provideInvalidTypes()
{
return array(
array(true, 'string', 'The option "option" with value true is expected to be of type "string", but is of type "boolean".'),
array(false, 'string', 'The option "option" with value false is expected to be of type "string", but is of type "boolean".'),
array(fopen(__FILE__, 'r'), 'string', 'The option "option" with value resource is expected to be of type "string", but is of type "resource".'),
array(array(), 'string', 'The option "option" with value array is expected to be of type "string", but is of type "array".'),
array(new OptionsResolver(), 'string', 'The option "option" with value Symfony\Component\OptionsResolver\OptionsResolver is expected to be of type "string", but is of type "Symfony\Component\OptionsResolver\OptionsResolver".'),
array(42, 'string', 'The option "option" with value 42 is expected to be of type "string", but is of type "integer".'),
array(null, 'string', 'The option "option" with value null is expected to be of type "string", but is of type "NULL".'),
array('bar', '\stdClass', 'The option "option" with value "bar" is expected to be of type "\stdClass", but is of type "string".'),
);
return [
[true, 'string', 'The option "option" with value true is expected to be of type "string", but is of type "boolean".'],
[false, 'string', 'The option "option" with value false is expected to be of type "string", but is of type "boolean".'],
[fopen(__FILE__, 'r'), 'string', 'The option "option" with value resource is expected to be of type "string", but is of type "resource".'],
[[], 'string', 'The option "option" with value array is expected to be of type "string", but is of type "array".'],
[new OptionsResolver(), 'string', 'The option "option" with value Symfony\Component\OptionsResolver\OptionsResolver is expected to be of type "string", but is of type "Symfony\Component\OptionsResolver\OptionsResolver".'],
[42, 'string', 'The option "option" with value 42 is expected to be of type "string", but is of type "integer".'],
[null, 'string', 'The option "option" with value null is expected to be of type "string", but is of type "NULL".'],
['bar', '\stdClass', 'The option "option" with value "bar" is expected to be of type "\stdClass", but is of type "string".'],
];
}
public function testResolveSucceedsIfValidType()
@ -587,7 +587,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidTypeMultiple()
{
$this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedTypes('foo', array('string', 'bool'));
$this->resolver->setAllowedTypes('foo', ['string', 'bool']);
$this->resolver->resolve();
}
@ -595,7 +595,7 @@ class OptionsResolverTest extends TestCase
public function testResolveSucceedsIfValidTypeMultiple()
{
$this->resolver->setDefault('foo', true);
$this->resolver->setAllowedTypes('foo', array('string', 'bool'));
$this->resolver->setAllowedTypes('foo', ['string', 'bool']);
$this->assertNotEmpty($this->resolver->resolve());
}
@ -611,14 +611,14 @@ class OptionsResolverTest extends TestCase
public function testResolveSucceedsIfTypedArray()
{
$this->resolver->setDefault('foo', null);
$this->resolver->setAllowedTypes('foo', array('null', 'DateTime[]'));
$this->resolver->setAllowedTypes('foo', ['null', 'DateTime[]']);
$data = array(
'foo' => array(
$data = [
'foo' => [
new \DateTime(),
new \DateTime(),
),
);
],
];
$result = $this->resolver->resolve($data);
$this->assertEquals($data, $result);
}
@ -681,7 +681,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidAddedTypeMultiple()
{
$this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedTypes('foo', array('string', 'bool'));
$this->resolver->addAllowedTypes('foo', ['string', 'bool']);
$this->resolver->resolve();
}
@ -689,7 +689,7 @@ class OptionsResolverTest extends TestCase
public function testResolveSucceedsIfValidAddedTypeMultiple()
{
$this->resolver->setDefault('foo', 'bar');
$this->resolver->addAllowedTypes('foo', array('string', 'bool'));
$this->resolver->addAllowedTypes('foo', ['string', 'bool']);
$this->assertNotEmpty($this->resolver->resolve());
}
@ -747,7 +747,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefined('foo');
$this->resolver->setAllowedValues('foo', 'bar');
$this->resolver->resolve(array('foo' => 42));
$this->resolver->resolve(['foo' => 42]);
}
/**
@ -778,7 +778,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('foo', 'bar');
$this->resolver->setAllowedValues('foo', 'bar');
$this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'bar'], $this->resolver->resolve());
}
public function testResolveSucceedsIfValidValueIsNull()
@ -786,7 +786,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('foo', null);
$this->resolver->setAllowedValues('foo', null);
$this->assertEquals(array('foo' => null), $this->resolver->resolve());
$this->assertEquals(['foo' => null], $this->resolver->resolve());
}
/**
@ -796,7 +796,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidValueMultiple()
{
$this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', array('bar', false, null));
$this->resolver->setAllowedValues('foo', ['bar', false, null]);
$this->resolver->resolve();
}
@ -804,9 +804,9 @@ class OptionsResolverTest extends TestCase
public function testResolveSucceedsIfValidValueMultiple()
{
$this->resolver->setDefault('foo', 'baz');
$this->resolver->setAllowedValues('foo', array('bar', 'baz'));
$this->resolver->setAllowedValues('foo', ['bar', 'baz']);
$this->assertEquals(array('foo' => 'baz'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'baz'], $this->resolver->resolve());
}
public function testResolveFailsIfClosureReturnsFalse()
@ -836,7 +836,7 @@ class OptionsResolverTest extends TestCase
return true;
});
$this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'bar'], $this->resolver->resolve());
$this->assertSame('bar', $passedValue);
}
@ -846,11 +846,11 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfAllClosuresReturnFalse()
{
$this->resolver->setDefault('foo', 42);
$this->resolver->setAllowedValues('foo', array(
$this->resolver->setAllowedValues('foo', [
function () { return false; },
function () { return false; },
function () { return false; },
));
]);
$this->resolver->resolve();
}
@ -858,13 +858,13 @@ class OptionsResolverTest extends TestCase
public function testResolveSucceedsIfAnyClosureReturnsTrue()
{
$this->resolver->setDefault('foo', 'bar');
$this->resolver->setAllowedValues('foo', array(
$this->resolver->setAllowedValues('foo', [
function () { return false; },
function () { return true; },
function () { return false; },
));
]);
$this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'bar'], $this->resolver->resolve());
}
/**
@ -905,7 +905,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('foo', 'bar');
$this->resolver->addAllowedValues('foo', 'bar');
$this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'bar'], $this->resolver->resolve());
}
public function testResolveSucceedsIfValidAddedValueIsNull()
@ -913,7 +913,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('foo', null);
$this->resolver->addAllowedValues('foo', null);
$this->assertEquals(array('foo' => null), $this->resolver->resolve());
$this->assertEquals(['foo' => null], $this->resolver->resolve());
}
/**
@ -922,7 +922,7 @@ class OptionsResolverTest extends TestCase
public function testResolveFailsIfInvalidAddedValueMultiple()
{
$this->resolver->setDefault('foo', 42);
$this->resolver->addAllowedValues('foo', array('bar', 'baz'));
$this->resolver->addAllowedValues('foo', ['bar', 'baz']);
$this->resolver->resolve();
}
@ -930,9 +930,9 @@ class OptionsResolverTest extends TestCase
public function testResolveSucceedsIfValidAddedValueMultiple()
{
$this->resolver->setDefault('foo', 'bar');
$this->resolver->addAllowedValues('foo', array('bar', 'baz'));
$this->resolver->addAllowedValues('foo', ['bar', 'baz']);
$this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'bar'], $this->resolver->resolve());
}
public function testAddAllowedValuesDoesNotOverwrite()
@ -941,7 +941,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setAllowedValues('foo', 'bar');
$this->resolver->addAllowedValues('foo', 'baz');
$this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'bar'], $this->resolver->resolve());
}
public function testAddAllowedValuesDoesNotOverwrite2()
@ -950,7 +950,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setAllowedValues('foo', 'bar');
$this->resolver->addAllowedValues('foo', 'baz');
$this->assertEquals(array('foo' => 'baz'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'baz'], $this->resolver->resolve());
}
/**
@ -971,7 +971,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setAllowedValues('foo', function () { return false; });
$this->resolver->addAllowedValues('foo', function () { return true; });
$this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'bar'], $this->resolver->resolve());
}
public function testResolveSucceedsIfAnyAddedClosureReturnsTrue2()
@ -980,7 +980,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setAllowedValues('foo', function () { return true; });
$this->resolver->addAllowedValues('foo', function () { return false; });
$this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'bar'], $this->resolver->resolve());
}
public function testSetNormalizerReturnsThis()
@ -996,7 +996,7 @@ class OptionsResolverTest extends TestCase
return 'normalized';
});
$this->assertEquals(array('foo' => 'normalized'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'normalized'], $this->resolver->resolve());
}
/**
@ -1029,7 +1029,7 @@ class OptionsResolverTest extends TestCase
return 'normalized['.$value.']';
});
$this->assertEquals(array('foo' => 'normalized[bar]'), $this->resolver->resolve());
$this->assertEquals(['foo' => 'normalized[bar]'], $this->resolver->resolve());
}
public function testNormalizerReceivesPassedOption()
@ -1040,9 +1040,9 @@ class OptionsResolverTest extends TestCase
return 'normalized['.$value.']';
});
$resolved = $this->resolver->resolve(array('foo' => 'baz'));
$resolved = $this->resolver->resolve(['foo' => 'baz']);
$this->assertEquals(array('foo' => 'normalized[baz]'), $resolved);
$this->assertEquals(['foo' => 'normalized[baz]'], $resolved);
}
/**
@ -1089,10 +1089,10 @@ class OptionsResolverTest extends TestCase
return 'normalized';
});
$this->assertEquals(array(
$this->assertEquals([
'default' => 'bar',
'norm' => 'normalized',
), $this->resolver->resolve());
], $this->resolver->resolve());
}
public function testNormalizerCanAccessLazyOptions()
@ -1109,10 +1109,10 @@ class OptionsResolverTest extends TestCase
return 'normalized';
});
$this->assertEquals(array(
$this->assertEquals([
'lazy' => 'bar',
'norm' => 'normalized',
), $this->resolver->resolve());
], $this->resolver->resolve());
}
/**
@ -1156,7 +1156,7 @@ class OptionsResolverTest extends TestCase
{
$throw = true;
$this->resolver->setDefaults(array('catcher' => null, 'thrower' => null));
$this->resolver->setDefaults(['catcher' => null, 'thrower' => null]);
$this->resolver->setNormalizer('catcher', function (Options $options) {
try {
@ -1175,7 +1175,7 @@ class OptionsResolverTest extends TestCase
return true;
});
$this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve());
$this->assertSame(['catcher' => false, 'thrower' => true], $this->resolver->resolve());
}
public function testCaughtExceptionFromLazyDoesNotCrashOptionResolver()
@ -1199,7 +1199,7 @@ class OptionsResolverTest extends TestCase
return true;
});
$this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve());
$this->assertSame(['catcher' => false, 'thrower' => true], $this->resolver->resolve());
}
public function testInvokeEachNormalizerOnlyOnce()
@ -1236,7 +1236,7 @@ class OptionsResolverTest extends TestCase
public function testSetDefaultsReturnsThis()
{
$this->assertSame($this->resolver, $this->resolver->setDefaults(array('foo', 'bar')));
$this->assertSame($this->resolver, $this->resolver->setDefaults(['foo', 'bar']));
}
public function testSetDefaults()
@ -1244,16 +1244,16 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('one', '1');
$this->resolver->setDefault('two', 'bar');
$this->resolver->setDefaults(array(
$this->resolver->setDefaults([
'two' => '2',
'three' => '3',
));
]);
$this->assertEquals(array(
$this->assertEquals([
'one' => '1',
'two' => '2',
'three' => '3',
), $this->resolver->resolve());
], $this->resolver->resolve());
}
/**
@ -1262,7 +1262,7 @@ class OptionsResolverTest extends TestCase
public function testFailIfSetDefaultsFromLazyOption()
{
$this->resolver->setDefault('foo', function (Options $options) {
$options->setDefaults(array('two' => '2'));
$options->setDefaults(['two' => '2']);
});
$this->resolver->resolve();
@ -1281,7 +1281,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('baz', 'boo');
$this->resolver->remove('foo');
$this->assertSame(array('baz' => 'boo'), $this->resolver->resolve());
$this->assertSame(['baz' => 'boo'], $this->resolver->resolve());
}
public function testRemoveMultipleOptions()
@ -1290,9 +1290,9 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefault('baz', 'boo');
$this->resolver->setDefault('doo', 'dam');
$this->resolver->remove(array('foo', 'doo'));
$this->resolver->remove(['foo', 'doo']);
$this->assertSame(array('baz' => 'boo'), $this->resolver->resolve());
$this->assertSame(['baz' => 'boo'], $this->resolver->resolve());
}
public function testRemoveLazyOption()
@ -1302,7 +1302,7 @@ class OptionsResolverTest extends TestCase
});
$this->resolver->remove('foo');
$this->assertSame(array(), $this->resolver->resolve());
$this->assertSame([], $this->resolver->resolve());
}
public function testRemoveNormalizer()
@ -1314,7 +1314,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->remove('foo');
$this->resolver->setDefault('foo', 'bar');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
public function testRemoveAllowedTypes()
@ -1324,17 +1324,17 @@ class OptionsResolverTest extends TestCase
$this->resolver->remove('foo');
$this->resolver->setDefault('foo', 'bar');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
public function testRemoveAllowedValues()
{
$this->resolver->setDefault('foo', 'bar');
$this->resolver->setAllowedValues('foo', array('baz', 'boo'));
$this->resolver->setAllowedValues('foo', ['baz', 'boo']);
$this->resolver->remove('foo');
$this->resolver->setDefault('foo', 'bar');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
/**
@ -1378,7 +1378,7 @@ class OptionsResolverTest extends TestCase
});
$this->resolver->clear();
$this->assertSame(array(), $this->resolver->resolve());
$this->assertSame([], $this->resolver->resolve());
}
public function testClearNormalizer()
@ -1390,7 +1390,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->clear();
$this->resolver->setDefault('foo', 'bar');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
public function testClearAllowedTypes()
@ -1400,7 +1400,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->clear();
$this->resolver->setDefault('foo', 'bar');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
public function testClearAllowedValues()
@ -1410,7 +1410,7 @@ class OptionsResolverTest extends TestCase
$this->resolver->clear();
$this->resolver->setDefault('foo', 'bar');
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
$this->assertSame(['foo' => 'bar'], $this->resolver->resolve());
}
/**
@ -1469,7 +1469,7 @@ class OptionsResolverTest extends TestCase
// accessed
});
$this->resolver->resolve(array('default2' => 42, 'required' => 'value'));
$this->resolver->resolve(['default2' => 42, 'required' => 'value']);
}
/**
@ -1567,7 +1567,7 @@ class OptionsResolverTest extends TestCase
Assert::assertCount(4, $options);
});
$this->assertCount(4, $this->resolver->resolve(array('required' => 'value')));
$this->assertCount(4, $this->resolver->resolve(['required' => 'value']));
}
/**
@ -1592,18 +1592,18 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][]');
$this->assertEquals(array(
'foo' => array(
array(
$this->assertEquals([
'foo' => [
[
1, 2,
),
),
), $this->resolver->resolve(
array(
'foo' => array(
array(1, 2),
),
)
],
],
], $this->resolver->resolve(
[
'foo' => [
[1, 2],
],
]
));
}
@ -1612,26 +1612,26 @@ class OptionsResolverTest extends TestCase
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][][][]');
$this->assertEquals(array(
'foo' => array(
array(
array(
array(
$this->assertEquals([
'foo' => [
[
[
[
1, 2,
),
),
),
),
), $this->resolver->resolve(
array(
'foo' => array(
array(
array(
array(1, 2),
),
),
),
)
],
],
],
],
], $this->resolver->resolve(
[
'foo' => [
[
[
[1, 2],
],
],
],
]
));
}
@ -1645,15 +1645,15 @@ class OptionsResolverTest extends TestCase
$this->resolver->setAllowedTypes('foo', 'float[][][][]');
$this->resolver->resolve(
array(
'foo' => array(
array(
array(
array(1, 2),
),
),
),
)
[
'foo' => [
[
[
[1, 2],
],
],
],
]
);
}
@ -1665,11 +1665,11 @@ class OptionsResolverTest extends TestCase
{
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][]');
$this->resolver->resolve(array(
'foo' => array(
array(1, true, 'str', array(2, 3)),
),
));
$this->resolver->resolve([
'foo' => [
[1, true, 'str', [2, 3]],
],
]);
}
/**
@ -1680,11 +1680,11 @@ class OptionsResolverTest extends TestCase
{
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'int[][]');
$this->resolver->resolve(array(
'foo' => array(
array(true, 'str', array(2, 3)),
),
));
$this->resolver->resolve([
'foo' => [
[true, 'str', [2, 3]],
],
]);
}
/**
@ -1695,11 +1695,11 @@ class OptionsResolverTest extends TestCase
{
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[][][]');
$this->resolver->resolve(array(
'foo' => array(
array('str', array(1, 2)),
),
));
$this->resolver->resolve([
'foo' => [
['str', [1, 2]],
],
]);
}
/**
@ -1710,12 +1710,12 @@ class OptionsResolverTest extends TestCase
{
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[][][]');
$this->resolver->resolve(array(
'foo' => array(
array(
array('str'), array(1, 2), ),
),
));
$this->resolver->resolve([
'foo' => [
[
['str'], [1, 2], ],
],
]);
}
/**
@ -1726,11 +1726,11 @@ class OptionsResolverTest extends TestCase
{
$this->resolver->setDefined('foo');
$this->resolver->setAllowedTypes('foo', 'string[]');
$this->resolver->resolve(array(
'foo' => array(
array(
array('str'), array(1, 2), ),
),
));
$this->resolver->resolve([
'foo' => [
[
['str'], [1, 2], ],
],
]);
}
}

Binary file not shown.