规范代码

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;
use think\Config;
use think\Env;
use think\Exception;
use think\exception\HttpException;
use think\exception\HttpResponseException;
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 应用管理

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,11 +11,6 @@
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\Jsonp as JsonpResponse;
use think\response\Redirect as RedirectResponse;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -252,7 +252,7 @@ class Input
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\Option as InputOption;
use think\console\Output;
use think\console\helper\Descriptor as DescriptorHelper;
class Help extends Command
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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