@@ -73,7 +73,7 @@ |
||
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | /** |
| 76 | - * @param $className |
|
| 76 | + * @param string $className |
|
| 77 | 77 | * @return self |
| 78 | 78 | */ |
| 79 | 79 | static function readWithoutCache($className) |
@@ -62,13 +62,13 @@ |
||
| 62 | 62 | $meta = self::readWithoutCache($className); |
| 63 | 63 | $cache->set($key, $meta, 0, $fileName?new ClassModifiedChecker($className):null); |
| 64 | 64 | return $meta; |
| 65 | - }catch (\Exception $e){ |
|
| 65 | + } catch (\Exception $e){ |
|
| 66 | 66 | $cache->set($key, $e->getMessage(), 0, $fileName?new ClassModifiedChecker($className):null); |
| 67 | 67 | throw $e; |
| 68 | 68 | } |
| 69 | - }elseif(is_string($res)){ |
|
| 69 | + } elseif(is_string($res)){ |
|
| 70 | 70 | \PhpBoot\abort($res); |
| 71 | - }else{ |
|
| 71 | + } else{ |
|
| 72 | 72 | return $res; |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | class AnnotationReader implements \ArrayAccess |
| 47 | 47 | { |
| 48 | - static public function createDocBlockFactory(){ |
|
| 48 | + static public function createDocBlockFactory() { |
|
| 49 | 49 | $fqsenResolver = new FqsenResolver(); |
| 50 | - $tagFactory = new StandardTagFactory($fqsenResolver,[]); |
|
| 50 | + $tagFactory = new StandardTagFactory($fqsenResolver, []); |
|
| 51 | 51 | $descriptionFactory = new DescriptionFactory($tagFactory); |
| 52 | 52 | $tagFactory->addService($descriptionFactory); |
| 53 | 53 | $tagFactory->addService(new TypeResolver($fqsenResolver)); |
@@ -72,22 +72,22 @@ discard block |
||
| 72 | 72 | self::assertAnnotationEnabled(); |
| 73 | 73 | $rfl = new \ReflectionClass($className) or \PhpBoot\abort("load class $className failed"); |
| 74 | 74 | $fileName = $rfl->getFileName(); |
| 75 | - $key = str_replace('\\','.',self::class).md5($fileName.$className); |
|
| 75 | + $key = str_replace('\\', '.', self::class).md5($fileName.$className); |
|
| 76 | 76 | $oldData = null; |
| 77 | - $cache = new CheckableCache($localCache?:new ApcCache()); |
|
| 77 | + $cache = new CheckableCache($localCache ?: new ApcCache()); |
|
| 78 | 78 | $res = $cache->get('ann:'.$key, null, $oldData, false); |
| 79 | - if($res === null){ |
|
| 80 | - try{ |
|
| 79 | + if ($res === null) { |
|
| 80 | + try { |
|
| 81 | 81 | $meta = self::readWithoutCache($className); |
| 82 | - $cache->set($key, $meta, 0, $fileName?new ClassModifiedChecker($className):null); |
|
| 82 | + $cache->set($key, $meta, 0, $fileName ? new ClassModifiedChecker($className) : null); |
|
| 83 | 83 | return $meta; |
| 84 | - }catch (\Exception $e){ |
|
| 85 | - $cache->set($key, $e->getMessage(), 0, $fileName?new ClassModifiedChecker($className):null); |
|
| 84 | + }catch (\Exception $e) { |
|
| 85 | + $cache->set($key, $e->getMessage(), 0, $fileName ? new ClassModifiedChecker($className) : null); |
|
| 86 | 86 | throw $e; |
| 87 | 87 | } |
| 88 | - }elseif(is_string($res)){ |
|
| 88 | + }elseif (is_string($res)) { |
|
| 89 | 89 | \PhpBoot\abort($res); |
| 90 | - }else{ |
|
| 90 | + }else { |
|
| 91 | 91 | return $res; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -104,19 +104,19 @@ discard block |
||
| 104 | 104 | $reader->class->name = $className; |
| 105 | 105 | |
| 106 | 106 | //method annotations |
| 107 | - foreach ($rfl->getMethods() as $i){ |
|
| 107 | + foreach ($rfl->getMethods() as $i) { |
|
| 108 | 108 | $block = self::readAnnotationBlock($i->getDocComment()); |
| 109 | 109 | $block->name = $i->getName(); |
| 110 | - $reader->methods[$i->getName()]=$block; |
|
| 110 | + $reader->methods[$i->getName()] = $block; |
|
| 111 | 111 | } |
| 112 | 112 | //property annotations |
| 113 | - foreach ($rfl->getProperties() as $i){ |
|
| 113 | + foreach ($rfl->getProperties() as $i) { |
|
| 114 | 114 | if ($i->isStatic()) { |
| 115 | 115 | continue; |
| 116 | 116 | } |
| 117 | 117 | $block = self::readAnnotationBlock($i->getDocComment()); |
| 118 | 118 | $block->name = $i->getName(); |
| 119 | - $reader->properties[$i->getName()]=$block; |
|
| 119 | + $reader->properties[$i->getName()] = $block; |
|
| 120 | 120 | } |
| 121 | 121 | while ($rfl = $rfl->getParentClass()) { |
| 122 | 122 | foreach ($rfl->getProperties(\ReflectionProperty::IS_PRIVATE) as $i) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | $block = self::readAnnotationBlock($i->getDocComment()); |
| 127 | 127 | $block->name = $i->getName(); |
| 128 | - $reader->properties[$i->getName()]=$block; |
|
| 128 | + $reader->properties[$i->getName()] = $block; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | return $reader; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | static private function readAnnotationBlock($doc) |
| 135 | 135 | { |
| 136 | 136 | $annBlock = new AnnotationBlock(); |
| 137 | - if(empty($doc)){ |
|
| 137 | + if (empty($doc)) { |
|
| 138 | 138 | return $annBlock; |
| 139 | 139 | } |
| 140 | 140 | $docFactory = AnnotationReader::createDocBlockFactory(); |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | $annTag->parent = $annBlock; |
| 150 | 150 | $annTag->description = strval($desc); |
| 151 | 151 | $annTag->name = $tag->getName(); |
| 152 | - $annTag->children=[]; |
|
| 153 | - if($desc){ |
|
| 152 | + $annTag->children = []; |
|
| 153 | + if ($desc) { |
|
| 154 | 154 | $output = new AnnotationTagsOutput(); |
| 155 | 155 | $desc->render($output); |
| 156 | 156 | foreach ($output->tags as $child) { |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | * @var AnnotationBlock[] |
| 175 | 175 | */ |
| 176 | 176 | |
| 177 | - public $methods=[]; |
|
| 177 | + public $methods = []; |
|
| 178 | 178 | /** |
| 179 | 179 | * @var AnnotationBlock[] |
| 180 | 180 | */ |
| 181 | - public $properties=[]; |
|
| 181 | + public $properties = []; |
|
| 182 | 182 | |
| 183 | 183 | public function offsetExists($offset) |
| 184 | 184 | { |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | /** |
| 9 | 9 | * AnnotationTag constructor. |
| 10 | 10 | * @param string $name |
| 11 | - * @param string $summary |
|
| 12 | 11 | * @param string $description |
| 13 | 12 | * @param array $children |
| 14 | 13 | * @param AnnotationBlock|AnnotationTag|null $parent |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | * @param array $children |
| 14 | 14 | * @param AnnotationBlock|AnnotationTag|null $parent |
| 15 | 15 | */ |
| 16 | - public function __construct($name='', |
|
| 17 | - $description='', |
|
| 18 | - $children=[], |
|
| 19 | - $parent=null) |
|
| 16 | + public function __construct($name = '', |
|
| 17 | + $description = '', |
|
| 18 | + $children = [], |
|
| 19 | + $parent = null) |
|
| 20 | 20 | { |
| 21 | 21 | $this->name = $name; |
| 22 | 22 | $this->description = $description; |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @var string |
| 33 | 33 | */ |
| 34 | - public $description=''; |
|
| 34 | + public $description = ''; |
|
| 35 | 35 | /** |
| 36 | 36 | * @var AnnotationBlock[] |
| 37 | 37 | */ |
| 38 | - public $children=[]; |
|
| 38 | + public $children = []; |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @var AnnotationBlock|null |
@@ -375,7 +375,7 @@ |
||
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
| 378 | - * @return \string[] |
|
| 378 | + * @return string[] |
|
| 379 | 379 | */ |
| 380 | 380 | public function getGlobalHooks() |
| 381 | 381 | { |
@@ -24,7 +24,6 @@ |
||
| 24 | 24 | use PhpBoot\DB\DB; |
| 25 | 25 | use PhpBoot\DI\DIContainerBuilder; |
| 26 | 26 | use PhpBoot\DI\Traits\EnableDIAnnotations; |
| 27 | -use PhpBoot\Lock\LocalAutoLock; |
|
| 28 | 27 | use PhpBoot\Utils\Logger; |
| 29 | 28 | use Psr\Container\ContainerExceptionInterface; |
| 30 | 29 | use Psr\Container\ContainerInterface; |
@@ -87,7 +87,7 @@ discard block |
||
| 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()) |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | return $next($request); |
| 272 | 272 | |
| 273 | - }elseif ($res[0] == Dispatcher::NOT_FOUND) { |
|
| 273 | + } elseif ($res[0] == Dispatcher::NOT_FOUND) { |
|
| 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]); |
@@ -294,7 +294,7 @@ discard block |
||
| 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 | |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | Request::class => \DI\factory([Application::class, 'createRequestFromGlobals']), |
| 95 | 95 | ]; |
| 96 | - if(function_exists('apc_fetch')){ |
|
| 96 | + if (function_exists('apc_fetch')) { |
|
| 97 | 97 | $default += [ |
| 98 | 98 | Cache::class => \DI\object(ApcCache::class) |
| 99 | 99 | ]; |
| 100 | - }else{ |
|
| 100 | + }else { |
|
| 101 | 101 | $default += [ |
| 102 | 102 | Cache::class => \DI\object(FilesystemCache::class) |
| 103 | 103 | ->constructorParameter('directory', sys_get_temp_dir()) |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | * @param string[] $hooks hook class names |
| 140 | 140 | * @return void |
| 141 | 141 | */ |
| 142 | - public function loadRoutesFromClass($className, $hooks=[]) |
|
| 142 | + public function loadRoutesFromClass($className, $hooks = []) |
|
| 143 | 143 | { |
| 144 | 144 | $cache = new CheckableCache($this->cache); |
| 145 | 145 | |
| 146 | - $key = 'loadRoutesFromClass:' . md5(__CLASS__ . ':' . $className); |
|
| 146 | + $key = 'loadRoutesFromClass:'.md5(__CLASS__.':'.$className); |
|
| 147 | 147 | $routes = $cache->get($key, $this); |
| 148 | 148 | |
| 149 | 149 | $controller = null; |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | $this->routes[] = [ |
| 161 | 161 | $method, |
| 162 | 162 | $uri, |
| 163 | - function (Application $app, Request $request) use ($cache, $className, $actionName, $controller) { |
|
| 163 | + function(Application $app, Request $request) use ($cache, $className, $actionName, $controller) { |
|
| 164 | 164 | |
| 165 | - $key = 'loadRoutesFromClass:route:' . md5(__CLASS__ . ':' . $className . ':' . $actionName); |
|
| 165 | + $key = 'loadRoutesFromClass:route:'.md5(__CLASS__.':'.$className.':'.$actionName); |
|
| 166 | 166 | |
| 167 | 167 | $routeInstance = $cache->get($key, $this); |
| 168 | 168 | if ($routeInstance == $this) { |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | * @param string[] $hooks |
| 191 | 191 | * @return void |
| 192 | 192 | */ |
| 193 | - public function loadRoutesFromPath($fromPath, $namespace = '', $hooks=[]) |
|
| 193 | + public function loadRoutesFromPath($fromPath, $namespace = '', $hooks = []) |
|
| 194 | 194 | { |
| 195 | 195 | $dir = @dir($fromPath) or abort("dir $fromPath not exist"); |
| 196 | 196 | |
| 197 | - $getEach = function () use ($dir) { |
|
| 197 | + $getEach = function() use ($dir) { |
|
| 198 | 198 | $name = $dir->read(); |
| 199 | 199 | if (!$name) { |
| 200 | 200 | return $name; |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | if ($entry == '.' || $entry == '..') { |
| 207 | 207 | continue; |
| 208 | 208 | } |
| 209 | - $path = $fromPath . '/' . str_replace('\\', '/', $entry); |
|
| 209 | + $path = $fromPath.'/'.str_replace('\\', '/', $entry); |
|
| 210 | 210 | if (is_file($path) && substr_compare($entry, '.php', strlen($entry) - 4, 4, true) == 0) { |
| 211 | - $class_name = $namespace . '\\' . substr($entry, 0, strlen($entry) - 4); |
|
| 211 | + $class_name = $namespace.'\\'.substr($entry, 0, strlen($entry) - 4); |
|
| 212 | 212 | $this->loadRoutesFromClass($class_name, $hooks); |
| 213 | - } else { |
|
| 213 | + }else { |
|
| 214 | 214 | //\Log::debug($path.' ignored'); |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * @param callable $handler function(Application $app, Request $request):Response |
| 224 | 224 | * @param string[] $hooks |
| 225 | 225 | */ |
| 226 | - public function addRoute($method, $uri, callable $handler, $hooks=[]) |
|
| 226 | + public function addRoute($method, $uri, callable $handler, $hooks = []) |
|
| 227 | 227 | { |
| 228 | 228 | $this->routes[] = [$method, $uri, $handler, $hooks]; |
| 229 | 229 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | { |
| 250 | 250 | // TODO 把 Route里的异常处理 ExceptionRenderer 移到这里更妥? |
| 251 | 251 | $renderer = $this->get(ExceptionRenderer::class); |
| 252 | - try{ |
|
| 252 | + try { |
|
| 253 | 253 | if ($request == null) { |
| 254 | 254 | $request = $this->make(Request::class); |
| 255 | 255 | } |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | $uri = rawurldecode($uri); |
| 261 | 261 | |
| 262 | - $next = function (Request $request)use($uri){ |
|
| 262 | + $next = function(Request $request)use($uri){ |
|
| 263 | 263 | $dispatcher = $this->getDispatcher(); |
| 264 | 264 | $res = $dispatcher->dispatch($request->getMethod(), $uri); |
| 265 | 265 | if ($res[0] == Dispatcher::FOUND) { |
@@ -268,10 +268,10 @@ discard block |
||
| 268 | 268 | $request->attributes->add($res[2]); |
| 269 | 269 | } |
| 270 | 270 | list($handler, $hooks) = $res[1]; |
| 271 | - $next = function (Request $request)use($handler){ |
|
| 271 | + $next = function(Request $request)use($handler){ |
|
| 272 | 272 | return $handler($this, $request); |
| 273 | 273 | }; |
| 274 | - foreach (array_reverse($hooks) as $hookName){ |
|
| 274 | + foreach (array_reverse($hooks) as $hookName) { |
|
| 275 | 275 | $next = function($request)use($hookName, $next){ |
| 276 | 276 | $hook = $this->get($hookName); |
| 277 | 277 | /**@var $hook HookInterface*/ |
@@ -284,12 +284,12 @@ discard block |
||
| 284 | 284 | \PhpBoot\abort(new NotFoundHttpException(), [$request->getMethod(), $uri]); |
| 285 | 285 | } elseif ($res[0] == Dispatcher::METHOD_NOT_ALLOWED) { |
| 286 | 286 | \PhpBoot\abort(new MethodNotAllowedHttpException($res[1]), [$request->getMethod(), $uri]); |
| 287 | - } else { |
|
| 287 | + }else { |
|
| 288 | 288 | \PhpBoot\abort("unknown dispatch return {$res[0]}"); |
| 289 | 289 | } |
| 290 | 290 | }; |
| 291 | 291 | |
| 292 | - foreach (array_reverse($this->getGlobalHooks()) as $hookName){ |
|
| 292 | + foreach (array_reverse($this->getGlobalHooks()) as $hookName) { |
|
| 293 | 293 | $next = function($request)use($hookName, $next){ |
| 294 | 294 | $hook = $this->get($hookName); |
| 295 | 295 | /**@var $hook HookInterface*/ |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | return $response; |
| 306 | 306 | |
| 307 | - }catch (\Exception $e){ |
|
| 307 | + }catch (\Exception $e) { |
|
| 308 | 308 | $renderer->render($e); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -4,6 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | class ClassModifiedChecker extends FileModifiedChecker |
| 6 | 6 | { |
| 7 | + /** |
|
| 8 | + * @param string $className |
|
| 9 | + */ |
|
| 7 | 10 | function __construct($className){ |
| 8 | 11 | $class = new \ReflectionClass($className); |
| 9 | 12 | $files = []; |
@@ -4,11 +4,11 @@ discard block |
||
| 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 |
||
| 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->getFileName(); |
| 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 | } |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use DI\FactoryInterface; |
| 6 | 6 | use \DI\InvokerInterface as DIInvokerInterface; |
| 7 | 7 | use Doctrine\Common\Cache\Cache; |
| 8 | -use PhpBoot\Cache\LocalCacheInterface; |
|
| 9 | 8 | use PhpBoot\Controller\Annotations\BindAnnotationHandler; |
| 10 | 9 | use PhpBoot\Controller\Annotations\ClassAnnotationHandler; |
| 11 | 10 | use PhpBoot\Controller\Annotations\HookAnnotationHandler; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | class ControllerContainerBuilder extends ContainerBuilder |
| 21 | 21 | { |
| 22 | - static $DEFAULT_ANNOTATIONS=[ |
|
| 22 | + static $DEFAULT_ANNOTATIONS = [ |
|
| 23 | 23 | [ClassAnnotationHandler::class, 'class'], |
| 24 | 24 | [PathAnnotationHandler::class, "class.children[?name=='path']"], |
| 25 | 25 | [RouteAnnotationHandler::class, "methods.*.children[?name=='route'][]"], |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | Cache $cache, |
| 44 | 44 | array $annotations = null) |
| 45 | 45 | { |
| 46 | - if($annotations){ |
|
| 46 | + if ($annotations) { |
|
| 47 | 47 | parent::__construct($annotations, $cache); |
| 48 | - }else{ |
|
| 48 | + }else { |
|
| 49 | 49 | parent::__construct(self::$DEFAULT_ANNOTATIONS, $cache); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | { |
| 46 | 46 | if($annotations){ |
| 47 | 47 | parent::__construct($annotations, $cache); |
| 48 | - }else{ |
|
| 48 | + } else{ |
|
| 49 | 49 | parent::__construct(self::$DEFAULT_ANNOTATIONS, $cache); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * 获取指定参数信息 |
| 94 | - * @param $name |
|
| 94 | + * @param string|null $name |
|
| 95 | 95 | * @return ParamMeta|null |
| 96 | 96 | */ |
| 97 | 97 | public function getParamMeta($name){ |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @param ParamMeta[] $paramMates |
| 17 | 17 | */ |
| 18 | - public function __construct(array $paramMates=[]){ |
|
| 18 | + public function __construct(array $paramMates = []) { |
|
| 19 | 19 | $this->paramMetas = $paramMates; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -26,32 +26,32 @@ discard block |
||
| 26 | 26 | * @param array $reference |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | - public function handle(Application $app, Request $request, array &$params, array &$reference){ |
|
| 29 | + public function handle(Application $app, Request $request, array &$params, array &$reference) { |
|
| 30 | 30 | |
| 31 | 31 | $vld = new Validator(); |
| 32 | 32 | $req = ['request'=>$request]; |
| 33 | 33 | $requestArray = new ArrayAdaptor($req); |
| 34 | 34 | $inputs = []; |
| 35 | - foreach ($this->paramMetas as $k=>$meta){ |
|
| 36 | - if($meta->isPassedByReference){ |
|
| 35 | + foreach ($this->paramMetas as $k=>$meta) { |
|
| 36 | + if ($meta->isPassedByReference) { |
|
| 37 | 37 | // param PassedByReference is used to output |
| 38 | 38 | continue; |
| 39 | 39 | } |
| 40 | 40 | $source = \JmesPath\search($meta->source, $requestArray); |
| 41 | - if ($source !== null){ |
|
| 41 | + if ($source !== null) { |
|
| 42 | 42 | $source = ArrayAdaptor::strip($source); |
| 43 | - if($source instanceof ParameterBag){ |
|
| 43 | + if ($source instanceof ParameterBag) { |
|
| 44 | 44 | $source = $source->all(); |
| 45 | 45 | } |
| 46 | - if($meta->container){ |
|
| 46 | + if ($meta->container) { |
|
| 47 | 47 | $inputs[$meta->name] = $meta->container->make($source); |
| 48 | - }else{ |
|
| 48 | + }else { |
|
| 49 | 49 | $inputs[$meta->name] = $source; |
| 50 | 50 | } |
| 51 | - if($meta->validation){ |
|
| 51 | + if ($meta->validation) { |
|
| 52 | 52 | $vld->rule($meta->validation, $meta->name); |
| 53 | 53 | } |
| 54 | - }else{ |
|
| 54 | + }else { |
|
| 55 | 55 | $meta->isOptional or \PhpBoot\abort(new BadRequestHttpException("the parameter \"{$meta->source}\" is missing")); |
| 56 | 56 | $inputs[$meta->name] = $meta->default; |
| 57 | 57 | } |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | 69 | $pos = 0; |
| 70 | - foreach ($this->paramMetas as $meta){ |
|
| 71 | - if($meta->isPassedByReference){ |
|
| 70 | + foreach ($this->paramMetas as $meta) { |
|
| 71 | + if ($meta->isPassedByReference) { |
|
| 72 | 72 | $params[$pos] = &$reference[$meta->name]; |
| 73 | - }else{ |
|
| 73 | + }else { |
|
| 74 | 74 | $params[$pos] = $inputs[$meta->name]; |
| 75 | 75 | } |
| 76 | 76 | $pos++; |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function getParamNames(){ |
|
| 82 | - return array_map(function($meta){return $meta->name;}, $this->paramMetas); |
|
| 81 | + public function getParamNames() { |
|
| 82 | + return array_map(function($meta) {return $meta->name; }, $this->paramMetas); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * 获取参数列表 |
| 87 | 87 | * @return ParamMeta[] |
| 88 | 88 | */ |
| 89 | - public function getParamMetas(){ |
|
| 89 | + public function getParamMetas() { |
|
| 90 | 90 | return $this->paramMetas; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * @param $name |
| 96 | 96 | * @return ParamMeta|null |
| 97 | 97 | */ |
| 98 | - public function getParamMeta($name){ |
|
| 99 | - foreach ($this->paramMetas as $meta){ |
|
| 100 | - if($meta->name == $name){ |
|
| 98 | + public function getParamMeta($name) { |
|
| 99 | + foreach ($this->paramMetas as $meta) { |
|
| 100 | + if ($meta->name == $name) { |
|
| 101 | 101 | return $meta; |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -45,13 +45,13 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | if($meta->container){ |
| 47 | 47 | $inputs[$meta->name] = $meta->container->make($source); |
| 48 | - }else{ |
|
| 48 | + } else{ |
|
| 49 | 49 | $inputs[$meta->name] = $source; |
| 50 | 50 | } |
| 51 | 51 | if($meta->validation){ |
| 52 | 52 | $vld->rule($meta->validation, $meta->name); |
| 53 | 53 | } |
| 54 | - }else{ |
|
| 54 | + } else{ |
|
| 55 | 55 | $meta->isOptional or \PhpBoot\abort(new BadRequestHttpException("the parameter \"{$meta->source}\" is missing")); |
| 56 | 56 | $inputs[$meta->name] = $meta->default; |
| 57 | 57 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | foreach ($this->paramMetas as $meta){ |
| 71 | 71 | if($meta->isPassedByReference){ |
| 72 | 72 | $params[$pos] = &$reference[$meta->name]; |
| 73 | - }else{ |
|
| 73 | + } else{ |
|
| 74 | 74 | $params[$pos] = $inputs[$meta->name]; |
| 75 | 75 | } |
| 76 | 76 | $pos++; |
@@ -82,6 +82,9 @@ |
||
| 82 | 82 | return new DB($app, $connection); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | + /** |
|
| 86 | + * @param \PDO $connection |
|
| 87 | + */ |
|
| 85 | 88 | public function __construct(Application $app, $connection) |
| 86 | 89 | { |
| 87 | 90 | $this->app = $app; |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | |
| 69 | 69 | static public function connect(Application $app, |
| 70 | - $dsn, |
|
| 71 | - $username, |
|
| 72 | - $password, |
|
| 73 | - $options = []) |
|
| 70 | + $dsn, |
|
| 71 | + $username, |
|
| 72 | + $password, |
|
| 73 | + $options = []) |
|
| 74 | 74 | { |
| 75 | 75 | $options += [ |
| 76 | 76 | \PDO::ATTR_ERRMODE =>\PDO::ERRMODE_EXCEPTION, |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | return $this->connection; |
| 166 | 166 | } |
| 167 | 167 | /** |
| 168 | - * Splice sql use raw string(without escaping) |
|
| 168 | + * Splice sql use raw string(without escaping) |
|
| 169 | 169 | * for example: |
| 170 | 170 | * where('time>?', 'now()') => " WHERE time > 'now()' " |
| 171 | 171 | * where('time>?', Sql::raw('now()')) => " WHERE time > now() " |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | $obj = new SelectRule(new Context($this->connection)); |
| 102 | 102 | if($column0 == null){ |
| 103 | 103 | $args = ['*']; |
| 104 | - }elseif(is_array($column0)){ |
|
| 104 | + } elseif(is_array($column0)){ |
|
| 105 | 105 | $args = $column0; |
| 106 | - }else{ |
|
| 106 | + } else{ |
|
| 107 | 107 | $args = func_get_args(); |
| 108 | 108 | } |
| 109 | 109 | foreach ($args as &$arg){ |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $res = $callback($this); |
| 171 | 171 | $this->getConnection()->commit() or \PhpBoot\abort('commit failed'); |
| 172 | 172 | return $res; |
| 173 | - }catch (\Exception $e){ |
|
| 173 | + } catch (\Exception $e){ |
|
| 174 | 174 | $this->getConnection()->rollBack(); |
| 175 | 175 | Logger::warning('commit failed with '.get_class($e).' '.$e->getMessage()); |
| 176 | 176 | throw $e; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @author caoym <[email protected]> |
| 52 | 52 | */ |
| 53 | -class DB{ |
|
| 53 | +class DB { |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * DB constructor. |
@@ -90,18 +90,18 @@ discard block |
||
| 90 | 90 | * @param string $column0 |
| 91 | 91 | * @return \PhpBoot\DB\rules\select\FromRule |
| 92 | 92 | */ |
| 93 | - function select($column0=null, $_=null){ |
|
| 93 | + function select($column0 = null, $_ = null) { |
|
| 94 | 94 | $obj = new SelectRule(new Context($this->connection)); |
| 95 | - if($column0 == null){ |
|
| 95 | + if ($column0 == null) { |
|
| 96 | 96 | $args = ['*']; |
| 97 | - }elseif(is_array($column0)){ |
|
| 97 | + }elseif (is_array($column0)) { |
|
| 98 | 98 | $args = $column0; |
| 99 | - }else{ |
|
| 99 | + }else { |
|
| 100 | 100 | $args = func_get_args(); |
| 101 | 101 | } |
| 102 | - foreach ($args as &$arg){ |
|
| 102 | + foreach ($args as &$arg) { |
|
| 103 | 103 | $arg = DB::wrap($arg); |
| 104 | - if($arg == '*'){ |
|
| 104 | + if ($arg == '*') { |
|
| 105 | 105 | continue; |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | * @param string $table |
| 133 | 133 | * @return \PhpBoot\DB\rules\basic\WhereRule |
| 134 | 134 | */ |
| 135 | - public function deleteFrom($table){ |
|
| 136 | - $obj = new DeleteRule(new Context($this->connection)); |
|
| 135 | + public function deleteFrom($table) { |
|
| 136 | + $obj = new DeleteRule(new Context($this->connection)); |
|
| 137 | 137 | return $obj->deleteFrom($table); |
| 138 | 138 | } |
| 139 | 139 | /** |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | * @param string $table |
| 142 | 142 | * @return \PhpBoot\DB\rules\replace\ValuesRule |
| 143 | 143 | */ |
| 144 | - public function replaceInto($table){ |
|
| 145 | - $obj = new ReplaceIntoRule(new Context($this->connection)); |
|
| 144 | + public function replaceInto($table) { |
|
| 145 | + $obj = new ReplaceIntoRule(new Context($this->connection)); |
|
| 146 | 146 | return $obj->replaceInto($table); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function transaction(callable $callback) |
| 155 | 155 | { |
| 156 | - if($this->inTransaction){ |
|
| 156 | + if ($this->inTransaction) { |
|
| 157 | 157 | return $callback($this); |
| 158 | 158 | } |
| 159 | 159 | $this->getConnection()->beginTransaction() or \PhpBoot\abort('beginTransaction failed'); |
| 160 | 160 | $this->inTransaction = true; |
| 161 | - try{ |
|
| 161 | + try { |
|
| 162 | 162 | $res = $callback($this); |
| 163 | 163 | $this->getConnection()->commit() or \PhpBoot\abort('commit failed'); |
| 164 | 164 | return $res; |
| 165 | - }catch (\Exception $e){ |
|
| 165 | + }catch (\Exception $e) { |
|
| 166 | 166 | $this->getConnection()->rollBack(); |
| 167 | 167 | Logger::warning('commit failed with '.get_class($e).' '.$e->getMessage()); |
| 168 | 168 | throw $e; |
@@ -183,12 +183,12 @@ discard block |
||
| 183 | 183 | * @param string $str |
| 184 | 184 | * @return Raw |
| 185 | 185 | */ |
| 186 | - static public function raw($str){ |
|
| 186 | + static public function raw($str) { |
|
| 187 | 187 | return new Raw($str); |
| 188 | 188 | } |
| 189 | 189 | static public function wrap($value) |
| 190 | 190 | { |
| 191 | - if($value instanceof Raw){ |
|
| 191 | + if ($value instanceof Raw) { |
|
| 192 | 192 | return $value->get(); |
| 193 | 193 | } |
| 194 | 194 | $value = trim($value); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | return $value; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if(strpos($value, '.') !== false && !preg_match('/\\s+/', $value)){ |
|
| 199 | + if (strpos($value, '.') !== false && !preg_match('/\\s+/', $value)) { |
|
| 200 | 200 | return $value; |
| 201 | 201 | } |
| 202 | 202 | return '`'.str_replace('`', '``', $value).'`'; |
@@ -209,8 +209,8 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | return $this->app; |
| 211 | 211 | } |
| 212 | - const ORDER_BY_ASC ='ASC'; |
|
| 213 | - const ORDER_BY_DESC ='DESC'; |
|
| 212 | + const ORDER_BY_ASC = 'ASC'; |
|
| 213 | + const ORDER_BY_DESC = 'DESC'; |
|
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * @var \PDO |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace PhpBoot\ORM; |
| 4 | 4 | |
| 5 | -use DI\Container; |
|
| 6 | 5 | use DI\FactoryInterface; |
| 7 | 6 | use Doctrine\Common\Cache\Cache; |
| 8 | 7 | use PhpBoot\DI\DIContainerBuilder; |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | class ModelContainerBuilder extends EntityContainerBuilder |
| 18 | 18 | { |
| 19 | - static $DEFAULT_ANNOTATIONS=[ |
|
| 19 | + static $DEFAULT_ANNOTATIONS = [ |
|
| 20 | 20 | [ClassAnnotationHandler::class, 'class'], |
| 21 | 21 | [PKAnnotationHandler::class, "class.children[?name=='pk']"], |
| 22 | 22 | [TableAnnotationHandler::class, "class.children[?name=='table']"], |
@@ -5,6 +5,9 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | class AnnotationParams implements \Countable, \ArrayAccess |
| 7 | 7 | { |
| 8 | + /** |
|
| 9 | + * @param integer $limit |
|
| 10 | + */ |
|
| 8 | 11 | public function __construct($text, $limit) |
| 9 | 12 | { |
| 10 | 13 | if($limit == 1){ |
@@ -142,6 +145,12 @@ discard block |
||
| 142 | 145 | } |
| 143 | 146 | } |
| 144 | 147 | |
| 148 | + /** |
|
| 149 | + * @param integer $pos |
|
| 150 | + * @param string $default |
|
| 151 | + * |
|
| 152 | + * @return string |
|
| 153 | + */ |
|
| 145 | 154 | public function getRawParam($pos, $default = null) |
| 146 | 155 | { |
| 147 | 156 | if(isset($this->rawParams[$pos])){ |
@@ -151,6 +160,9 @@ discard block |
||
| 151 | 160 | } |
| 152 | 161 | } |
| 153 | 162 | |
| 163 | + /** |
|
| 164 | + * @param boolean $ignoreError |
|
| 165 | + */ |
|
| 154 | 166 | private function stripSlashes($text, $ignoreError) |
| 155 | 167 | { |
| 156 | 168 | if(strlen($text)>=2 && substr($text,0,1) == '"'){ |
@@ -7,31 +7,31 @@ discard block |
||
| 7 | 7 | { |
| 8 | 8 | public function __construct($text, $limit) |
| 9 | 9 | { |
| 10 | - if($limit == 1){ |
|
| 10 | + if ($limit == 1) { |
|
| 11 | 11 | $this->rawParams[] = $text; |
| 12 | 12 | return; |
| 13 | 13 | } |
| 14 | - if($limit <= 0){ |
|
| 14 | + if ($limit<=0) { |
|
| 15 | 15 | return; |
| 16 | 16 | } |
| 17 | 17 | $text = ltrim($text); |
| 18 | 18 | $pos = 0; |
| 19 | 19 | $state = 'stateNormal'; |
| 20 | 20 | $len = strlen($text); |
| 21 | - if($len == 0){ |
|
| 21 | + if ($len == 0) { |
|
| 22 | 22 | return; |
| 23 | 23 | } |
| 24 | - while (true){ |
|
| 25 | - if($state == 'stateNormal' && count($this->rawParams)+1 == $limit){ |
|
| 24 | + while (true) { |
|
| 25 | + if ($state == 'stateNormal' && count($this->rawParams) + 1 == $limit) { |
|
| 26 | 26 | break; |
| 27 | 27 | } |
| 28 | 28 | $pos = $this->$state($text, $pos, $state); |
| 29 | - if($pos === false || $pos>= $len){ |
|
| 29 | + if ($pos === false || $pos>=$len) { |
|
| 30 | 30 | break; |
| 31 | 31 | } |
| 32 | 32 | }; |
| 33 | - if($this->prePos != strlen($text)){ |
|
| 34 | - $this->rawParams[] = substr($text,$this->prePos); |
|
| 33 | + if ($this->prePos != strlen($text)) { |
|
| 34 | + $this->rawParams[] = substr($text, $this->prePos); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
@@ -42,16 +42,16 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | //查找引号或者空格 |
| 44 | 44 | $found = []; |
| 45 | - $todo = substr($text,$pos); |
|
| 46 | - if(!preg_match('/[\s"\']/', $todo, $found, PREG_OFFSET_CAPTURE) || |
|
| 47 | - count($found)==0){ |
|
| 48 | - $this->rawParams[] = substr($text,$this->prePos); |
|
| 45 | + $todo = substr($text, $pos); |
|
| 46 | + if (!preg_match('/[\s"\']/', $todo, $found, PREG_OFFSET_CAPTURE) || |
|
| 47 | + count($found) == 0) { |
|
| 48 | + $this->rawParams[] = substr($text, $this->prePos); |
|
| 49 | 49 | $this->prePos = strlen($text); |
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | list($chars, $offset) = $found[0]; |
| 53 | 53 | |
| 54 | - if($chars == '"'){ |
|
| 54 | + if ($chars == '"') { |
|
| 55 | 55 | $next = 'stateDoubleQ'; |
| 56 | 56 | return $pos + $offset + 1; |
| 57 | 57 | } |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | // $next = 'stateSingleQ'; |
| 60 | 60 | // return $pos + $offset + 1; |
| 61 | 61 | // } |
| 62 | - else{ |
|
| 63 | - $this->rawParams[] = substr($text,$this->prePos, $pos-$this->prePos+$offset); |
|
| 62 | + else { |
|
| 63 | + $this->rawParams[] = substr($text, $this->prePos, $pos - $this->prePos + $offset); |
|
| 64 | 64 | $next = 'stateSpace'; |
| 65 | 65 | $this->prePos = $pos + $offset + 1; |
| 66 | 66 | return $this->prePos; |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | private function stateSpace($text, $pos, &$next) |
| 74 | 74 | { |
| 75 | 75 | $found = []; |
| 76 | - $todo = substr($text,$pos); |
|
| 77 | - if(!preg_match('/\S/', $todo, $found, PREG_OFFSET_CAPTURE) || |
|
| 78 | - count($found)==0){ |
|
| 76 | + $todo = substr($text, $pos); |
|
| 77 | + if (!preg_match('/\S/', $todo, $found, PREG_OFFSET_CAPTURE) || |
|
| 78 | + count($found) == 0) { |
|
| 79 | 79 | return false; |
| 80 | 80 | } |
| 81 | 81 | list($chars, $offset) = $found[0]; |
@@ -105,20 +105,20 @@ discard block |
||
| 105 | 105 | /** |
| 106 | 106 | * 进入双引号状态 |
| 107 | 107 | */ |
| 108 | - private function stateDoubleQ($text, $pos, &$next){ |
|
| 108 | + private function stateDoubleQ($text, $pos, &$next) { |
|
| 109 | 109 | |
| 110 | 110 | $found = []; |
| 111 | - $todo = substr($text,$pos); |
|
| 112 | - if(!preg_match('/[\\\\"]/', $todo, $found, PREG_OFFSET_CAPTURE) || |
|
| 113 | - count($found)==0){ |
|
| 111 | + $todo = substr($text, $pos); |
|
| 112 | + if (!preg_match('/[\\\\"]/', $todo, $found, PREG_OFFSET_CAPTURE) || |
|
| 113 | + count($found) == 0) { |
|
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | list($chars, $offset) = $found[0]; |
| 117 | - if($chars == '\\'){ |
|
| 118 | - return $pos+$offset+2; |
|
| 119 | - }else{ |
|
| 117 | + if ($chars == '\\') { |
|
| 118 | + return $pos + $offset + 2; |
|
| 119 | + }else { |
|
| 120 | 120 | $next = 'stateNormal'; |
| 121 | - return $pos+$offset+1; |
|
| 121 | + return $pos + $offset + 1; |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -127,38 +127,38 @@ discard block |
||
| 127 | 127 | return count($this->rawParams); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public function getParam($pos, $default = null, $ignoreError=false) |
|
| 130 | + public function getParam($pos, $default = null, $ignoreError = false) |
|
| 131 | 131 | { |
| 132 | - if(isset($this->cachedParams[$pos])){ |
|
| 132 | + if (isset($this->cachedParams[$pos])) { |
|
| 133 | 133 | return $this->cachedParams[$pos]; |
| 134 | 134 | } |
| 135 | - if(isset($this->rawParams[$pos])){ |
|
| 135 | + if (isset($this->rawParams[$pos])) { |
|
| 136 | 136 | $param = $this->rawParams[$pos]; |
| 137 | 137 | $param = $this->stripSlashes($param, $ignoreError); |
| 138 | 138 | $this->cachedParams[$pos] = $param; |
| 139 | 139 | return $param; |
| 140 | - }else{ |
|
| 140 | + }else { |
|
| 141 | 141 | return $default; |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | public function getRawParam($pos, $default = null) |
| 146 | 146 | { |
| 147 | - if(isset($this->rawParams[$pos])){ |
|
| 147 | + if (isset($this->rawParams[$pos])) { |
|
| 148 | 148 | return $this->rawParams[$pos]; |
| 149 | - }else{ |
|
| 149 | + }else { |
|
| 150 | 150 | return $default; |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | private function stripSlashes($text, $ignoreError) |
| 155 | 155 | { |
| 156 | - if(strlen($text)>=2 && substr($text,0,1) == '"'){ |
|
| 156 | + if (strlen($text)>=2 && substr($text, 0, 1) == '"') { |
|
| 157 | 157 | $decoded = json_decode($text); |
| 158 | - if(json_last_error()){ |
|
| 159 | - if($ignoreError){ |
|
| 158 | + if (json_last_error()) { |
|
| 159 | + if ($ignoreError) { |
|
| 160 | 160 | return $text; |
| 161 | - }else{ |
|
| 161 | + }else { |
|
| 162 | 162 | \PhpBoot\abort('json_decode failed with '.json_last_error_msg(), [$text]); |
| 163 | 163 | } |
| 164 | 164 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | list($chars, $offset) = $found[0]; |
| 117 | 117 | if($chars == '\\'){ |
| 118 | 118 | return $pos+$offset+2; |
| 119 | - }else{ |
|
| 119 | + } else{ |
|
| 120 | 120 | $next = 'stateNormal'; |
| 121 | 121 | return $pos+$offset+1; |
| 122 | 122 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $param = $this->stripSlashes($param, $ignoreError); |
| 138 | 138 | $this->cachedParams[$pos] = $param; |
| 139 | 139 | return $param; |
| 140 | - }else{ |
|
| 140 | + } else{ |
|
| 141 | 141 | return $default; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | if(isset($this->rawParams[$pos])){ |
| 148 | 148 | return $this->rawParams[$pos]; |
| 149 | - }else{ |
|
| 149 | + } else{ |
|
| 150 | 150 | return $default; |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | if(json_last_error()){ |
| 159 | 159 | if($ignoreError){ |
| 160 | 160 | return $text; |
| 161 | - }else{ |
|
| 161 | + } else{ |
|
| 162 | 162 | \PhpBoot\abort('json_decode failed with '.json_last_error_msg(), [$text]); |
| 163 | 163 | } |
| 164 | 164 | } |