1 | <?php |
||
14 | class CodeGeneratorService extends AbstractService { |
||
15 | |||
16 | private $codegen; |
||
17 | |||
18 | public function getCodegenFile() { |
||
22 | |||
23 | /** |
||
24 | * Loads the contents from codegen.json into a collection |
||
25 | * |
||
26 | * @throws JsonEmptyException |
||
27 | * @throws \RuntimeException |
||
28 | * @return CodegenSchema |
||
29 | */ |
||
30 | public function getCodegen() { |
||
40 | |||
41 | // /** |
||
42 | // * Returns the codegen part for the given action name or an empty map |
||
43 | // * |
||
44 | // * @param string $name |
||
45 | // * @return Map |
||
46 | // */ |
||
47 | // public function getCodegenAction($name) { |
||
48 | // $codegen = $this->getCodegen(); |
||
49 | |||
50 | // if (isset($codegen['actions'])) { |
||
|
|||
51 | // $actions = $codegen['actions']; |
||
52 | |||
53 | // if (isset($actions[$name])) { |
||
54 | // return $actions[$name]; |
||
55 | // } |
||
56 | // } |
||
57 | |||
58 | // return null; |
||
59 | // } |
||
60 | |||
61 | /** |
||
62 | * Adds authors to the docblock of the given struct |
||
63 | * |
||
64 | * @param AbstractPhpStruct $struct |
||
65 | 15 | * @param array $package |
|
66 | 15 | */ |
|
67 | public function addAuthors(AbstractPhpStruct $struct, PackageSchema $package) { |
||
82 | 15 | ||
83 | 15 | /** |
|
84 | * Returns code for hydrating a propel model |
||
85 | * |
||
86 | * @param string $modelName |
||
87 | * @return string |
||
88 | */ |
||
89 | public function getWriteFields($modelName) { |
||
108 | |||
109 | /** |
||
110 | * Returns the fields for a model |
||
111 | 5 | * |
|
112 | 5 | * @param string $modelName |
|
113 | 5 | * @return array |
|
114 | */ |
||
115 | 5 | public function getReadFields($modelName) { |
|
134 | |||
135 | // /** |
||
136 | // * Returns conversions for model columns |
||
137 | // * |
||
138 | // * @param string $model |
||
139 | // * @param string $type |
||
140 | // * @return array |
||
141 | // */ |
||
142 | // public function getConversions($model, $type) { |
||
143 | // return $this->getActionProp($model, $type, 'conversion'); |
||
144 | // } |
||
145 | |||
146 | // /** |
||
147 | // * Returns model columns that should be filtered |
||
148 | // * |
||
149 | // * @param string $model |
||
150 | 5 | // * @param string $type |
|
151 | 5 | // * @return array |
|
152 | // */ |
||
153 | // public function getFilter($model, $type) { |
||
154 | 5 | // return $this->getActionProp($model, $type, 'filter'); |
|
155 | 5 | // } |
|
156 | 5 | ||
157 | 5 | /** |
|
158 | 5 | * Returns computed model fields |
|
159 | 5 | * |
|
160 | * @param Table $table |
||
161 | 5 | * @return array<string> |
|
162 | */ |
||
163 | public function getComputedFields(Table $table) { |
||
182 | 2 | ||
183 | /** |
||
184 | * Helper to represent an array as php code |
||
185 | * |
||
186 | 2 | * @param array $array |
|
187 | * @return string |
||
188 | */ |
||
189 | 15 | public function arrayToCode(array $array) { |
|
201 | 15 | ||
202 | // public function mapToCode(array $array) { |
||
203 | // $fields = ''; |
||
204 | 15 | // foreach ($array as $k => $item) { |
|
205 | 15 | // $fields .= sprintf("\t'%s' => %s,\n", $k, $this->arrayToCode($item)); |
|
206 | 15 | // } |
|
207 | |||
208 | 15 | // if (strlen($fields) > 0) { |
|
209 | // $fields = substr($fields, 0, -2); |
||
210 | 15 | // } |
|
211 | 15 | ||
212 | // return sprintf("[\n%s\n]", $fields); |
||
213 | // } |
||
214 | 15 | ||
215 | /** |
||
216 | * Returns the filename for a given struct |
||
217 | 15 | * |
|
218 | 15 | * @param AbstractPhpStruct $struct |
|
219 | 15 | * @return string |
|
220 | */ |
||
221 | public function getFilename(AbstractPhpStruct $struct) { |
||
235 | |||
236 | public function dumpStruct(AbstractPhpStruct $struct, $overwrite = false) { |
||
252 | } |
||
253 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.