File tree Expand file tree Collapse file tree 1 file changed +28
-17
lines changed
src/App/Normalizer/Component Expand file tree Collapse file tree 1 file changed +28
-17
lines changed Original file line number Diff line number Diff line change 88 */
99class SchemaTypeNormalizer
1010{
11+ /**
12+ * @private
13+ * @type array
14+ */
15+ const MANAGED_TYPE_LIST = [
16+ 'array ' => true ,
17+ 'number ' => true ,
18+ 'object ' => true ,
19+ 'string ' => true ,
20+ 'integer ' => true ,
21+ 'boolean ' => true ,
22+ 'null ' => true ,
23+ ];
24+ /**
25+ * @private
26+ * @type array
27+ */
28+ const RENAMED_TYPE_LIST = [
29+ 'float ' => 'number ' ,
30+ 'collection ' => 'array ' ,
31+ ];
1132 /**
1233 * @param TypeDoc $doc
1334 *
14- * @return mixed| string
35+ * @return string
1536 *
1637 * @throws \ReflectionException
1738 */
1839 public function normalize (TypeDoc $ doc ) : string
1940 {
2041 $ type = str_replace ('Doc ' , '' , lcfirst ((new \ReflectionClass ($ doc ))->getShortName ()));
21- // translate type
22- switch ($ type ) {
23- case 'array ' :
24- case 'number ' :
25- case 'object ' :
26- case 'string ' :
27- case 'integer ' :
28- case 'boolean ' :
29- case 'null ' :
30- return $ type ;
31- case 'float ' :
32- return 'number ' ;
33- case 'collection ' :
34- return 'array ' ;
35- default :
36- return 'string ' ;
42+ if (array_key_exists ($ type , self ::MANAGED_TYPE_LIST )) {
43+ return $ type ;
44+ } elseif (array_key_exists ($ type , self ::RENAMED_TYPE_LIST )) {
45+ return self ::RENAMED_TYPE_LIST [$ type ];
3746 }
47+
48+ return 'string ' ;
3849 }
3950}
You can’t perform that action at this time.
0 commit comments