规范代码

This commit is contained in:
thinkphp
2016-12-24 21:37:05 +08:00
parent 81bde424be
commit 43b364e286
45 changed files with 106 additions and 195 deletions

View File

@@ -11,19 +11,9 @@
namespace think; namespace think;
use think\Config;
use think\Env;
use think\Exception;
use think\exception\HttpException; use think\exception\HttpException;
use think\exception\HttpResponseException; use think\exception\HttpResponseException;
use think\exception\RouteNotFoundException; use think\exception\RouteNotFoundException;
use think\Hook;
use think\Lang;
use think\Loader;
use think\Log;
use think\Request;
use think\Response;
use think\Route;
/** /**
* App 应用管理 * App 应用管理

View File

@@ -11,8 +11,6 @@
namespace think; namespace think;
use think\App;
class Cache class Cache
{ {
protected static $instance = []; protected static $instance = [];

View File

@@ -317,7 +317,7 @@ class Console
if (!$command->isEnabled()) { if (!$command->isEnabled()) {
$command->setConsole(null); $command->setConsole(null);
return null; return;
} }
if (null === $command->getDefinition()) { if (null === $command->getDefinition()) {

View File

@@ -13,7 +13,6 @@ namespace think;
\think\Loader::import('controller/Jump', TRAIT_PATH, EXT); \think\Loader::import('controller/Jump', TRAIT_PATH, EXT);
use think\Exception;
use think\exception\ValidateException; use think\exception\ValidateException;
class Controller class Controller

View File

@@ -149,7 +149,7 @@ class Cookie
} }
return $value; return $value;
} else { } else {
return null; return;
} }
} }

View File

@@ -11,8 +11,6 @@
namespace think; namespace think;
use think\App;
use think\Collection;
use think\db\Query; use think\db\Query;
use think\paginator\Collection as PaginatorCollection; use think\paginator\Collection as PaginatorCollection;

View File

@@ -11,11 +11,7 @@
namespace think; namespace think;
use think\Config;
use think\exception\ClassNotFoundException; use think\exception\ClassNotFoundException;
use think\Log;
use think\Request;
use think\Response;
use think\response\Redirect; use think\response\Redirect;
class Debug class Debug
@@ -179,7 +175,7 @@ class Debug
} }
if ($echo) { if ($echo) {
echo ($output); echo ($output);
return null; return;
} else { } else {
return $output; return $output;
} }

View File

@@ -11,11 +11,6 @@
namespace think; namespace think;
use think\App;
use think\Debug;
use think\Loader;
use think\Log;
class Hook class Hook
{ {

View File

@@ -11,10 +11,6 @@
namespace think; namespace think;
use think\App;
use think\Cookie;
use think\Log;
class Lang class Lang
{ {
// 语言数据 // 语言数据

View File

@@ -12,14 +12,8 @@
namespace think; namespace think;
use InvalidArgumentException; use InvalidArgumentException;
use think\Cache;
use think\Collection;
use think\Config;
use think\Db;
use think\db\Query; use think\db\Query;
use think\Exception;
use think\Exception\ValidateException; use think\Exception\ValidateException;
use think\Loader;
use think\model\Relation; use think\model\Relation;
use think\model\relation\BelongsTo; use think\model\relation\BelongsTo;
use think\model\relation\BelongsToMany; use think\model\relation\BelongsToMany;

View File

@@ -12,7 +12,6 @@
namespace think; namespace think;
use think\paginator\Collection as PaginatorCollection; use think\paginator\Collection as PaginatorCollection;
use think\Request;
abstract class Paginator abstract class Paginator
{ {
@@ -42,14 +41,14 @@ abstract class Paginator
'var_page' => 'page', 'var_page' => 'page',
'path' => '/', 'path' => '/',
'query' => [], 'query' => [],
'fragment' => '' 'fragment' => '',
]; ];
protected function __construct($items, $listRows, $currentPage = null, $total = null, $simple = false, $options = []) protected function __construct($items, $listRows, $currentPage = null, $total = null, $simple = false, $options = [])
{ {
$this->options = array_merge($this->options, $options); $this->options = array_merge($this->options, $options);
$this->options['path'] = $this->options['path'] != '/' ? rtrim($this->options['path'], '/') : $this->options['path']; $this->options['path'] = '/' != $this->options['path'] ? rtrim($this->options['path'], '/') : $this->options['path'];
$this->simple = $simple; $this->simple = $simple;
$this->listRows = $listRows; $this->listRows = $listRows;
@@ -182,7 +181,7 @@ abstract class Paginator
*/ */
public function hasPages() public function hasPages()
{ {
return !($this->currentPage == 1 && !$this->hasMore); return !(1 == $this->currentPage && !$this->hasMore);
} }
/** /**
@@ -239,7 +238,6 @@ abstract class Paginator
return $this; return $this;
} }
/** /**
* 构造锚点字符串 * 构造锚点字符串
* *

View File

@@ -14,9 +14,9 @@ namespace think;
use think\process\exception\Failed as ProcessFailedException; use think\process\exception\Failed as ProcessFailedException;
use think\process\exception\Timeout as ProcessTimeoutException; use think\process\exception\Timeout as ProcessTimeoutException;
use think\process\pipes\Pipes; use think\process\pipes\Pipes;
use think\process\Utils;
use think\process\pipes\Unix as UnixPipes; use think\process\pipes\Unix as UnixPipes;
use think\process\pipes\Windows as WindowsPipes; use think\process\pipes\Windows as WindowsPipes;
use think\process\Utils;
class Process class Process
{ {
@@ -147,7 +147,7 @@ class Process
$this->enhanceSigchildCompatibility = '\\' !== DS && $this->isSigchildEnabled(); $this->enhanceSigchildCompatibility = '\\' !== DS && $this->isSigchildEnabled();
$this->options = array_replace([ $this->options = array_replace([
'suppress_errors' => true, 'suppress_errors' => true,
'binary_pipes' => true 'binary_pipes' => true,
], $options); ], $options);
} }
@@ -490,7 +490,7 @@ class Process
public function getExitCodeText() public function getExitCodeText()
{ {
if (null === $exitcode = $this->getExitCode()) { if (null === $exitcode = $this->getExitCode()) {
return null; return;
} }
return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error'; return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
@@ -586,7 +586,7 @@ class Process
*/ */
public function isStarted() public function isStarted()
{ {
return $this->status != self::STATUS_READY; return self::STATUS_READY != $this->status;
} }
/** /**
@@ -597,7 +597,7 @@ class Process
{ {
$this->updateStatus(false); $this->updateStatus(false);
return $this->status == self::STATUS_TERMINATED; return self::STATUS_TERMINATED == $this->status;
} }
/** /**
@@ -922,7 +922,7 @@ class Process
*/ */
public function checkTimeout() public function checkTimeout()
{ {
if ($this->status !== self::STATUS_STARTED) { if (self::STATUS_STARTED !== $this->status) {
return; return;
} }
@@ -1083,7 +1083,7 @@ class Process
if (3 == $type) { if (3 == $type) {
$this->fallbackExitcode = (int) $data; $this->fallbackExitcode = (int) $data;
} else { } else {
$callback($type === self::STDOUT ? self::OUT : self::ERR, $data); $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
} }
} }
} }

View File

@@ -11,11 +11,6 @@
namespace think; namespace think;
use think\Config;
use think\Exception;
use think\File;
use think\Session;
class Request class Request
{ {
/** /**
@@ -891,7 +886,7 @@ class Request
return $array[$name]; return $array[$name];
} }
} }
return null; return;
} }
/** /**

View File

@@ -11,11 +11,6 @@
namespace think; namespace think;
use think\Cache;
use think\Config;
use think\Debug;
use think\Env;
use think\Request;
use think\response\Json as JsonResponse; use think\response\Json as JsonResponse;
use think\response\Jsonp as JsonpResponse; use think\response\Jsonp as JsonpResponse;
use think\response\Redirect as RedirectResponse; use think\response\Redirect as RedirectResponse;

View File

@@ -11,14 +11,7 @@
namespace think; namespace think;
use think\App;
use think\Config;
use think\exception\HttpException; use think\exception\HttpException;
use think\Hook;
use think\Loader;
use think\Log;
use think\Request;
use think\Response;
class Route class Route
{ {

View File

@@ -11,7 +11,6 @@
namespace think; namespace think;
use think\App;
use think\exception\ClassNotFoundException; use think\exception\ClassNotFoundException;
class Session class Session

View File

@@ -12,7 +12,6 @@
namespace think; namespace think;
use think\exception\TemplateNotFoundException; use think\exception\TemplateNotFoundException;
use think\Request;
/** /**
* ThinkPHP分离出来的模板引擎 * ThinkPHP分离出来的模板引擎
@@ -130,7 +129,7 @@ class Template
} elseif (isset($this->config[$config])) { } elseif (isset($this->config[$config])) {
return $this->config[$config]; return $this->config[$config];
} else { } else {
return null; return;
} }
} }
@@ -669,7 +668,7 @@ class Template
$content = str_replace($matches[0], '', $content); $content = str_replace($matches[0], '', $content);
return explode(',', $matches['name']); return explode(',', $matches['name']);
} }
return null; return;
} }
/** /**

View File

@@ -11,11 +11,6 @@
namespace think; namespace think;
use think\Config;
use think\Loader;
use think\Request;
use think\Route;
class Url class Url
{ {
// 生成URL地址的root // 生成URL地址的root

View File

@@ -11,13 +11,7 @@
namespace think; namespace think;
use think\Db;
use think\exception\ClassNotFoundException; use think\exception\ClassNotFoundException;
use think\File;
use think\Lang;
use think\Loader;
use think\Request;
use think\Session;
class Validate class Validate
{ {

View File

@@ -11,9 +11,6 @@
namespace think; namespace think;
use think\Loader;
use think\Request;
class View class View
{ {
// 视图实例 // 视图实例

View File

@@ -105,7 +105,7 @@ abstract class Driver
$this->rm($name); $this->rm($name);
return $result; return $result;
} else { } else {
return null; return;
} }
} }

View File

@@ -12,7 +12,6 @@
namespace think\cache\driver; namespace think\cache\driver;
use think\cache\Driver; use think\cache\Driver;
use think\Exception;
class Memcache extends Driver class Memcache extends Driver
{ {

View File

@@ -12,7 +12,6 @@
namespace think\cache\driver; namespace think\cache\driver;
use think\cache\Driver; use think\cache\Driver;
use think\Exception;
/** /**
* Sqlite缓存驱动 * Sqlite缓存驱动

View File

@@ -12,7 +12,6 @@
namespace think\cache\driver; namespace think\cache\driver;
use think\cache\Driver; use think\cache\Driver;
use think\Exception;
/** /**
* Wincache缓存驱动 * Wincache缓存驱动
@@ -28,7 +27,7 @@ class Wincache extends Driver
/** /**
* 架构函数 * 架构函数
* @param array $options 缓存参数 * @param array $options 缓存参数
* @throws Exception * @throws \BadFunctionCallException
* @access public * @access public
*/ */
public function __construct($options = []) public function __construct($options = [])

View File

@@ -12,7 +12,6 @@
namespace think\cache\driver; namespace think\cache\driver;
use think\cache\Driver; use think\cache\Driver;
use think\Exception;
/** /**
* Xcache缓存驱动 * Xcache缓存驱动

View File

@@ -252,7 +252,7 @@ class Input
return $token; return $token;
} }
return null; return;
} }
/** /**

View File

@@ -16,7 +16,6 @@ use think\console\Input;
use think\console\input\Argument as InputArgument; use think\console\input\Argument as InputArgument;
use think\console\input\Option as InputOption; use think\console\input\Option as InputOption;
use think\console\Output; use think\console\Output;
use think\console\helper\Descriptor as DescriptorHelper;
class Help extends Command class Help extends Command
{ {

View File

@@ -196,7 +196,7 @@ class Console
private function getSttyColumns() private function getSttyColumns()
{ {
if (!function_exists('proc_open')) { if (!function_exists('proc_open')) {
return null; return;
} }
$descriptorspec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; $descriptorspec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']];
@@ -209,7 +209,7 @@ class Console
return $info; return $info;
} }
return null; return;
} }
/** /**
@@ -234,7 +234,7 @@ class Console
return $matches[2] . 'x' . $matches[1]; return $matches[2] . 'x' . $matches[1];
} }
} }
return null; return;
} }
private function stringWidth($string) private function stringWidth($string)

View File

@@ -12,9 +12,6 @@
namespace think\db; namespace think\db;
use PDO; use PDO;
use think\Db;
use think\db\Connection;
use think\db\Query;
use think\Exception; use think\Exception;
abstract class Builder abstract class Builder

View File

@@ -16,7 +16,6 @@ use PDOStatement;
use think\Collection; use think\Collection;
use think\Db; use think\Db;
use think\db\exception\BindParamException; use think\db\exception\BindParamException;
use think\db\Query;
use think\Debug; use think\Debug;
use think\Exception; use think\Exception;
use think\exception\PDOException; use think\exception\PDOException;

View File

@@ -16,8 +16,6 @@ use think\Cache;
use think\Collection; use think\Collection;
use think\Config; use think\Config;
use think\Db; use think\Db;
use think\db\Builder;
use think\db\Connection;
use think\db\exception\BindParamException; use think\db\exception\BindParamException;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException; use think\db\exception\ModelNotFoundException;

View File

@@ -11,8 +11,6 @@
namespace think\exception; namespace think\exception;
use think\exception\DbException;
/** /**
* PDO异常处理类 * PDO异常处理类
* 重新封装了系统的\PDOException类 * 重新封装了系统的\PDOException类

View File

@@ -11,8 +11,6 @@
namespace think\exception; namespace think\exception;
use think\exception\HttpException;
class RouteNotFoundException extends HttpException class RouteNotFoundException extends HttpException
{ {

View File

@@ -209,19 +209,19 @@ class Socket
} }
if (!isset($_SERVER[$key])) { if (!isset($_SERVER[$key])) {
return null; return;
} }
if (empty($args)) { if (empty($args)) {
if (!preg_match('/SocketLog\((.*?)\)/', $_SERVER[$key], $match)) { if (!preg_match('/SocketLog\((.*?)\)/', $_SERVER[$key], $match)) {
$args = ['tabid' => null]; $args = ['tabid' => null];
return null; return;
} }
parse_str($match[1], $args); parse_str($match[1], $args);
} }
if (isset($args[$name])) { if (isset($args[$name])) {
return $args[$name]; return $args[$name];
} }
return null; return;
} }
/** /**

View File

@@ -12,7 +12,6 @@
namespace think\model\relation; namespace think\model\relation;
use think\Model; use think\Model;
use think\model\relation\OneToOne;
class BelongsTo extends OneToOne class BelongsTo extends OneToOne
{ {

View File

@@ -12,7 +12,6 @@
namespace think\model\relation; namespace think\model\relation;
use think\Model; use think\Model;
use think\model\relation\OneToOne;
class HasOne extends OneToOne class HasOne extends OneToOne
{ {

View File

@@ -16,7 +16,6 @@ use think\Exception;
use think\Loader; use think\Loader;
use think\Model; use think\Model;
use think\model\Relation; use think\model\Relation;
use think\model\relation\BelongsTo;
abstract class OneToOne extends Relation abstract class OneToOne extends Relation
{ {

View File

@@ -15,7 +15,6 @@ use think\Process;
class Builder class Builder
{ {
private $arguments; private $arguments;
private $cwd; private $cwd;
private $env = null; private $env = null;

View File

@@ -11,7 +11,6 @@
namespace think\process\exception; namespace think\process\exception;
use think\Process; use think\Process;
class Failed extends \RuntimeException class Failed extends \RuntimeException

View File

@@ -139,7 +139,7 @@ class Unix extends Pipes
} }
if ('' !== $data) { if ('' !== $data) {
if ($type === 'input') { if ('input' === $type) {
$this->inputBuffer .= $data; $this->inputBuffer .= $data;
} else { } else {
$read[$type] = $data; $read[$type] = $data;
@@ -147,7 +147,7 @@ class Unix extends Pipes
} }
if (false === $data || (true === $close && feof($pipe) && '' === $data)) { if (false === $data || (true === $close && feof($pipe) && '' === $data)) {
if ($type === 'input') { if ('input' === $type) {
$this->input = null; $this->input = null;
} else { } else {
fclose($this->pipes[$type]); fclose($this->pipes[$type]);

View File

@@ -11,7 +11,7 @@
namespace traits\think; namespace traits\think;
use \think\Exception; use think\Exception;
trait Instance trait Instance
{ {