数组定义规范统一

This commit is contained in:
thinkphp
2013-04-01 11:03:19 +08:00
parent 668aca97c8
commit 6f5db51323
33 changed files with 87 additions and 87 deletions

View File

@@ -12,7 +12,7 @@
namespace Think; namespace Think;
class Auto { class Auto {
protected $auto = array(); protected $auto = [];
public function rule($rule){ public function rule($rule){
$this->auto = $rule; $this->auto = $rule;
@@ -33,7 +33,7 @@ class Auto {
// array('field','填充内容','附加规则',[额外参数]) // array('field','填充内容','附加规则',[额外参数])
switch(trim($auto[2])) { switch(trim($auto[2])) {
case 'callback': // 使用回调方法 case 'callback': // 使用回调方法
$args = isset($auto[3])?(array)$auto[3]:array(); $args = isset($auto[3])?(array)$auto[3]:[];
if(isset($data[$auto[0]])) { if(isset($data[$auto[0]])) {
array_unshift($args,$data[$auto[0]]); array_unshift($args,$data[$auto[0]]);
} }

View File

@@ -36,11 +36,11 @@ class ShowPageTrace {
private function showTrace() { private function showTrace() {
// 系统默认显示信息 // 系统默认显示信息
$files = get_included_files(); $files = get_included_files();
$info = array(); $info = [];
foreach ($files as $key=>$file){ foreach ($files as $key=>$file){
$info[] = $file.' ( '.number_format(filesize($file)/1024,2).' KB )'; $info[] = $file.' ( '.number_format(filesize($file)/1024,2).' KB )';
} }
$trace = array(); $trace = [];
Debug::remark('START',$GLOBALS['startTime']); Debug::remark('START',$GLOBALS['startTime']);
$base = array( $base = array(
'请求信息' => date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']).' '.$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['REQUEST_METHOD'].' : '.$_SERVER['PHP_SELF'], '请求信息' => date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']).' '.$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['REQUEST_METHOD'].' : '.$_SERVER['PHP_SELF'],
@@ -70,9 +70,9 @@ class ShowPageTrace {
$name = strtoupper($name); $name = strtoupper($name);
if(strpos($name,'|')) {// 多组信息 if(strpos($name,'|')) {// 多组信息
$array = explode('|',$name); $array = explode('|',$name);
$result = array(); $result = [];
foreach($array as $name){ foreach($array as $name){
$result += isset($debug[$name])?$debug[$name]:array(); $result += isset($debug[$name])?$debug[$name]:[];
} }
$trace[$title] = $result; $trace[$title] = $result;
}else{ }else{

View File

@@ -20,7 +20,7 @@ class ReadHtmlCacheBehavior {
protected $options = array( protected $options = array(
'HTML_CACHE_ON' => false, 'HTML_CACHE_ON' => false,
'HTML_CACHE_TIME' => 60, 'HTML_CACHE_TIME' => 60,
'HTML_CACHE_RULES' => array(), 'HTML_CACHE_RULES' => [],
'HTML_FILE_SUFFIX' => '.html', 'HTML_FILE_SUFFIX' => '.html',
); );

View File

@@ -45,7 +45,7 @@ class TokenBuildBehavior extends Behavior {
$tokenName = C('TOKEN_NAME'); $tokenName = C('TOKEN_NAME');
$tokenType = C('TOKEN_TYPE'); $tokenType = C('TOKEN_TYPE');
if(!isset($_SESSION[$tokenName])) { if(!isset($_SESSION[$tokenName])) {
$_SESSION[$tokenName] = array(); $_SESSION[$tokenName] = [];
} }
// 标识当前页面唯一性 // 标识当前页面唯一性
$tokenKey = md5($_SERVER['REQUEST_URI']); $tokenKey = md5($_SERVER['REQUEST_URI']);

View File

@@ -28,7 +28,7 @@ class Apc {
* @param array $options 缓存参数 * @param array $options 缓存参数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if(!function_exists('apc_cache_info')) { if(!function_exists('apc_cache_info')) {
throw New Exception('_NOT_SUPPERT_:Apc'); throw New Exception('_NOT_SUPPERT_:Apc');
} }
@@ -65,7 +65,7 @@ class Apc {
// 记录缓存队列 // 记录缓存队列
$queue = apc_fetch('__info__'); $queue = apc_fetch('__info__');
if(!$queue) { if(!$queue) {
$queue = array(); $queue = [];
} }
if(false===array_search($name, $queue)) array_push($queue,$name); if(false===array_search($name, $queue)) array_push($queue,$name);
if(count($queue) > $this->options['length']) { if(count($queue) > $this->options['length']) {

View File

@@ -36,7 +36,7 @@ class Db {
* @param array $options 缓存参数 * @param array $options 缓存参数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if(!empty($options)) { if(!empty($options)) {
$this->options = array_merge($this->options,$options); $this->options = array_merge($this->options,$options);
} }
@@ -101,7 +101,7 @@ class Db {
$queue = xcache_get('__info__'); $queue = xcache_get('__info__');
if(!$result) { if(!$result) {
$this->handler->execute('INSERT INTO '.$this->options['table'].' (`cachekey`,`data`,`expire`) VALUES (\'__info__\',\'\',0)'); $this->handler->execute('INSERT INTO '.$this->options['table'].' (`cachekey`,`data`,`expire`) VALUES (\'__info__\',\'\',0)');
$queue = array(); $queue = [];
}else{ }else{
$queue = unserialize($result[0]['data']); $queue = unserialize($result[0]['data']);
} }

View File

@@ -26,7 +26,7 @@ class Eaccelerator {
* @param array $options 缓存参数 * @param array $options 缓存参数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if(!empty($options)) { if(!empty($options)) {
$this->options = array_merge($this->options,$options); $this->options = array_merge($this->options,$options);
} }
@@ -61,7 +61,7 @@ class Eaccelerator {
// 记录缓存队列 // 记录缓存队列
$queue = eaccelerator_get('__info__'); $queue = eaccelerator_get('__info__');
if(!$queue) { if(!$queue) {
$queue = array(); $queue = [];
} }
if(false===array_search($name, $queue)) array_push($queue,$name); if(false===array_search($name, $queue)) array_push($queue,$name);
if(count($queue) > $this->options['length']) { if(count($queue) > $this->options['length']) {

View File

@@ -29,7 +29,7 @@ class File {
* 架构函数 * 架构函数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if(!empty($options)) { if(!empty($options)) {
$this->options = array_merge($this->options,$options); $this->options = array_merge($this->options,$options);
} }
@@ -133,7 +133,7 @@ class File {
$queue_file = dirname($filename).'/__info__.php'; $queue_file = dirname($filename).'/__info__.php';
$queue = unserialize(file_get_contents($queue_file)); $queue = unserialize(file_get_contents($queue_file));
if(!$queue) { if(!$queue) {
$queue = array(); $queue = [];
} }
if(false===array_search($name, $queue)) array_push($queue,$name); if(false===array_search($name, $queue)) array_push($queue,$name);
if(count($queue) > $this->options['length']) { if(count($queue) > $this->options['length']) {

View File

@@ -29,7 +29,7 @@ class Memcache {
* @param array $options 缓存参数 * @param array $options 缓存参数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if ( !extension_loaded('memcache') ) { if ( !extension_loaded('memcache') ) {
throw new Exception('_NOT_SUPPERT_:memcache'); throw new Exception('_NOT_SUPPERT_:memcache');
} }
@@ -71,7 +71,7 @@ class Memcache {
// 记录缓存队列 // 记录缓存队列
$queue = $this->handler->get('__info__'); $queue = $this->handler->get('__info__');
if(!$queue) { if(!$queue) {
$queue = array(); $queue = [];
} }
if(false===array_search($name, $queue)) array_push($queue,$name); if(false===array_search($name, $queue)) array_push($queue,$name);
if(count($queue) > $this->options['length']) { if(count($queue) > $this->options['length']) {

View File

@@ -30,7 +30,7 @@ class Redis {
* @param array $options 缓存参数 * @param array $options 缓存参数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if ( !extension_loaded('redis') ) { if ( !extension_loaded('redis') ) {
throw new Exception('_NOT_SUPPERT_:redis'); throw new Exception('_NOT_SUPPERT_:redis');
} }
@@ -77,7 +77,7 @@ class Redis {
// 记录缓存队列 // 记录缓存队列
$queue = $this->handler->get('__info__'); $queue = $this->handler->get('__info__');
if(!$queue) { if(!$queue) {
$queue = array(); $queue = [];
} }
if(false===array_search($name, $queue)) array_push($queue,$name); if(false===array_search($name, $queue)) array_push($queue,$name);
if(count($queue) > $this->options['length']) { if(count($queue) > $this->options['length']) {

View File

@@ -29,7 +29,7 @@ class Secache {
* @param array $options 缓存参数 * @param array $options 缓存参数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if(!empty($options)) { if(!empty($options)) {
$this->options = array_merge($this->options,$options); $this->options = array_merge($this->options,$options);
} }
@@ -67,7 +67,7 @@ class Secache {
// 记录缓存队列 // 记录缓存队列
$queue = $this->handler->fetch(md5('__info__')); $queue = $this->handler->fetch(md5('__info__'));
if(!$queue) { if(!$queue) {
$queue = array(); $queue = [];
} }
if(false===array_search($key, $queue)) array_push($queue,$key); if(false===array_search($key, $queue)) array_push($queue,$key);
if(count($queue) > $this->options['length']) { if(count($queue) > $this->options['length']) {
@@ -669,7 +669,7 @@ class secache{
} }
function _all_schemas(){ function _all_schemas(){
$schema = array(); $schema = [];
for($i=0;$i<16;$i++){ for($i=0;$i<16;$i++){
$this->_seek(60+$i*$this->schema_item_size); $this->_seek(60+$i*$this->schema_item_size);
$info = unpack('V1'.implode('/V1',$this->schema_struct),fread($this->_rs,$this->schema_item_size)); $info = unpack('V1'.implode('/V1',$this->schema_struct),fread($this->_rs,$this->schema_item_size));
@@ -683,7 +683,7 @@ class secache{
} }
function schemaStatus(){ function schemaStatus(){
$return = array(); $return = [];
foreach($this->_all_schemas() as $k=>$schemaItem){ foreach($this->_all_schemas() as $k=>$schemaItem){
if($schemaItem['free']){ if($schemaItem['free']){
$this->_dfollow($schemaItem['free'],$schemaItem['freecount']); $this->_dfollow($schemaItem['free'],$schemaItem['freecount']);

View File

@@ -24,7 +24,7 @@ class Simple {
* 架构函数 * 架构函数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if(!empty($options)) { if(!empty($options)) {
$this->options = array_merge($this->options,$options); $this->options = array_merge($this->options,$options);
} }

View File

@@ -29,7 +29,7 @@ class Sqlite {
* @param array $options 缓存参数 * @param array $options 缓存参数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if ( !extension_loaded('sqlite') ) { if ( !extension_loaded('sqlite') ) {
throw new Exception('_NOT_SUPPERT_:sqlite'); throw new Exception('_NOT_SUPPERT_:sqlite');
} }

View File

@@ -26,7 +26,7 @@ class Wincache {
* @param array $options 缓存参数 * @param array $options 缓存参数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if ( !function_exists('wincache_ucache_info') ) { if ( !function_exists('wincache_ucache_info') ) {
throw new Exception('_NOT_SUPPERT_:WinCache'); throw new Exception('_NOT_SUPPERT_:WinCache');
} }
@@ -64,7 +64,7 @@ class Wincache {
// 记录缓存队列 // 记录缓存队列
$queue = wincache_ucache_get('__info__'); $queue = wincache_ucache_get('__info__');
if(!$queue) { if(!$queue) {
$queue = array(); $queue = [];
} }
if(false===array_search($name, $queue)) array_push($queue,$name); if(false===array_search($name, $queue)) array_push($queue,$name);
if(count($queue) > $this->options['length']) { if(count($queue) > $this->options['length']) {

View File

@@ -26,7 +26,7 @@ class Xcache {
* @param array $options 缓存参数 * @param array $options 缓存参数
* @access public * @access public
*/ */
public function __construct($options=array()) { public function __construct($options=[]) {
if ( !function_exists('xcache_info') ) { if ( !function_exists('xcache_info') ) {
throw new Exception('_NOT_SUPPERT_:Xcache'); throw new Exception('_NOT_SUPPERT_:Xcache');
} }
@@ -67,7 +67,7 @@ class Xcache {
// 记录缓存队列 // 记录缓存队列
$queue = xcache_get('__info__'); $queue = xcache_get('__info__');
if(!$queue) { if(!$queue) {
$queue = array(); $queue = [];
} }
if(false===array_search($name, $queue)) array_push($queue,$name); if(false===array_search($name, $queue)) array_push($queue,$name);
if(count($queue) > $this->options['length']) { if(count($queue) > $this->options['length']) {

View File

@@ -117,7 +117,7 @@ class Controller {
*/ */
private function dispatchJump($message,$status=1,$jumpUrl='',$ajax=false) { private function dispatchJump($message,$status=1,$jumpUrl='',$ajax=false) {
if(true === $ajax || IS_AJAX) {// AJAX提交 if(true === $ajax || IS_AJAX) {// AJAX提交
$data = is_array($ajax)?$ajax:array(); $data = is_array($ajax)?$ajax:[];
$data['info'] = $message; $data['info'] = $message;
$data['status'] = $status; $data['status'] = $status;
$data['url'] = $jumpUrl; $data['url'] = $jumpUrl;

View File

@@ -26,7 +26,7 @@ class Mysql extends Driver{
$this->initConnect(true); $this->initConnect(true);
$sql = 'SHOW COLUMNS FROM `'.$tableName.'`'; $sql = 'SHOW COLUMNS FROM `'.$tableName.'`';
$result = $this->query($sql); $result = $this->query($sql);
$info = array(); $info = [];
if($result) { if($result) {
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$val['Field']] = array( $info[$val['Field']] = array(
@@ -49,7 +49,7 @@ class Mysql extends Driver{
public function getTables($dbName='') { public function getTables($dbName='') {
$sql = !empty($dbName)?'SHOW TABLES FROM '.$dbName:'SHOW TABLES '; $sql = !empty($dbName)?'SHOW TABLES FROM '.$dbName:'SHOW TABLES ';
$result = $this->query($sql); $result = $this->query($sql);
$info = array(); $info = [];
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$key] = current($val); $info[$key] = current($val);
} }

View File

@@ -69,7 +69,7 @@ class Oracle extends Driver{
."from user_tab_columns a,(select column_name from user_constraints c,user_cons_columns col " ."from user_tab_columns a,(select column_name from user_constraints c,user_cons_columns col "
."where c.constraint_name=col.constraint_name and c.constraint_type='P'and c.table_name='".strtoupper($tableName) ."where c.constraint_name=col.constraint_name and c.constraint_type='P'and c.table_name='".strtoupper($tableName)
."') b where table_name='".strtoupper($tableName)."' and a.column_name=b.column_name(+)"); ."') b where table_name='".strtoupper($tableName)."' and a.column_name=b.column_name(+)");
$info = array(); $info = [];
if($result) { if($result) {
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[strtolower($val['column_name'])] = array( $info[strtolower($val['column_name'])] = array(
@@ -91,7 +91,7 @@ class Oracle extends Driver{
*/ */
public function getTables($dbName='') { public function getTables($dbName='') {
$result = $this->query("select table_name from user_tables"); $result = $this->query("select table_name from user_tables");
$info = array(); $info = [];
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$key] = current($val); $info[$key] = current($val);
} }

View File

@@ -26,7 +26,7 @@ class Pgsql extends Driver{
*/ */
public function getFields($tableName) { public function getFields($tableName) {
$result = $this->query('select fields_name as "Field",fields_type as "Type",fields_not_null as "Null",fields_key_name as "Key",fields_default as "Default",fields_default as "Extra" from table_msg('.$tableName.');'); $result = $this->query('select fields_name as "Field",fields_type as "Type",fields_not_null as "Null",fields_key_name as "Key",fields_default as "Default",fields_default as "Extra" from table_msg('.$tableName.');');
$info = array(); $info = [];
if($result){ if($result){
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$val['Field']] = array( $info[$val['Field']] = array(
@@ -49,7 +49,7 @@ class Pgsql extends Driver{
*/ */
public function getTables($dbName='') { public function getTables($dbName='') {
$result = $this->query("select tablename as Tables_in_test from pg_tables where schemaname ='public'"); $result = $this->query("select tablename as Tables_in_test from pg_tables where schemaname ='public'");
$info = array(); $info = [];
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$key] = current($val); $info[$key] = current($val);
} }

View File

@@ -26,7 +26,7 @@ class Sqlite extends Driver {
*/ */
public function getFields($tableName) { public function getFields($tableName) {
$result = $this->query('PRAGMA table_info( '.$tableName.' )'); $result = $this->query('PRAGMA table_info( '.$tableName.' )');
$info = array(); $info = [];
if($result){ if($result){
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$val['Field']] = array( $info[$val['Field']] = array(
@@ -51,7 +51,7 @@ class Sqlite extends Driver {
$result = $this->query("SELECT name FROM sqlite_master WHERE type='table' " $result = $this->query("SELECT name FROM sqlite_master WHERE type='table' "
. "UNION ALL SELECT name FROM sqlite_temp_master " . "UNION ALL SELECT name FROM sqlite_temp_master "
. "WHERE type='table' ORDER BY name"); . "WHERE type='table' ORDER BY name");
$info = array(); $info = [];
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$key] = current($val); $info[$key] = current($val);
} }

View File

@@ -34,7 +34,7 @@ class Sqlsrv extends Driver{
AND t.table_schema = c.table_schema AND t.table_schema = c.table_schema
AND t.table_name = c.table_name AND t.table_name = c.table_name
WHERE t.table_name = '$tableName'"); WHERE t.table_name = '$tableName'");
$info = array(); $info = [];
if($result) { if($result) {
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$val['column_name']] = array( $info[$val['column_name']] = array(
@@ -60,7 +60,7 @@ class Sqlsrv extends Driver{
FROM INFORMATION_SCHEMA.TABLES FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' WHERE TABLE_TYPE = 'BASE TABLE'
"); ");
$info = array(); $info = [];
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$info[$key] = current($val); $info[$key] = current($val);
} }
@@ -117,7 +117,7 @@ class Sqlsrv extends Driver{
* @param array $options 表达式 * @param array $options 表达式
* @return false | integer * @return false | integer
*/ */
public function delete($options=array()) { public function delete($options=[]) {
$this->model = $options['model']; $this->model = $options['model'];
$sql = 'DELETE FROM ' $sql = 'DELETE FROM '
.$this->parseTable($options['table']) .$this->parseTable($options['table'])

View File

@@ -18,7 +18,7 @@ class Error {
* @param mixed $e 异常对象 * @param mixed $e 异常对象
*/ */
static public function appException($e) { static public function appException($e) {
$error = array(); $error = [];
$error['message'] = $e->getMessage(); $error['message'] = $e->getMessage();
$error['file'] = $e->getFile(); $error['file'] = $e->getFile();
$error['line'] = $e->getLine(); $error['line'] = $e->getLine();
@@ -77,7 +77,7 @@ class Error {
if(IS_CLI) { if(IS_CLI) {
exit(is_array($error)?$error['message']:$error); exit(is_array($error)?$error['message']:$error);
} }
$e = array(); $e = [];
if (Config::get('app_debug')) { if (Config::get('app_debug')) {
//调试模式下输出错误信息 //调试模式下输出错误信息
if (!is_array($error)) { if (!is_array($error)) {

View File

@@ -16,13 +16,13 @@ class Gif{
* GIF帧列表 * GIF帧列表
* @var array * @var array
*/ */
private $frames = array(); private $frames = [];
/** /**
* 每帧等待时间列表 * 每帧等待时间列表
* @var array * @var array
*/ */
private $delays = array(); private $delays = [];
/** /**
* 构造方法用于解码GIF图片 * 构造方法用于解码GIF图片

View File

@@ -21,7 +21,7 @@ class Input {
* @param array $args 参数 array(key,filter,default) * @param array $args 参数 array(key,filter,default)
* @return mixed * @return mixed
*/ */
static public function __callStatic($type,$args=array()) { static public function __callStatic($type,$args=[]) {
switch(strtolower($type)) { switch(strtolower($type)) {
case 'get': $input =& $_GET;break; case 'get': $input =& $_GET;break;
case 'post': $input =& $_POST;break; case 'post': $input =& $_POST;break;

View File

@@ -20,14 +20,14 @@ class File {
const SAPI = 4; const SAPI = 4;
// 日志信息 // 日志信息
protected $log = array(); protected $log = [];
protected $config = array( protected $config = array(
'log_time_format' => '[ c ]', 'log_time_format' => '[ c ]',
'log_file_size' => 2097152, 'log_file_size' => 2097152,
'log_allow_level' => array('ERR','NOTIC','DEBUG','SQL','INFO'), 'log_allow_level' => array('ERR','NOTIC','DEBUG','SQL','INFO'),
); );
public function __construct($config=array()){ public function __construct($config=[]){
$this->config = array_merge($this->config,$config); $this->config = array_merge($this->config,$config);
} }
@@ -75,12 +75,12 @@ class File {
$message = date($this->config['log_time_format']).' '.$_SERVER['REMOTE_ADDR'].' '.$_SERVER['REQUEST_URI']."\r\n"; $message = date($this->config['log_time_format']).' '.$_SERVER['REMOTE_ADDR'].' '.$_SERVER['REQUEST_URI']."\r\n";
if($level) { if($level) {
$message .= implode('',$log)."\r\n"; $message .= implode('',$log)."\r\n";
$this->log[$level] = array(); $this->log[$level] = [];
}else{ }else{
foreach($log as $info){ foreach($log as $info){
$message .= implode('',$info)."\r\n"; $message .= implode('',$info)."\r\n";
} }
$this->log = array(); $this->log = [];
} }
error_log($message, 3,$destination); error_log($message, 3,$destination);
//clearstatcache(); //clearstatcache();

View File

@@ -173,7 +173,7 @@ abstract class Driver {
* @param string $method 请求方法GET/POST * @param string $method 请求方法GET/POST
* @return array $data 响应数据 * @return array $data 响应数据
*/ */
protected function http($url, $params, $method = 'GET', $header = array()){ protected function http($url, $params, $method = 'GET', $header = []){
$vars = http_build_query($params); $vars = http_build_query($params);
$opts = array( $opts = array(
CURLOPT_TIMEOUT => 30, CURLOPT_TIMEOUT => 30,

View File

@@ -39,7 +39,7 @@ class Douban extends Driver{
*/ */
public function call($api, $param = '', $method = 'GET'){ public function call($api, $param = '', $method = 'GET'){
/* 豆瓣调用公共参数 */ /* 豆瓣调用公共参数 */
$params = array(); $params = [];
$header = array("Authorization: Bearer {$this->token['access_token']}"); $header = array("Authorization: Bearer {$this->token['access_token']}");
$data = $this->http($this->url($api), $this->param($params, $param), $method, $header); $data = $this->http($this->url($api), $this->param($params, $param), $method, $header);
return json_decode($data, true); return json_decode($data, true);

View File

@@ -39,7 +39,7 @@ class Github extends Driver{
*/ */
public function call($api, $param = '', $method = 'GET'){ public function call($api, $param = '', $method = 'GET'){
/* Github 调用公共参数 */ /* Github 调用公共参数 */
$params = array(); $params = [];
$header = array("Authorization: bearer {$this->token['access_token']}"); $header = array("Authorization: bearer {$this->token['access_token']}");
$data = $this->http($this->url($api), $this->param($params, $param), $method, $header); $data = $this->http($this->url($api), $this->param($params, $param), $method, $header);

View File

@@ -45,7 +45,7 @@ class Google extends Driver{
*/ */
public function call($api, $param = '', $method = 'GET'){ public function call($api, $param = '', $method = 'GET'){
/* Google 调用公共参数 */ /* Google 调用公共参数 */
$params = array(); $params = [];
$header = array("Authorization: Bearer {$this->token['access_token']}"); $header = array("Authorization: Bearer {$this->token['access_token']}");
$data = $this->http($this->url($api), $this->param($params, $param), $method, $header); $data = $this->http($this->url($api), $this->param($params, $param), $method, $header);

View File

@@ -61,7 +61,7 @@ class Renren extends Driver{
/* 签名 */ /* 签名 */
ksort($params); ksort($params);
$param = array(); $param = [];
foreach ($params as $key => $value){ foreach ($params as $key => $value){
$param[] = "{$key}={$value}"; $param[] = "{$key}={$value}";
} }

View File

@@ -21,30 +21,30 @@ use Think\TagLib;
class Cx extends TagLib { class Cx extends TagLib {
// 标签定义 // 标签定义
protected $tags = array( protected $tags = [
// 标签定义: attr 属性列表 close 是否闭合0 或者1 默认1 alias 标签别名 level 嵌套层次 // 标签定义: attr 属性列表 close 是否闭合0 或者1 默认1 alias 标签别名 level 嵌套层次
'php' => array(), 'php' => [],
'volist' => array('attr'=>'name,id,offset,length,key,mod','level'=>3,'alias'=>'iterate'), 'volist' => ['attr'=>'name,id,offset,length,key,mod','level'=>3,'alias'=>'iterate'],
'foreach' => array('attr'=>'name,item,key','level'=>3), 'foreach' => ['attr'=>'name,item,key','level'=>3],
'if' => array('attr'=>'condition','level'=>2), 'if' => ['attr'=>'condition','level'=>2],
'elseif' => array('attr'=>'condition','close'=>0), 'elseif' => ['attr'=>'condition','close'=>0],
'else' => array('attr'=>'','close'=>0), 'else' => ['attr'=>'','close'=>0],
'switch' => array('attr'=>'name','level'=>2), 'switch' => ['attr'=>'name','level'=>2],
'case' => array('attr'=>'value,break'), 'case' => ['attr'=>'value,break'],
'default' => array('attr'=>'','close'=>0), 'default' => ['attr'=>'','close'=>0],
'compare' => array('attr'=>'name,value,type','level'=>3,'alias'=>'eq,equal,notequal,neq,gt,lt,egt,elt,heq,nheq'), 'compare' => ['attr'=>'name,value,type','level'=>3,'alias'=>'eq,equal,notequal,neq,gt,lt,egt,elt,heq,nheq'],
'range' => array('attr'=>'name,value,type','level'=>3,'alias'=>'in,notin,between,notbetween'), 'range' => ['attr'=>'name,value,type','level'=>3,'alias'=>'in,notin,between,notbetween'],
'empty' => array('attr'=>'name','level'=>3), 'empty' => ['attr'=>'name','level'=>3],
'notempty' => array('attr'=>'name','level'=>3), 'notempty' => ['attr'=>'name','level'=>3],
'present' => array('attr'=>'name','level'=>3), 'present' => ['attr'=>'name','level'=>3],
'notpresent'=> array('attr'=>'name','level'=>3), 'notpresent'=> ['attr'=>'name','level'=>3],
'defined' => array('attr'=>'name','level'=>3), 'defined' => ['attr'=>'name','level'=>3],
'notdefined'=> array('attr'=>'name','level'=>3), 'notdefined'=> ['attr'=>'name','level'=>3],
'import' => array('attr'=>'file,href,type,value,basepath','close'=>0,'alias'=>'load,css,js'), 'import' => ['attr'=>'file,href,type,value,basepath','close'=>0,'alias'=>'load,css,js'],
'assign' => array('attr'=>'name,value','close'=>0), 'assign' => ['attr'=>'name,value','close'=>0],
'define' => array('attr'=>'name,value','close'=>0), 'define' => ['attr'=>'name,value','close'=>0],
'for' => array('attr'=>'start,end,name,comparison,step', 'level'=>3), 'for' => ['attr'=>'start,end,name,comparison,step', 'level'=>3],
); ];
/** /**
* php标签解析 * php标签解析
@@ -498,10 +498,10 @@ class Cx extends TagLib {
list($val,$version) = explode('?',$val); list($val,$version) = explode('?',$val);
switch($type) { switch($type) {
case 'js': case 'js':
$parseStr .= '<script type="text/javascript" src="'.$basepath.'/'.str_replace(array('.','#'), array('/','.'),$val).'.js'.($version?'?'.$version:'').'"></script>'; $parseStr .= '<script type="text/javascript" src="'.$basepath.'/'.str_replace(['.','#'], ['/','.'],$val).'.js'.($version?'?'.$version:'').'"></script>';
break; break;
case 'css': case 'css':
$parseStr .= '<link rel="stylesheet" type="text/css" href="'.$basepath.'/'.str_replace(array('.','#'), array('/','.'),$val).'.css'.($version?'?'.$version:'').'" />'; $parseStr .= '<link rel="stylesheet" type="text/css" href="'.$basepath.'/'.str_replace(['.','#'], ['/','.'],$val).'.css'.($version?'?'.$version:'').'" />';
break; break;
case 'php': case 'php':
$parseStr .= '<?php import("'.$val.'"); ?>'; $parseStr .= '<?php import("'.$val.'"); ?>';

View File

@@ -66,7 +66,7 @@ class Url {
if(is_string($vars)) { // aaa=1&bbb=2 转换成数组 if(is_string($vars)) { // aaa=1&bbb=2 转换成数组
parse_str($vars,$vars); parse_str($vars,$vars);
}elseif(!is_array($vars)){ }elseif(!is_array($vars)){
$vars = array(); $vars = [];
} }
if(isset($info['query'])) { // 解析地址里面参数 合并到vars if(isset($info['query'])) { // 解析地址里面参数 合并到vars
parse_str($info['query'],$params); parse_str($info['query'],$params);
@@ -89,7 +89,7 @@ class Url {
// 解析分组、模块和操作 // 解析分组、模块和操作
$url = trim($url,$depr); $url = trim($url,$depr);
$path = explode($depr,$url); $path = explode($depr,$url);
$var = array(); $var = [];
$var[Config::get('var_action')] = !empty($path)?array_pop($path):ACTION_NAME; $var[Config::get('var_action')] = !empty($path)?array_pop($path):ACTION_NAME;
if(Config::get('require_controller')) { if(Config::get('require_controller')) {
$var[Config::get('var_controller')] = !empty($path)?array_pop($path):CONTROLLER_NAME; $var[Config::get('var_controller')] = !empty($path)?array_pop($path):CONTROLLER_NAME;

View File

@@ -12,7 +12,7 @@
namespace Think; namespace Think;
class Validate { class Validate {
protected $validate = array(); // 自动验证定义 protected $validate = []; // 自动验证定义
// 是否批处理验证 // 是否批处理验证
protected $patchValidate = false; protected $patchValidate = false;
protected $error = ''; protected $error = '';
@@ -29,12 +29,12 @@ class Validate {
* @param string $type 创建类型 * @param string $type 创建类型
* @return boolean * @return boolean
*/ */
public function valid($data,$rule=array()) { public function valid($data,$rule=[]) {
$validate = $rule?$rule:$this->validate; $validate = $rule?$rule:$this->validate;
// 属性验证 // 属性验证
if($validate) { // 如果设置了数据自动验证则进行数据验证 if($validate) { // 如果设置了数据自动验证则进行数据验证
if($this->patchValidate) { // 重置验证错误信息 if($this->patchValidate) { // 重置验证错误信息
$this->error = array(); $this->error = [];
} }
foreach($validate as $key=>$val) { foreach($validate as $key=>$val) {
// 验证因子定义格式 // 验证因子定义格式
@@ -87,7 +87,7 @@ class Validate {
protected function _validationFieldItem($data,$val) { protected function _validationFieldItem($data,$val) {
switch(strtolower(trim($val[4]))) { switch(strtolower(trim($val[4]))) {
case 'callback':// 调用方法进行验证 case 'callback':// 调用方法进行验证
$args = isset($val[5])?(array)$val[5]:array(); $args = isset($val[5])?(array)$val[5]:[];
if(is_string($val[0]) && strpos($val[0], ',')) if(is_string($val[0]) && strpos($val[0], ','))
$val[0] = explode(',', $val[0]); $val[0] = explode(',', $val[0]);
if(is_array($val[0])){ if(is_array($val[0])){