@@ -286,6 +286,7 @@ public function clear(): void
286
286
continue ;
287
287
}
288
288
$ functions [strtolower ($ namespacedName )] = $ pathPart ;
289
+ $ stmt = $ this ->filterFunctionPhpDocs ($ stmt );
289
290
} else {
290
291
throw new \Exception (sprintf ('Unhandled node type %s in %s on line %s. ' , get_class ($ stmt ), $ stubPath , $ stmt ->getLine ()));
291
292
}
@@ -820,6 +821,44 @@ private function filterClassPhpDocs(Node\Stmt\ClassLike $class): Node\Stmt\Class
820
821
return $ class ;
821
822
}
822
823
824
+ private function filterFunctionPhpDocs (Node \Stmt \Function_ $ function ): Node \Stmt \Function_
825
+ {
826
+ $ namespacedName = $ function ->namespacedName ->toString ();
827
+ if (in_array ($ namespacedName , [
828
+ 'xml_set_element_handler ' ,
829
+ 'xml_set_character_data_handler ' ,
830
+ 'xml_set_processing_instruction_handler ' ,
831
+ 'xml_set_default_handler ' ,
832
+ 'xml_set_unparsed_entity_decl_handler ' ,
833
+ 'xml_set_notation_decl_handler ' ,
834
+ 'xml_set_external_entity_ref_handler ' ,
835
+ 'xml_set_start_namespace_decl_handler ' ,
836
+ 'xml_set_end_namespace_decl_handler ' ,
837
+ ], true )) {
838
+ $ comments = $ function ->getAttribute ('comments ' );
839
+ if (null !== $ comments ) {
840
+ $ function ->setAttribute ('comments ' , array_map (
841
+ fn (Comment \Doc $ doc ): Comment \Doc => new Comment \Doc (
842
+ str_replace (
843
+ '@param callable $ ' ,
844
+ '@param callable|string|null $ ' ,
845
+ $ doc ->getText (),
846
+ ),
847
+ $ doc ->getStartLine (),
848
+ $ doc ->getStartFilePos (),
849
+ $ doc ->getStartTokenPos (),
850
+ $ doc ->getEndLine (),
851
+ $ doc ->getEndFilePos (),
852
+ $ doc ->getEndTokenPos (),
853
+ ),
854
+ $ comments
855
+ ));
856
+ }
857
+ }
858
+
859
+ return $ function ;
860
+ }
861
+
823
862
private function parseDocComment (string $ docComment ): PhpDocNode
824
863
{
825
864
$ tokens = new TokenIterator ($ this ->phpDocLexer ->tokenize ($ docComment ));
0 commit comments