@@ -24,20 +24,15 @@ abstract class ClassGenerator {
2424 public const NAMESPACE_MODEL = 'Models ' ;
2525 public const NAMESPACE_REQUEST = 'Requests ' ;
2626
27- /**
28- * @var string
29- */
30- private $ namespace_name ;
27+ private string $ namespace_name ;
3128
3229 /**
3330 * @var ClassType[]
3431 */
35- public $ classes = [];
32+ public array $ classes = [];
3633
3734 /**
3835 * Creates a generator for a specific namespace
39- *
40- * @param string $namespace_name
4136 */
4237 public function __construct (string $ namespace_name ){
4338 $ this ->namespace_name = $ this ->stringNotEndWith ($ namespace_name , '\\' );
@@ -55,11 +50,6 @@ abstract public function saveClasses(string $dir);
5550
5651 abstract public function generate (string $ file_path );
5752
58- /**
59- * @param string $yaml_path
60- * @param string $dir
61- * @return int
62- */
6353 public function runFull (string $ yaml_path , string $ dir ): int {
6454 $ this ->generate ($ yaml_path );
6555
@@ -69,13 +59,7 @@ public function runFull(string $yaml_path, string $dir): int{
6959 return count ($ this ->classes );
7060 }
7161
72- /**
73- * @param string $yaml_path
74- * @param string $dir
75- *
76- * @return int
77- */
78- public function runFullWithMoreSpecificity (string $ yaml_path , string $ dir ){
62+ public function runFullWithMoreSpecificity (string $ yaml_path , string $ dir ): int {
7963 $ this ->generate ($ yaml_path , true );
8064
8165 $ this ->saveClasses ($ dir );
@@ -87,9 +71,6 @@ public function runFullWithMoreSpecificity(string $yaml_path, string $dir){
8771 /**
8872 * Saves generated classes down as PHP files
8973 *
90- * @param string $dir
91- * @param string $namespace_name
92- * @param string $use
9374 * @throws RuntimeException
9475 * @throws FileNotFoundException
9576 */
@@ -110,10 +91,6 @@ protected function saveClassesInternal(string $dir, string $namespace_name, stri
11091 abstract public function dumpParentClass (string $ dir );
11192
11293 /**
113- * @param string $dir
114- * @param string $file
115- * @param string $namespace
116- * @param string $namespace_use
11794 * @throws FileNotFoundException
11895 */
11996 protected function dumpParentInternal (string $ dir , string $ file , string $ namespace , string $ namespace_use = '' ): void {
@@ -128,21 +105,10 @@ protected function dumpParentInternal(string $dir, string $file, string $namespa
128105 file_put_contents ("$ dir/ $ file_name " , $ content );
129106 }
130107
131- /**
132- * Utility function
133- *
134- * @param string $string
135- * @param string $char
136- * @return string
137- */
138108 protected function stringNotEndWith (string $ string , string $ char ): string {
139109 return $ string [strlen ($ string )-1 ]===$ char ? substr ($ string , 0 , -1 ) : $ string ;
140110 }
141111
142- /**
143- * @param string $string
144- * @return string
145- */
146112 protected function unPlural (string $ string ): string {
147113 if (substr ($ string , -3 )==='ies ' ){
148114 return substr ($ string , 0 , -3 ).'y ' ;
@@ -156,9 +122,6 @@ protected function unPlural(string $string): string{
156122
157123 /**
158124 * Changes a Swagger definition into a type
159- *
160- * @param array $property
161- * @return string
162125 */
163126 protected function typeFromRef (array $ property ): string {
164127 if (!isset ($ property ['$ref ' ])){
@@ -168,20 +131,13 @@ protected function typeFromRef(array $property): string{
168131 return str_replace ('#/definitions/ ' , '' , $ property ['$ref ' ]);
169132 }
170133
171- /**
172- * @param string $dir
173- * @param string $namespace
174- * @return string
175- */
176134 protected function dirNamespace (string $ dir , string $ namespace ): string {
177135 $ dir = $ this ->stringNotEndWith ($ dir , '/ ' );
178136
179137 return "$ dir/ $ namespace " ;
180138 }
181139
182140 /**
183- * @param string $dir
184- * @return string
185141 * @throws FileNotFoundException
186142 */
187143 private function checkDir (string $ dir ): string {
@@ -195,10 +151,6 @@ private function checkDir(string $dir): string{
195151 return $ dir ;
196152 }
197153
198- /**
199- * @param string $type
200- * @return bool
201- */
202154 protected function notScalarType (string $ type ): bool {
203155 return !in_array ($ type , ['integer ' , 'string ' , 'boolean ' , 'number ' , 'null ' ]);
204156 }
0 commit comments