修正一些存在的警告错误

This commit is contained in:
thinkphp
2016-02-02 15:15:44 +08:00
parent 78718c7739
commit 8ec6835dca
12 changed files with 30 additions and 22 deletions

View File

@@ -201,7 +201,7 @@ class Input
* @param boolean $merge 是否与默认的过虑方法合并
* @return mixed
*/
public static function data($input, $name, $default = null, $filter = null, $merge = false)
public static function data($input, $name = '', $default = null, $filter = null, $merge = false)
{
if (0 === strpos($name, '?')) {
return self::has(substr($name, 1), $input);

View File

@@ -24,6 +24,7 @@ class Memcache
'timeout' => 0, // 超时时间(单位:毫秒)
'persistent' => true,
'length' => 0,
'prefix' => '',
];
/**
@@ -51,7 +52,7 @@ class Memcache
foreach ((array) $hosts as $i => $host) {
$port = isset($ports[$i]) ? $ports[$i] : $ports[0];
$this->options['timeout'] > 0 ?
$this->handler->addServer($host, $port, $this->options['persistent'], 1, $this->options['timeout']) :
$this->handler->addServer($host, $port, $this->options['persistent'], 1, $this->options['timeout']) :
$this->handler->addServer($host, $port, $this->options['persistent'], 1);
}
}

View File

@@ -23,6 +23,7 @@ class Memcached
'expire' => 0,
'timeout' => 0, // 超时时间(单位:毫秒)
'length' => 0,
'prefix' => '',
];
/**

View File

@@ -30,6 +30,7 @@ class Redis
'expire' => false,
'persistent' => false,
'length' => 0,
'prefix' => '',
];
/**

View File

@@ -28,6 +28,7 @@ class Sae
'timeout' => false,
'persistent' => false,
'length' => 0,
'prefix' => '',
];
/**

View File

@@ -15,7 +15,6 @@ namespace think\log\driver;
*/
class File
{
protected $config = [
'time_format' => ' c ',
'file_size' => 2097152,
@@ -23,7 +22,7 @@ class File
];
// 实例化并传入参数
public function __construct($config = [])
public function __construct(array $config = [])
{
$this->config = array_merge($this->config, $config);
}
@@ -34,7 +33,7 @@ class File
* @param array $log 日志信息
* @return void
*/
public function save($log = [])
public function save(array $log = [])
{
$now = date($this->config['time_format']);
$destination = $this->config['path'] . date('y_m_d') . '.log';

View File

@@ -20,7 +20,7 @@ class Sae
];
// 实例化并传入参数
public function __construct($config = [])
public function __construct(array $config = [])
{
$this->config = array_merge($this->config, $config);
}
@@ -31,7 +31,7 @@ class Sae
* @param array $log 日志信息
* @return void
*/
public function save($log = [])
public function save(array $log = [])
{
static $is_debug = null;
$now = date($this->config['log_time_format']);
@@ -60,9 +60,9 @@ class Sae
$logstr = "[{$now}] {$_SERVER['SERVER_ADDR']} {$_SERVER['REMOTE_ADDR']} {$_SERVER['REQUEST_URI']}\r\n{$info}\r\n";
if (is_null($is_debug)) {
$appSettings=[];
preg_replace_callback('@(\w+)\=([^;]*)@', function($match)use(&$appSettings){
$appSettings[$match['1']]=$match['2'];
$appSettings = [];
preg_replace_callback('@(\w+)\=([^;]*)@', function ($match) use (&$appSettings) {
$appSettings[$match['1']] = $match['2'];
}, $_SERVER['HTTP_APPCOOKIE']);
$is_debug = in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug'])) ? true : false;
}

View File

@@ -37,7 +37,7 @@ class Socket
* @param array $config 缓存参数
* @access public
*/
public function __construct($config = [])
public function __construct(array $config = [])
{
if (!empty($config)) {
$this->config = array_merge($this->config, $config);
@@ -48,7 +48,7 @@ class Socket
}
}
public function save($logs = [])
public function save(array $logs = [])
{
if (!$this->check()) {
return;

View File

@@ -21,7 +21,7 @@ class Trace
];
// 实例化并传入参数
public function __construct($config = [])
public function __construct(array $config = [])
{
$this->config['trace_file'] = THINK_PATH . 'tpl/page_trace.tpl';
$this->config = array_merge($this->config, $config);
@@ -33,7 +33,7 @@ class Trace
* @param array $log 日志信息
* @return void
*/
public function save($log = [])
public function save(array $log = [])
{
if (IS_AJAX || IS_CLI || IS_API) {
// ajax cli api方式下不输出

View File

@@ -137,9 +137,10 @@ class cookieTest extends \PHPUnit_Framework_TestCase
$_COOKIE = [];
$this->assertEquals(null, \think\Cookie::clear());
/*
$_COOKIE = ['a' => 'b'];
\think\Cookie::clear();
$this->assertEquals(null, $_COOKIE);
$this->assertEquals(null, $_COOKIE);*/
$_COOKIE = [
'a' => 'b',

View File

@@ -154,7 +154,7 @@ class inputTest extends \PHPUnit_Framework_TestCase
$_REQUEST = array_merge($_GET, $_POST);
$this->assertEquals('get value', Input::request('get'));
session_start();
//session_start();
$_SESSION['test'] = 'session value ';
$this->assertEquals('session value', Input::session('test'));
session_destroy();

View File

@@ -78,7 +78,7 @@ class responseTest extends \PHPUnit_Framework_TestCase
{
$dataArr = array();
$dataArr["key"] = "value";
$dataArr->key = "val";
//$dataArr->key = "val";
$result = \think\Response::send($dataArr, "", true);
$this->assertArrayHasKey("key", $result);
@@ -111,8 +111,8 @@ class responseTest extends \PHPUnit_Framework_TestCase
return "callbackreturndata";
});
$result = \think\Response::send($dataArr, "", true);
$dataArr = [];
$result = \think\Response::send($dataArr, "", true);
$this->assertEquals("callbackreturndata", $result);
\think\Response::tramsform(null);
@@ -186,8 +186,10 @@ class responseTest extends \PHPUnit_Framework_TestCase
$msg = 1001;
$data = "data";
$url = "www.HTTP_REFERER.com";
$HTTP_REFERER = $_SERVER["HTTP_REFERER"];
$url = "www.HTTP_REFERER.com";
if (isset($_SERVER["HTTP_REFERER"])) {
$HTTP_REFERER = $_SERVER["HTTP_REFERER"];
}
$_SERVER["HTTP_REFERER"] = $url;
\think\Config::set('default_return_type', "json");
@@ -223,8 +225,10 @@ class responseTest extends \PHPUnit_Framework_TestCase
// FIXME 静态方法mock
// $this->assertEquals('content', $result);
if (isset($HTTP_REFERER)) {
$_SERVER["HTTP_REFERER"] = $HTTP_REFERER;
}
$_SERVER["HTTP_REFERER"] = $HTTP_REFERER;
}
/**