@@ -236,7 +236,7 @@ public static function extractAnnotationData(string $className, string $methodNa
236236 * @param string $type The prefix with which the lines should start, such as '@param'.
237237 * @return array Returns an array of filtered annotations.
238238 */
239- private static function filterAnnotations (array $ annotations , string $ type )
239+ public static function filterAnnotations (array $ annotations , string $ type )
240240 {
241241 $ rows = [];
242242 foreach ($ annotations as $ annotation ) {
@@ -246,56 +246,4 @@ private static function filterAnnotations(array $annotations, string $type)
246246 }
247247 return $ rows ;
248248 }
249-
250- private static function extractFormatData (array $ annotations ): array
251- {
252- $ formats = [];
253- $ filtered = self ::filterAnnotations ($ annotations , "@format_def " );
254- foreach ($ filtered as $ annotation ) {
255- // sample: @format user_info { "name":"format:name", "points":"format:int", "comments":"format:string[]" }
256- $ tokens = explode (" " , $ annotation );
257- $ name = $ tokens [1 ];
258-
259- $ jsonStart = strpos ($ annotation , "{ " );
260- $ json = substr ($ annotation , $ jsonStart );
261- $ format = json_decode ($ json );
262-
263- $ formats [$ name ] = $ format ;
264- }
265- return $ formats ;
266- }
267-
268- private static function extractMethodFormats (string $ className , string $ methodName ): array
269- {
270- $ annotations = self ::getMethodAnnotations ($ className , $ methodName );
271- return self ::extractFormatData ($ annotations );
272- }
273-
274- public static function extractClassFormats (string $ className ): array
275- {
276- $ methods = get_class_methods ($ className );
277- $ formatDicts = [];
278- foreach ($ methods as $ method ) {
279- $ formatDicts [] = self ::extractMethodFormats ($ className , $ method );
280- }
281-
282- return array_merge (...$ formatDicts );
283- }
284-
285- public static function extractMethodCheckedParams (string $ className , string $ methodName ): array
286- {
287- $ annotations = self ::getMethodAnnotations ($ className , $ methodName );
288- $ filtered = self ::filterAnnotations ($ annotations , "@checked_param " );
289-
290- $ paramMap = [];
291- foreach ($ filtered as $ annotation ) {
292- // sample: @checked_param format:group group
293- $ tokens = explode (" " , $ annotation );
294- $ format = $ tokens [1 ];
295- $ name = $ tokens [2 ];
296- $ paramMap [$ name ] = $ format ;
297- }
298-
299- return $ paramMap ;
300- }
301249}
0 commit comments