@@ -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; |
@@ -83,11 +83,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -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 |
@@ -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->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 | } |
@@ -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("param $source is required")); |
56 | 56 | $inputs[$meta->name] = $meta->default; |
57 | 57 | } |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | ); |
67 | 67 | |
68 | 68 | $pos = 0; |
69 | - foreach ($this->paramMetas as $meta){ |
|
70 | - if($meta->isPassedByReference){ |
|
69 | + foreach ($this->paramMetas as $meta) { |
|
70 | + if ($meta->isPassedByReference) { |
|
71 | 71 | $params[$pos] = &$reference[$meta->name]; |
72 | - }else{ |
|
72 | + }else { |
|
73 | 73 | $params[$pos] = $inputs[$meta->name]; |
74 | 74 | } |
75 | 75 | $pos++; |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - public function getParamNames(){ |
|
81 | - return array_map(function($meta){return $meta->name;}, $this->paramMetas); |
|
80 | + public function getParamNames() { |
|
81 | + return array_map(function($meta) {return $meta->name; }, $this->paramMetas); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * 获取参数列表 |
86 | 86 | * @return ParamMeta[] |
87 | 87 | */ |
88 | - public function getParamMetas(){ |
|
88 | + public function getParamMetas() { |
|
89 | 89 | return $this->paramMetas; |
90 | 90 | } |
91 | 91 | |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param $name |
95 | 95 | * @return ParamMeta|null |
96 | 96 | */ |
97 | - public function getParamMeta($name){ |
|
98 | - foreach ($this->paramMetas as $meta){ |
|
99 | - if($meta->name == $name){ |
|
97 | + public function getParamMeta($name) { |
|
98 | + foreach ($this->paramMetas as $meta) { |
|
99 | + if ($meta->name == $name) { |
|
100 | 100 | return $meta; |
101 | 101 | } |
102 | 102 | } |
@@ -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("param $source is required")); |
56 | 56 | $inputs[$meta->name] = $meta->default; |
57 | 57 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | foreach ($this->paramMetas as $meta){ |
70 | 70 | if($meta->isPassedByReference){ |
71 | 71 | $params[$pos] = &$reference[$meta->name]; |
72 | - }else{ |
|
72 | + } else{ |
|
73 | 73 | $params[$pos] = $inputs[$meta->name]; |
74 | 74 | } |
75 | 75 | $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() " |
@@ -100,9 +100,9 @@ |
||
100 | 100 | $obj = new SelectRule(new Context($this->connection)); |
101 | 101 | if($column0 == null){ |
102 | 102 | $args = ['*']; |
103 | - }elseif(is_array($column0)){ |
|
103 | + } elseif(is_array($column0)){ |
|
104 | 104 | $args = $column0; |
105 | - }else{ |
|
105 | + } else{ |
|
106 | 106 | $args = func_get_args(); |
107 | 107 | } |
108 | 108 | foreach ($args as &$arg){ |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @author caoym <[email protected]> |
57 | 57 | */ |
58 | -class DB{ |
|
58 | +class DB { |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * DB constructor. |
@@ -96,18 +96,18 @@ discard block |
||
96 | 96 | * @param string $column0 |
97 | 97 | * @return \PhpBoot\DB\rules\select\FromRule |
98 | 98 | */ |
99 | - function select($column0=null, $_=null){ |
|
99 | + function select($column0 = null, $_ = null) { |
|
100 | 100 | $obj = new SelectRule(new Context($this->connection)); |
101 | - if($column0 == null){ |
|
101 | + if ($column0 == null) { |
|
102 | 102 | $args = ['*']; |
103 | - }elseif(is_array($column0)){ |
|
103 | + }elseif (is_array($column0)) { |
|
104 | 104 | $args = $column0; |
105 | - }else{ |
|
105 | + }else { |
|
106 | 106 | $args = func_get_args(); |
107 | 107 | } |
108 | - foreach ($args as &$arg){ |
|
108 | + foreach ($args as &$arg) { |
|
109 | 109 | $arg = DB::wrap($arg); |
110 | - if($arg == '*'){ |
|
110 | + if ($arg == '*') { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $table |
140 | 140 | * @return \PhpBoot\DB\rules\basic\WhereRule |
141 | 141 | */ |
142 | - public function deleteFrom($table){ |
|
143 | - $obj = new DeleteRule(new Context($this->connection)); |
|
142 | + public function deleteFrom($table) { |
|
143 | + $obj = new DeleteRule(new Context($this->connection)); |
|
144 | 144 | return $obj->deleteFrom($table); |
145 | 145 | } |
146 | 146 | /** |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * @param string $table |
149 | 149 | * @return \PhpBoot\DB\rules\replace\ValuesRule |
150 | 150 | */ |
151 | - public function replaceInto($table){ |
|
152 | - $obj = new ReplaceIntoRule(new Context($this->connection)); |
|
151 | + public function replaceInto($table) { |
|
152 | + $obj = new ReplaceIntoRule(new Context($this->connection)); |
|
153 | 153 | return $obj->replaceInto($table); |
154 | 154 | } |
155 | 155 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param string $str |
169 | 169 | * @return Raw |
170 | 170 | */ |
171 | - static public function raw($str){ |
|
171 | + static public function raw($str) { |
|
172 | 172 | return new Raw($str); |
173 | 173 | } |
174 | 174 | static public function wrap($value) |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if ($value === '*') { |
177 | 177 | return $value; |
178 | 178 | } |
179 | - if($value instanceof Raw){ |
|
179 | + if ($value instanceof Raw) { |
|
180 | 180 | return $value->get(); |
181 | 181 | } |
182 | 182 | return '`'.str_replace('`', '``', $value).'`'; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | { |
190 | 190 | return $this->app; |
191 | 191 | } |
192 | - const ORDER_BY_ASC ='ASC'; |
|
193 | - const ORDER_BY_DESC ='DESC'; |
|
192 | + const ORDER_BY_ASC = 'ASC'; |
|
193 | + const ORDER_BY_DESC = 'DESC'; |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * @var \PDO |
@@ -24,6 +24,9 @@ |
||
24 | 24 | |
25 | 25 | class UpdateSetRule extends WhereRule |
26 | 26 | { |
27 | + /** |
|
28 | + * @param \PhpBoot\DB\Context $context |
|
29 | + */ |
|
27 | 30 | public function __construct($context){ |
28 | 31 | parent::__construct($context); |
29 | 32 | $this->impl = new UpdateSetImpl(); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | class UpdateSetRule extends WhereRule |
26 | 26 | { |
27 | - public function __construct($context){ |
|
27 | + public function __construct($context) { |
|
28 | 28 | parent::__construct($context); |
29 | 29 | $this->impl = new UpdateSetImpl(); |
30 | 30 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param mixed $_ |
38 | 38 | * @return \PhpBoot\DB\rules\update\UpdateSetRule |
39 | 39 | */ |
40 | - public function set($expr, $_=null) { |
|
40 | + public function set($expr, $_ = null) { |
|
41 | 41 | $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1)); |
42 | 42 | return $this; |
43 | 43 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | - * @param $object |
|
91 | + * @param Swagger $object |
|
92 | 92 | * @return array |
93 | 93 | */ |
94 | 94 | static public function objectToArray($object) |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * @param Application $app |
115 | 115 | * @param ControllerContainer $controller |
116 | - * @param $action |
|
116 | + * @param integer $action |
|
117 | 117 | * @param Route $route |
118 | 118 | * @return array |
119 | 119 | */ |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * @param Application $app |
164 | 164 | * @param ControllerContainer $controller |
165 | - * @param $action |
|
165 | + * @param integer $action |
|
166 | 166 | * @param Route $route |
167 | 167 | * @return null|ResponseObject |
168 | 168 | */ |
@@ -299,6 +299,9 @@ discard block |
||
299 | 299 | return new RefSchemaObject("#/definitions/$name"); |
300 | 300 | } |
301 | 301 | |
302 | + /** |
|
303 | + * @param integer $action |
|
304 | + */ |
|
302 | 305 | public function getParamsSchema(Application $app, |
303 | 306 | ControllerContainer $controller, |
304 | 307 | $action, |
@@ -8,7 +8,6 @@ discard block |
||
8 | 8 | use PhpBoot\Docgen\Swagger\Schemas\ArraySchemaObject; |
9 | 9 | use PhpBoot\Docgen\Swagger\Schemas\BodyParameterObject; |
10 | 10 | use PhpBoot\Docgen\Swagger\Schemas\OperationObject; |
11 | -use PhpBoot\Docgen\Swagger\Schemas\OtherParameterObject; |
|
12 | 11 | use PhpBoot\Docgen\Swagger\Schemas\PrimitiveSchemaObject; |
13 | 12 | use PhpBoot\Docgen\Swagger\Schemas\RefSchemaObject; |
14 | 13 | use PhpBoot\Docgen\Swagger\Schemas\ResponseObject; |
@@ -22,7 +21,6 @@ discard block |
||
22 | 21 | use PhpBoot\Metas\ParamMeta; |
23 | 22 | use PhpBoot\Metas\ReturnMeta; |
24 | 23 | use PhpBoot\Utils\ArrayHelper; |
25 | -use PhpBoot\Validator\Validator; |
|
26 | 24 | use Symfony\Component\HttpKernel\Exception\HttpException; |
27 | 25 | |
28 | 26 | class Swagger extends SwaggerObject |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | * @return RefSchemaObject |
235 | 235 | */ |
236 | 236 | public function makeTempSchema(Application $app, |
237 | - ControllerContainer $controller, |
|
238 | - $action, |
|
239 | - Route $route, |
|
240 | - array $arr, $suffix) |
|
237 | + ControllerContainer $controller, |
|
238 | + $action, |
|
239 | + Route $route, |
|
240 | + array $arr, $suffix) |
|
241 | 241 | { |
242 | 242 | $className = self::getShortClassName($controller->getClassName()); |
243 | 243 | $name = $className . ucfirst($action) . $suffix; |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | * @return RefSchemaObject |
294 | 294 | */ |
295 | 295 | public function getRefSchema(Application $app, |
296 | - ControllerContainer $controller, |
|
297 | - $action, |
|
298 | - Route $route, |
|
299 | - EntityContainer $container) |
|
296 | + ControllerContainer $controller, |
|
297 | + $action, |
|
298 | + Route $route, |
|
299 | + EntityContainer $container) |
|
300 | 300 | { |
301 | 301 | $name = $container->getClassName(); |
302 | 302 | if (!isset($this->definitions[$name])) { |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | * @return ArraySchemaObject |
445 | 445 | */ |
446 | 446 | public function getArraySchema(Application $app, |
447 | - ControllerContainer $controller, |
|
448 | - $action, |
|
449 | - Route $route, |
|
450 | - ArrayContainer $container) |
|
447 | + ControllerContainer $controller, |
|
448 | + $action, |
|
449 | + Route $route, |
|
450 | + ArrayContainer $container) |
|
451 | 451 | { |
452 | 452 | $schema = new ArraySchemaObject(); |
453 | 453 | $itemContainer = $container->getContainer(); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $op->description = $route->getDescription(); |
59 | 59 | |
60 | 60 | $op->parameters = $this->getParamsSchema($app, $controller, $action, $route); |
61 | - if($this->hasFileParam($route)){ |
|
61 | + if ($this->hasFileParam($route)) { |
|
62 | 62 | $op->consumes = ['multipart/form-data']; |
63 | 63 | } |
64 | 64 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | if (is_array($v) || is_object($v)) { |
110 | 110 | $res[$k] = self::objectToArray($v); |
111 | - } else { |
|
111 | + }else { |
|
112 | 112 | $res[$k] = $v; |
113 | 113 | } |
114 | 114 | } |
@@ -140,21 +140,21 @@ discard block |
||
140 | 140 | //TODO status 重复怎么办 |
141 | 141 | if ($ins instanceof HttpException) { |
142 | 142 | $status = $ins->getStatusCode(); |
143 | - } else { |
|
143 | + }else { |
|
144 | 144 | |
145 | 145 | $status = 500; |
146 | 146 | } |
147 | 147 | if (isset($res[$status])) { |
148 | 148 | //$this->warnings[] = "status response $status has been used for $name, $desc"; |
149 | 149 | $res = $res[$status]; |
150 | - } else { |
|
150 | + }else { |
|
151 | 151 | $res = new ResponseObject(); |
152 | 152 | } |
153 | 153 | $shortName = self::getShortClassName($name); |
154 | 154 | $desc = "$shortName: $desc"; |
155 | 155 | $res->description = implode("\n", [$res->description, $desc]); |
156 | 156 | $error = $app->get(ExceptionRenderer::class)->render($ins)->getContent(); |
157 | - if($error){ |
|
157 | + if ($error) { |
|
158 | 158 | $res->examples = [$shortName => $error]; |
159 | 159 | } |
160 | 160 | //$res->schema = new RefSchemaObject("#/definitions/$name"); |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | { |
214 | 214 | if ($content instanceof ReturnMeta || $content instanceof ParamMeta) { |
215 | 215 | return $this->makeExample($content->container); |
216 | - }elseif ($content instanceof TypeContainerInterface){ |
|
216 | + }elseif ($content instanceof TypeContainerInterface) { |
|
217 | 217 | return $content->makeExample(); |
218 | - }elseif(is_array($content)) { |
|
218 | + }elseif (is_array($content)) { |
|
219 | 219 | $res = []; |
220 | 220 | foreach ($content as $k => $v) { |
221 | 221 | $res[$k] = $this->makeExample($v); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | array $arr, $suffix) |
241 | 241 | { |
242 | 242 | $className = self::getShortClassName($controller->getClassName()); |
243 | - $name = $className . ucfirst($action) . $suffix; |
|
243 | + $name = $className.ucfirst($action).$suffix; |
|
244 | 244 | |
245 | 245 | $schema = new SimpleModelSchemaObject(); |
246 | 246 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } elseif ($v->container instanceof EntityContainer) { |
259 | 259 | $sub = $this->getRefSchema($app, $controller, $action, $route, $v->container); |
260 | 260 | //TODO array for validation |
261 | - } else { |
|
261 | + }else { |
|
262 | 262 | $sub = new PrimitiveSchemaObject(); |
263 | 263 | $sub->type = self::mapType($v->type); |
264 | 264 | self::mapValidation($v->validation, $sub); |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | $schema->required[] = $k; |
271 | 271 | } |
272 | 272 | $schema->properties[$k] = $sub; |
273 | - } else { |
|
273 | + }else { |
|
274 | 274 | //TODO how to do? |
275 | 275 | } |
276 | 276 | } |
277 | 277 | $unused = $name; |
278 | 278 | $tempId = 0; |
279 | 279 | while (isset($this->definitions[$unused])) { |
280 | - $unused = $name . $tempId; |
|
280 | + $unused = $name.$tempId; |
|
281 | 281 | $tempId++; |
282 | 282 | } |
283 | 283 | $this->definitions[$unused] = $schema; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $in = 'query'; |
317 | 317 | |
318 | 318 | $bodyType = 'body'; // 当有文件上传时, 必须是formData方式 |
319 | - if($this->hasFileParam($route)){ |
|
319 | + if ($this->hasFileParam($route)) { |
|
320 | 320 | $bodyType = 'formData'; |
321 | 321 | } |
322 | 322 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | || $route->getMethod() == 'PATCH' |
356 | 356 | ) { |
357 | 357 | $in = $bodyType; |
358 | - } else { |
|
358 | + }else { |
|
359 | 359 | $in = 'query'; |
360 | 360 | } |
361 | 361 | } |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | } elseif ($param->container instanceof EntityContainer) { |
367 | 367 | $paramSchema = $this->getRefSchema($app, $controller, $action, $route, $param->container); |
368 | 368 | //TODO array for validation |
369 | - } else { |
|
369 | + }else { |
|
370 | 370 | $paramSchema = new PrimitiveSchemaObject(); |
371 | - if($isFile){ |
|
371 | + if ($isFile) { |
|
372 | 372 | $paramSchema->type = 'file'; |
373 | - }else{ |
|
373 | + }else { |
|
374 | 374 | $paramSchema->type = self::mapType($param->type); |
375 | 375 | self::mapValidation($param->validation, $paramSchema); |
376 | 376 | } |
@@ -382,10 +382,10 @@ discard block |
||
382 | 382 | $paramSchema->default = $param->default; |
383 | 383 | $paramSchema->required = !$param->isOptional; |
384 | 384 | $parameters[] = $paramSchema; |
385 | - } else { |
|
385 | + }else { |
|
386 | 386 | if (!$name) { |
387 | 387 | $body = $param; |
388 | - } else { |
|
388 | + }else { |
|
389 | 389 | ArrayHelper::set($body, $name, $param); |
390 | 390 | } |
391 | 391 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $paramSchema->in = 'body'; |
399 | 399 | if (is_array($body)) { |
400 | 400 | $paramSchema->schema = $this->makeTempSchema($app, $controller, $action, $route, $body, 'Req'); |
401 | - } else { |
|
401 | + }else { |
|
402 | 402 | $paramSchema->schema = $this->getAnySchema($app, $controller, $action, $route, $body->container); |
403 | 403 | } |
404 | 404 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | } elseif ($container instanceof ScalarTypeContainer) { |
426 | 426 | $schema = new PrimitiveSchemaObject(); |
427 | 427 | $schema->type = self::mapType($container->getType()); |
428 | - } elseif($container == null){ |
|
429 | - $schema = null ;//new PrimitiveSchemaObject(); |
|
428 | + } elseif ($container == null) { |
|
429 | + $schema = null; //new PrimitiveSchemaObject(); |
|
430 | 430 | //$schema->type = null; |
431 | 431 | }else { |
432 | 432 | $schema = new PrimitiveSchemaObject(); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | } elseif ($itemContainer instanceof ScalarTypeContainer) { |
459 | 459 | $itemSchema = new PrimitiveSchemaObject(); |
460 | 460 | $itemSchema->type = self::mapType($itemContainer->getType()); |
461 | - } else { |
|
461 | + }else { |
|
462 | 462 | $itemSchema = new PrimitiveSchemaObject(); |
463 | 463 | //$itemSchema->type = 'mixed'; |
464 | 464 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | $propertySchema = $this->getRefSchema($app, $controller, $action, $route, $property->container); |
485 | 485 | } elseif ($property->container instanceof ArrayContainer) { |
486 | 486 | $propertySchema = $this->getArraySchema($app, $controller, $action, $route, $property->container); |
487 | - } else { |
|
487 | + }else { |
|
488 | 488 | $propertySchema = new PrimitiveSchemaObject(); |
489 | 489 | $propertySchema->type = self::mapType($property->type); |
490 | 490 | $propertySchema->description = implode("\n", [$property->summary, $property->description]); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | { |
502 | 502 | $params = $route->getRequestHandler()->getParamMetas(); |
503 | 503 | foreach ($params as $name => $param) { |
504 | - if(strpos($param->source, 'request.files.')===0){ |
|
504 | + if (strpos($param->source, 'request.files.') === 0) { |
|
505 | 505 | return true; |
506 | 506 | } |
507 | 507 | } |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | */ |
515 | 515 | static public function mapValidation($v, PrimitiveSchemaObject $schemaObject) |
516 | 516 | { |
517 | - if(!$v){ |
|
517 | + if (!$v) { |
|
518 | 518 | return $schemaObject; |
519 | 519 | } |
520 | 520 | $rules = explode('|', $v); |
@@ -530,15 +530,15 @@ discard block |
||
530 | 530 | } elseif ($rule == 'lengthBetween' && isset($params[0]) && isset($params[1])) { |
531 | 531 | $schemaObject->minLength = intval($params[0]); |
532 | 532 | $schemaObject->maxLength = intval($params[1]); |
533 | - } elseif ($rule == 'lengthMin'&& isset($params[0])) { |
|
533 | + } elseif ($rule == 'lengthMin' && isset($params[0])) { |
|
534 | 534 | $schemaObject->minLength = intval($params[0]); |
535 | - } elseif ($rule == 'lengthMax'&& isset($params[0])) { |
|
535 | + } elseif ($rule == 'lengthMax' && isset($params[0])) { |
|
536 | 536 | $schemaObject->maxLength = intval($params[0]); |
537 | - } elseif ($rule == 'min'&& isset($params[0])) { |
|
537 | + } elseif ($rule == 'min' && isset($params[0])) { |
|
538 | 538 | $schemaObject->minimum = floatval($params[0]); |
539 | - } elseif ($rule == 'max'&& isset($params[0])) { |
|
539 | + } elseif ($rule == 'max' && isset($params[0])) { |
|
540 | 540 | $schemaObject->maximum = floatval($params[0]); |
541 | - } elseif ($rule == 'regex'&& isset($params[0])) { |
|
541 | + } elseif ($rule == 'regex' && isset($params[0])) { |
|
542 | 542 | $schemaObject->pattern = $params[0]; |
543 | 543 | } elseif ($rule == 'optional') { |
544 | 544 | $schemaObject->required = false; |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | { |
214 | 214 | if ($content instanceof ReturnMeta || $content instanceof ParamMeta) { |
215 | 215 | return $this->makeExample($content->container); |
216 | - }elseif ($content instanceof TypeContainerInterface){ |
|
216 | + } elseif ($content instanceof TypeContainerInterface){ |
|
217 | 217 | return $content->makeExample(); |
218 | - }elseif(is_array($content)) { |
|
218 | + } elseif(is_array($content)) { |
|
219 | 219 | $res = []; |
220 | 220 | foreach ($content as $k => $v) { |
221 | 221 | $res[$k] = $this->makeExample($v); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $paramSchema = new PrimitiveSchemaObject(); |
371 | 371 | if($isFile){ |
372 | 372 | $paramSchema->type = 'file'; |
373 | - }else{ |
|
373 | + } else{ |
|
374 | 374 | $paramSchema->type = self::mapType($param->type); |
375 | 375 | self::mapValidation($param->validation, $paramSchema); |
376 | 376 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | } elseif($container == null){ |
429 | 429 | $schema = null ;//new PrimitiveSchemaObject(); |
430 | 430 | //$schema->type = null; |
431 | - }else { |
|
431 | + } else { |
|
432 | 432 | $schema = new PrimitiveSchemaObject(); |
433 | 433 | //$schema->type = 'mixed'; |
434 | 434 | } |