GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( b4390b...d91f3b )
by cao
04:15
created
src/Controller/Annotations/HookAnnotationHandler.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@
 block discarded – undo
18 18
      */
19 19
     public function __invoke(ControllerContainer $container, $ann)
20 20
     {
21
-        if(!$ann->parent){
21
+        if (!$ann->parent) {
22 22
             Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()} should be used with parent route");
23 23
             return;
24 24
         }
25 25
         $target = $ann->parent->name;
26 26
         $route = $container->getRoute($target);
27
-        if(!$route){
27
+        if (!$route) {
28 28
             Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target should be used with parent route");
29
-            return ;
29
+            return;
30 30
         }
31 31
         $params = new AnnotationParams($ann->description, 2);
32 32
         count($params)>0 or \PhpBoot\abort("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target require at least one param, 0 given");
Please login to merge, or discard this patch.
src/Controller/ControllerContainer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function getRoute($actionName)
50 50
     {
51
-        if (array_key_exists($actionName, $this->routes)){
51
+        if (array_key_exists($actionName, $this->routes)) {
52 52
             return $this->routes[$actionName];
53 53
         }
54 54
         return false;
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
     /**
171 171
      * @var Route[]
172 172
      */
173
-    private $routes=[];
173
+    private $routes = [];
174 174
 
175 175
     /**
176 176
      * @var string
177 177
      */
178
-    private $description='';
178
+    private $description = '';
179 179
     /**
180 180
      * @var string
181 181
      */
182
-    private $summary='';
182
+    private $summary = '';
183 183
 
184 184
     /**
185 185
      * @var string
Please login to merge, or discard this patch.
src/Controller/Route.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
 class Route
9 9
 {
10 10
     public function __construct(
11
-        $method='',
12
-        $uri='',
13
-        RequestHandler $requestHandler=null,
14
-        ResponseHandler $responseHandler=null,
15
-        ExceptionHandler $exceptionHandler=null,
16
-        $hooks=[],
11
+        $method = '',
12
+        $uri = '',
13
+        RequestHandler $requestHandler = null,
14
+        ResponseHandler $responseHandler = null,
15
+        ExceptionHandler $exceptionHandler = null,
16
+        $hooks = [],
17 17
         $summary = '',
18 18
         $description = '')
19 19
     {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
                     $res = call_user_func_array($function, $params);
51 51
                     return $this->responseHandler->handle($app, $res, $reference);
52 52
                 };
53
-                foreach (array_reverse($this->hooks) as $hookName){
53
+                foreach (array_reverse($this->hooks) as $hookName) {
54 54
                     $next = function($request)use($app, $hookName, $next){
55 55
                         $hook = $app->get($hookName);
56 56
                         /**@var $hook HookInterface*/
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
     /**
263 263
      * @var string
264 264
      */
265
-    private $description='';
265
+    private $description = '';
266 266
 
267 267
     /**
268 268
      * hook class names
269 269
      * @var string[]
270 270
      */
271
-    private $hooks=[];
271
+    private $hooks = [];
272 272
 
273 273
     /**
274 274
      * @var string[]
275 275
      */
276
-    private $pathParams =[];
276
+    private $pathParams = [];
277 277
 
278 278
 }
279 279
\ No newline at end of file
Please login to merge, or discard this patch.
src/Cache/CheckableCache.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class CheckableCache
11 11
 {
12
-    function __construct(Cache $impl){
12
+    function __construct(Cache $impl) {
13 13
         $this->impl = $impl;
14 14
     }
15 15
    
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @param bool $deleteExpiredData
44 44
      * @return mixed
45 45
      */
46
-    public function get($name, $default = null, &$expiredData=null, $deleteExpiredData=true)
46
+    public function get($name, $default = null, &$expiredData = null, $deleteExpiredData = true)
47 47
     {
48 48
         $expiredData = null;
49 49
         $res = $this->impl->fetch($name);
@@ -52,18 +52,18 @@  discard block
 block discarded – undo
52 52
             // 如果指定了checker, ttl代表每次检查的间隔时间, 0表示每次get都需要经过checker检查
53 53
             // 如果没有指定checker, ttl表示缓存过期时间, 为0表示永不过期
54 54
             if ($checker !== null) {
55
-                if ($ttl == 0 || ($createdTime + $ttl < time())) {
55
+                if ($ttl == 0 || ($createdTime + $ttl<time())) {
56 56
                     $valid = $checker($data, $createdTime);
57
-                    if(!$valid){
57
+                    if (!$valid) {
58 58
                         $expiredData = $data;
59
-                        if($deleteExpiredData){
59
+                        if ($deleteExpiredData) {
60 60
                             $this->impl->delete($name);
61 61
                         }
62 62
                         return $default;
63 63
                     }
64 64
                     
65 65
                 }
66
-            }else if ($ttl != 0 && ($createdTime + $ttl < time())) {
66
+            }else if ($ttl != 0 && ($createdTime + $ttl<time())) {
67 67
                 $this->impl->delete($name);
68 68
                 return $default;
69 69
             }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * 删除
76 76
      * @param string $name
77 77
      */
78
-    public function del($name){
78
+    public function del($name) {
79 79
         return  $this->impl->delete($name);
80 80
     }
81 81
     public function getImpl()
Please login to merge, or discard this patch.
src/Cache/ClassModifiedChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
 
5 5
 class ClassModifiedChecker extends FileModifiedChecker
6 6
 {
7
-    function __construct($className){
7
+    function __construct($className) {
8 8
         $class = new \ReflectionClass($className);
9 9
         $files = [];
10 10
 
11
-        if($class->getFileName()){
11
+        if ($class->getFileName()) {
12 12
             $files[] = $class->getFileName();
13 13
             self::getParentFileName($class, $files);
14 14
         }
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
     static public function getParentFileName(\ReflectionClass $class, array &$files)
19 19
     {
20 20
         $parent = $class->getParentClass();
21
-        if(!$parent){
21
+        if (!$parent) {
22 22
             return;
23 23
         }
24
-        if($parent->getFileName()){
24
+        if ($parent->getFileName()) {
25 25
             $files[] = $parent->getParentClass();
26 26
             self::getParentFileName($parent, $files);
27 27
         }
28
-        foreach ($class->getInterfaces() as $interface){
29
-            if($interface->getFileName()){
28
+        foreach ($class->getInterfaces() as $interface) {
29
+            if ($interface->getFileName()) {
30 30
                 $files[] = $interface->getFileName();
31 31
                 self::getParentFileName($interface, $files);
32 32
             }
Please login to merge, or discard this patch.
src/Cache/FileModifiedChecker.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,25 +10,25 @@  discard block
 block discarded – undo
10 10
     /**
11 11
      * @param string|array $fileName 文件的绝对路径
12 12
      */
13
-    function __construct($fileName){
13
+    function __construct($fileName) {
14 14
         $fileNames = array();
15
-        if(is_string($fileName)){
16
-            $fileNames[]=$fileName;
17
-        }else{
15
+        if (is_string($fileName)) {
16
+            $fileNames[] = $fileName;
17
+        }else {
18 18
             is_array($fileName) or \PhpBoot\abort(new \InvalidArgumentException("string or array is required by param 0"));
19 19
             $fileNames = $fileName;
20 20
         }
21
-        foreach ($fileNames as $fileName){
22
-            if(is_file($fileName)){
21
+        foreach ($fileNames as $fileName) {
22
+            if (is_file($fileName)) {
23 23
                 $this->fileName[$fileName] = @filemtime($fileName);
24 24
             }else {
25 25
                 $this->fileName[$fileName] = @filemtime($fileName);
26
-                if(!is_dir($fileName)){
26
+                if (!is_dir($fileName)) {
27 27
                     continue;
28 28
                 }
29 29
                 $files = @dir($fileName) or \PhpBoot\abort("open dir $fileName failed");
30
-                while (!!($file = $files->read())){
31
-                    if($file == '.' || $file == '..') {
30
+                while (!!($file = $files->read())) {
31
+                    if ($file == '.' || $file == '..') {
32 32
                         continue;
33 33
                     }
34 34
                     $this->fileName[$fileName.'/'.$file] = @filemtime($fileName.'/'.$file);
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
      * @param int $createdTime
44 44
      * @return boolean
45 45
      */
46
-    public function __invoke($data, $createdTime){
47
-        foreach ($this->fileName as $name => $time){
48
-            if(@filemtime($name) != $time){
46
+    public function __invoke($data, $createdTime) {
47
+        foreach ($this->fileName as $name => $time) {
48
+            if (@filemtime($name) != $time) {
49 49
                 return false;
50 50
             }
51 51
         }
52 52
         return true;
53 53
     }
54
-    private $fileName=[]; //文件全路径
54
+    private $fileName = []; //文件全路径
55 55
 }
Please login to merge, or discard this patch.
src/Application.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 
84 84
             Request::class => \DI\factory([Application::class, 'createRequestFromGlobals']),
85 85
         ];
86
-        if(function_exists('apc_fetch')){
86
+        if (function_exists('apc_fetch')) {
87 87
             $default += [
88 88
                 Cache::class => \DI\object(ApcCache::class)
89 89
             ];
90
-        }else{
90
+        }else {
91 91
             $default += [
92 92
                 Cache::class => \DI\object(FilesystemCache::class)
93 93
                     ->constructorParameter('directory', sys_get_temp_dir())
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
      * @param string[] $hooks hook class names
130 130
      * @return void
131 131
      */
132
-    public function loadRoutesFromClass($className, $hooks=[])
132
+    public function loadRoutesFromClass($className, $hooks = [])
133 133
     {
134 134
         $cache = new CheckableCache($this->cache);
135 135
 
136
-        $key = 'loadRoutesFromClass:' . md5(__CLASS__ . ':' . $className);
136
+        $key = 'loadRoutesFromClass:'.md5(__CLASS__.':'.$className);
137 137
         $routes = $cache->get($key, $this);
138 138
 
139 139
         $controller = null;
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
             $this->routes[] = [
151 151
                 $method,
152 152
                 $uri,
153
-                function (Application $app, Request $request) use ($cache, $className, $actionName, $controller) {
153
+                function(Application $app, Request $request) use ($cache, $className, $actionName, $controller) {
154 154
 
155
-                    $key = 'loadRoutesFromClass:route:' . md5(__CLASS__ . ':' . $className . ':' . $actionName);
155
+                    $key = 'loadRoutesFromClass:route:'.md5(__CLASS__.':'.$className.':'.$actionName);
156 156
 
157 157
                     $routeInstance = $cache->get($key, $this);
158 158
                     if ($routeInstance == $this) {
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
      * @param string[] $hooks
181 181
      * @return void
182 182
      */
183
-    public function loadRoutesFromPath($fromPath, $namespace = '', $hooks=[])
183
+    public function loadRoutesFromPath($fromPath, $namespace = '', $hooks = [])
184 184
     {
185 185
         $dir = @dir($fromPath);
186 186
 
187
-        $getEach = function () use ($dir) {
187
+        $getEach = function() use ($dir) {
188 188
             $name = $dir->read();
189 189
             if (!$name) {
190 190
                 return $name;
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
             if ($entry == '.' || $entry == '..') {
197 197
                 continue;
198 198
             }
199
-            $path = $fromPath . '/' . str_replace('\\', '/', $entry);
199
+            $path = $fromPath.'/'.str_replace('\\', '/', $entry);
200 200
             if (is_file($path) && substr_compare($entry, '.php', strlen($entry) - 4, 4, true) == 0) {
201
-                $class_name = $namespace . '\\' . substr($entry, 0, strlen($entry) - 4);
201
+                $class_name = $namespace.'\\'.substr($entry, 0, strlen($entry) - 4);
202 202
                 $this->loadRoutesFromClass($class_name, $hooks);
203
-            } else {
203
+            }else {
204 204
                 //\Log::debug($path.' ignored');
205 205
             }
206 206
         }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @param callable $handler function(Application $app, Request $request):Response
214 214
      * @param string[] $hooks
215 215
      */
216
-    public function addRoute($method, $uri, callable $handler, $hooks=[])
216
+    public function addRoute($method, $uri, callable $handler, $hooks = [])
217 217
     {
218 218
         $this->routes[] = [$method, $uri, $handler, $hooks];
219 219
     }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     {
240 240
         //  TODO 把 Route里的异常处理 ExceptionRenderer 移到这里更妥?
241 241
         $renderer = $this->get(ExceptionRenderer::class);
242
-        try{
242
+        try {
243 243
             if ($request == null) {
244 244
                 $request = $this->make(Request::class);
245 245
             }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
             }
250 250
             $uri = rawurldecode($uri);
251 251
 
252
-            $next = function (Request $request)use($uri){
252
+            $next = function(Request $request)use($uri){
253 253
                 $dispatcher = $this->getDispatcher();
254 254
                 $res = $dispatcher->dispatch($request->getMethod(), $uri);
255 255
                 if ($res[0] == Dispatcher::FOUND) {
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
                         $request->attributes->add($res[2]);
259 259
                     }
260 260
                     list($handler, $hooks) = $res[1];
261
-                    $next = function (Request $request)use($handler){
261
+                    $next = function(Request $request)use($handler){
262 262
                         return $handler($this, $request);
263 263
                     };
264
-                    foreach (array_reverse($hooks) as $hookName){
264
+                    foreach (array_reverse($hooks) as $hookName) {
265 265
                         $next = function($request)use($hookName, $next){
266 266
                             $hook = $this->get($hookName);
267 267
                             /**@var $hook HookInterface*/
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
                     \PhpBoot\abort(new NotFoundHttpException(), [$request->getMethod(), $uri]);
275 275
                 } elseif ($res[0] == Dispatcher::METHOD_NOT_ALLOWED) {
276 276
                     \PhpBoot\abort(new MethodNotAllowedHttpException($res[1]), [$request->getMethod(), $uri]);
277
-                } else {
277
+                }else {
278 278
                     \PhpBoot\abort("unknown dispatch return {$res[0]}");
279 279
                 }
280 280
             };
281 281
 
282
-            foreach (array_reverse($this->getGlobalHooks()) as $hookName){
282
+            foreach (array_reverse($this->getGlobalHooks()) as $hookName) {
283 283
                 $next = function($request)use($hookName, $next){
284 284
                     $hook = $this->get($hookName);
285 285
                     /**@var $hook HookInterface*/
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             }
295 295
             return $response;
296 296
 
297
-        }catch (\Exception $e){
297
+        }catch (\Exception $e) {
298 298
             $renderer->render($e);
299 299
         }
300 300
 
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use PhpBoot\ORM\ModelWithObject;
6 6
 use PhpBoot\Utils\Logger;
7 7
 
8
-if (! function_exists('PhpBoot\abort')) {
8
+if (!function_exists('PhpBoot\abort')) {
9 9
     /**
10 10
      * 抛出异常, 并记录日志
11 11
      * @param string|\Exception $error
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
      * @param string $level "error"|"warning"|"info"|"debug"|null
14 14
      * @throws \Exception
15 15
      */
16
-    function abort($error = '', $context=[], $level='warning')
16
+    function abort($error = '', $context = [], $level = 'warning')
17 17
     {
18
-        if(is_object($context)){
18
+        if (is_object($context)) {
19 19
             $context = get_object_vars($context);
20 20
         }
21
-        if($error instanceof \Exception){
21
+        if ($error instanceof \Exception) {
22 22
             $e = $error;
23 23
             $message = "exception '".get_class($error)."' with message {$error->getMessage()}";
24
-        }else{
24
+        }else {
25 25
             $e = new \RuntimeException($error);
26 26
             $message = $error;
27 27
         }
28 28
         $trace = $e->getTrace();
29 29
 
30
-        if($e->getFile() == __FILE__){
30
+        if ($e->getFile() == __FILE__) {
31 31
             $file = $trace[0]['file'];
32 32
             $line = $trace[0]['line'];
33
-        }else{
33
+        }else {
34 34
             $file = $e->getFile();
35 35
             $line = $e->getLine();
36 36
         }
37
-        if($level){
38
-           Logger::$level($message, $context +['@file'=>$file, '@line'=>$line]);
37
+        if ($level) {
38
+           Logger::$level($message, $context + ['@file'=>$file, '@line'=>$line]);
39 39
         }
40 40
         throw $e;
41 41
     }
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
      */
52 52
     function model(DB $db, $entity)
53 53
     {
54
-        if(is_object($entity)){
54
+        if (is_object($entity)) {
55 55
             return $db->getApp()->make(ModelWithObject::class, ['db'=>$db, 'entity'=>$entity]);
56
-        }else{
56
+        }else {
57 57
             return $db->getApp()->make(ModelWithClass::class, ['db'=>$db, 'entityName'=>$entity]);
58 58
         }
59 59
     }
Please login to merge, or discard this patch.
src/DB/Context.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * @author caoym
5 5
  */
6
-class Context{
6
+class Context {
7 7
 
8 8
     public function __construct($connection)
9 9
     {
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
      * 拼接sql语句,并自动插入空格
15 15
      * @param string $sql 表达式
16 16
      */
17
-    public function appendSql($sql, $addSpace=true){
18
-        if($this->sql == ''){
17
+    public function appendSql($sql, $addSpace = true) {
18
+        if ($this->sql == '') {
19 19
             $this->sql = $sql;
20
-        }else{
21
-            if($addSpace){
20
+        }else {
21
+            if ($addSpace) {
22 22
                 $this->sql = $this->sql.' '.$sql;
23
-            }else{
23
+            }else {
24 24
                 $this->sql = $this->sql.$sql;
25 25
             }
26 26
         }
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
      * 增加绑定变量值
30 30
      * @param array $params 变量
31 31
      */
32
-    public function appendParams($params){
32
+    public function appendParams($params) {
33 33
         $this->params = array_merge($this->params, $params);
34 34
     }
35 35
 
36 36
     public function handleResult($result)
37 37
     {
38
-        if($resultHandler = $this->resultHandler){
38
+        if ($resultHandler = $this->resultHandler) {
39 39
             return $resultHandler($result);
40
-        }else{
40
+        }else {
41 41
             return $result;
42 42
         }
43 43
     }
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
      * @var callable
46 46
      */
47 47
     public $resultHandler;
48
-    public $sql='';
49
-    public $params=[];
48
+    public $sql = '';
49
+    public $params = [];
50 50
     /**
51 51
      * @var \PDO
52 52
      */
Please login to merge, or discard this patch.