From 43b364e2867132cd8735cd261153bbbdc9946f12 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 24 Dec 2016 21:37:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 10 -- library/think/Cache.php | 2 - library/think/Collection.php | 6 +- library/think/Console.php | 2 +- library/think/Controller.php | 1 - library/think/Cookie.php | 2 +- library/think/Db.php | 2 - library/think/Debug.php | 6 +- library/think/Hook.php | 5 - library/think/Lang.php | 4 - library/think/Model.php | 6 - library/think/Paginator.php | 14 +-- library/think/Process.php | 112 +++++++++--------- library/think/Request.php | 7 +- library/think/Response.php | 5 - library/think/Route.php | 7 -- library/think/Session.php | 1 - library/think/Template.php | 5 +- library/think/Url.php | 5 - library/think/Validate.php | 6 - library/think/View.php | 3 - library/think/cache/Driver.php | 2 +- library/think/cache/driver/Memcache.php | 1 - library/think/cache/driver/Sqlite.php | 1 - library/think/cache/driver/Wincache.php | 3 +- library/think/cache/driver/Xcache.php | 1 - library/think/console/Input.php | 2 +- library/think/console/command/Help.php | 3 +- .../think/console/command/optimize/Schema.php | 2 +- .../think/console/output/driver/Console.php | 14 +-- library/think/db/Builder.php | 3 - library/think/db/Connection.php | 1 - library/think/db/Query.php | 2 - library/think/exception/PDOException.php | 2 - .../exception/RouteNotFoundException.php | 2 - library/think/log/driver/Socket.php | 6 +- library/think/model/relation/BelongsTo.php | 1 - library/think/model/relation/HasOne.php | 1 - library/think/model/relation/OneToOne.php | 1 - library/think/process/Builder.php | 7 +- library/think/process/Utils.php | 4 +- .../exception/{Faild.php => Failed.php} | 1 - library/think/process/pipes/Unix.php | 20 ++-- library/think/process/pipes/Windows.php | 8 +- library/traits/think/Instance.php | 2 +- 45 files changed, 106 insertions(+), 195 deletions(-) rename library/think/process/exception/{Faild.php => Failed.php} (99%) diff --git a/library/think/App.php b/library/think/App.php index dc22cbe1..a7e1ddfa 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -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 应用管理 diff --git a/library/think/Cache.php b/library/think/Cache.php index 208190be..372da705 100644 --- a/library/think/Cache.php +++ b/library/think/Cache.php @@ -11,8 +11,6 @@ namespace think; -use think\App; - class Cache { protected static $instance = []; diff --git a/library/think/Collection.php b/library/think/Collection.php index 8315268a..cf2888d5 100644 --- a/library/think/Collection.php +++ b/library/think/Collection.php @@ -225,11 +225,11 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria $result = []; foreach ($this->items as $row) { - $key = $value = null; + $key = $value = null; $keySet = $valueSet = false; if (null !== $index_key && array_key_exists($index_key, $row)) { $keySet = true; - $key = (string)$row[$index_key]; + $key = (string) $row[$index_key]; } if (null === $column_key) { $valueSet = true; @@ -368,6 +368,6 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria if ($items instanceof self) { return $items->all(); } - return (array)$items; + return (array) $items; } } diff --git a/library/think/Console.php b/library/think/Console.php index ab8e0211..233489b5 100644 --- a/library/think/Console.php +++ b/library/think/Console.php @@ -317,7 +317,7 @@ class Console if (!$command->isEnabled()) { $command->setConsole(null); - return null; + return; } if (null === $command->getDefinition()) { diff --git a/library/think/Controller.php b/library/think/Controller.php index fe4efae2..e9d6829b 100644 --- a/library/think/Controller.php +++ b/library/think/Controller.php @@ -13,7 +13,6 @@ namespace think; \think\Loader::import('controller/Jump', TRAIT_PATH, EXT); -use think\Exception; use think\exception\ValidateException; class Controller diff --git a/library/think/Cookie.php b/library/think/Cookie.php index 12b5cc31..f1c2426a 100644 --- a/library/think/Cookie.php +++ b/library/think/Cookie.php @@ -149,7 +149,7 @@ class Cookie } return $value; } else { - return null; + return; } } diff --git a/library/think/Db.php b/library/think/Db.php index c67cba6f..4998469f 100644 --- a/library/think/Db.php +++ b/library/think/Db.php @@ -11,8 +11,6 @@ namespace think; -use think\App; -use think\Collection; use think\db\Query; use think\paginator\Collection as PaginatorCollection; diff --git a/library/think/Debug.php b/library/think/Debug.php index e36a764e..24acd3d3 100644 --- a/library/think/Debug.php +++ b/library/think/Debug.php @@ -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; } diff --git a/library/think/Hook.php b/library/think/Hook.php index 4d69ca54..4559cd30 100644 --- a/library/think/Hook.php +++ b/library/think/Hook.php @@ -11,11 +11,6 @@ namespace think; -use think\App; -use think\Debug; -use think\Loader; -use think\Log; - class Hook { diff --git a/library/think/Lang.php b/library/think/Lang.php index e064ae45..551481f1 100644 --- a/library/think/Lang.php +++ b/library/think/Lang.php @@ -11,10 +11,6 @@ namespace think; -use think\App; -use think\Cookie; -use think\Log; - class Lang { // 语言数据 diff --git a/library/think/Model.php b/library/think/Model.php index d8e76ce6..71fbfc69 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -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; diff --git a/library/think/Paginator.php b/library/think/Paginator.php index 7385ebb0..dc4cdeeb 100644 --- a/library/think/Paginator.php +++ b/library/think/Paginator.php @@ -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; @@ -63,7 +62,7 @@ abstract class Paginator $items = $items->slice(0, $this->listRows); } else { $this->total = $total; - $this->lastPage = (int)ceil($total / $listRows); + $this->lastPage = (int) ceil($total / $listRows); $this->currentPage = $this->setCurrentPage($currentPage); $this->hasMore = $this->currentPage < $this->lastPage; } @@ -134,7 +133,7 @@ abstract class Paginator { $page = Request::instance()->request($varPage); - if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int)$page >= 1) { + if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) { return $page; } @@ -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; } - /** * 构造锚点字符串 * @@ -255,4 +253,4 @@ abstract class Paginator * @return mixed */ abstract public function render(); -} \ No newline at end of file +} diff --git a/library/think/Process.php b/library/think/Process.php index 1982de24..6f3faa31 100644 --- a/library/think/Process.php +++ b/library/think/Process.php @@ -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 { @@ -47,10 +47,10 @@ class Process private $exitcode; private $fallbackExitcode; private $processInformation; - private $outputDisabled = false; + private $outputDisabled = false; private $stdout; private $stderr; - private $enhanceWindowsCompatibility = true; + private $enhanceWindowsCompatibility = true; private $enhanceSigchildCompatibility; private $process; private $status = self::STATUS_READY; @@ -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; } /** @@ -645,7 +645,7 @@ class Process * @param string $line */ public function addOutput($line) - { +{ $this->lastOutputTime = microtime(true); $this->stdout .= $line; } @@ -655,7 +655,7 @@ class Process * @param string $line */ public function addErrorOutput($line) - { +{ $this->lastOutputTime = microtime(true); $this->stderr .= $line; } @@ -665,7 +665,7 @@ class Process * @return string */ public function getCommandLine() - { +{ return $this->commandline; } @@ -675,7 +675,7 @@ class Process * @return self */ public function setCommandLine($commandline) - { +{ $this->commandline = $commandline; return $this; @@ -686,7 +686,7 @@ class Process * @return float|null */ public function getTimeout() - { +{ return $this->timeout; } @@ -695,7 +695,7 @@ class Process * @return float|null */ public function getIdleTimeout() - { +{ return $this->idleTimeout; } @@ -705,7 +705,7 @@ class Process * @return self */ public function setTimeout($timeout) - { +{ $this->timeout = $this->validateTimeout($timeout); return $this; @@ -717,7 +717,7 @@ class Process * @return self */ public function setIdleTimeout($timeout) - { +{ if (null !== $timeout && $this->outputDisabled) { throw new \LogicException('Idle timeout can not be set while the output is disabled.'); } @@ -733,7 +733,7 @@ class Process * @return self */ public function setTty($tty) - { +{ if ('\\' === DS && $tty) { throw new \RuntimeException('TTY mode is not supported on Windows platform.'); } @@ -741,7 +741,7 @@ class Process throw new \RuntimeException('TTY mode requires /dev/tty to be readable.'); } - $this->tty = (bool)$tty; + $this->tty = (bool) $tty; return $this; } @@ -751,7 +751,7 @@ class Process * @return bool */ public function isTty() - { +{ return $this->tty; } @@ -761,8 +761,8 @@ class Process * @return self */ public function setPty($bool) - { - $this->pty = (bool)$bool; +{ + $this->pty = (bool) $bool; return $this; } @@ -772,7 +772,7 @@ class Process * @return bool */ public function isPty() - { +{ return $this->pty; } @@ -781,7 +781,7 @@ class Process * @return string|null */ public function getWorkingDirectory() - { +{ if (null === $this->cwd) { return getcwd() ?: null; } @@ -795,7 +795,7 @@ class Process * @return self */ public function setWorkingDirectory($cwd) - { +{ $this->cwd = $cwd; return $this; @@ -806,7 +806,7 @@ class Process * @return array */ public function getEnv() - { +{ return $this->env; } @@ -816,14 +816,14 @@ class Process * @return self */ public function setEnv(array $env) - { +{ $env = array_filter($env, function ($value) { return !is_array($value); }); $this->env = []; foreach ($env as $key => $value) { - $this->env[(binary)$key] = (binary)$value; + $this->env[(binary) $key] = (binary) $value; } return $this; @@ -834,7 +834,7 @@ class Process * @return null|string */ public function getInput() - { +{ return $this->input; } @@ -844,7 +844,7 @@ class Process * @return self */ public function setInput($input) - { +{ if ($this->isRunning()) { throw new \LogicException('Input can not be set while the process is running.'); } @@ -859,7 +859,7 @@ class Process * @return array */ public function getOptions() - { +{ return $this->options; } @@ -869,7 +869,7 @@ class Process * @return self */ public function setOptions(array $options) - { +{ $this->options = $options; return $this; @@ -880,7 +880,7 @@ class Process * @return bool */ public function getEnhanceWindowsCompatibility() - { +{ return $this->enhanceWindowsCompatibility; } @@ -890,8 +890,8 @@ class Process * @return self */ public function setEnhanceWindowsCompatibility($enhance) - { - $this->enhanceWindowsCompatibility = (bool)$enhance; +{ + $this->enhanceWindowsCompatibility = (bool) $enhance; return $this; } @@ -901,7 +901,7 @@ class Process * @return bool */ public function getEnhanceSigchildCompatibility() - { +{ return $this->enhanceSigchildCompatibility; } @@ -911,8 +911,8 @@ class Process * @return self */ public function setEnhanceSigchildCompatibility($enhance) - { - $this->enhanceSigchildCompatibility = (bool)$enhance; +{ + $this->enhanceSigchildCompatibility = (bool) $enhance; return $this; } @@ -921,8 +921,8 @@ class Process * 是否超时 */ public function checkTimeout() - { - if ($this->status !== self::STATUS_STARTED) { +{ + if (self::STATUS_STARTED !== $this->status) { return; } @@ -944,7 +944,7 @@ class Process * @return bool */ public static function isPtySupported() - { +{ static $result; if (null !== $result) { @@ -970,7 +970,7 @@ class Process * @return array */ private function getDescriptors() - { +{ if ('\\' === DS) { $this->processPipes = WindowsPipes::create($this, $this->input); } else { @@ -994,7 +994,7 @@ class Process * @return callable */ protected function buildCallback($callback) - { +{ $out = self::OUT; $callback = function ($type, $data) use ($callback, $out) { if ($out == $type) { @@ -1016,7 +1016,7 @@ class Process * @param bool $blocking */ protected function updateStatus($blocking) - { +{ if (self::STATUS_STARTED !== $this->status) { return; } @@ -1036,7 +1036,7 @@ class Process * @return bool */ protected function isSigchildEnabled() - { +{ if (null !== self::$sigchild) { return self::$sigchild; } @@ -1057,8 +1057,8 @@ class Process * @return float|null */ private function validateTimeout($timeout) - { - $timeout = (float)$timeout; +{ + $timeout = (float) $timeout; if (0.0 === $timeout) { $timeout = null; @@ -1075,15 +1075,15 @@ class Process * @param bool $close */ private function readPipes($blocking, $close) - { +{ $result = $this->processPipes->readAndWrite($blocking, $close); $callback = $this->callback; foreach ($result as $type => $data) { if (3 == $type) { - $this->fallbackExitcode = (int)$data; + $this->fallbackExitcode = (int) $data; } else { - $callback($type === self::STDOUT ? self::OUT : self::ERR, $data); + $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data); } } } @@ -1092,7 +1092,7 @@ class Process * 捕获退出码 */ private function captureExitCode() - { +{ if (isset($this->processInformation['exitcode']) && -1 != $this->processInformation['exitcode']) { $this->exitcode = $this->processInformation['exitcode']; } @@ -1103,7 +1103,7 @@ class Process * @return int 退出码 */ private function close() - { +{ $this->processPipes->close(); if (is_resource($this->process)) { $exitcode = proc_close($this->process); @@ -1117,7 +1117,7 @@ class Process if (-1 === $this->exitcode && null !== $this->fallbackExitcode) { $this->exitcode = $this->fallbackExitcode; } elseif (-1 === $this->exitcode && $this->processInformation['signaled'] - && 0 < $this->processInformation['termsig'] + && 0 < $this->processInformation['termsig'] ) { $this->exitcode = 128 + $this->processInformation['termsig']; } @@ -1129,7 +1129,7 @@ class Process * 重置数据 */ private function resetProcessData() - { +{ $this->starttime = null; $this->callback = null; $this->exitcode = null; @@ -1151,7 +1151,7 @@ class Process * @return bool */ private function doSignal($signal, $throwException) - { +{ if (!$this->isRunning()) { if ($throwException) { throw new \LogicException('Can not send signal on a non running process.'); @@ -1186,7 +1186,7 @@ class Process * @param string $functionName */ private function requireProcessIsStarted($functionName) - { +{ if (!$this->isStarted()) { throw new \LogicException(sprintf('Process must be started before calling %s.', $functionName)); } @@ -1197,9 +1197,9 @@ class Process * @param string $functionName */ private function requireProcessIsTerminated($functionName) - { +{ if (!$this->isTerminated()) { throw new \LogicException(sprintf('Process must be terminated before calling %s.', $functionName)); } } -} \ No newline at end of file +} diff --git a/library/think/Request.php b/library/think/Request.php index 49f39610..a806dd87 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -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; } /** diff --git a/library/think/Response.php b/library/think/Response.php index a7ebecf7..8b107589 100644 --- a/library/think/Response.php +++ b/library/think/Response.php @@ -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; diff --git a/library/think/Route.php b/library/think/Route.php index a37f0e17..7a31659a 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -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 { diff --git a/library/think/Session.php b/library/think/Session.php index 9bafe116..6870e164 100644 --- a/library/think/Session.php +++ b/library/think/Session.php @@ -11,7 +11,6 @@ namespace think; -use think\App; use think\exception\ClassNotFoundException; class Session diff --git a/library/think/Template.php b/library/think/Template.php index 667eac74..072cc80c 100644 --- a/library/think/Template.php +++ b/library/think/Template.php @@ -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; } /** diff --git a/library/think/Url.php b/library/think/Url.php index 9ea900d8..75fffac6 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -11,11 +11,6 @@ namespace think; -use think\Config; -use think\Loader; -use think\Request; -use think\Route; - class Url { // 生成URL地址的root diff --git a/library/think/Validate.php b/library/think/Validate.php index 1fe27d1f..528861b4 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -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 { diff --git a/library/think/View.php b/library/think/View.php index b724ba91..1be47f4e 100644 --- a/library/think/View.php +++ b/library/think/View.php @@ -11,9 +11,6 @@ namespace think; -use think\Loader; -use think\Request; - class View { // 视图实例 diff --git a/library/think/cache/Driver.php b/library/think/cache/Driver.php index a2a57795..f21da7bf 100644 --- a/library/think/cache/Driver.php +++ b/library/think/cache/Driver.php @@ -105,7 +105,7 @@ abstract class Driver $this->rm($name); return $result; } else { - return null; + return; } } diff --git a/library/think/cache/driver/Memcache.php b/library/think/cache/driver/Memcache.php index bddf7157..ca2f8aa8 100644 --- a/library/think/cache/driver/Memcache.php +++ b/library/think/cache/driver/Memcache.php @@ -12,7 +12,6 @@ namespace think\cache\driver; use think\cache\Driver; -use think\Exception; class Memcache extends Driver { diff --git a/library/think/cache/driver/Sqlite.php b/library/think/cache/driver/Sqlite.php index 6dbd41fe..907f93df 100644 --- a/library/think/cache/driver/Sqlite.php +++ b/library/think/cache/driver/Sqlite.php @@ -12,7 +12,6 @@ namespace think\cache\driver; use think\cache\Driver; -use think\Exception; /** * Sqlite缓存驱动 diff --git a/library/think/cache/driver/Wincache.php b/library/think/cache/driver/Wincache.php index a9cc7d22..11d059e4 100644 --- a/library/think/cache/driver/Wincache.php +++ b/library/think/cache/driver/Wincache.php @@ -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 = []) diff --git a/library/think/cache/driver/Xcache.php b/library/think/cache/driver/Xcache.php index 6b18b3fc..e790ef7c 100644 --- a/library/think/cache/driver/Xcache.php +++ b/library/think/cache/driver/Xcache.php @@ -12,7 +12,6 @@ namespace think\cache\driver; use think\cache\Driver; -use think\Exception; /** * Xcache缓存驱动 diff --git a/library/think/console/Input.php b/library/think/console/Input.php index 269196eb..2482dfdc 100644 --- a/library/think/console/Input.php +++ b/library/think/console/Input.php @@ -252,7 +252,7 @@ class Input return $token; } - return null; + return; } /** diff --git a/library/think/console/command/Help.php b/library/think/console/command/Help.php index eb0858a3..bae2c653 100644 --- a/library/think/console/command/Help.php +++ b/library/think/console/command/Help.php @@ -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 { @@ -67,4 +66,4 @@ EOF $this->command = null; } -} \ No newline at end of file +} diff --git a/library/think/console/command/optimize/Schema.php b/library/think/console/command/optimize/Schema.php index a1f40cd9..6ac38a36 100644 --- a/library/think/console/command/optimize/Schema.php +++ b/library/think/console/command/optimize/Schema.php @@ -50,7 +50,7 @@ class Schema extends Command } $output->writeln('Succeed!'); return; - } else if ($input->hasOption('table')) { + } elseif ($input->hasOption('table')) { $table = $input->getOption('table'); if (!strpos($table, '.')) { $dbName = Db::getConfig('database'); diff --git a/library/think/console/output/driver/Console.php b/library/think/console/output/driver/Console.php index af4341b7..a6e89218 100644 --- a/library/think/console/output/driver/Console.php +++ b/library/think/console/output/driver/Console.php @@ -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) @@ -356,10 +356,10 @@ class Console { if (DIRECTORY_SEPARATOR === '\\') { return - '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD - || false !== getenv('ANSICON') - || 'ON' === getenv('ConEmuANSI') - || 'xterm' === getenv('TERM'); + '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD + || false !== getenv('ANSICON') + || 'ON' === getenv('ConEmuANSI') + || 'xterm' === getenv('TERM'); } return function_exists('posix_isatty') && @posix_isatty($stream); diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 9aa61cdc..fb315057 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -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 diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index f3138421..3b6d92c8 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -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; diff --git a/library/think/db/Query.php b/library/think/db/Query.php index e2f9ef7a..6daa6f67 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -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; diff --git a/library/think/exception/PDOException.php b/library/think/exception/PDOException.php index 677092b9..1d88e9f6 100644 --- a/library/think/exception/PDOException.php +++ b/library/think/exception/PDOException.php @@ -11,8 +11,6 @@ namespace think\exception; -use think\exception\DbException; - /** * PDO异常处理类 * 重新封装了系统的\PDOException类 diff --git a/library/think/exception/RouteNotFoundException.php b/library/think/exception/RouteNotFoundException.php index 6ee2f7b6..f85a3c4b 100644 --- a/library/think/exception/RouteNotFoundException.php +++ b/library/think/exception/RouteNotFoundException.php @@ -11,8 +11,6 @@ namespace think\exception; -use think\exception\HttpException; - class RouteNotFoundException extends HttpException { diff --git a/library/think/log/driver/Socket.php b/library/think/log/driver/Socket.php index 612a9021..08fd8ace 100644 --- a/library/think/log/driver/Socket.php +++ b/library/think/log/driver/Socket.php @@ -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; } /** diff --git a/library/think/model/relation/BelongsTo.php b/library/think/model/relation/BelongsTo.php index b29355a0..0f1f0c73 100644 --- a/library/think/model/relation/BelongsTo.php +++ b/library/think/model/relation/BelongsTo.php @@ -12,7 +12,6 @@ namespace think\model\relation; use think\Model; -use think\model\relation\OneToOne; class BelongsTo extends OneToOne { diff --git a/library/think/model/relation/HasOne.php b/library/think/model/relation/HasOne.php index fbfc8042..4ac1a589 100644 --- a/library/think/model/relation/HasOne.php +++ b/library/think/model/relation/HasOne.php @@ -12,7 +12,6 @@ namespace think\model\relation; use think\Model; -use think\model\relation\OneToOne; class HasOne extends OneToOne { diff --git a/library/think/model/relation/OneToOne.php b/library/think/model/relation/OneToOne.php index a5a5de9d..0f22898b 100644 --- a/library/think/model/relation/OneToOne.php +++ b/library/think/model/relation/OneToOne.php @@ -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 { diff --git a/library/think/process/Builder.php b/library/think/process/Builder.php index 826e6745..da561639 100644 --- a/library/think/process/Builder.php +++ b/library/think/process/Builder.php @@ -15,10 +15,9 @@ use think\Process; class Builder { - private $arguments; private $cwd; - private $env = null; + private $env = null; private $input; private $timeout = 60; private $options = []; @@ -155,7 +154,7 @@ class Builder return $this; } - $timeout = (float)$timeout; + $timeout = (float) $timeout; if ($timeout < 0) { throw new \InvalidArgumentException('The timeout value must be a valid positive integer or float number.'); @@ -231,4 +230,4 @@ class Builder return $process; } -} \ No newline at end of file +} diff --git a/library/think/process/Utils.php b/library/think/process/Utils.php index 3ed136a5..f94c6488 100644 --- a/library/think/process/Utils.php +++ b/library/think/process/Utils.php @@ -60,7 +60,7 @@ class Utils return $input; } if (is_scalar($input)) { - return (string)$input; + return (string) $input; } throw new \InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller)); } @@ -72,4 +72,4 @@ class Utils return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1]; } -} \ No newline at end of file +} diff --git a/library/think/process/exception/Faild.php b/library/think/process/exception/Failed.php similarity index 99% rename from library/think/process/exception/Faild.php rename to library/think/process/exception/Failed.php index 23df369d..52950823 100644 --- a/library/think/process/exception/Faild.php +++ b/library/think/process/exception/Failed.php @@ -11,7 +11,6 @@ namespace think\process\exception; - use think\Process; class Failed extends \RuntimeException diff --git a/library/think/process/pipes/Unix.php b/library/think/process/pipes/Unix.php index abfe61b2..fd99a5d6 100644 --- a/library/think/process/pipes/Unix.php +++ b/library/think/process/pipes/Unix.php @@ -25,14 +25,14 @@ class Unix extends Pipes public function __construct($ttyMode, $ptyMode, $input, $disableOutput) { - $this->ttyMode = (bool)$ttyMode; - $this->ptyMode = (bool)$ptyMode; - $this->disableOutput = (bool)$disableOutput; + $this->ttyMode = (bool) $ttyMode; + $this->ptyMode = (bool) $ptyMode; + $this->disableOutput = (bool) $disableOutput; if (is_resource($input)) { $this->input = $input; } else { - $this->inputBuffer = (string)$input; + $this->inputBuffer = (string) $input; } } @@ -134,12 +134,12 @@ class Unix extends Pipes $type = (false !== $found = array_search($pipe, $this->pipes)) ? $found : 'input'; $data = ''; - while ('' !== $dataread = (string)fread($pipe, self::CHUNK_SIZE)) { + while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) { $data .= $dataread; } 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]); @@ -160,7 +160,7 @@ class Unix extends Pipes while (strlen($this->inputBuffer)) { $written = fwrite($w[0], $this->inputBuffer, 2 << 18); // write 512k if ($written > 0) { - $this->inputBuffer = (string)substr($this->inputBuffer, $written); + $this->inputBuffer = (string) substr($this->inputBuffer, $written); } else { break; } @@ -180,7 +180,7 @@ class Unix extends Pipes */ public function areOpen() { - return (bool)$this->pipes; + return (bool) $this->pipes; } /** @@ -193,4 +193,4 @@ class Unix extends Pipes { return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled()); } -} \ No newline at end of file +} diff --git a/library/think/process/pipes/Windows.php b/library/think/process/pipes/Windows.php index 2cc44ca7..bba7e9b8 100644 --- a/library/think/process/pipes/Windows.php +++ b/library/think/process/pipes/Windows.php @@ -30,7 +30,7 @@ class Windows extends Pipes public function __construct($disableOutput, $input) { - $this->disableOutput = (bool)$disableOutput; + $this->disableOutput = (bool) $disableOutput; if (!$this->disableOutput) { @@ -128,7 +128,7 @@ class Windows extends Pipes */ public function areOpen() { - return (bool)$this->pipes && (bool)$this->fileHandles; + return (bool) $this->pipes && (bool) $this->fileHandles; } /** @@ -213,7 +213,7 @@ class Windows extends Pipes while (strlen($this->inputBuffer)) { $written = fwrite($w[0], $this->inputBuffer, 2 << 18); if ($written > 0) { - $this->inputBuffer = (string)substr($this->inputBuffer, $written); + $this->inputBuffer = (string) substr($this->inputBuffer, $written); } else { break; } @@ -225,4 +225,4 @@ class Windows extends Pipes unset($this->pipes[0]); } } -} \ No newline at end of file +} diff --git a/library/traits/think/Instance.php b/library/traits/think/Instance.php index 206a9412..4dd005e4 100644 --- a/library/traits/think/Instance.php +++ b/library/traits/think/Instance.php @@ -11,7 +11,7 @@ namespace traits\think; -use \think\Exception; +use think\Exception; trait Instance {